| GStreamer Application Development Manual (0.8.7) | ||
|---|---|---|
| <<< Previous | Bins | Next >>> |
You can see from Figure 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 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.
Figure 2 is a representation of a ghost pad. The sink pad of element one is now also a pad of the bin.
Ghost pads can actually be added to all GstElements and not just
GstBins. Use the following code example to add a ghost pad to a bin:
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");
|
In the above example, the bin now also has a pad: the pad called 'sink' of the given element.
We can now, for example, link the source pad of a filesrc element to the bin with:
GstElement *filesrc;
filesrc = gst_element_factory_create ("filesrc", "disk_reader");
gst_element_link_pads (filesrc, "src", bin, "sink");
...
|
| <<< Previous | Home | Next >>> |
| Custom bins | Up | Buffers |