an optional and cutomizable element

Tim-Philipp Müller t.i.m at zen.co.uk
Sat Jan 5 06:02:55 PST 2013


On Sat, 2013-01-05 at 13:22 +1300, Angelica Perduta wrote:

Hi Angelica,

> I want to add an optional element in my manually constructed pipe.
> So I thought of having a configurable string to pass to
> gst_parse_launch (this will then implement my customizable filter).
> The problem is that I can't understand how to link to the source and
> sink pads of the element that  gst_parse_launch creates.
> So simplified down it's like this:
> 
> [code]
> GstElement *pSink = gst_parse_launch("audioconvert ! autoaudiosink", &pErr);
> GstElement *pSource = gst_element_factory_make ("audiotestsrc", "source");
> pPipe = gst_pipeline_new("test_pipe");
> gst_bin_add_many(GST_BIN(pPipe), pSource, pSink, NULL);
> if (!gst_element_link (pSource, pSink)) cs::fail("failed link\n"); //
> it fails to link them :(
> [/code]

By default gst_parse_launch() creates a top-level pipeline, which is
self-contained and has no pads (you can add it to another pipeline, then
it should behave like a normal bin, but it's better to just create a bin
from the start then, to make sure you're not running into weird bugs).

Use gst_parse_bin_from_description() instead of gst_parse_launch() and
pass ghost_unlinked_pads=TRUE.

The problem is that the pipeline/bin created has no external pads at
all, and the unlinked pad from the audioconvert inside the bin is not
visible to the world outside that bin. A ghostpad is a pad created at
the bin that links to the unlinked pad of the internal audioconvert and
so makes that visible to the outside world.

Cheers 
 -Tim

PS: just to be sure, for playback purposes also check out uridecodebin
and playbin.



More information about the gstreamer-devel mailing list