Skip to content

Commit

Permalink
fix: edge case where the length of enabledLayers doesn't match with t…
Browse files Browse the repository at this point in the history
…he number of encodings
  • Loading branch information
oliverlaz committed Nov 6, 2024
1 parent 8fb6e05 commit 47f60c3
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/client/src/rtc/Publisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 47f60c3

Please sign in to comment.