Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/core/source/stream_selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ export type StreamSelector = (
/** Prevents selectors from mutating the canonical identities and compatibility graph they inspect. */
export function freezeStreamCatalog(catalog: StreamCatalog): StreamCatalog {
for (const track of catalog.tracks) {
if (track.codecs) {
Object.freeze(track.codecs);
}
Object.freeze(track);
}
for (const option of catalog.options) {
Expand Down
1 change: 1 addition & 0 deletions test/core/source/hls/stream_catalog.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ describe("HLS stream catalog", () => {
expect(Object.isFrozen(plan.catalog)).toBe(true);
expect(Object.isFrozen(plan.catalog.options[0].tracks)).toBe(true);
expect(plan.catalog.tracks.every(Object.isFrozen)).toBe(true);
expect(Object.isFrozen(plan.catalog.tracks[0].codecs)).toBe(true);
expect(plan.catalog.tracks.every((track) => !("url" in track))).toBe(true);
expect(plan.catalog.tracks.map((track) => plan.mediaTracks.get(track)?.sourcePath)).toEqual([
"https://media.example/low.m3u8",
Expand Down