<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML ><HEAD ><TITLE >Ghost pads</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="Bins" HREF="chapter-bins-api.html"><LINK REL="PREVIOUS" TITLE="Custom bins" HREF="section-bin-custom.html"><LINK REL="NEXT" TITLE="Buffers" HREF="chapter-buffers-api.html"></HEAD ><BODY CLASS="sect1" 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="section-bin-custom.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" >Chapter 16. Bins</TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="chapter-buffers-api.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="sect1" ><H1 CLASS="sect1" ><A NAME="section-bin-ghostpads" >16.4. Ghost pads</A ></H1 ><P > You can see from <A HREF="section-bin-ghostpads.html#section-bin-noghost-img" >Figure 16-1</A > how a bin has no pads of its own. This is where "ghost pads" come into play. </P ><DIV CLASS="figure" ><A NAME="section-bin-noghost-img" ></A ><P ><B >Figure 16-1. Visualisation of a <CODE CLASS="classname" >GstBin</CODE > element without ghost pads</B ></P ><DIV CLASS="mediaobject" ><P ><IMG SRC="images/bin-element-noghost.png"></P ></DIV ></DIV ><P > A ghost pad is a pad from some element in the bin that has been promoted to the bin. This way, the bin also has a pad. The bin becomes just another element with a pad and you can then use the bin just like any other element. This is a very important feature for creating custom bins. </P ><DIV CLASS="figure" ><A NAME="section-bin-ghost-img" ></A ><P ><B >Figure 16-2. Visualisation of a <CODE CLASS="classname" >GstBin</CODE > element with a ghost pad</B ></P ><DIV CLASS="mediaobject" ><P ><IMG SRC="images/bin-element-ghost.png"></P ></DIV ></DIV ><P > <A HREF="section-bin-ghostpads.html#section-bin-ghost-img" >Figure 16-2</A > is a representation of a ghost pad. The sink pad of element one is now also a pad of the bin. </P ><P > Ghost pads can actually be added to all <CODE CLASS="classname" >GstElement</CODE >s and not just <CODE CLASS="classname" >GstBin</CODE >s. Use the following code example to add a ghost pad to a bin: </P ><PRE CLASS="programlisting" > GstElement *bin; GstElement *element; element = gst_element_factory_create ("mad", "decoder"); bin = gst_bin_new ("mybin"); gst_bin_add (GST_BIN (bin), element); gst_element_add_ghost_pad (bin, gst_element_get_pad (element, "sink"), "sink"); </PRE ><P > In the above example, the bin now also has a pad: the pad called 'sink' of the given element. </P ><P > We can now, for example, link the source pad of a filesrc element to the bin with: </P ><PRE CLASS="programlisting" > GstElement *filesrc; filesrc = gst_element_factory_create ("filesrc", "disk_reader"); gst_element_link_pads (filesrc, "src", bin, "sink"); ... </PRE ></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="section-bin-custom.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="chapter-buffers-api.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Custom bins</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="chapter-bins-api.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Buffers</TD ></TR ></TABLE ></DIV ></BODY ></HTML >