a2736922d0eb262306632afe057fbfc2cb81a77b
[platform/upstream/gstreamer.git] / docs / gst / tmpl / gstpadtemplate.sgml
1 <!-- ##### SECTION Title ##### -->
2 GstPadTemplate
3
4 <!-- ##### SECTION Short_Description ##### -->
5 Describe the media type of a pad.
6
7 <!-- ##### SECTION Long_Description ##### -->
8 <para>
9 Padtemplates describe the possible media types a pad or an elementfactory can
10 handle. 
11 </para>
12 <para>
13 Pad and PadTemplates have #GstCaps attached to it to describe the media type they
14 are capable of dealing with.  gst_pad_template_get_caps() is used to get the
15 caps of a padtemplate. It's not possible to modify the caps of a padtemplate after
16 creation. 
17 </para>
18 <para>
19 Padtemplates can be created with gst_pad_template_new() or with the convenient
20 GST_PAD_TEMPLATE_FACTORY() macro. A padtemplate can be used to create a pad or 
21 to add to an elementfactory.
22 </para>
23 <para>
24 The following code example shows the code to create a pad from a padtemplate.
25 <programlisting>
26   GST_PAD_TEMPLATE_FACTORY (my_template_factory,
27     "sink",             /* the name of the pad */
28     GST_PAD_SINK,       /* the direction of the pad */
29     GST_PAD_ALWAYS,     /* when this pad will be present */
30     GST_CAPS_NEW (      /* the capabilities of the padtemplate */
31       "my_caps",
32       "audio/raw",
33         "format",       GST_PROPS_STRING ("int"),
34         "channels",     GST_PROPS_INT_RANGE (1, 6)
35     )
36   )
37
38   void
39   my_method (void) 
40   {
41     GstPad *pad;
42   
43     pad = gst_pad_new_from_template (GST_PAD_TEMPLATE_GET (my_template_factory), "sink");
44     ...
45   }
46 </programlisting>
47 </para>
48 <para>
49 The following example shows you how to add the padtemplate to an elementfactory:
50 <programlisting>
51   gboolean
52   my_factory_init (GstPlugin *plugin)
53   {
54     GstElementFactory *factory;
55
56     factory = gst_element_factory_new ("my_factory", GST_TYPE_MYFACTORY, &amp;gst_myfactory_details);
57     g_return_val_if_fail (factory != NULL, FALSE);
58
59     gst_element_factory_add_pad_template (factory, GST_PAD_TEMPLATE_GET (my_template_factory));
60
61     gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
62
63     return TRUE;
64   }
65
66 </programlisting>
67 </para>
68
69 <!-- ##### SECTION See_Also ##### -->
70 <para>
71 #GstPad, #GstElementFactory
72 </para>
73
74 <!-- ##### ENUM GstPadPresence ##### -->
75 <para>
76 Indicates when this pad will become available.
77 </para>
78
79 @GST_PAD_ALWAYS: the pad is always available
80 @GST_PAD_SOMETIMES: the pad will become available depending on the media stream
81 @GST_PAD_REQUEST: th pad is only available on request with 
82 gst_element_request_pad_by_name() or gst_element_request_compatible_pad().
83
84 <!-- ##### STRUCT GstPadTemplate ##### -->
85 <para>
86 The padtemplate object.
87 </para>
88
89
90 <!-- ##### ENUM GstPadTemplateFlags ##### -->
91 <para>
92 Flags for the padtemplate
93 </para>
94
95 @GST_PAD_TEMPLATE_FIXED: The padtemplate has no variable properties
96 @GST_PAD_TEMPLATE_FLAG_LAST: first flag that can be used by subclasses.
97
98 <!-- ##### MACRO GST_PAD_TEMPLATE_CAPS ##### -->
99 <para>
100 Get a handle to the padtemplate #GstCaps
101 </para>
102
103 @templ: the template to query
104
105
106 <!-- ##### MACRO GST_PAD_TEMPLATE_DIRECTION ##### -->
107 <para>
108 Get the direction of the padtemplate.
109 </para>
110
111 @templ: the template to query
112
113
114 <!-- ##### MACRO GST_PAD_TEMPLATE_NAME_TEMPLATE ##### -->
115 <para>
116 Get the nametemplate of the padtemplate.
117 </para>
118
119 @templ: the template to query
120
121
122 <!-- ##### MACRO GST_PAD_TEMPLATE_PRESENCE ##### -->
123 <para>
124 Get the presence of the padtemplate.
125 </para>
126
127 @templ: the template to query
128
129
130 <!-- ##### MACRO GST_PAD_TEMPLATE_IS_FIXED ##### -->
131 <para>
132 Check if the properties of the padtemplate are fixed
133 </para>
134
135 @templ: the template to query
136
137
138 <!-- ##### FUNCTION gst_pad_template_new ##### -->
139 <para>
140
141 </para>
142
143 @name_template: 
144 @direction: 
145 @presence: 
146 @caps: 
147 @Returns: 
148 <!-- # Unused Parameters # -->
149 @Varargs: 
150
151
152 <!-- ##### FUNCTION gst_pad_template_get_caps ##### -->
153 <para>
154
155 </para>
156
157 @templ: 
158 @Returns: 
159
160
161 <!-- ##### FUNCTION gst_pad_template_get_caps_by_name ##### -->
162 <para>
163
164 </para>
165
166 @templ: 
167 @name: 
168 @Returns: 
169
170
171 <!-- ##### SIGNAL GstPadTemplate::pad-created ##### -->
172 <para>
173 This signal is fired when an element creates a pad from this 
174 template.
175 </para>
176
177 @gstpadtemplate: the object which received the signal.
178 @arg1: The pad that was created.
179