2004-01-28 15:08:17 +00:00
|
|
|
<chapter id="chapter-pads">
|
2003-10-09 12:42:49 +00:00
|
|
|
<title>Pads</title>
|
2001-01-04 23:35:50 +00:00
|
|
|
<para>
|
2004-01-28 15:08:17 +00:00
|
|
|
As we have seen in <xref linkend="chapter-elements"/>, the pads are the element's
|
2003-10-09 12:42:49 +00:00
|
|
|
interface to the outside world.
|
2001-01-04 23:35:50 +00:00
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
The specific type of media that the element can handle will be exposed by the pads.
|
2003-10-09 12:42:49 +00:00
|
|
|
The description of this media type is done with capabilities(see
|
2004-01-28 15:08:17 +00:00
|
|
|
<xref linkend="section-caps"/>)
|
2003-10-09 12:42:49 +00:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
Pads are either source or sink pads. The terminology is defined from the
|
|
|
|
view of the element itself: elements accept data on their sink pads, and
|
|
|
|
send data out on their source pads. Sink pads are drawn on the left,
|
|
|
|
while source pads are drawn on the right of an element. In general,
|
|
|
|
data flows from left to right in the graph.<footnote>
|
|
|
|
<para>
|
|
|
|
In reality, there is no objection to data flowing from a
|
|
|
|
source pad to the sink pad of an element upstream. Data will, however,
|
|
|
|
always flow from a source pad of one element to the sink pad of
|
|
|
|
another.
|
|
|
|
</para></footnote>
|
2001-01-04 23:35:50 +00:00
|
|
|
</para>
|
|
|
|
|
2004-01-28 15:08:17 +00:00
|
|
|
<sect1 id="section-pads-type">
|
2003-10-09 12:42:49 +00:00
|
|
|
<title>Types of pads</title>
|
|
|
|
|
2004-01-28 15:08:17 +00:00
|
|
|
<sect2 id="section-pads-dynamic">
|
2001-01-15 00:53:07 +00:00
|
|
|
<title>Dynamic pads</title>
|
|
|
|
<para>
|
2003-10-09 12:42:49 +00:00
|
|
|
Some elements might not have all of their pads when the element is
|
|
|
|
created. This
|
|
|
|
can happen, for example, with an MPEG system demultiplexer. The
|
2002-09-14 14:13:34 +00:00
|
|
|
demultiplexer will create its pads at runtime when it detects the
|
2003-10-09 12:42:49 +00:00
|
|
|
different elementary streams in the MPEG system stream.
|
2001-01-15 00:53:07 +00:00
|
|
|
</para>
|
|
|
|
<para>
|
2002-04-07 23:32:16 +00:00
|
|
|
Running <application>gst-inspect mpegdemux</application> will show that
|
2001-01-15 00:53:07 +00:00
|
|
|
the element has only one pad: a sink pad called 'sink'. The other pads are
|
2003-10-09 12:42:49 +00:00
|
|
|
"dormant". You can see this in the pad template because there is
|
|
|
|
an 'Exists: Sometimes'
|
|
|
|
property. Depending on the type of MPEG file you play, the pads will
|
|
|
|
be created. We
|
2001-01-15 00:53:07 +00:00
|
|
|
will see that this is very important when you are going to create dynamic
|
|
|
|
pipelines later on in this manual.
|
|
|
|
</para>
|
|
|
|
</sect2>
|
2004-01-28 15:08:17 +00:00
|
|
|
<sect2 id="section-pads-request">
|
2001-02-22 23:18:51 +00:00
|
|
|
<title>Request pads</title>
|
|
|
|
<para>
|
2002-09-08 21:17:16 +00:00
|
|
|
An element can also have request pads. These pads are not created
|
2002-09-14 14:13:34 +00:00
|
|
|
automatically but are only created on demand. This is very useful
|
|
|
|
for multiplexers, aggregators and tee elements.
|
2001-02-22 23:18:51 +00:00
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
The tee element, for example, has one input pad and a request padtemplate for the
|
|
|
|
output pads. Whenever an element wants to get an output pad from the tee element, it
|
|
|
|
has to request the pad.
|
|
|
|
</para>
|
|
|
|
</sect2>
|
2003-10-09 12:42:49 +00:00
|
|
|
|
2001-01-06 02:35:17 +00:00
|
|
|
</sect1>
|
2003-10-09 12:42:49 +00:00
|
|
|
|
2004-01-28 15:08:17 +00:00
|
|
|
<sect1 id="section-caps">
|
2003-10-09 12:42:49 +00:00
|
|
|
<title>Capabilities of a pad</title>
|
2001-01-04 23:35:50 +00:00
|
|
|
<para>
|
|
|
|
Since the pads play a very important role in how the element is viewed by the
|
2003-10-09 12:42:49 +00:00
|
|
|
outside world, a mechanism is implemented to describe the data that can
|
|
|
|
flow through the pad by using capabilities.
|
2001-01-04 23:35:50 +00:00
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
We will briefly describe what capabilities are, enough for you to get a basic understanding
|
|
|
|
of the concepts. You will find more information on how to create capabilities in the
|
2002-04-07 23:32:16 +00:00
|
|
|
Plugin Writer's Guide.
|
2001-01-04 23:35:50 +00:00
|
|
|
</para>
|
|
|
|
|
2004-01-28 15:08:17 +00:00
|
|
|
<sect2 id="section-pads-caps">
|
2003-12-29 14:15:02 +00:00
|
|
|
<title>Capabilities</title>
|
2001-01-04 23:35:50 +00:00
|
|
|
<para>
|
2003-10-09 12:42:49 +00:00
|
|
|
Capabilities are attached to a pad in order to describe
|
|
|
|
what type of media the pad can handle.
|
2001-01-04 23:35:50 +00:00
|
|
|
</para>
|
|
|
|
<para>
|
2003-10-09 12:42:49 +00:00
|
|
|
Capabilities is shorthand for "capability chain". A capability chain
|
|
|
|
is a chain of one capability or more.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
The basic entity is a capability, and is defined by a name, a MIME
|
|
|
|
type and a set of properties. A capability can be chained to
|
|
|
|
another capability, which is why we commonly refer to a chain of
|
2003-12-29 14:15:02 +00:00
|
|
|
capability entities as "capabilities".
|
|
|
|
<footnote>
|
2003-10-09 12:42:49 +00:00
|
|
|
<para>
|
|
|
|
It is important to understand that the term "capabilities" refers
|
|
|
|
to a chain of one capability or more. This will be clearer when
|
|
|
|
you see the structure definition of a <classname>GstCaps</classname>
|
|
|
|
element.
|
2003-12-29 14:15:02 +00:00
|
|
|
</para>
|
|
|
|
</footnote>
|
2001-01-04 23:35:50 +00:00
|
|
|
</para>
|
|
|
|
<para>
|
2002-04-07 23:32:16 +00:00
|
|
|
Below is a dump of the capabilities of the element mad, as shown by
|
|
|
|
<command>gst-inspect</command>.
|
2001-01-04 23:35:50 +00:00
|
|
|
You can see two pads: sink and src. Both pads have capability information attached to them.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
The sink pad (input pad) is called 'sink' and takes data of MIME type 'audio/mp3'. It also has
|
|
|
|
three properties: layer, bitrate and framed.
|
|
|
|
</para>
|
|
|
|
<para>
|
2002-09-14 14:13:34 +00:00
|
|
|
The source pad (output pad) is called 'src' and outputs data of
|
|
|
|
MIME type 'audio/raw'. It also has four properties: format, depth,
|
|
|
|
rate and channels.
|
2001-01-04 23:35:50 +00:00
|
|
|
</para>
|
|
|
|
<programlisting>
|
|
|
|
Pads:
|
2002-04-07 23:32:16 +00:00
|
|
|
SINK template: 'sink'
|
|
|
|
Availability: Always
|
|
|
|
Capabilities:
|
|
|
|
'mad_sink':
|
|
|
|
MIME type: 'audio/mp3':
|
2001-01-04 23:35:50 +00:00
|
|
|
|
2002-04-07 23:32:16 +00:00
|
|
|
SRC template: 'src'
|
|
|
|
Availability: Always
|
2001-01-04 23:35:50 +00:00
|
|
|
Capabilities:
|
2002-04-07 23:32:16 +00:00
|
|
|
'mad_src':
|
|
|
|
MIME type: 'audio/raw':
|
|
|
|
format: String: int
|
|
|
|
endianness: Integer: 1234
|
|
|
|
width: Integer: 16
|
|
|
|
depth: Integer: 16
|
|
|
|
channels: Integer range: 1 - 2
|
|
|
|
law: Integer: 0
|
|
|
|
signed: Boolean: TRUE
|
|
|
|
rate: Integer range: 11025 - 48000
|
2001-01-04 23:35:50 +00:00
|
|
|
</programlisting>
|
|
|
|
</sect2>
|
2004-01-28 15:08:17 +00:00
|
|
|
<sect2 id="section-pads-props">
|
2003-10-09 12:42:49 +00:00
|
|
|
<title>What are properties ?</title>
|
2001-01-04 23:35:50 +00:00
|
|
|
<para>
|
2002-09-14 14:13:34 +00:00
|
|
|
Properties are used to describe extra information for
|
2003-10-09 12:42:49 +00:00
|
|
|
capabilities. A property consists of a key (a string) and
|
|
|
|
a value. There are different possible value types that can be used:
|
2001-01-04 23:35:50 +00:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<itemizedlist>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2003-10-09 12:42:49 +00:00
|
|
|
basic types:
|
2001-05-02 23:46:27 +00:00
|
|
|
</para>
|
2003-10-09 12:42:49 +00:00
|
|
|
<itemizedlist>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
an integer value: the property has this exact value.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
a boolean value: the property is either TRUE or FALSE.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
a fourcc value: this is a value that is commonly used to
|
|
|
|
describe an encoding for video,
|
|
|
|
as used for example by the AVI specification.
|
|
|
|
<footnote><para>
|
|
|
|
fourcc values consist of four bytes.
|
|
|
|
<ulink url="http://www.fourcc.org" type="http">The FOURCC
|
|
|
|
Definition List</ulink> is the most complete resource
|
|
|
|
on the allowed fourcc values.
|
|
|
|
</para></footnote>
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
a float value: the property has this exact floating point value.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
a string value.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</itemizedlist>
|
2001-05-02 23:46:27 +00:00
|
|
|
</listitem>
|
2003-10-09 12:42:49 +00:00
|
|
|
|
2001-05-02 23:46:27 +00:00
|
|
|
<listitem>
|
|
|
|
<para>
|
2003-10-09 12:42:49 +00:00
|
|
|
range types:
|
2001-05-02 23:46:27 +00:00
|
|
|
</para>
|
2003-10-09 12:42:49 +00:00
|
|
|
<itemizedlist>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
an integer range value: the property denotes a range of
|
|
|
|
possible integer. For example, the wavparse element has
|
|
|
|
a source pad where the "rate" property can go from 8000 to
|
|
|
|
48000.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
a float range value: the property denotes a range of possible
|
|
|
|
floating point values.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</itemizedlist>
|
2001-05-02 23:46:27 +00:00
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2003-10-09 12:42:49 +00:00
|
|
|
a list value: the property can take any value from a list of
|
|
|
|
basic value types or range types.
|
2001-05-02 23:46:27 +00:00
|
|
|
</para>
|
|
|
|
</listitem>
|
2001-01-04 23:35:50 +00:00
|
|
|
</itemizedlist>
|
|
|
|
|
|
|
|
</sect2>
|
2004-01-28 15:08:17 +00:00
|
|
|
<sect2 id="section-pads-caps-use">
|
2002-09-14 14:13:34 +00:00
|
|
|
<title>What capabilities are used for</title>
|
2001-01-05 18:50:41 +00:00
|
|
|
<para>
|
|
|
|
Capabilities describe in great detail the type of media that is handled by the pads.
|
|
|
|
They are mostly used for:
|
|
|
|
</para>
|
|
|
|
<itemizedlist>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Autoplugging: automatically finding plugins for a set of capabilities
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
2003-01-09 14:15:37 +00:00
|
|
|
Compatibility detection: when two pads are linked, <application>GStreamer</application>
|
2001-01-05 18:50:41 +00:00
|
|
|
can verify if the two pads are talking about the same media types.
|
2003-10-09 12:42:49 +00:00
|
|
|
The process of linking two pads and checking if they are compatible
|
|
|
|
is called "caps negotiation".
|
2001-01-05 18:50:41 +00:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</itemizedlist>
|
|
|
|
</sect2>
|
2001-01-04 23:35:50 +00:00
|
|
|
</sect1>
|
|
|
|
</chapter>
|