You can see from Figure 7-1 how a bin has no pads of its own. This is where "ghost pads" come into play.
A ghost pad is a pad from some element in the bin that can be accessed directly from the bin as well. Compare it to a symbolic link in UNIX filesystems. Using ghost pads on bins, the bin also has a pad and can transparently be used as an element in other parts of your code.
Figure 7-2 is a representation of a
ghost pad. The sink pad of element one is now also a pad of the bin.
Obviously, ghost pads can be added to any type of elements, not just
to a GstBin.
A ghostpad is created using the function
gst_element_add_ghost_pad ():
#include <gst/gst.h>
int
main (int argc,
char *argv[])
{
GstElement *bin, *sink;
/* init */
gst_init (&argc, &argv);
/* create element, add to bin, add ghostpad */
sink = gst_element_factory_make ("fakesink", "sink");
bin = gst_bin_new ("mybin");
gst_bin_add (GST_BIN (bin), sink);
gst_element_add_ghost_pad (bin,
gst_element_get_pad (sink, "sink"), "sink");
[..]
}
In the above example, the bin now also has a pad: the pad called "sink" of the given element. The bin can, from here on, be used as a substitute for the sink element. You could, for example, link another element to the bin.