From: Olivier CrĂȘte Date: Mon, 16 May 2022 22:05:25 +0000 (-0400) Subject: webrtcbin: Reject creating an offer if a locked mline has no caps X-Git-Tag: 1.22.0~1011 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0930c467d485316fbf80c25211632b6b4b9381fd;p=platform%2Fupstream%2Fgstreamer.git webrtcbin: Reject creating an offer if a locked mline has no caps This avoids getting in a bunch of corner cases. We'd have to insert a "rejected" line from the start as a place-holder to get around this, but the rest of the code just becomes more complicated, so just disallow it for now. Part-of: --- diff --git a/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcbin.c b/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcbin.c index 1528133..ea41e49 100644 --- a/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcbin.c +++ b/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcbin.c @@ -3257,8 +3257,16 @@ sdp_media_from_transceiver (GstWebRTCBin * webrtc, GstSDPMedia * media, } if (!caps) { - GST_WARNING_OBJECT (webrtc, "no caps available for transceiver %" - GST_PTR_FORMAT ", skipping", trans); + if (WEBRTC_TRANSCEIVER (trans)->mline_locked) { + g_set_error (error, GST_WEBRTC_ERROR, + GST_WEBRTC_ERROR_INTERNAL_FAILURE, + "Transceiver <%s> with mid %s has locked mline %u, but no caps. " + "Can't produce offer.", GST_OBJECT_NAME (trans), trans->mid, + trans->mline); + } else { + GST_WARNING_OBJECT (webrtc, "no caps available for transceiver %" + GST_PTR_FORMAT ", skipping", trans); + } return FALSE; } } diff --git a/subprojects/gst-plugins-bad/tests/check/elements/webrtcbin.c b/subprojects/gst-plugins-bad/tests/check/elements/webrtcbin.c index 76767d7..53ac48a 100644 --- a/subprojects/gst-plugins-bad/tests/check/elements/webrtcbin.c +++ b/subprojects/gst-plugins-bad/tests/check/elements/webrtcbin.c @@ -4067,6 +4067,36 @@ GST_START_TEST (test_reject_create_offer) GST_END_TEST; +GST_START_TEST (test_reject_create_offer_mline_locked_no_caps) +{ + GstHarness *h; + GstPromise *promise; + const GstStructure *s; + GstPromiseResult res; + GError *error = NULL; + + h = gst_harness_new_with_padnames ("webrtcbin", "sink_0", NULL); + + promise = gst_promise_new (); + g_signal_emit_by_name (h->element, "create-offer", NULL, promise); + res = gst_promise_wait (promise); + fail_unless_equals_int (res, GST_PROMISE_RESULT_REPLIED); + s = gst_promise_get_reply (promise); + fail_unless (s != NULL); + gst_structure_get (s, "error", G_TYPE_ERROR, &error, NULL); + fail_unless (g_error_matches (error, GST_WEBRTC_ERROR, + GST_WEBRTC_ERROR_INTERNAL_FAILURE)); + fail_unless_equals_string (error->message, + "Transceiver with mid (null) has locked mline 0," + " but no caps. Can't produce offer."); + g_clear_error (&error); + gst_promise_unref (promise); + + gst_harness_teardown (h); +} + +GST_END_TEST; + GST_START_TEST (test_reject_set_description) { struct test_webrtc *t = test_webrtc_new (); @@ -5514,6 +5544,7 @@ webrtcbin_suite (void) test_bundle_codec_preferences_rtx_no_duplicate_payloads); tcase_add_test (tc, test_reject_request_pad); tcase_add_test (tc, test_reject_create_offer); + tcase_add_test (tc, test_reject_create_offer_mline_locked_no_caps); tcase_add_test (tc, test_reject_set_description); tcase_add_test (tc, test_force_second_media); tcase_add_test (tc, test_codec_preferences_caps);