mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-30 13:41:48 +00:00
3b7659725f
Original commit message from CVS: typos and style fixes
106 lines
3 KiB
XML
106 lines
3 KiB
XML
<chapter id="cha-links">
|
|
<title>Linking elements</title>
|
|
<para>
|
|
You can link the different pads of elements together so that the elements
|
|
form a chain.
|
|
</para>
|
|
|
|
<figure float="1" id="sec-link">
|
|
<title>Visualisation of three linked elements</title>
|
|
<mediaobject>
|
|
<imageobject>
|
|
<imagedata fileref="images/linked-elements.ℑ" format="&IMAGE;" />
|
|
</imageobject>
|
|
</mediaobject>
|
|
</figure>
|
|
<para>
|
|
By linking these three elements, we have created a very simple
|
|
chain. The effect of this will be that the output of the source element
|
|
(element1) will be used as input for the filter element (element2). The
|
|
filter element will do something with the data and send the result to
|
|
the final sink element (element3).
|
|
</para>
|
|
<para>
|
|
Imagine the above graph as a simple MPEG audio decoder. The source
|
|
element is a disk source, the filter element is the MPEG decoder and
|
|
the sink element is your audiocard. We will use this simple graph to
|
|
construct an MPEG player later in this manual.
|
|
</para>
|
|
|
|
<sect1 id="sec-link-basic">
|
|
<title>Making simple links</title>
|
|
<para>
|
|
You can link two pads with:
|
|
</para>
|
|
<programlisting>
|
|
GstPad *srcpad, *sinkpad;
|
|
|
|
srcpad = gst_element_get_pad (element1, "src");
|
|
sinpad = gst_element_get_pad (element2, "sink");
|
|
|
|
// link them
|
|
gst_pad_link (srcpad, sinkpad);
|
|
....
|
|
// and unlink them
|
|
gst_pad_unlink (srcpad, sinkpad);
|
|
|
|
</programlisting>
|
|
<para>
|
|
A convenient shortcut for the above code is done with the gst_element_link_pads ()
|
|
function:
|
|
</para>
|
|
<programlisting>
|
|
|
|
// link them
|
|
gst_element_link_pads (element1, "src", element2, "sink");
|
|
....
|
|
// and unlink them
|
|
gst_element_unlink_pads (element1, "src", element2, "sink");
|
|
|
|
</programlisting>
|
|
<para>
|
|
An even more convenient shortcut for single-source, single-sink elements is the
|
|
gst_element_link () function:
|
|
</para>
|
|
<programlisting>
|
|
|
|
// link them
|
|
gst_element_link (element1, element2);
|
|
....
|
|
// and unlink them
|
|
gst_element_unlink (element1, element2);
|
|
|
|
</programlisting>
|
|
<para>
|
|
If you have more than one element to link, the gst_element_link_many () function takes
|
|
a NULL-terminated list of elements:
|
|
</para>
|
|
<programlisting>
|
|
|
|
// link them
|
|
gst_element_link_many (element1, element2, element3, element4, NULL);
|
|
....
|
|
// and unlink them
|
|
gst_element_unlink_many (element1, element2, element3, element4, NULL);
|
|
|
|
</programlisting>
|
|
<para>
|
|
You can query if a pad is linked with GST_PAD_IS_LINKED (pad).
|
|
</para>
|
|
<para>
|
|
To query for the <classname>GstPad</classname> a pad is linked to, use
|
|
gst_pad_get_peer (pad).
|
|
</para>
|
|
</sect1>
|
|
|
|
<sect1 id="sec-link-filtered">
|
|
<title>Making filtered links</title>
|
|
<para>
|
|
You can also force a specific media type on the link by using gst_pad_link_filtered ()
|
|
and gst_element_link_filtered () with capabilities.
|
|
See <xref linkend="sec-caps"/> for
|
|
an explanation of capabilities.
|
|
</para>
|
|
</sect1>
|
|
|
|
</chapter>
|