rtpfunnel: don't enforce twcc during upstream negotiation
authorMathieu Duponchelle <mathieu@centricular.com>
Tue, 9 Nov 2021 18:41:14 +0000 (19:41 +0100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Fri, 12 Nov 2021 18:40:32 +0000 (18:40 +0000)
A previous patch has caused rtpfunnel to output twcc-related
information downstream, however this leaked into upstream
negotiation (through funnel->srccaps), causing payloader to
negotiate twcc caps even when not prompted to do so by the user.

Fix this by only enforcing that upstream sends us application/x-rtp
caps as was the case originally.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1278>

subprojects/gst-plugins-good/gst/rtpmanager/gstrtpfunnel.c
subprojects/gst-plugins-good/tests/check/elements/rtpfunnel.c

index 67a3c23..092e7c3 100644 (file)
@@ -374,16 +374,19 @@ gst_rtp_funnel_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
       GstStructure *s;
       guint ssrc;
       guint8 ext_id;
+      GstCaps *rtpcaps = gst_caps_new_empty_simple (RTP_CAPS);
 
       gst_event_parse_caps (event, &caps);
 
       GST_OBJECT_LOCK (funnel);
-      if (!gst_caps_can_intersect (funnel->srccaps, caps)) {
+      if (!gst_caps_can_intersect (rtpcaps, caps)) {
         GST_ERROR_OBJECT (funnel, "Can't intersect with caps %" GST_PTR_FORMAT,
             caps);
         g_assert_not_reached ();
       }
 
+      gst_caps_unref (rtpcaps);
+
       s = gst_caps_get_structure (caps, 0);
       if (gst_structure_get_uint (s, "ssrc", &ssrc)) {
         fpad->ssrc = ssrc;
@@ -430,15 +433,17 @@ gst_rtp_funnel_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
     {
       GstCaps *filter_caps;
       GstCaps *new_caps;
+      GstCaps *rtpcaps = gst_caps_new_empty_simple (RTP_CAPS);
 
       gst_query_parse_caps (query, &filter_caps);
 
       GST_OBJECT_LOCK (funnel);
       if (filter_caps) {
-        new_caps = gst_caps_intersect_full (funnel->srccaps, filter_caps,
+        new_caps = gst_caps_intersect_full (rtpcaps, filter_caps,
             GST_CAPS_INTERSECT_FIRST);
+        gst_caps_unref (rtpcaps);
       } else {
-        new_caps = gst_caps_copy (funnel->srccaps);
+        new_caps = rtpcaps;
       }
       GST_OBJECT_UNLOCK (funnel);
 
index 1b22f7c..5e7ee45 100644 (file)
@@ -310,12 +310,13 @@ GST_START_TEST (rtpfunnel_twcc_caps)
   gst_harness_set_src_caps_str (h0, "application/x-rtp, "
       "ssrc=(uint)123, extmap-5=" TWCC_EXTMAP_STR "");
 
-  /* request a second sinkpad, and verify the extmap is
-     present in the caps when doing a caps-query downstream */
+  /* request a second sinkpad, the extmap should not be
+     present in the caps when doing a caps-query downstream,
+     as we don't want to force upstream (typically a payloader)
+     to use the extension */
   h1 = gst_harness_new_with_element (h->element, "sink_1", NULL);
   caps = gst_pad_query_caps (GST_PAD_PEER (h1->srcpad), NULL);
-  expected_caps = gst_caps_from_string ("application/x-rtp, "
-      "extmap-5=" TWCC_EXTMAP_STR "");
+  expected_caps = gst_caps_new_empty_simple ("application/x-rtp");
   fail_unless (gst_caps_is_equal (expected_caps, caps));
   gst_caps_unref (caps);
   gst_caps_unref (expected_caps);