Examining the Basic Code

First we will examine the code you would be likely to place in a header file (although since the interface to the code is entirely defined by the plugin system, and doesn't depend on reading a header file, this is not crucial.)

Example 3.1. Example Plugin Header File

#include <gst/gst.h>

/* Definition of structure storing data for this element. */
typedef struct _GstMyFilter {
  GstElement element;

  GstPad *sinkpad, *srcpad;

  gboolean silent;

} GstMyFilter;

/* Standard definition defining a class for this element. */
typedef struct _GstMyFilterClass {
  GstElementClass parent_class;
} GstMyFilterClass;

/* Standard macros for defining types for this element.  */
#define GST_TYPE_MY_FILTER (gst_my_filter_get_type())
#define GST_MY_FILTER(obj) \
#define GST_MY_FILTER_CLASS(klass) \
#define GST_IS_MY_FILTER(obj) \
#define GST_IS_MY_FILTER_CLASS(klass) \

/* Standard function returning type information. */
GType gst_my_filter_get_type (void);

Using this header file, you can use the following macro to setup the GObject basics in your source file so that all functions will be called appropriately:

#include "filter.h"

G_DEFINE_TYPE (GstMyFilter, gst_my_filter, GST_TYPE_ELEMENT);