GStreamer Core Reference Manual | |||
---|---|---|---|
<<< Previous Page | Home | Up | Next Page >>> |
#include <gst/gst.h> struct GstTypeFactory; struct GstTypeDefinition; GstCaps* (*GstTypeFindFunc) (GstBuffer *buf, gpointer priv); GstTypeFactory* gst_type_factory_new (GstTypeDefinition *definition); GstTypeFactory* gst_type_factory_find (const gchar *name); |
A GstTypeFactory is used to add a new type and a typedetection function to a plugin. Typefactories are named so they can be found with gst_type_factory_find().
gst_type_factory_new() is used to create a new typefactory from the given GstTypeDefinition. A typefactory is added to a GstPlugin with gst_plugin_add_feature() as shown in the example:
static GstCaps* avi_type_find (GstBuffer *buf, gpointer private) { gchar *data = GST_BUFFER_DATA (buf); if (strncmp (&data[0], "RIFF", 4)) return NULL; if (strncmp (&data[8], "AVI ", 4)) return NULL; return gst_caps_new ("avi_type_find","video/avi", NULL); } /* typedefinition for 'avi' */ static GstTypeDefinition avidefinition = { "avidecoder_video/avi", /* the name of this definition */ "video/avi", /* the mime type */ ".avi", /* the file extensions */ avi_type_find, /* a pointer to a GstTypeFindFunc function */ }; static gboolean plugin_init (GModule *module, GstPlugin *plugin) { GstTypeFactory *type; ... type = gst_type_factory_new (&avidefinition); gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (type)); ... } |
struct GstTypeDefinition { gchar *name; gchar *mime; gchar *exts; GstTypeFindFunc typefindfunc; }; |
The typedefinition structure.
gchar *name | The name of this factory |
gchar *mime | The mime type of the new type. |
gchar *exts | The extensions of this type. |
GstTypeFindFunc typefindfunc | An optional typefind function. |
GstCaps* (*GstTypeFindFunc) (GstBuffer *buf, gpointer priv); |
This is the function that will be called when a typefind has to be performed by a plugin.
buf : | the buffer with media on which to perform the typefind |
priv : | private; don't touch |
Returns : | A GstCaps structure describing the type or NULL if the type was not recognized by this function; |
GstTypeFactory* gst_type_factory_new (GstTypeDefinition *definition); |
Creata a new typefactory from the given definition.
definition : | the definition to use |
Returns : | the new typefactory |
GstTypeFactory* gst_type_factory_find (const gchar *name); |
Return the TypeFactory with the given name.
name : | the name of the typefactory to find |
Returns : | a GstTypeFactory with the given name; |