| GStreamer Application Development Manual | ||
|---|---|---|
| <<< Previous | Bins | Next >>> |
You can see from figure ... how a bin has no pads of its own. This is where Ghostpads come into play.
A ghostpad 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.
Above is a representation of a ghostpad. the sinkpad of element one is now also a pad of the bin.
Ghostpads can actually be added to all GstElements and not just GstBins. Use the following code example to add a ghostpad to a bin:
GstElement *bin;
GstElement *element;
element = gst_elementfactory_create ("mpg123", "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"));
|
In the above example, the bin now also has a pad: the pad called 'sink' of the given element. We can now, for example, connect the srcpad of a disksrc to the bin with:
GstElement *disksrc;
disksrc = gst_elementfactory_create ("disksrc", "disk_reader");
gst_element_connect (disksrc, "src", bin, "sink");
...
|
| <<< Previous | Home | Next >>> |
| Custom bins | Up | Buffers |