GStreamer Application Development Manual | ||
---|---|---|
<<< Previous | More on factories | Next >>> |
GStreamer assigns a unique number to all registered MIME types. GStreamer also keeps a reference to a function that can be used to determine if a given buffer is of the given MIME type.
There is also an association between a MIME type and a file extension.
The type information is maintained in a list of GstType. The definition of a GstType is like:
typedef GstCaps (*GstTypeFindFunc) (GstBuffer *buf,gpointer *priv); typedef struct _GstType GstType; struct _GstType { guint16 id; /* type id (assigned) */ gchar *mime; /* MIME type */ gchar *exts; /* space-delimited list of extensions */ GstTypeFindFunc typefindfunc; /* typefind function */ }; |
All operations on GstType occur via their guint16 id numbers, with GstType structure private to the GStreamer library.
We can obtain the id for a given MIME type with the following piece of code:
guint16 id; id = gst_type_find_by_mime("audio/mpeg"); |
This function will return 0 if the type was not known.
We can obtain the GstType for a given id with the following piece of code:
GstType *type; type = gst_type_find_by_id(id); |
This function will return NULL if the id was associated with any known GstType
We can obtain the id for a given file extension with the following piece of code:
guint16 id; id = gst_type_find_by_ext(".mp3"); |
This function will return 0 if the extension was not known.
When we have obtained a given type id using one of the above methods, we can obtain a list of all the elements that operate on this MIME type or extension.
Obtain a list of all the elements that use this id as source with:
GList *list; list = gst_type_gst_srcs(id); |
Obtain a list of all the elements that use this id as sink with:
GList *list; list = gst_type_gst_sinks(id); |
When you have a list of elements, you can simply take the first element of the list to obtain an appropriate element.
![]() | As you can see, there might be a multitude of elements that are able to operate on video/raw types. some might include:
|
You can obtain a GList of elements that will transform the source id into the destination id.
GList *list; list = gst_type_gst_sink_to_src(sourceid, sinkid); |
This piece of code will give you the elements needed to construct a path from sourceid to sinkid. This function is mainly used in autoplugging the pipeline.
<<< Previous | Home | Next >>> |
more on MIME Types | Up | creating elements with the factory |