Dynamic pipelines
Jorge Fernandez Monteagudo
jorgefm at cirsa.com
Tue May 14 14:12:51 PDT 2013
Hi!
I've follow your idea but I still have no sound. When I create the pipeline I create the audio bin where I add
all the elements and I create a ghost pad to be linked on the pad-added signal. This is the code:
// Create audio bin elements
audio_bin = gst_bin_new( NULL );
audio_queue = gst_element_factory_make( "queue", NULL );
audio_decode = gst_element_factory_make( "faad", NULL );
audio_sink = gst_element_factory_make( "alsasink", NULL );
// Compose the audio bin.
gst_bin_add_many( GST_BIN( audio_bin ),
audio_queue, audio_decode, audio_sink, NULL );
// Link all elements that can be automatically linked because they have "Always" pads.
if( gst_element_link_many( audio_queue, audio_decode, audio_sink, NULL ) != TRUE ) {
gst_object_unref( audio_bin );
gst_object_unref( pipeline );
return;
}
// Create ghost pad on the bin and link to audio queue.
GstPad *sinkpad = gst_element_get_static_pad( audio_queue, "sink" );
gst_element_add_pad( audio_bin, gst_ghost_pad_new( "audiosink", sinkpad ) );
gst_object_unref( sinkpad );
Then on the pad-added signal from the demux element I have:
static void on_pad_demux_added( GstElement *element, GstPad *pad, gpointer data )
{
gchar *name;
GstCaps *caps;
GstPad *sinkpad;
// Retrieve negotiated caps (or acceptable caps if negotiation is not finished yet).
caps = gst_pad_get_negotiated_caps( pad );
if( !caps )
caps = gst_pad_get_caps_reffed( pad );
// Get the pad name and link the next element when audio sink is detected.
name = gst_pad_get_name( pad );
if( strncmp( name, "audio", 5 ) == 0 && audio_bin != NULL ) {
// Get the audio sink from the bin.
sinkpad = gst_element_get_pad( audio_bin, "audiosink" );
// Link demux src pad to audio sink pad of bin.
gst_pad_link( pad, sinkpad );
gst_object_unref( sinkpad );
// Add audio bin to the pipeline.
gst_bin_add( GST_BIN(pipeline), audio_bin );
//gst_element_set_state( audio_bin, GST_STATE_PLAYING );
}
gst_caps_unref( caps );
g_free( caps_str );
g_free( name );
}
Then when I run the app I can see the video but I get no audio. Am I missing something?
Maybe some state change, like the commented line? Any hint is welcome!
Thanks!
________________________________________
From: gstreamer-devel-bounces+jorgefm=cirsa.com at lists.freedesktop.org [gstreamer-devel-bounces+jorgefm=cirsa.com at lists.freedesktop.org] On Behalf Of Stirling Westrup [swestrup at gmail.com]
Sent: Tuesday, May 14, 2013 12:07 AM
To: Discussion of the development of and with GStreamer
Subject: Re: Dynamic pipelines
The secret is to not add any elements to a pipeline that aren't going to be used by the pipeline. I have a very similar setup in my application and I ended up creating output bins for the audio and video outputs. Then on a pad-added signal I insert the needed bin and connect it to the pad.
On EOS, after the pipeline is put into the ready state I pull the two bins back out of the pipeline in anticipation of the next file to play.
On Mon, May 13, 2013 at 5:05 PM, Jorge Fernandez Monteagudo <jorgefm at cirsa.com<mailto:jorgefm at cirsa.com>> wrote:
Hi all!
I have implemented this pipeline by code:
gst-launch-0.10 filesrc location=test.mp4 ! qtdemux name=demux \
demux.video_00 ! queue max-size-buffers=2 max-size-time=0 max-size-bytes=0 ! ffdec_h264 ! xvimagesink \
demux.audio_00 ! queue max-size-buffers=8000 max-size-time=0 max-size-bytes=0 ! faad ! alsasink
When I try to play a 'test.mp4' without audio channel the pipeline is frozen. I use the qtdemux callback
"pad-added" to link the demux with the queues. When no audio channel is present no link is made from
demux and audio queue. The problem is that the elements has been added initially to the pipeline but
they never has data, then they can change to ready or playing state
// Compose the pipeline.
gst_bin_add_many( GST_BIN( pipeline ), filesrc, demux,
video_queue, video_decode, video_sink,
audio_queue, audio_decode, audio_sink, NULL );
// Link all elements that can be automatically linked because they have "Always" pads.
if( gst_element_link_many( filesrc, demux, NULL ) != TRUE ||
gst_element_link_many( video_queue, video_decode, NULL ) != TRUE ||
gst_element_link_many( video_decode, video_sink, NULL ) != TRUE ||
gst_element_link_many( audio_queue, audio_decode, NULL ) != TRUE ||
gst_element_link_many( audio_decode, audio_sink, NULL ) != TRUE ) {
TRACEMSG( "%s - One element could not be linked.\n", __FUNCTION__ );
gst_object_unref( pipeline );
return NULL;
}
I think its a begginer question but how can I solve this? Ideally I would like to know if it's
possible to generate the correct pipeline at runtime? What's the correct way to implement this?
Thanks!!
Jorge
Este mensaje se dirige exclusivamente a su destinatario y puede contener información privilegiada o CONFIDENCIAL. Si no es vd. el destinatario indicado, queda notificado de que la utilización, divulgación y/o copia sin autorización está prohibida en virtud de la legislación vigente. Si ha recibido este mensaje por error, le rogamos que nos lo comunique inmediatamente por esta misma vía y proceda a su destrucción.
This message is intended exclusively for its addressee and may contain information that is CONFIDENTIAL and protected by professional privilege.
If you are not the intended recipient you are hereby notified that any dissemination, copy or disclosure of this communication is strictly prohibited by law. If this message has been received in error, please immediately notify us via e-mail and delete it.
_______________________________________________
gstreamer-devel mailing list
gstreamer-devel at lists.freedesktop.org<mailto:gstreamer-devel at lists.freedesktop.org>
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
--
Stirling Westrup
Programmer, Entrepreneur.
https://www.linkedin.com/e/fpf/77228
http://www.linkedin.com/in/swestrup
http://technaut.livejournal.com
http://sourceforge.net/users/stirlingwestrup
_______________________________________________
gstreamer-devel mailing list
gstreamer-devel at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
More information about the gstreamer-devel
mailing list