From: Matthew Waters Date: Tue, 16 Nov 2021 06:28:04 +0000 (+1100) Subject: webrtc: explicitly error out in a couple of renegotiation cases X-Git-Tag: 1.22.0~1981 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e28c45fd050f35dd2344fb305783b9158fedac2b;p=platform%2Fupstream%2Fgstreamer.git webrtc: explicitly error out in a couple of renegotiation cases Part-of: --- diff --git a/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcbin.c b/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcbin.c index 8def7cf..bfc7d47 100644 --- a/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcbin.c +++ b/subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcbin.c @@ -3047,10 +3047,15 @@ sdp_media_from_transceiver (GstWebRTCBin * webrtc, GstSDPMedia * media, if (last_media) { const char *setup = gst_sdp_media_get_attribute_val (last_media, "setup"); - if (setup) + if (setup) { gst_sdp_media_add_attribute (media, "setup", setup); - else + } else { + g_set_error (error, GST_WEBRTC_ERROR, + GST_WEBRTC_ERROR_INVALID_MODIFICATION, + "media %u cannot renegotiate without an existing a=setup line", + media_idx); return FALSE; + } } else { /* mandated by JSEP */ gst_sdp_media_add_attribute (media, "setup", "actpass"); @@ -3179,7 +3184,16 @@ sdp_media_from_transceiver (GstWebRTCBin * webrtc, GstSDPMedia * media, /* Some identifier; we also add the media name to it so it's identifiable */ if (trans->mid) { - gst_sdp_media_add_attribute (media, "mid", trans->mid); + const char *media_mid = gst_sdp_media_get_attribute_val (media, "mid"); + if (!media_mid) { + gst_sdp_media_add_attribute (media, "mid", trans->mid); + } else if (g_strcmp0 (media_mid, trans->mid) != 0) { + g_set_error (error, GST_WEBRTC_ERROR, + GST_WEBRTC_ERROR_INVALID_MODIFICATION, + "Cannot change media %u mid value from \'%s\' to \'%s\'", + media_idx, media_mid, trans->mid); + return FALSE; + } mid = g_strdup (trans->mid); } else { const GstStructure *s = gst_caps_get_structure (caps, 0); @@ -4168,7 +4182,7 @@ _create_answer_task (GstWebRTCBin * webrtc, const GstStructure * options, * that we cannot actually support */ if (trans_caps) { answer_caps = gst_caps_intersect (offer_caps, trans_caps); - gst_caps_unref (trans_caps); + gst_clear_caps (&trans_caps); } else { answer_caps = gst_caps_ref (offer_caps); } @@ -4180,8 +4194,8 @@ _create_answer_task (GstWebRTCBin * webrtc, const GstStructure * options, 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); + gst_clear_caps (&answer_caps); + gst_clear_caps (&offer_caps); goto rejected; } diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/webrtc/webrtc_fwd.h b/subprojects/gst-plugins-bad/gst-libs/gst/webrtc/webrtc_fwd.h index d181873..e8858ac 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/webrtc/webrtc_fwd.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/webrtc/webrtc_fwd.h @@ -450,6 +450,13 @@ GQuark gst_webrtc_error_quark (void); * * Since: 1.20 */ +/** + * GST_WEBRTC_ERROR_INVALID_MODIFICATION: + * + * invalid-modification (part of WebIDL specification) + * + * Since: 1.22 + */ typedef enum /**/ { GST_WEBRTC_ERROR_DATA_CHANNEL_FAILURE, @@ -460,8 +467,8 @@ typedef enum /**/ GST_WEBRTC_ERROR_HARDWARE_ENCODER_NOT_AVAILABLE, GST_WEBRTC_ERROR_ENCODER_ERROR, GST_WEBRTC_ERROR_INVALID_STATE, - GST_WEBRTC_ERROR_INTERNAL_FAILURE + GST_WEBRTC_ERROR_INTERNAL_FAILURE, + GST_WEBRTC_ERROR_INVALID_MODIFICATION, } GstWebRTCError; - #endif /* __GST_WEBRTC_FWD_H__ */