From 204c82dfd14dbc0b5ee898967497e93931043f10 Mon Sep 17 00:00:00 2001 From: Philipp Hancke Date: Thu, 22 Feb 2024 08:05:05 +0100 Subject: [PATCH] e2ee: fix setCodecPreferences capabilities check --- .../insertable-streams/endtoend-encryption/js/main.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/content/insertable-streams/endtoend-encryption/js/main.js b/src/content/insertable-streams/endtoend-encryption/js/main.js index b4b20c9f2..a0ef59c5d 100644 --- a/src/content/insertable-streams/endtoend-encryption/js/main.js +++ b/src/content/insertable-streams/endtoend-encryption/js/main.js @@ -47,6 +47,9 @@ let preferredAudioCodecMimeType = 'audio/opus'; // eslint-disable-next-line prefer-const let preferredVideoCodecMimeType = 'video/VP8'; +const supportsSetCodecPreferences = window.RTCRtpTransceiver && + 'setCodecPreferences' in window.RTCRtpTransceiver.prototype; + let hasEnoughAPIs = !!window.RTCRtpScriptTransform; if (!hasEnoughAPIs) { @@ -150,7 +153,7 @@ function setupReceiverTransform(receiver) { } function maybeSetCodecPreferences(trackEvent) { - if (!'setCodecPreferences' in window.RTCRtpTransceiver.prototype) return; + if (!supportsSetCodecPreferences) return; if (trackEvent.track.kind === 'audio' && preferredAudioCodecMimeType ) { const {codecs} = RTCRtpReceiver.getCapabilities('audio'); const selectedCodecIndex = codecs.findIndex(c => c.mimeType === preferredAudioCodecMimeType);