Skip to content

Commit 358eb24

Browse files
authored
Merge pull request #1650 from fippo/scp-fix
e2ee: fix setCodecPreferences capabilities check
2 parents 832b3cd + 204c82d commit 358eb24

File tree

1 file changed

+4
-1
lines changed
  • src/content/insertable-streams/endtoend-encryption/js

1 file changed

+4
-1
lines changed

src/content/insertable-streams/endtoend-encryption/js/main.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ let preferredAudioCodecMimeType = 'audio/opus';
4747
// eslint-disable-next-line prefer-const
4848
let preferredVideoCodecMimeType = 'video/VP8';
4949

50+
const supportsSetCodecPreferences = window.RTCRtpTransceiver &&
51+
'setCodecPreferences' in window.RTCRtpTransceiver.prototype;
52+
5053
let hasEnoughAPIs = !!window.RTCRtpScriptTransform;
5154

5255
if (!hasEnoughAPIs) {
@@ -150,7 +153,7 @@ function setupReceiverTransform(receiver) {
150153
}
151154

152155
function maybeSetCodecPreferences(trackEvent) {
153-
if (!'setCodecPreferences' in window.RTCRtpTransceiver.prototype) return;
156+
if (!supportsSetCodecPreferences) return;
154157
if (trackEvent.track.kind === 'audio' && preferredAudioCodecMimeType ) {
155158
const {codecs} = RTCRtpReceiver.getCapabilities('audio');
156159
const selectedCodecIndex = codecs.findIndex(c => c.mimeType === preferredAudioCodecMimeType);

0 commit comments

Comments
 (0)