Chapter 15. Linking elements

15.1. Making simple links

You can link two pads with:


 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);

  

A convenient shortcut for the above code is done with the gst_element_link_pads () function:


 // link them
 gst_element_link_pads (element1, "src", element2, "sink");
   ....
 // and unlink them
 gst_element_unlink_pads (element1, "src", element2, "sink");

  

An even more convenient shortcut but only works for single-source, single-sink elements is the gst_element_link () function:


 // link them
 gst_element_link (element1, element2);
   ....
 // and unlink them
 gst_element_unlink (element1, element2);

  

If you have more than one element to link, the gst_element_link_many () function takes a NULL-terminated list of elements. Again this only works for single-source single-sink elements:


 // link them
 gst_element_link_many (element1, element2, element3, element4, NULL);
   ....
 // and unlink them
 gst_element_unlink_many (element1, element2, element3, element4, NULL);

  

You can query if a pad is linked with GST_PAD_IS_LINKED (pad).

To query for the GstPad a pad is linked to, use gst_pad_get_peer (pad).