rtpmux: Send stream-start before caps
authorNicolas Dufresne <nicolas.dufresne@collabora.co.uk>
Sun, 12 May 2013 03:24:36 +0000 (23:24 -0400)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Mon, 13 May 2013 13:37:05 +0000 (15:37 +0200)
gst/rtpmanager/gstrtpmux.c
gst/rtpmanager/gstrtpmux.h
tests/check/elements/rtpmux.c

index c731588..7e55fc4 100644 (file)
@@ -554,6 +554,16 @@ gst_rtp_mux_setcaps (GstPad * pad, GstRTPMux * rtp_mux, GstCaps * caps)
       "clock-base", G_TYPE_UINT, rtp_mux->ts_base,
       "seqnum-base", G_TYPE_UINT, rtp_mux->seqnum_base, NULL);
 
+  if (rtp_mux->send_stream_start) {
+    gchar s_id[32];
+
+    /* stream-start (FIXME: create id based on input ids) */
+    g_snprintf (s_id, sizeof (s_id), "interleave-%08x", g_random_int ());
+    gst_pad_push_event (rtp_mux->srcpad, gst_event_new_stream_start (s_id));
+
+    rtp_mux->send_stream_start = FALSE;
+  }
+
   GST_DEBUG_OBJECT (rtp_mux,
       "setting caps %" GST_PTR_FORMAT " on src pad..", caps);
   ret = gst_pad_set_caps (rtp_mux->srcpad, caps);
@@ -815,6 +825,7 @@ gst_rtp_mux_ready_to_paused (GstRTPMux * rtp_mux)
   GST_OBJECT_LOCK (rtp_mux);
 
   g_clear_object (&rtp_mux->last_pad);
+  rtp_mux->send_stream_start = TRUE;
 
   if (rtp_mux->ssrc == -1)
     rtp_mux->current_ssrc = g_random_int ();
index 8c87aa2..3582a75 100644 (file)
@@ -75,6 +75,7 @@ struct _GstRTPMux
   GstPad *last_pad; /* protected by object lock */
 
   GstClockTime last_stop;
+  gboolean send_stream_start;
 };
 
 struct _GstRTPMuxClass
index 4ced8e7..2a81294 100644 (file)
@@ -148,6 +148,11 @@ test_basic (const gchar * elem_name, const gchar * sink2, int count,
   gst_pad_set_active (src1, TRUE);
   gst_pad_set_active (src2, TRUE);
 
+  fail_unless (gst_pad_push_event (src1,
+          gst_event_new_stream_start ("stream1")));
+  fail_unless (gst_pad_push_event (src2,
+          gst_event_new_stream_start ("stream2")));
+
   gst_caps_set_simple (sinkcaps,
       "payload", G_TYPE_INT, 98, "seqnum-base", G_TYPE_UINT, 100,
       "clock-base", G_TYPE_UINT, 1000, "ssrc", G_TYPE_UINT, 66, NULL);