webrtcbin: Enforce compatible caps on pad request
authorOlivier Crête <olivier.crete@collabora.com>
Fri, 26 Mar 2021 19:23:34 +0000 (15:23 -0400)
committerOlivier Crête <olivier.crete@collabora.com>
Mon, 12 Apr 2021 21:55:07 +0000 (17:55 -0400)
If a pad is requested with certain caps and there is already a
transceiver, reject the pad request if the caps don't match.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2104>

ext/webrtc/gstwebrtcbin.c

index e1dcaee..fe4cff2 100644 (file)
@@ -6234,6 +6234,16 @@ gst_webrtc_bin_request_new_pad (GstElement * element, GstPadTemplate * templ,
         gst_object_unref (pad2);
         return NULL;
       }
+
+      if (caps && trans->codec_preferences) {
+        if (!gst_caps_can_intersect (caps, trans->codec_preferences)) {
+          GST_ERROR_OBJECT (element, "Tried to request a new sink pad %s for"
+              " existing m-line %d, but requested caps %" GST_PTR_FORMAT
+              " don't match existing codec preferences %" GST_PTR_FORMAT,
+              name, serial, caps, trans->codec_preferences);
+          return NULL;
+        }
+      }
     }
   }