diff --git a/packages/client/src/rtc/Publisher.ts b/packages/client/src/rtc/Publisher.ts index 8cf7e67af..690571291 100644 --- a/packages/client/src/rtc/Publisher.ts +++ b/packages/client/src/rtc/Publisher.ts @@ -390,12 +390,14 @@ export class Publisher { let changed = false; for (const encoder of params.encodings) { - const layer = - usesSvcCodec || enabledLayers.length === 1 - ? // for SVC, we only have one layer (q) and often rid is omitted - enabledLayers[0] - : // for non-SVC, we need to find the layer by rid (simulcast) - enabledLayers.find((l) => l.name === encoder.rid); + const layer = usesSvcCodec + ? // for SVC, we only have one layer (q) and often rid is omitted + enabledLayers[0] + : // for non-SVC, we need to find the layer by rid (simulcast) + enabledLayers.find((l) => l.name === encoder.rid) ?? + (enabledLayers.length === 1 && params.encodings.length === 1) + ? enabledLayers[0] + : undefined; // flip 'active' flag only when necessary const shouldActivate = !!layer?.active;