<br><br><div class="gmail_quote">On Tue, Oct 20, 2009 at 9:21 AM, Rajesh Marathe <span dir="ltr"><<a href="mailto:rmarathe@i-rode.com">rmarathe@i-rode.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 am new to gstreamer and started working on it very recently. While I<br>
am studying, I wrote a program to play two streams alternately using<br>
gstreamer. Details below:<br>
<br>
Development environment:<br>
-------------------------------------<br>
<br>
LTIB and iMX27ADS board. Host PC has Redhat EL5.0.<br>
<br>
Problem description:<br>
-----------------------------<br>
<br>
I have two MP4 files. My intention is to play the first file for a few<br>
seconds and pause the same and play the second file fully. After getting<br>
End-of-Steam message for second file, resume and complete the first<br>
file. My program looks like this:<br>
<br>
int<br>
main (int argc,<br>
char *argv[])<br>
{<br>
GMainLoop *loop;<br>
GstStateChangeReturn retval;<br>
<br>
<br>
/* Initialisation */<br>
gst_init (&argc, &argv);<br>
<br>
loop = g_main_loop_new (NULL, FALSE);<br>
<br>
/* Create gstreamer elements */<br>
masterpipe = GstCreatePipelineMaster ("master-player", argv[1]);<br>
slavepipe = GstCreatePipelineSlave ("slave-player", argv[2]);<br>
<br>
retval = gst_element_set_state (slavepipe, GST_STATE_PAUSED);<br>
<br>
retval = gst_element_set_state (masterpipe, GST_STATE_PLAYING);<br>
<br>
g_timeout_add (4000, (GSourceFunc) cb_print_position, masterpipe);<br>
g_main_loop_run (loop);<br>
...<br>
...<br>
}<br>
<br>
static GstElement * GstCreatePipelineMaster (char *name, char *file)<br>
{<br>
<br>
GstElement *pipeline;<br>
<br>
/* Create gstreamer elements */<br>
pipeline = gst_pipeline_new (name);<br>
source = gst_element_factory_make ("filesrc","file-source");<br>
demuxer = gst_element_factory_make<br>
("mfw_mp4demuxer","avi-demuxer");<br>
decvd = gst_element_factory_make ("mfw_vpudecoder",<br>
"video-decoder");<br>
decad = gst_element_factory_make ("mad", "mp3-decoder");<br>
vdsink = gst_element_factory_make ("mfw_v4lsink",<br>
"video-sink");<br>
vdqueue = gst_element_factory_make ("queue",<br>
"video-queue");<br>
adqueue = gst_element_factory_make ("queue",<br>
"audio-queue");<br>
adsink = gst_element_factory_make ("fakesink",<br>
"audio-sink");<br>
<br>
g_object_set (decvd, "codec-type", "std_mpeg4", NULL);<br>
if (!pipeline || !source || !demuxer || !decvd || !decad || !vdsink<br>
|| !vdqueue || !adqueue || !adsink) {<br>
return NULL;<br>
}<br>
<br>
/* Set up the pipeline */<br>
<br>
/* we set the input filename to the source element */<br>
g_object_set (G_OBJECT (source), "location", file, NULL);<br>
<br>
<br>
/* we add all elements into the pipeline */<br>
/* file-source | ogg-demuxer | vorbis-decoder | converter |<br>
alsa-output */<br>
gst_bin_add_many (GST_BIN (pipeline),<br>
source, demuxer, decvd, decad,/* adqueue,<br>
vdqueue,*/ vdsink, adsink, NULL);<br>
<br>
/* we link the elements together */<br>
/* file-source -> ogg-demuxer ~> vorbis-decoder -> converter -><br>
alsa-output */<br>
gst_element_link (source, demuxer);<br>
gst_element_link (decvd, vdsink);<br>
// gst_element_link (vdqueue, vdsink);<br>
// gst_element_link (decad, adqueue);<br>
// gst_element_link (adqueue, adsink);<br>
gst_element_link (decad, adsink);<br>
<br>
g_signal_connect (demuxer, "pad-added", G_CALLBACK (on_pad_added), NULL);<br>
<br>
return pipeline;<br>
}<br>
<br>
static GstElement * GstCreatePipelineSlave (char *name, char *file)<br>
{<br>
<br>
GstElement *pipeline;<br>
<br>
/* Create gstreamer elements */<br>
pipeline = gst_pipeline_new (name);<br>
<br>
/* Set up the pipeline */<br>
<br>
/* we set the input filename to the source element */<br>
g_object_set (G_OBJECT (source), "location", file, NULL);<br>
<br>
<br>
/* we add all elements into the pipeline */<br>
/* file-source | ogg-demuxer | vorbis-decoder | converter |<br>
alsa-output */<br>
gst_bin_add_many (GST_BIN (pipeline),<br>
source, demuxer, decvd, decad,/* adqueue,<br>
vdqueue,*/ vdsink, adsink, NULL);<br>
<br>
return pipeline;<br>
<br>
}<br>
<br>
<br>
Please note above, that I am creating two pipelines Master and slave and<br>
adding same elements to the master adn slave 'bin's. Is this okay to do ?<br></blockquote><div> </div><div>The elements can only have a single parent bin, it can't be inside two bins at the same time. </div><div>
You would probably notice the problem by checking the result of gst_bin_add*</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
I do see the master playing and after few seconds the timer function is<br>
called in which I move the master to 'PAUSE' state and slave to<br>
'PLAYING'. But the slave media does not play at all??<br>
<br>
Can anybody let me know what is wrong above ?<br>
<br>
regards,<br>
Rajesh Marathe.<br>
<br>
------------------------------------------------------------------------------<br>
Come build with us! The BlackBerry(R) Developer Conference in SF, CA<br>
is the only developer event you need to attend this year. Jumpstart your<br>
developing skills, take BlackBerry mobile applications to market and stay<br>
ahead of the curve. Join us from November 9 - 12, 2009. Register now!<br>
<a href="http://p.sf.net/sfu/devconference" target="_blank">http://p.sf.net/sfu/devconference</a><br>
_______________________________________________<br>
Gstreamer-embedded mailing list<br>
<a href="mailto:Gstreamer-embedded@lists.sourceforge.net">Gstreamer-embedded@lists.sourceforge.net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/gstreamer-embedded" target="_blank">https://lists.sourceforge.net/lists/listinfo/gstreamer-embedded</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Thiago Sousa Santos<br>