Skip to content

Commit

Permalink
mimeTypeToVideoCodecString should not throw (#1302)
Browse files Browse the repository at this point in the history
* mimeTypeToVideoCodecString should not throw

The current implementation is not resilient to codecs changes.
If a new codec is introduced, previously working code would start failing.

* changeset
  • Loading branch information
davidzhao authored Oct 26, 2024
1 parent 09f031f commit ed3666d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/heavy-garlics-greet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'livekit-client': patch
---

fix: mimeTypeToVideoCodecString should not throw
7 changes: 1 addition & 6 deletions src/room/track/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
type ScreenShareCaptureOptions,
type VideoCaptureOptions,
type VideoCodec,
videoCodecs,
} from './options';
import type { AudioTrack } from './types';

Expand Down Expand Up @@ -188,11 +187,7 @@ export function screenCaptureToDisplayMediaStreamOptions(
}

export function mimeTypeToVideoCodecString(mimeType: string) {
const codec = mimeType.split('/')[1].toLowerCase() as VideoCodec;
if (!videoCodecs.includes(codec)) {
throw Error(`Video codec not supported: ${codec}`);
}
return codec;
return mimeType.split('/')[1].toLowerCase() as VideoCodec;
}

export function getTrackPublicationInfo<T extends TrackPublication>(
Expand Down

0 comments on commit ed3666d

Please sign in to comment.