From de0348c756b7bda11a700bf7ea9e9393cab16421 Mon Sep 17 00:00:00 2001 From: Philipp Hancke Date: Wed, 10 Mar 2021 10:53:52 +0100 Subject: [PATCH] dont attempt to overwrite RTCSessionDescription.sdp follow-up on #1042 --- src/js/common_shim.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/js/common_shim.js b/src/js/common_shim.js index 772a725c..6e252ab0 100644 --- a/src/js/common_shim.js +++ b/src/js/common_shim.js @@ -331,9 +331,19 @@ export function removeExtmapAllowMixed(window, browserDetails) { window.RTCPeerConnection.prototype.setRemoteDescription = function setRemoteDescription(desc) { if (desc && desc.sdp && desc.sdp.indexOf('\na=extmap-allow-mixed') !== -1) { - desc.sdp = desc.sdp.split('\n').filter((line) => { + const sdp = desc.sdp.split('\n').filter((line) => { return line.trim() !== 'a=extmap-allow-mixed'; }).join('\n'); + // Safari enforces read-only-ness of RTCSessionDescription fields. + if (window.RTCSessionDescription && + desc instanceof window.RTCSessionDescription) { + arguments[0] = new window.RTCSessionDescription({ + type: desc.type, + sdp, + }); + } else { + desc.sdp = sdp; + } } return nativeSRD.apply(this, arguments); };