From 249b2d54d7068c6ea2943c7e2c9834716ceb3552 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Cr=C3=AAte?= Date: Fri, 26 Mar 2021 15:23:34 -0400 Subject: [PATCH] webrtcbin: Enforce compatible caps on pad request 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: --- ext/webrtc/gstwebrtcbin.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ext/webrtc/gstwebrtcbin.c b/ext/webrtc/gstwebrtcbin.c index e1dcaeeffe..fe4cff2f94 100644 --- a/ext/webrtc/gstwebrtcbin.c +++ b/ext/webrtc/gstwebrtcbin.c @@ -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; + } + } } }