4 The type system is used to attach meaning to the bytes in a GstBuffer.
5 A plugin can decide to add metadata to the GstBuffer, this metadata
6 will carry an associated typeid.
8 Types are also used by the plugins to expose the type of their pads to
11 Types are essential for autoplugging.
13 We will explain the inner workings of the type system in this document, as
14 well as the API used in the plugins.
20 a) identification of the type
22 Types are identified by one or more MIME types.
26 The type of any given GstBuffer can be detected using
28 - a typefind function: a function that will inspect the bytes
29 in the buffer and return a gboolean indicating the
30 buffer is of the given type.
32 - a template for the bytes/bits in the data that must be
33 satisfied in order for the GstBuffer to be of the given
36 - other properties that act more like a hint like:
37 the extension of the source filename.
38 the URI of the source.
44 a) the core libraries will create to types:
49 b) all other types will be provided by the plugins
51 before a type can become available to other plugins, the plugin
52 has to register the type.
54 The system will keep a directed graph of the types and the plugins
63 video/mpeg1 audio/mp3 -----\
65 mpeg_play mpeg2dec mpg123 xing ...
67 video/raw audio/raw-----\
69 videosink SDLsink audiosink alsasink ...
72 The system can find the needed plugins to convert video/mpeg to
73 audio/raw using this graph.
79 some types can have the same meaning for example:
81 audio/mp3 and audio/mpeg
85 video/raw and image/raw
88 a plugin that exposes its output type as audio/mpeg and another plugins
89 with input type audio/mp3 can be connected. The system has to know about
90 the equivalence of both types, even it they have a different mime type.
96 some plugins can ouput a specific subset of an allready existing type.
100 mp3parse inputs audio/mp3 and packs the stream into mp3 audio frames
101 with mime type: audio/mp3-frame
103 mpg123 only accepts audio/mp3-frame but not audio/mp3.
105 another mp3 decoder (libmpg123) can accept audio/mp3 (and thus also
108 it must be possible to connect both libmpg123 and mpg123 to the mp3parse
110 it must not be possible to connect mpg123 to an element that outputs only
111 audio/mp3 but not audio/mp3-frame.
114 We say that audio/mp3-frame is a more specific subset of type audio/mp3.
116 we can create a type hierarchy:
120 audio/mp3-frame audio/mp3-layer12
122 audio/mp3-layer1 audio/mp3-layer2
128 certain plugins might accept multiple non equivalent types in one of their
129 input pads. Consequently a plugin might output non equivalent types in
132 It must therefore be possible to specify multiple types for a pad.
136 mpegdemux may be able to demux both MPEG1 and MPEG2 system streams.
137 we show the type hierarchy of the video/mpeg as follows:
141 video/mpeg1 video/mpeg2 ---------------\
143 mpeg1-system* mpeg1-video mpeg2-ts mpeg2-ps* mpeg2-video
146 the mpegdemux element might specify the type of the input pad as
147 one of video/mpeg1-system and video/mpeg2-ts
151 7. definition of types
152 ----------------------
154 A plugin will provide the following information to the type system:
156 - a mime type string describing the hierarchy and where the types
157 they provide are located in that hierarchy.
159 - typefind functions for some of the types.
161 - extensions for some of the types
163 We will propose a syntax to define the type hierarchy
165 a) equivalent types :
167 separated with a | sign
169 ( audio/mp3 | audio/mpeg )
175 ( audio/mp3 ( audio/mp3-frame))
179 ( mpegdemux ( video/mpeg1-system + video/mpeg2-ps) )
181 the pad will have type mpegdemux which is the parent for
182 type video/mpeg1-system or video/mpeg2-ps
186 video/mpeg1-system video/mpeg2-ps
190 once the type hierarchy has been registered, the typeid of each
191 element can be obtained with:
193 guint16 gst_type_find_by_mime (gchar *mime)
195 extra typefind functions and/or extensions can be added to the
202 The more specific typefind functions, the functions associated with
203 types in the leaf nodes, are tried first.
205 when a specific type has been found ex. video/mpeg1-system elements
206 that can handle this type or one of its parents are selected:
208 mpegdemux: mpeg1parse: supermpegdecoder:
210 video/mpeg video/mpeg video/mpeg
212 mpegdemux video/mpeg1-system
216 In the above case, also the super mpeg element is selected because it stated
217 that it can handle all sorts of video/mpeg data.
222 suppose the typefind functions finds an mp3 stream, fillowing elments
229 mpg123 is not selected because its pad type is too specific (audio/mp3-frame):
237 if the typefind would find a mp3-frame type, all three objects would be selected.
243 It is clear that clear indications have to be given to the type hierarchy,
244 especially for the top nodes.
246 The more specific an element is in its mime type specification, the more flexible
247 and extendible the plugin system can be.