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