From 5de4c3c828f54974805c2087c9b63d84c75940c4 Mon Sep 17 00:00:00 2001 From: William Belcher Date: Tue, 18 Jul 2023 14:48:42 +1000 Subject: [PATCH] Fix: Firefox console errors `TypeError: this.preferredCodec.split is not a function` (#310) * Fix select codec on Firefox * Restore indentation in cirrus (cherry picked from commit 503b565bc5aa5b80594cef20aae2530dc60cb7df) --- Frontend/library/src/Config/SettingOption.ts | 13 ++++++++++++- .../PeerConnectionController.ts | 6 ++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Frontend/library/src/Config/SettingOption.ts b/Frontend/library/src/Config/SettingOption.ts index 3b682fbe..cc5726e3 100644 --- a/Frontend/library/src/Config/SettingOption.ts +++ b/Frontend/library/src/Config/SettingOption.ts @@ -103,11 +103,22 @@ export class SettingOption< public set selected(value: string) { // A user may not specify the full possible value so we instead use the closest match. // eg ?xxx=H264 would select 'H264 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f' - const filteredList = this.options.filter( + let filteredList = this.options.filter( (option: string) => option.indexOf(value) !== -1 ); if (filteredList.length) { this.value = filteredList[0]; + return; + } + + // A user has specified a codec with a fmtp string but this codec + fmtp line isn't available. + // in that case, just use the codec + filteredList = this.options.filter( + (option: string) => option.indexOf(value.split(' ')[0]) !== -1 + ); + if (filteredList.length) { + this.value = filteredList[0]; + return; } } } diff --git a/Frontend/library/src/PeerConnectionController/PeerConnectionController.ts b/Frontend/library/src/PeerConnectionController/PeerConnectionController.ts index 255a375b..1ba096f8 100644 --- a/Frontend/library/src/PeerConnectionController/PeerConnectionController.ts +++ b/Frontend/library/src/PeerConnectionController/PeerConnectionController.ts @@ -372,10 +372,12 @@ export class PeerConnectionController { if (RTCRtpReceiver.getCapabilities && this.preferredCodec != '') { for (const transceiver of this.peerConnection?.getTransceivers() ?? []) { if ( - transceiver && + transceiver && transceiver.receiver && transceiver.receiver.track && - transceiver.receiver.track.kind === 'video' + transceiver.receiver.track.kind === 'video' && + // As of 06/2023, FireFox has added RTCRtpReceiver.getCapabilities, but hasn't added the ability to set codec preferences + transceiver.setCodecPreferences ) { const preferredRTPCodec = this.preferredCodec.split(' '); const codecs = [