2004-01-28 15:08:17 +00:00
|
|
|
<chapter id="chapter-links-api">
|
2003-12-29 14:15:02 +00:00
|
|
|
<title>Linking elements</title>
|
2004-01-28 15:08:17 +00:00
|
|
|
<sect1 id="section-link-basic">
|
2003-12-29 14:15:02 +00:00
|
|
|
<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>
|
2004-07-16 00:43:57 +00:00
|
|
|
An even more convenient shortcut but only works for single-source, single-sink elements is the
|
2003-12-29 14:15:02 +00:00
|
|
|
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
|
2004-07-16 00:43:57 +00:00
|
|
|
a NULL-terminated list of elements. Again this only works for single-source single-sink
|
|
|
|
elements:
|
2003-12-29 14:15:02 +00:00
|
|
|
</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>
|
|
|
|
|
2004-01-28 15:08:17 +00:00
|
|
|
<sect1 id="section-link-filtered">
|
2003-12-29 14:15:02 +00:00
|
|
|
<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.
|
2004-01-28 15:08:17 +00:00
|
|
|
See <xref linkend="section-caps"/> for
|
2003-12-29 14:15:02 +00:00
|
|
|
an explanation of capabilities.
|
|
|
|
</para>
|
|
|
|
</sect1>
|
|
|
|
|
|
|
|
</chapter>
|