Hi ,

i want to implement the below pipeline using gstreamer API in c.


  /* Audio has to play repeatedly */
  gst-launch-0.10 interleave name=i ! alsasink filesrc 
location=/home/saravanan/Music/1.wav ! decodebin ! audioconvert ! i.sink1 
filesrc location=/home/saravanan/Music/s.wav ! decodebin ! audioconvert ! 
i.sink0

For this i have done the coding, but it is not giving error as well as not 
playing also. Please guide me to solve the below code issue.


#include <gst/gst.h>

gboolean bus_callback(GstBus *bus, GstMessage *msg, gpointer data)
{
    GstElement *play = GST_ELEMENT(data);
    switch (GST_MESSAGE_TYPE(msg))
    {
    case GST_MESSAGE_EOS:
        /* restart playback if at end */
        if (!gst_element_seek(play,
                    1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH,
                    GST_SEEK_TYPE_SET,  2000000000, //2 seconds (in nanoseconds)
                    GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE)) {
            g_print("Seek failed!\n");
        }
        break;
    default:
        break;
    }
    return TRUE;
}

/* gst-launch-0.10 interleave name=i ! alsasink filesrc 
location=/home/saravanan/Music/1.wav ! decodebin ! audioconvert ! 
audio/x-raw-int,channels=1 ! i.sink1 filesrc 
location=/home/saravanan/Music/s.wav ! decodebin ! audioconvert ! 
audio/x-raw-int,channels=1 ! i.sink0 */

gint
main (gint   argc,
      gchar *argv[])
{
  GMainLoop  *loop;

  GstElement *pipeline,
             *filesrc_ch_1, *filesrc_ch_2,
             *audioconvert_ch_1, *audioconvert_ch_2,
             *decodebin_ch_1, *decodebin_ch_2,
             *interleave, *alsasink;

  GstPad *pad_ch_1, *pad_ch_2;
  GstBus *bus;
  gchar *name1, *name2;
  /* init GStreamer */
  gst_init (&argc, &argv);
  loop = g_main_loop_new (NULL, FALSE);


  /* make sure we have a URI */
  if (argc != 3) {
    g_print ("Usage: %s <URI>\n", argv[0]);
    return -1;
  }

  pipeline = gst_pipeline_new ("pipeline0");

  g_signal_connect (pipeline, "deep_notify",
         G_CALLBACK(gst_object_default_deep_notify), NULL);

  alsasink = gst_element_factory_make("alsasink", "alsasink");
  g_assert (alsasink);

  /* channel 1*/
  filesrc_ch_1  = gst_element_factory_make ("filesrc", "filesrcchannel1");
  g_assert (filesrc_ch_1);

  decodebin_ch_1 = gst_element_factory_make("decodebin", "decodechannel1");
  g_assert (decodebin_ch_1);

  audioconvert_ch_1 = gst_element_factory_make("audioconvert", 
"audioconvertchannle1");
  g_assert (audioconvert_ch_1);

  /* channel 2*/
  filesrc_ch_2  = gst_element_factory_make ("filesrc", "filesrcchannel2");
  g_assert (filesrc_ch_2);

  decodebin_ch_2 = gst_element_factory_make("decodebin", "decodechannel2");
  g_assert (decodebin_ch_2);

  audioconvert_ch_2 = gst_element_factory_make("audioconvert", 
"audioconvertchannel2");
  g_assert (audioconvert_ch_2);

  interleave = gst_element_factory_make ("interleave", "interleave");
  g_assert (interleave);


  g_object_set (G_OBJECT (filesrc_ch_1), "location", argv[1], NULL);
  g_object_set (G_OBJECT (filesrc_ch_2), "location", argv[2], NULL);


  pad_ch_1 = gst_element_get_request_pad (interleave, "sink%d");
  name1 = gst_pad_get_name (pad_ch_1);
  g_print ("A new pad %s was created\n", name1);

  pad_ch_2 = gst_element_get_request_pad (interleave, "sink%d");
  name2 = gst_pad_get_name (pad_ch_2);
  g_print ("A new pad %s was created\n", name2);

  if (!gst_element_link (audioconvert_ch_1, decodebin_ch_1))
  {
      g_error ("Failed to link audioconvert_ch_1 and decodebin_ch_1");
  }

  if (!gst_element_link (audioconvert_ch_2, decodebin_ch_2))
  {
      g_error ("Failed to link audioconvert_ch_2 and decodebin_ch_2");
  }

  gst_bin_add_many (GST_BIN (pipeline), interleave, alsasink,
                    filesrc_ch_1, decodebin_ch_1, audioconvert_ch_1,
                    filesrc_ch_2, decodebin_ch_2, audioconvert_ch_2,
                    NULL);


  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
  gst_bus_add_watch (bus, bus_callback, pipeline);
  gst_object_unref (bus);

  gst_element_set_state (pipeline, GST_STATE_PLAYING);

  /* now run */
  g_main_loop_run (loop);

  /* also clean up */
  gst_element_set_state (pipeline, GST_STATE_NULL);
  gst_object_unref (GST_OBJECT (pipeline));

  return 0;
}



Thanks,
Saravanan.



Larsen & Toubro Limited

www.larsentoubro.com

This Email may contain confidential or privileged information for the intended 
recipient (s) If you are not the intended recipient, please do not use or 
disseminate the information, notify the sender and delete it from your system.
_______________________________________________
gstreamer-embedded mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-embedded

Reply via email to