summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2021-06-08 11:39:27 +0300
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>2021-06-25 09:45:24 +0000
commit4efdb40f43e1c5445b03d14f375e9e1087d57057 (patch)
tree8809b0945f2b432b8fe7d86ee45d42b9a3f71137 /ext
parentb7951fb897af6a06e8e102e5e8e7f4933205dcba (diff)
downloadgstreamer-plugins-bad-4efdb40f43e1c5445b03d14f375e9e1087d57057.tar.gz
webrtcbin: When creating a new transceiver as part of creating the answer also take its codec preferences into account
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2310>
Diffstat (limited to 'ext')
-rw-r--r--ext/webrtc/gstwebrtcbin.c42
1 files changed, 29 insertions, 13 deletions
diff --git a/ext/webrtc/gstwebrtcbin.c b/ext/webrtc/gstwebrtcbin.c
index e0e8d305f..88702357c 100644
--- a/ext/webrtc/gstwebrtcbin.c
+++ b/ext/webrtc/gstwebrtcbin.c
@@ -3706,34 +3706,50 @@ _create_answer_task (GstWebRTCBin * webrtc, const GstStructure * options,
g_assert (answer_caps != NULL);
} else {
/* if no transceiver, then we only receive that stream and respond with
- * the exact same caps */
- /* FIXME: how to validate that subsequent elements can actually receive
- * this payload/format */
+ * the intersection with the transceivers codec preferences caps */
answer_dir = GST_WEBRTC_RTP_TRANSCEIVER_DIRECTION_RECVONLY;
- answer_caps = gst_caps_ref (offer_caps);
- }
-
- if (gst_caps_is_empty (answer_caps)) {
- GST_WARNING_OBJECT (webrtc, "Could not create caps for media");
- if (rtp_trans)
- gst_object_unref (rtp_trans);
- gst_caps_unref (answer_caps);
- gst_caps_unref (offer_caps);
- goto rejected;
}
seen_transceivers = g_list_prepend (seen_transceivers, rtp_trans);
if (!rtp_trans) {
+ GstCaps *trans_caps;
+
trans = _create_webrtc_transceiver (webrtc, answer_dir, i);
rtp_trans = GST_WEBRTC_RTP_TRANSCEIVER (trans);
GST_LOG_OBJECT (webrtc, "Created new transceiver %" GST_PTR_FORMAT
" for mline %u", trans, i);
+
+ trans_caps = _find_codec_preferences (webrtc, rtp_trans, i, error);
+ if (*error) {
+ gst_caps_unref (offer_caps);
+ goto rejected;
+ }
+
+ GST_TRACE_OBJECT (webrtc, "trying to compare %" GST_PTR_FORMAT
+ " and %" GST_PTR_FORMAT, offer_caps, trans_caps);
+
+ /* FIXME: technically this is a little overreaching as some fields we
+ * we can deal with not having and/or we may have unrecognized fields
+ * that we cannot actually support */
+ if (trans_caps) {
+ answer_caps = gst_caps_intersect (offer_caps, trans_caps);
+ gst_caps_unref (trans_caps);
+ } else {
+ answer_caps = gst_caps_ref (offer_caps);
+ }
} else {
trans = WEBRTC_TRANSCEIVER (rtp_trans);
}
+ if (gst_caps_is_empty (answer_caps)) {
+ GST_WARNING_OBJECT (webrtc, "Could not create caps for media");
+ gst_caps_unref (answer_caps);
+ gst_caps_unref (offer_caps);
+ goto rejected;
+ }
+
if (!_update_transceiver_kind_from_caps (rtp_trans, answer_caps))
GST_WARNING_OBJECT (webrtc,
"Trying to change transceiver %d kind from %d to %d",