From d4a47d0e8a79e39428e54549ad8b10a282667ea7 Mon Sep 17 00:00:00 2001 From: Hristo Terezov Date: Fri, 28 Feb 2025 10:36:30 -0600 Subject: [PATCH] fix(TPCUtils): handle missing codec in isRunningInSimulcastMode. Aparently we call this for all tracks including for the audio tracks and it is failing with JS error. This leads to "participant unable to unmute". --- modules/RTC/TPCUtils.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/modules/RTC/TPCUtils.js b/modules/RTC/TPCUtils.js index c8e24aee5e..accba44b7c 100644 --- a/modules/RTC/TPCUtils.js +++ b/modules/RTC/TPCUtils.js @@ -712,20 +712,25 @@ export class TPCUtils { * Returns a boolean indicating whether the video encoder is running in Simulcast mode, i.e., three encodings need * to be configured in 4:2:1 resolution order with temporal scalability. * - * @param {CodecMimeType} codec - The video codec in use. + * @param {CodecMimeType} videoCodec - The video codec in use. * @returns {boolean} */ - isRunningInSimulcastMode(codec) { - return codec === CodecMimeType.VP8 // VP8 always + isRunningInSimulcastMode(videoCodec) { + if (!this.codecSettings || !this.codecSettings[videoCodec]) { + // If codec settings are not available, assume no simulcast + return false; + } + + return videoCodec === CodecMimeType.VP8 // VP8 always // K-SVC mode for VP9 when no scalability mode is set. Though only one outbound-rtp stream is present, // three separate encodings have to be configured. - || (!this.codecSettings[codec].scalabilityModeEnabled && codec === CodecMimeType.VP9) + || (!this.codecSettings[videoCodec].scalabilityModeEnabled && videoCodec === CodecMimeType.VP9) // When scalability is enabled, always for H.264, and only when simulcast is explicitly enabled via // config.js for VP9 and AV1 since full SVC is the default mode for these 2 codecs. - || (this.codecSettings[codec].scalabilityModeEnabled - && (codec === CodecMimeType.H264 || this.codecSettings[codec].useSimulcast)); + || (this.codecSettings[videoCodec].scalabilityModeEnabled + && (videoCodec === CodecMimeType.H264 || this.codecSettings[videoCodec].useSimulcast)); } /**