diff options
author | Olivier CrĂȘte <olivier.crete@collabora.com> | 2021-03-31 11:40:28 -0400 |
---|---|---|
committer | Olivier CrĂȘte <olivier.crete@collabora.com> | 2021-04-12 18:37:27 -0400 |
commit | c7107fd940a09f02b077516966b3d4dd7b7e171e (patch) | |
tree | caf6662b03d127423c8e47a3a69d4790611a2d72 /ext | |
parent | 09c65fe5346c137f266cb0fa9655961e7b07546a (diff) | |
download | gstreamer-plugins-bad-c7107fd940a09f02b077516966b3d4dd7b7e171e.tar.gz |
webrtcbin: Ensure that query caps method returns valid caps
This means rejecting any caps that aren't fixed. Also, use a filter
that will create unfixed caps if the other side just returns ANY.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2104>
Diffstat (limited to 'ext')
-rw-r--r-- | ext/webrtc/gstwebrtcbin.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/ext/webrtc/gstwebrtcbin.c b/ext/webrtc/gstwebrtcbin.c index c92e4ad72..18e722243 100644 --- a/ext/webrtc/gstwebrtcbin.c +++ b/ext/webrtc/gstwebrtcbin.c @@ -1511,9 +1511,28 @@ _find_codec_preferences (GstWebRTCBin * webrtc, GST_LOG_OBJECT (webrtc, "Using current pad caps: %" GST_PTR_FORMAT, caps); } else { - if ((caps = gst_pad_peer_query_caps (GST_PAD (pad), NULL))) - GST_LOG_OBJECT (webrtc, "Using peer query caps: %" GST_PTR_FORMAT, - caps); + static GstStaticCaps static_filter = + GST_STATIC_CAPS ("application/x-rtp, " + "media = (string) { audio, video }, payload = (int) [ 0, 127 ]"); + GstCaps *filter = gst_static_caps_get (&static_filter); + + filter = gst_caps_make_writable (filter); + + if (rtp_trans->kind == GST_WEBRTC_KIND_AUDIO) + gst_caps_set_simple (filter, "media", G_TYPE_STRING, "audio", NULL); + else if (rtp_trans->kind == GST_WEBRTC_KIND_VIDEO) + gst_caps_set_simple (filter, "media", G_TYPE_STRING, "video", NULL); + + caps = gst_pad_peer_query_caps (GST_PAD (pad), filter); + GST_LOG_OBJECT (webrtc, "Using peer query caps: %" GST_PTR_FORMAT, + caps); + + if (!gst_caps_is_fixed (caps) || gst_caps_is_equal_fixed (caps, filter) + || gst_caps_is_empty (caps) || gst_caps_is_any (caps)) { + gst_caps_unref (caps); + caps = NULL; + } + gst_caps_unref (filter); } if (caps) { if (trans) @@ -1539,6 +1558,9 @@ _add_supported_attributes_to_caps (GstWebRTCBin * webrtc, GstCaps *ret; guint i; + if (caps == NULL) + return NULL; + ret = gst_caps_make_writable (caps); for (i = 0; i < gst_caps_get_size (ret); i++) { |