fix manual id's
[platform/upstream/gstreamer.git] / docs / manual / basics-pads.xml
1 <chapter id="chapter-pads">
2   <title>Pads</title>
3   <para>
4     As we have seen in <xref linkend="chapter-elements"/>, the pads are the element's
5     interface to the outside world. 
6   </para>
7   <para>
8     The specific type of media that the element can handle will be exposed by the pads.
9     The description of this media type is done with capabilities(see
10     <xref linkend="section-caps"/>)
11   </para>
12
13   <para>
14     Pads are either source or sink pads.  The terminology is defined from the
15     view of the element itself: elements accept data on their sink pads, and
16     send data out on their source pads.  Sink pads are drawn on the left,
17     while source pads are drawn on the right of an element.  In general,
18     data flows from left to right in the graph.<footnote>
19       <para>
20         In reality, there is no objection to data flowing from a
21         source pad to the sink pad of an element upstream.  Data will, however,
22         always flow from a source pad of one element to the sink pad of
23         another.
24       </para></footnote>
25   </para>
26
27   <sect1 id="section-pads-type">
28     <title>Types of pads</title>
29  
30     <sect2 id="section-pads-dynamic">
31       <title>Dynamic pads</title>
32       <para> 
33         Some elements might not have all of their pads when the element is
34         created. This
35         can happen, for example, with an MPEG system demultiplexer. The
36         demultiplexer will create its pads at runtime when it detects the
37         different elementary streams in the MPEG system stream.
38       </para> 
39       <para> 
40         Running <application>gst-inspect mpegdemux</application> will show that
41         the element has only one pad: a sink pad called 'sink'. The other pads are 
42         "dormant".  You can see this in the pad template because there is
43         an 'Exists: Sometimes'
44         property. Depending on the type of MPEG file you play, the pads will
45         be created. We
46         will see that this is very important when you are going to create dynamic 
47         pipelines later on in this manual.
48       </para> 
49     </sect2>
50     <sect2 id="section-pads-request">
51       <title>Request pads</title>
52       <para> 
53         An element can also have request pads. These pads are not created
54         automatically but are only created on demand. This is very useful
55         for multiplexers, aggregators and tee elements.
56       </para> 
57       <para> 
58         The tee element, for example, has one input pad and a request padtemplate for the
59         output pads. Whenever an element wants to get an output pad from the tee element, it 
60         has to request the pad.
61       </para> 
62     </sect2>
63
64   </sect1>
65
66   <sect1 id="section-caps">
67     <title>Capabilities of a pad</title>
68     <para> 
69       Since the pads play a very important role in how the element is viewed by the
70       outside world, a mechanism is implemented to describe the data that can
71       flow through the pad by using capabilities.
72     </para>
73     <para> 
74       We will briefly describe what capabilities are, enough for you to get a basic understanding
75       of the concepts. You will find more information on how to create capabilities in the 
76       Plugin Writer's Guide.
77     </para>
78
79     <sect2 id="section-pads-caps">
80       <title>Capabilities</title>
81       <para> 
82         Capabilities are attached to a pad in order to describe
83         what type of media the pad can handle.
84       </para>
85       <para> 
86         Capabilities is shorthand for "capability chain".  A capability chain
87         is a chain of one capability or more.
88       </para>
89       <para>
90         The basic entity is a capability, and is defined by a name, a MIME
91         type and a set of properties.  A capability can be chained to
92         another capability, which is why we commonly refer to a chain of
93         capability entities as "capabilities".
94         <footnote>
95           <para>
96             It is important to understand that the term "capabilities" refers
97             to a chain of one capability or more.  This will be clearer when
98             you see the structure definition of a <classname>GstCaps</classname>
99             element.
100           </para>
101         </footnote>
102       </para>
103       <para> 
104         Below is a dump of the capabilities of the element mad, as shown by 
105         <command>gst-inspect</command>.    
106         You can see two pads: sink and src. Both pads have capability information attached to them.
107       </para>
108       <para> 
109         The sink pad (input pad) is called 'sink' and takes data of MIME type 'audio/mp3'. It also has
110         three properties: layer, bitrate and framed.
111       </para>
112       <para> 
113         The source pad (output pad) is called 'src' and outputs data of
114         MIME type 'audio/raw'. It also has four properties: format, depth,
115         rate and channels.
116       </para>
117       <programlisting>
118 Pads:
119   SINK template: 'sink'
120     Availability: Always
121     Capabilities:
122       'mad_sink':
123         MIME type: 'audio/mp3':
124
125   SRC template: 'src'
126     Availability: Always
127     Capabilities:
128       'mad_src':
129         MIME type: 'audio/raw':
130         format: String: int
131         endianness: Integer: 1234
132         width: Integer: 16
133         depth: Integer: 16
134         channels: Integer range: 1 - 2
135         law: Integer: 0
136         signed: Boolean: TRUE
137         rate: Integer range: 11025 - 48000
138       </programlisting>
139     </sect2>
140     <sect2 id="section-pads-props">
141       <title>What are properties ?</title>
142       <para> 
143         Properties are used to describe extra information for 
144         capabilities. A property consists of a key (a string) and
145         a value. There are different possible value types that can be used:
146       </para> 
147
148       <itemizedlist>
149         <listitem>
150           <para>
151             basic types:
152           </para>
153           <itemizedlist>
154             <listitem>
155               <para>
156                 an integer value: the property has this exact value. 
157               </para>
158             </listitem>
159             <listitem>
160               <para>
161                 a boolean value: the property is either TRUE or FALSE.
162               </para>
163             </listitem>
164             <listitem>
165               <para>
166                 a fourcc value: this is a value that is commonly used to
167                 describe an encoding for video,
168                 as used for example by the AVI specification.
169                 <footnote><para>
170                   fourcc values consist of four bytes.
171                   <ulink url="http://www.fourcc.org" type="http">The FOURCC
172                   Definition List</ulink> is the most complete resource
173                   on the allowed fourcc values.
174                 </para></footnote>
175               </para>
176             </listitem>
177             <listitem>
178               <para>
179                 a float value: the property has this exact floating point value.
180               </para>
181             </listitem>
182             <listitem>
183               <para>
184                 a string value.
185               </para>
186             </listitem>
187           </itemizedlist>
188         </listitem>
189
190         <listitem>
191           <para>
192             range types:
193           </para>
194           <itemizedlist>
195            <listitem>
196               <para>
197                 an integer range value: the property denotes a range of 
198                 possible integer. For example, the wavparse element has
199                 a source pad where the "rate" property can go from 8000 to
200                 48000.
201               </para>
202             </listitem>
203             <listitem>
204               <para>
205                 a float range value: the property denotes a range of possible
206                 floating point values.
207               </para>
208             </listitem>
209           </itemizedlist>
210         </listitem>
211         <listitem>
212           <para>
213             a list value: the property can take any value from a list of
214             basic value types or range types.
215           </para>
216         </listitem>
217       </itemizedlist>
218
219     </sect2>
220     <sect2 id="section-pads-caps-use">
221       <title>What capabilities are used for</title>
222       <para> 
223         Capabilities describe in great detail the type of media that is handled by the pads.
224         They are mostly used for:
225       </para> 
226       <itemizedlist>
227         <listitem>
228           <para>
229             Autoplugging: automatically finding plugins for a set of capabilities
230           </para>
231         </listitem>
232         <listitem>
233           <para>
234             Compatibility detection: when two pads are linked, <application>GStreamer</application>
235             can verify if the two pads are talking about the same media types.
236             The process of linking two pads and checking if they are compatible
237             is called "caps negotiation".
238           </para>
239         </listitem>
240       </itemizedlist>
241     </sect2>
242   </sect1>
243 </chapter>