Skip to content

Commit

Permalink
Require redundant levels to have matching RESOLUTION and CODECS attri…
Browse files Browse the repository at this point in the history
…butes

Resolves video-dev#3888
  • Loading branch information
Rob Walch committed May 12, 2021
1 parent ca70edb commit a5df1fa
Show file tree
Hide file tree
Showing 2 changed files with 127 additions and 80 deletions.
7 changes: 4 additions & 3 deletions src/controller/level-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default class LevelController extends BasePlaylistController {
let audioTracks: MediaPlaylist[] = [];
let subtitleTracks: MediaPlaylist[] = [];
let bitrateStart: number | undefined;
const levelSet: { [bitrate: number]: Level } = {};
const levelSet: { [key: string]: Level } = {};
let levelFromSet: Level;
let resolutionFound = false;
let videoCodecFound = false;
Expand All @@ -109,11 +109,12 @@ export default class LevelController extends BasePlaylistController {
levelParsed.audioCodec = undefined;
}

levelFromSet = levelSet[levelParsed.bitrate]; // FIXME: we would also have to match the resolution here
const levelKey = `${levelParsed.bitrate}-${levelParsed.attrs.RESOLUTION}-${levelParsed.attrs.CODECS}`;
levelFromSet = levelSet[levelKey];

if (!levelFromSet) {
levelFromSet = new Level(levelParsed);
levelSet[levelParsed.bitrate] = levelFromSet;
levelSet[levelKey] = levelFromSet;
levels.push(levelFromSet);
} else {
levelFromSet.url.push(levelParsed.url);
Expand Down
Loading

0 comments on commit a5df1fa

Please sign in to comment.