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: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2104>
This commit is contained in:
Olivier Crête 2021-03-26 15:23:34 -04:00
parent 902e40cae2
commit 249b2d54d7

View file

@ -6234,6 +6234,16 @@ gst_webrtc_bin_request_new_pad (GstElement * element, GstPadTemplate * templ,
gst_object_unref (pad2); gst_object_unref (pad2);
return NULL; 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;
}
}
} }
} }