Hi good people,<br><br>I&#39;m new to gstreamer and I have a problem of using decodebin as a decoder to play video file. Below is my sample code that I use. The code below runs fine for one stream of media. But if I want to play both streams(audio and video), it doesn&#39;t work. <br>
Can anyone tell me what I did wrong here? (Please don&#39;t suggest to use playbin) :)<br><br>Thank you.<br><br>Fariq.<br><br>####Sample code####<br><br>#include &lt;gst/gst.h&gt;<br>#include &lt;glib-2.0/glib/gprintf.h&gt;<br>
#include &lt;gstreamer-0.10/gst/gstelement.h&gt;<br>#include &lt;glib-2.0/glib/gmessages.h&gt;<br><br>GstElement *pipeline, *audio,*video,*audioqueue,*videoqueue;<br><br>static void<br>cb_newpad (GstElement *decodebin,<br>
       GstPad     *pad,<br>       gboolean    last,<br>       gpointer    data)<br>{<br>  GstPad *audiopad,*videopad;<br><br>  /* link audiopad */<br>  audiopad = gst_element_get_static_pad (audio, &quot;sink&quot;);<br>  if (!GST_PAD_IS_LINKED (audiopad)) {<br>
      gst_pad_link (pad, audiopad);<br>      g_print(&quot;audiopad has been linked&quot;);<br>    g_object_unref (audiopad);<br>    return;<br>  }<br>/* link videopad */<br>  videopad = gst_element_get_static_pad(video,&quot;sink&quot;);<br>
  if (!GST_PAD_IS_LINKED (videopad)) {<br>      gst_pad_link(pad,videopad);<br>      gst_element_link(videoqueue,video);<br>    g_object_unref (videopad);<br>    return;<br>  }<br>}<br><br>gint<br>main (gint   argc,<br>      gchar *argv[])<br>
{<br>  GMainLoop *loop;<br>  GstElement *src, *dec, *conv, *sink, *typefind,*typefind2;//*myplugin;<br>  GstElement *convVid,*videosink;<br>  GstPad *audiopad,*videopad;<br>  GstBus *bus;<br><br>  /* init GStreamer */<br>
  gst_init (&amp;argc, &amp;argv);<br>  loop = g_main_loop_new (NULL, FALSE);<br><br>  /* make sure we have input */<br>  if (argc != 2) {<br>    g_print (&quot;Usage: %s &lt;filename&gt;\n&quot;, argv[0]);<br>    return -1;<br>
  }<br><br>  g_print(&quot;Playing %s \n&quot;,argv[1]);<br><br>  /* setup */<br>  pipeline = gst_pipeline_new (&quot;pipeline&quot;);<br><br>  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));<br>  gst_bus_add_watch (bus, my_bus_callback, loop);<br>
  gst_object_unref (bus);<br><br>  src = gst_element_factory_make (&quot;filesrc&quot;, &quot;source&quot;);<br>  g_object_set (G_OBJECT (src), &quot;location&quot;, argv[1], NULL);<br>  typefind = gst_element_factory_make(&quot;typefind&quot;,&quot;typefinder&quot;);<br>
  g_signal_connect(typefind,&quot;have-type&quot;,G_CALLBACK(typefound_cb),loop);<br>  dec = gst_element_factory_make (&quot;decodebin&quot;, &quot;decoder&quot;);<br>  g_signal_connect (dec, &quot;new-decoded-pad&quot;, G_CALLBACK (cb_newpad), NULL);<br>
  //myplugin = gst_element_factory_make(&quot;myplugin&quot;,&quot;MyPlugin&quot;);<br>  audioqueue = gst_element_factory_make(&quot;queue&quot;,&quot;audioqueue&quot;);<br>  videoqueue = gst_element_factory_make(&quot;queue&quot;,&quot;videoqueue&quot;);<br>
  gst_bin_add_many (GST_BIN (pipeline), src,typefind,dec,NULL);<br>  gst_element_link_many (src,typefind,dec,NULL);<br><br>  /* create audio output */<br>  audio = gst_bin_new (&quot;audiobin&quot;);<br>  conv = gst_element_factory_make (&quot;audioconvert&quot;, &quot;aconv&quot;);<br>
  typefind2 = gst_element_factory_make(&quot;typefind&quot;,&quot;typefinder2&quot;);<br>  //g_signal_connect(typefind2,&quot;have-type&quot;,G_CALLBACK(typefound_cb),loop);<br>  audiopad = gst_element_get_static_pad (audioqueue, &quot;sink&quot;);<br>
  sink = gst_element_factory_make (&quot;osssink&quot;, &quot;sink&quot;);<br>  gst_bin_add_many (GST_BIN (audio),audioqueue,conv,typefind2, sink, NULL);<br>  gst_element_link_many (audioqueue,conv,typefind2, sink,NULL);<br>
  gst_element_add_pad (audio,<br>      gst_ghost_pad_new (&quot;sink&quot;, audiopad));<br>  gst_object_unref (audiopad);<br>  gst_bin_add (GST_BIN (pipeline), audio);<br><br>  /* create video output */<br>  video = gst_bin_new(&quot;videobin&quot;);<br>
  convVid = gst_element_factory_make(&quot;ffmpegcolorspace&quot;,&quot;converter&quot;);<br>  videopad = gst_element_get_static_pad(videoqueue,&quot;sink&quot;);<br>  videosink = gst_element_factory_make(&quot;xvimagesink&quot;,&quot;videosink&quot;);<br>
  gst_bin_add_many(GST_BIN(video),videoqueue,convVid,videosink,NULL);<br>  gst_element_link_many(videoqueue,convVid,videosink,NULL);<br>  gst_element_add_pad(video,gst_ghost_pad_new(&quot;sink&quot;,videopad));<br>  gst_object_unref(videopad);<br>
  gst_bin_add(GST_BIN(pipeline),video);<br><br>  /* run */<br>  gst_element_set_state (pipeline, GST_STATE_PLAYING);<br>  g_timeout_add (200, (GSourceFunc) cb_print_position, pipeline);<br>  g_main_loop_run (loop);<br><br>
  /* cleanup */<br>  gst_element_set_state (pipeline, GST_STATE_NULL);<br>  gst_object_unref (GST_OBJECT (pipeline));<br><br>  return 0;<br>}<br>