I am wondering that streamsynchronizer is only for 1-video and 1-audio and 1-text

HoonHee Lee hoonh83.lee at gmail.com
Wed Oct 23 02:31:58 PDT 2013


I changed that streamsyncronizer element has to be deployed in front of
streamiddemux element.

There is no blocking issue and it is working fine.

This is my test code changed.

--------------------------------------------------------------------------------------
#include <gst/gst.h>

#define NUM_STREAM 8

GstElement *pipeline;
GstElement *audiotestsrc[NUM_STREAM];
GstElement *audioconvert[NUM_STREAM];
GstElement *capsfilter[NUM_STREAM];
GstElement *vorbisenc[NUM_STREAM];
GstElement *oggmux[NUM_STREAM];
GstElement *funnel;
GstElement *demux;
GstElement *stream_synchronizer;
GstElement *queue[NUM_STREAM];
GstElement *filesink[NUM_STREAM];
gint pad_added_cnt = 0;

static gboolean
bus_call (GstBus * bus, GstMessage * msg, gpointer data)
{
  GMainLoop *loop = (GMainLoop *) data;

  switch (GST_MESSAGE_TYPE (msg)) {
    case GST_MESSAGE_EOS:{
      g_main_loop_quit (loop);
      break;
    }
    case GST_MESSAGE_ERROR:{
      g_main_loop_quit (loop);
      break;
    }
    default:
      break;
  }
  return TRUE;
}

static void
src_pad_added_cb (GstElement * demux, GstPad * pad, GstElement * pipeline)
{
/*
  GstPad *sync_sinkpad[NUM_STREAM];
  GstPad *sync_srcpad[NUM_STREAM];
*/
  GstPad *queue_sinkpad[NUM_STREAM];
  GstPad *queue_srcpad[NUM_STREAM];
  GstPad *filesink_sinkpad[NUM_STREAM];
/*
  GstIterator *it;
  GValue item = G_VALUE_INIT;
*/

/*
  sync_sinkpad[pad_added_cnt] = gst_element_get_request_pad
(stream_synchronizer, "sink_%u");
  it = gst_pad_iterate_internal_links (sync_sinkpad[pad_added_cnt]);
  g_assert (it);
  gst_iterator_next (it, &item);
  sync_srcpad[pad_added_cnt] = g_value_dup_object (&item);
  g_value_unset (&item);
  gst_iterator_free (it);
 
  gst_pad_link_full (pad, sync_sinkpad[pad_added_cnt],
GST_PAD_LINK_CHECK_NOTHING);
*/

  queue_sinkpad[pad_added_cnt] = gst_element_get_static_pad
(queue[pad_added_cnt], "sink");
  //gst_pad_link_full (sync_srcpad[pad_added_cnt],
queue_sinkpad[pad_added_cnt], GST_PAD_LINK_CHECK_NOTHING);
  gst_pad_link_full (pad, queue_sinkpad[pad_added_cnt],
GST_PAD_LINK_CHECK_NOTHING);

  queue_srcpad[pad_added_cnt] = gst_element_get_static_pad
(queue[pad_added_cnt], "src");
  filesink_sinkpad[pad_added_cnt] = gst_element_get_static_pad
(filesink[pad_added_cnt], "sink");
  gst_pad_link_full (queue_srcpad[pad_added_cnt],
filesink_sinkpad[pad_added_cnt], GST_PAD_LINK_CHECK_NOTHING);

  pad_added_cnt++;
}

gint
main (gint argc, gchar * argv[])
{
  GstCaps *caps;

  GstPad *funnel_sinkpad[NUM_STREAM];
  GstPad *funnel_srcpad;
  GstPad *demux_sinkpad;
  GstPad *oggmux_srcpad[NUM_STREAM];
  GstPad *sync_sinkpad;
  GstPad *sync_srcpad;
  GstIterator *it;
  GValue item = G_VALUE_INIT;

  GMainLoop *loop = NULL;
  GstBus *bus;
  guint bus_watch_id;
  guint stream_cnt = 0;

  gst_init (&argc, &argv);

  pipeline = gst_pipeline_new ("pipeline");

  for (stream_cnt = 0; stream_cnt < NUM_STREAM; stream_cnt++) {
    audiotestsrc[stream_cnt] = gst_element_factory_make ("audiotestsrc",
NULL);
    audioconvert[stream_cnt] = gst_element_factory_make ("audioconvert",
NULL);
    capsfilter[stream_cnt] = gst_element_factory_make ("capsfilter", NULL);
    vorbisenc[stream_cnt] = gst_element_factory_make ("vorbisenc", NULL);
    oggmux[stream_cnt] = gst_element_factory_make ("oggmux", NULL);
  }

  funnel = gst_element_factory_make ("funnel", NULL);
  demux = gst_element_factory_make ("streamiddemux", NULL);
  stream_synchronizer = gst_element_factory_make ("streamsynchronizer",
NULL);

  caps = gst_caps_from_string ("audio/x-raw,channels=1;");

  stream_cnt = 0;

  for (stream_cnt = 0; stream_cnt < NUM_STREAM; stream_cnt++) {
    queue[stream_cnt] = gst_element_factory_make ("queue", NULL);
    filesink[stream_cnt] = gst_element_factory_make ("filesink", NULL);

    g_object_set (audiotestsrc[stream_cnt], "wave", stream_cnt,
"num-buffers", 2000, NULL);
    g_object_set (capsfilter[stream_cnt], "caps", caps, NULL);
    g_object_set (filesink[stream_cnt], "location", g_strdup_printf
("filesink_%d.ogg", stream_cnt), NULL);
  }

  stream_cnt = 0;
  
  g_signal_connect (demux, "pad-added", G_CALLBACK (src_pad_added_cb),
loop);

  loop = g_main_loop_new (NULL, FALSE);

  bus = gst_element_get_bus (pipeline);
  bus_watch_id = gst_bus_add_watch (bus, bus_call, loop);
  g_object_unref (bus);

  for (stream_cnt = 0; stream_cnt < NUM_STREAM; stream_cnt++) {
    gst_bin_add_many (GST_BIN (pipeline), audiotestsrc[stream_cnt],
audioconvert[stream_cnt], capsfilter[stream_cnt],  vorbisenc[stream_cnt],
oggmux[stream_cnt], queue[stream_cnt], filesink[stream_cnt], NULL);
    if (stream_cnt == 0) {
      gst_bin_add_many (GST_BIN (pipeline), funnel, stream_synchronizer,
demux, NULL);
    }
  }

  stream_cnt = 0;

  for (stream_cnt = 0; stream_cnt < NUM_STREAM; stream_cnt++) {
    gst_element_link_many (audiotestsrc[stream_cnt],
audioconvert[stream_cnt], capsfilter[stream_cnt], vorbisenc[stream_cnt],
oggmux[stream_cnt], NULL);
  }

  stream_cnt = 0;

  for (stream_cnt = 0; stream_cnt < NUM_STREAM; stream_cnt++) {
    funnel_sinkpad[stream_cnt] = gst_element_get_request_pad (funnel,
"sink_%u");
    oggmux_srcpad[stream_cnt] = gst_element_get_static_pad
(oggmux[stream_cnt], "src");
    gst_pad_link (oggmux_srcpad[stream_cnt], funnel_sinkpad[stream_cnt]);
  }

  funnel_srcpad = gst_element_get_static_pad (funnel, "src");

  sync_sinkpad = gst_element_get_request_pad (stream_synchronizer,
"sink_%u");
  it = gst_pad_iterate_internal_links (sync_sinkpad);
  g_assert (it);
  gst_iterator_next (it, &item);
  sync_srcpad = g_value_dup_object (&item);
  g_value_unset (&item);
  gst_iterator_free (it);
 
  gst_pad_link_full (funnel_srcpad, sync_sinkpad,
GST_PAD_LINK_CHECK_NOTHING);

  demux_sinkpad = gst_element_get_static_pad (demux, "sink");
  gst_pad_link (sync_srcpad, demux_sinkpad);

  gst_element_set_state (pipeline, GST_STATE_PLAYING);
  g_main_loop_run (loop);

  gst_element_set_state (pipeline, GST_STATE_NULL);
  g_object_unref (pipeline);
  g_source_remove (bus_watch_id);
  g_main_loop_unref (loop);

  return 0;
}

--------------------------------------------------------------------------------------



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/I-am-wondering-that-streamsynchronizer-is-only-for-1-video-and-1-audio-and-1-text-tp4662414p4662806.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.


More information about the gstreamer-devel mailing list