Problems trying to play 2 streams simultaneously

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


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 ?

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.




[Index of Archives]     [Linux Embedded]     [Linux ARM Kernel]     [Linux for ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux Media]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux