Skip to content

Commit

Permalink
e2ee: fix setCodecPreferences capabilities check
Browse files Browse the repository at this point in the history
  • Loading branch information
fippo committed Feb 22, 2024
1 parent 832b3cd commit 204c82d
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 204c82d

Please sign in to comment.