1 <chapter id="cha-links">
2 <title>Linking elements</title>
4 You can link the different pads of elements together so that the elements
8 <figure float="1" id="sec-link">
9 <title>Visualisation of three linked elements</title>
12 <imagedata fileref="images/linked-elements.&magic;" format="&MAGIC;" />
17 By linking these three elements, we have created a very simple
18 chain. The effect of this will be that the output of the source element
19 (element1) will be used as input for the filter element (element2). The
20 filter element will do something with the data and send the result to
21 the final sink element (element3).
24 Imagine the above graph as a simple MPEG audio decoder. The source
25 element is a disk source, the filter element is the MPEG decoder and
26 the sink element is your audiocard. We will use this simple graph to
27 construct an MPEG player later in this manual.
30 <sect1 id="sec-link-basic">
31 <title>Making simple links</title>
33 You can link two pads with:
36 GstPad *srcpad, *sinkpad;
38 srcpad = gst_element_get_pad (element1, "src");
39 sinpad = gst_element_get_pad (element2, "sink");
42 gst_pad_link (srcpad, sinkpad);
45 gst_pad_unlink (srcpad, sinkpad);
49 A convenient shortcut for the above code is done with the gst_element_link_pads ()
55 gst_element_link_pads (element1, "src", element2, "sink");
58 gst_element_unlink_pads (element1, "src", element2, "sink");
62 An even more convenient shortcut for single-source, single-sink elements is the
63 gst_element_link () function:
68 gst_element_link (element1, element2);
71 gst_element_unlink (element1, element2);
75 If you have more than one element to link, the gst_element_link_many () function takes
76 a NULL-terminated list of elements:
81 gst_element_link_many (element1, element2, element3, element4, NULL);
84 gst_element_unlink_many (element1, element2, element3, element4, NULL);
88 You can query if a pad is linked with GST_PAD_IS_LINKED (pad).
91 To query for the <classname>GstPad</classname> a pad is linked to, use
92 gst_pad_get_peer (pad).
96 <sect1 id="sec-link-filtered">
97 <title>Making filtered links</title>
99 You can also force a specific media type on the link by using gst_pad_link_filtered ()
100 and gst_element_link_filtered (). FIXME link to caps documentation.