<div dir="ltr">I think you need to add bin to pipeline BEFORE linking it:<br><br> if( strncmp( name, "audio", 5 ) == 0 && audio_bin != NULL ) {<br>
<br>
// Add audio bin to the pipeline.<br>
gst_bin_add( GST_BIN(pipeline), audio_bin );<br>
<br>
// Get the audio sink from the bin.<br>
sinkpad = gst_element_get_pad( audio_bin, "audiosink" );<br>
<br>
// Link demux src pad to audio sink pad of bin.<br>
gst_pad_link( pad, sinkpad );<br>
gst_object_unref( sinkpad );<br>
<br>
//gst_element_set_state( audio_bin, GST_STATE_PLAYING );<br>
}<br>
<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, May 14, 2013 at 5:12 PM, Jorge Fernandez Monteagudo <span dir="ltr"><<a href="mailto:jorgefm@cirsa.com" target="_blank">jorgefm@cirsa.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi!<br>
<br>
I've follow your idea but I still have no sound. When I create the pipeline I create the audio bin where I add<br>
all the elements and I create a ghost pad to be linked on the pad-added signal. This is the code:<br>
<br>
// Create audio bin elements<br>
audio_bin = gst_bin_new( NULL );<br>
audio_queue = gst_element_factory_make( "queue", NULL );<br>
audio_decode = gst_element_factory_make( "faad", NULL );<br>
audio_sink = gst_element_factory_make( "alsasink", NULL );<br>
<br>
// Compose the audio bin.<br>
gst_bin_add_many( GST_BIN( audio_bin ),<br>
<div class="im"> audio_queue, audio_decode, audio_sink, NULL );<br>
<br>
// Link all elements that can be automatically linked because they have "Always" pads.<br>
</div> if( gst_element_link_many( audio_queue, audio_decode, audio_sink, NULL ) != TRUE ) {<br>
gst_object_unref( audio_bin );<br>
gst_object_unref( pipeline );<br>
return;<br>
}<br>
<br>
// Create ghost pad on the bin and link to audio queue.<br>
GstPad *sinkpad = gst_element_get_static_pad( audio_queue, "sink" );<br>
gst_element_add_pad( audio_bin, gst_ghost_pad_new( "audiosink", sinkpad ) );<br>
gst_object_unref( sinkpad );<br>
<br>
<br>
Then on the pad-added signal from the demux element I have:<br>
<br>
static void on_pad_demux_added( GstElement *element, GstPad *pad, gpointer data )<br>
{<br>
gchar *name;<br>
GstCaps *caps;<br>
GstPad *sinkpad;<br>
<br>
// Retrieve negotiated caps (or acceptable caps if negotiation is not finished yet).<br>
caps = gst_pad_get_negotiated_caps( pad );<br>
if( !caps )<br>
caps = gst_pad_get_caps_reffed( pad );<br>
<br>
// Get the pad name and link the next element when audio sink is detected.<br>
name = gst_pad_get_name( pad );<br>
<br>
if( strncmp( name, "audio", 5 ) == 0 && audio_bin != NULL ) {<br>
<br>
// Get the audio sink from the bin.<br>
sinkpad = gst_element_get_pad( audio_bin, "audiosink" );<br>
<br>
// Link demux src pad to audio sink pad of bin.<br>
gst_pad_link( pad, sinkpad );<br>
gst_object_unref( sinkpad );<br>
<br>
// Add audio bin to the pipeline.<br>
gst_bin_add( GST_BIN(pipeline), audio_bin );<br>
<br>
//gst_element_set_state( audio_bin, GST_STATE_PLAYING );<br>
}<br>
<br>
gst_caps_unref( caps );<br>
g_free( caps_str );<br>
g_free( name );<br>
}<br>
<br>
<br>
Then when I run the app I can see the video but I get no audio. Am I missing something?<br>
Maybe some state change, like the commented line? Any hint is welcome!<br>
<div><div class="h5"><br>
Thanks!<br>
<br>
________________________________________<br>
From: gstreamer-devel-bounces+jorgefm=<a href="mailto:cirsa.com@lists.freedesktop.org">cirsa.com@lists.freedesktop.org</a> [gstreamer-devel-bounces+jorgefm=<a href="mailto:cirsa.com@lists.freedesktop.org">cirsa.com@lists.freedesktop.org</a>] On Behalf Of Stirling Westrup [<a href="mailto:swestrup@gmail.com">swestrup@gmail.com</a>]<br>
Sent: Tuesday, May 14, 2013 12:07 AM<br>
To: Discussion of the development of and with GStreamer<br>
Subject: Re: Dynamic pipelines<br>
<br>
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.<br>
<br>
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.<br>
<br>
<br>
<br>
On Mon, May 13, 2013 at 5:05 PM, Jorge Fernandez Monteagudo <<a href="mailto:jorgefm@cirsa.com">jorgefm@cirsa.com</a><mailto:<a href="mailto:jorgefm@cirsa.com">jorgefm@cirsa.com</a>>> wrote:<br>
Hi all!<br>
<br>
I have implemented this pipeline by code:<br>
<br>
gst-launch-0.10 filesrc location=test.mp4 ! qtdemux name=demux \<br>
demux.video_00 ! queue max-size-buffers=2 max-size-time=0 max-size-bytes=0 ! ffdec_h264 ! xvimagesink \<br>
demux.audio_00 ! queue max-size-buffers=8000 max-size-time=0 max-size-bytes=0 ! faad ! alsasink<br>
<br>
When I try to play a 'test.mp4' without audio channel the pipeline is frozen. I use the qtdemux callback<br>
"pad-added" to link the demux with the queues. When no audio channel is present no link is made from<br>
demux and audio queue. The problem is that the elements has been added initially to the pipeline but<br>
they never has data, then they can change to ready or playing state<br>
<br>
// Compose the pipeline.<br>
gst_bin_add_many( GST_BIN( pipeline ), filesrc, demux,<br>
video_queue, video_decode, video_sink,<br>
audio_queue, audio_decode, audio_sink, NULL );<br>
<br>
// Link all elements that can be automatically linked because they have "Always" pads.<br>
if( gst_element_link_many( filesrc, demux, NULL ) != TRUE ||<br>
gst_element_link_many( video_queue, video_decode, NULL ) != TRUE ||<br>
gst_element_link_many( video_decode, video_sink, NULL ) != TRUE ||<br>
gst_element_link_many( audio_queue, audio_decode, NULL ) != TRUE ||<br>
gst_element_link_many( audio_decode, audio_sink, NULL ) != TRUE ) {<br>
TRACEMSG( "%s - One element could not be linked.\n", __FUNCTION__ );<br>
gst_object_unref( pipeline );<br>
return NULL;<br>
}<br>
<br>
I think its a begginer question but how can I solve this? Ideally I would like to know if it's<br>
possible to generate the correct pipeline at runtime? What's the correct way to implement this?<br>
<br>
Thanks!!<br>
Jorge<br>
<br>
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.<br>
<br>
This message is intended exclusively for its addressee and may contain information that is CONFIDENTIAL and protected by professional privilege.<br>
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.<br>
_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a><mailto:<a href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a>><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a><br>
<br>
<br>
<br>
--<br>
Stirling Westrup<br>
Programmer, Entrepreneur.<br>
<a href="https://www.linkedin.com/e/fpf/77228" target="_blank">https://www.linkedin.com/e/fpf/77228</a><br>
<a href="http://www.linkedin.com/in/swestrup" target="_blank">http://www.linkedin.com/in/swestrup</a><br>
<a href="http://technaut.livejournal.com" target="_blank">http://technaut.livejournal.com</a><br>
<a href="http://sourceforge.net/users/stirlingwestrup" target="_blank">http://sourceforge.net/users/stirlingwestrup</a><br>
_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a><br>
</div></div><a href="http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Stirling Westrup<br>Programmer, Entrepreneur.<br><a href="https://www.linkedin.com/e/fpf/77228" target="_blank">https://www.linkedin.com/e/fpf/77228</a><br><a href="http://www.linkedin.com/in/swestrup" target="_blank">http://www.linkedin.com/in/swestrup</a><br>
<a href="http://technaut.livejournal.com" target="_blank">http://technaut.livejournal.com</a><br><a href="http://sourceforge.net/users/stirlingwestrup" target="_blank">http://sourceforge.net/users/stirlingwestrup</a>
</div>