Skip to content

Commit

Permalink
Merge pull request #3889 from video-dev/feature/redundant-levels-with…
Browse files Browse the repository at this point in the history
…-resolution-and-codecs

Require redundant levels to have matching RESOLUTION and CODECS attributes
  • Loading branch information
robwalch committed May 14, 2021
2 parents 196891e + a5df1fa commit 847ba56
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
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

0 comments on commit 847ba56

Please sign in to comment.