Skip to content

Commit

Permalink
Avoid throwing unhandled error for simulcast codec tracks, (#999)
Browse files Browse the repository at this point in the history
* Avoid throwing unhandled error for simulcast codec tracks, log error instead

* Create smooth-keys-shop.md
  • Loading branch information
lukasIO authored Feb 2, 2024
1 parent 9eac8f3 commit 5e25a3d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/smooth-keys-shop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"livekit-client": patch
---

Avoid throwing unhandled error for simulcast codec tracks
3 changes: 3 additions & 0 deletions src/room/participant/LocalParticipant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,9 @@ export default class LocalParticipant extends Participant {
return;
}
const simulcastTrack = track.addSimulcastTrack(videoCodec, encodings);
if (!simulcastTrack) {
return;
}
const req = new AddTrackRequest({
cid: simulcastTrack.mediaStreamTrack.id,
type: Track.kindToProto(track.kind),
Expand Down
8 changes: 6 additions & 2 deletions src/room/track/LocalVideoTrack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,13 @@ export default class LocalVideoTrack extends LocalTrack {
}
}

addSimulcastTrack(codec: VideoCodec, encodings?: RTCRtpEncodingParameters[]): SimulcastTrackInfo {
addSimulcastTrack(
codec: VideoCodec,
encodings?: RTCRtpEncodingParameters[],
): SimulcastTrackInfo | undefined {
if (this.simulcastCodecs.has(codec)) {
throw new Error(`${codec} already added`);
this.log.error(`${codec} already added, skipping adding simulcast codec`, this.logContext);
return;
}
const simulcastCodecInfo: SimulcastTrackInfo = {
codec,
Expand Down

0 comments on commit 5e25a3d

Please sign in to comment.