rtpptdemux: Add ssrc to output caps
authorMathieu Duponchelle <mathieu@centricular.com>
Mon, 20 Nov 2017 17:08:38 +0000 (18:08 +0100)
committerMathieu Duponchelle <mathieu@centricular.com>
Wed, 21 Feb 2018 13:15:22 +0000 (14:15 +0100)
It may be useful downstream

https://bugzilla.gnome.org/show_bug.cgi?id=792696

gst/rtpmanager/gstrtpptdemux.c

index 9020a44..f7d1e68 100644 (file)
@@ -250,6 +250,7 @@ gst_rtp_pt_demux_get_caps (GstRtpPtDemux * rtpdemux, guint pt)
   GstCaps *caps;
   GValue ret = { 0 };
   GValue args[2] = { {0}, {0} };
+  GstCaps *sink_caps;
 
   /* figure out the caps */
   g_value_init (&args[0], GST_TYPE_ELEMENT);
@@ -267,10 +268,25 @@ gst_rtp_pt_demux_get_caps (GstRtpPtDemux * rtpdemux, guint pt)
   g_value_unset (&args[1]);
   caps = g_value_dup_boxed (&ret);
   g_value_unset (&ret);
+
+  sink_caps = gst_pad_get_current_caps (rtpdemux->sink);
   if (caps == NULL) {
-    caps = gst_pad_get_current_caps (rtpdemux->sink);
+    caps = gst_caps_ref (sink_caps);
+  } else {
+    GstStructure *s1;
+    GstStructure *s2;
+    guint ssrc;
+
+    caps = gst_caps_make_writable (caps);
+    s1 = gst_caps_get_structure (sink_caps, 0);
+    s2 = gst_caps_get_structure (caps, 0);
+
+    gst_structure_get_uint (s1, "ssrc", &ssrc);
+    gst_structure_set (s2, "ssrc", G_TYPE_UINT, ssrc, NULL);
   }
 
+  gst_caps_unref (sink_caps);
+
   GST_DEBUG ("pt %d, got caps %" GST_PTR_FORMAT, pt, caps);
 
   return caps;