<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML ><HEAD ><TITLE >Linking elements</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="GStreamer Application Development Manual" HREF="index.html"><LINK REL="UP" TITLE="Basic API" HREF="part-basic-api.html"><LINK REL="PREVIOUS" TITLE="Plugins" HREF="chapter-plugins-api.html"><LINK REL="NEXT" TITLE="Making filtered links" HREF="section-link-filtered.html"></HEAD ><BODY CLASS="chapter" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" ><SPAN CLASS="application" >GStreamer</SPAN > Application Development Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="chapter-plugins-api.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="section-link-filtered.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="chapter" ><H1 ><A NAME="chapter-links-api" ></A >Chapter 15. Linking elements</H1 ><DIV CLASS="sect1" ><H1 CLASS="sect1" ><A NAME="section-link-basic" >15.1. Making simple links</A ></H1 ><P > You can link two pads with: </P ><PRE CLASS="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); </PRE ><P > A convenient shortcut for the above code is done with the gst_element_link_pads () function: </P ><PRE CLASS="programlisting" > // link them gst_element_link_pads (element1, "src", element2, "sink"); .... // and unlink them gst_element_unlink_pads (element1, "src", element2, "sink"); </PRE ><P > An even more convenient shortcut for single-source, single-sink elements is the gst_element_link () function: </P ><PRE CLASS="programlisting" > // link them gst_element_link (element1, element2); .... // and unlink them gst_element_unlink (element1, element2); </PRE ><P > If you have more than one element to link, the gst_element_link_many () function takes a NULL-terminated list of elements: </P ><PRE CLASS="programlisting" > // link them gst_element_link_many (element1, element2, element3, element4, NULL); .... // and unlink them gst_element_unlink_many (element1, element2, element3, element4, NULL); </PRE ><P > You can query if a pad is linked with GST_PAD_IS_LINKED (pad). </P ><P > To query for the <CODE CLASS="classname" >GstPad</CODE > a pad is linked to, use gst_pad_get_peer (pad). </P ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="chapter-plugins-api.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="section-link-filtered.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Plugins</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="part-basic-api.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Making filtered links</TD ></TR ></TABLE ></DIV ></BODY ></HTML >