From 7a87693184a85cdc3b67f655b5c9ad0fc7f077d8 Mon Sep 17 00:00:00 2001 From: Rob Walch Date: Wed, 14 Sep 2022 12:13:21 -0700 Subject: [PATCH] Add Dolby Vision four ccs and filter out levels with unknown codecs mixed with levels where codecs are known Related to #4744 --- src/loader/m3u8-parser.ts | 12 +++++++++++- src/utils/codecs.ts | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/loader/m3u8-parser.ts b/src/loader/m3u8-parser.ts index bcefbff508f..8fc7f51cc76 100644 --- a/src/loader/m3u8-parser.ts +++ b/src/loader/m3u8-parser.ts @@ -85,6 +85,7 @@ export default class M3U8Parser { static parseMasterPlaylist(string: string, baseurl: string) { const levels: Array = []; + const levelsWithKnownCodecs: Array = []; const sessionData: Record = {}; let hasSessionData = false; MASTER_PLAYLIST_REGEX.lastIndex = 0; @@ -118,6 +119,10 @@ export default class M3U8Parser { level.videoCodec = M3U8Parser.convertAVC1ToAVCOTI(level.videoCodec); } + if (!level.unknownCodecs?.length) { + levelsWithKnownCodecs.push(level); + } + levels.push(level); } else if (result[3]) { // '#EXT-X-SESSION-DATA' is found, parse session data in group 3 @@ -128,8 +133,13 @@ export default class M3U8Parser { } } } + // Filter out levels with unknown codecs if it does not remove all levels + const stripUnknownCodecLevels = + levelsWithKnownCodecs.length > 0 && + levelsWithKnownCodecs.length < levels.length; + return { - levels, + levels: stripUnknownCodecLevels ? levelsWithKnownCodecs : levels, sessionData: hasSessionData ? sessionData : null, }; } diff --git a/src/utils/codecs.ts b/src/utils/codecs.ts index 6dadd4261a5..a6fbac9e8f3 100644 --- a/src/utils/codecs.ts +++ b/src/utils/codecs.ts @@ -42,7 +42,9 @@ const sampleEntryCodesISO = { avcp: true, av01: true, drac: true, + dva1: true, dvav: true, + dvh1: true, dvhe: true, encv: true, hev1: true,