More updates to the API docs.
[platform/upstream/gstreamer.git] / docs / gst / tmpl / gsttypefactory.sgml
1 <!-- ##### SECTION Title ##### -->
2 GstTypeFactory
3
4 <!-- ##### SECTION Short_Description ##### -->
5 Add types to plugins.
6
7 <!-- ##### SECTION Long_Description ##### -->
8 <para>
9 A GstTypeFactory is used to add a new type and a typedetection function 
10 to a plugin. Typefactories are named so they can be found with
11 gst_typefactory_find().
12 </para>
13 <para>
14 gst_typefactory_new() is used to create a new typefactory from the given
15 #GstTypeDefinition. A typefactory is added to a #GstPlugin with 
16 gst_plugin_add_feature() as shown in the example:
17 <programlisting>
18   static GstCaps*
19   avi_typefind (GstBuffer *buf, gpointer private)
20   {
21     gchar *data = GST_BUFFER_DATA (buf);
22                       
23     if (strncmp (&data[0], "RIFF", 4)) return NULL;
24     if (strncmp (&data[8], "AVI ", 4)) return NULL;
25                               
26     return gst_caps_new ("avi_typefind","video/avi", NULL);
27   }
28
29   /* typedefinition for 'avi' */
30   static GstTypeDefinition avidefinition = {
31     "avidecoder_video/avi",   /* the name of this definition */
32     "video/avi",              /* the mime type */
33     ".avi",                   /* the file extensions */
34     avi_typefind,             /* a pointer to a GstTypeFindFunc function */
35   };
36
37   static gboolean
38   plugin_init (GModule *module, GstPlugin *plugin)
39   {
40     GstTypeFactory *type;
41     ...
42     type = gst_typefactory_new (&amp;avidefinition);
43     gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (type));
44     ...
45   }
46 </programlisting>
47 </para>
48
49 <!-- ##### SECTION See_Also ##### -->
50 <para>
51 #GstPluginFeature, #GstPlugin
52 </para>
53
54 <!-- ##### STRUCT GstTypeFactory ##### -->
55 <para>
56 The struct with the typefactory information.
57 </para>
58
59 @feature: 
60 @mime: 
61 @exts: 
62 @typefindfunc: 
63
64 <!-- ##### STRUCT GstTypeDefinition ##### -->
65 <para>
66
67 </para>
68
69 @name: The name of this factory
70 @mime: The mime type of the new type.
71 @exts: The extensions of this type.
72 @typefindfunc: An optional typefind function.
73
74 <!-- ##### USER_FUNCTION GstTypeFindFunc ##### -->
75 <para>
76 This is the function that will be called when a typefind has to be
77 performed by a plugin.
78 </para>
79
80 @buf: the buffer with media on which to perform the typefind
81 @priv: private; don't touch
82 @Returns: A #GstCaps structure describing the type or NULL if the
83           type was not recognized by this function;
84
85
86 <!-- ##### FUNCTION gst_typefactory_new ##### -->
87 <para>
88
89 </para>
90
91 @definition: 
92 @Returns: 
93
94
95 <!-- ##### FUNCTION gst_typefactory_find ##### -->
96 <para>
97
98 </para>
99
100 @name: 
101 @Returns: 
102
103