From 92d356d4b07796fb734a72321315fead9688f57b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Olivier=20Cr=C3=AAte?= Date: Fri, 26 Mar 2021 15:54:35 -0400 Subject: [PATCH] webrtcbin: Enforce same-kind on request sink pad with a specific name Part-of: --- ext/webrtc/gstwebrtcbin.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/ext/webrtc/gstwebrtcbin.c b/ext/webrtc/gstwebrtcbin.c index fe4cff2..4d5e921 100644 --- a/ext/webrtc/gstwebrtcbin.c +++ b/ext/webrtc/gstwebrtcbin.c @@ -6235,14 +6235,27 @@ gst_webrtc_bin_request_new_pad (GstElement * element, GstPadTemplate * templ, return NULL; } - if (caps && trans->codec_preferences) { - if (!gst_caps_can_intersect (caps, trans->codec_preferences)) { + if (caps) { + if (trans->codec_preferences && + !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; } + + if (trans->kind != GST_WEBRTC_KIND_UNKNOWN) { + GstWebRTCKind kind = _kind_from_caps (caps); + + if (trans->kind != kind) { + 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 transceiver kind %d", + name, serial, caps, trans->kind); + return NULL; + } + } } } } @@ -6257,11 +6270,8 @@ gst_webrtc_bin_request_new_pad (GstElement * element, GstPadTemplate * templ, } pad = _create_pad_for_sdp_media (webrtc, GST_PAD_SINK, trans, serial); - if (caps && name && !_update_transceiver_kind_from_caps (trans, caps)) - GST_WARNING_OBJECT (webrtc, - "Trying to create pad %s with caps %" GST_PTR_FORMAT - " but transceiver %d already exists with a different" - " media type", name, caps, serial); + if (caps) + _update_transceiver_kind_from_caps (trans, caps); pad->block_id = gst_pad_add_probe (GST_PAD (pad), GST_PAD_PROBE_TYPE_BLOCK | GST_PAD_PROBE_TYPE_BUFFER | GST_PAD_PROBE_TYPE_BUFFER_LIST, -- 2.7.4