Skip to content

Commit

Permalink
Merge pull request video-dev#4237 from DiceTechnology/bugfix/incorrec…
Browse files Browse the repository at this point in the history
…t-manifest-parsing-around-init-segments

Bugfix: Incorrect manifest parsing around init segments
  • Loading branch information
robwalch authored Jul 12, 2022
2 parents 9529594 + 7fef02c commit 3a0dfe2
Showing 1 changed file with 34 additions and 11 deletions.
45 changes: 34 additions & 11 deletions src/loader/m3u8-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,18 +430,23 @@ export default class M3U8Parser {
}
case 'MAP': {
const mapAttrs = new AttrList(value1);
frag.relurl = mapAttrs.URI;
if (mapAttrs.BYTERANGE) {
frag.setByteRange(mapAttrs.BYTERANGE);
}
frag.level = id;
frag.sn = 'initSegment';
if (levelkey) {
frag.levelkey = levelkey;
if (frag.duration) {
// Initial segment tag is after segment duration tag.
// #EXTINF: 6.0
// #EXT-X-MAP:URI="init.mp4
const init = new Fragment(type, baseurl);
setInitSegment(init, mapAttrs, id, levelkey);
currentInitSegment = init;
frag.initSegment = currentInitSegment;
if (currentInitSegment.rawProgramDateTime && !frag.rawProgramDateTime) {
frag.rawProgramDateTime = currentInitSegment.rawProgramDateTime;
}
} else {
// Initial segment tag is before segment duration tag
setInitSegment(frag, mapAttrs, id, levelkey);
currentInitSegment = frag;
createNextFrag = true;
}
frag.initSegment = null;
currentInitSegment = frag;
createNextFrag = true;
break;
}
case 'SERVER-CONTROL': {
Expand Down Expand Up @@ -627,3 +632,21 @@ function assignProgramDateTime(frag, prevFrag) {
frag.rawProgramDateTime = null;
}
}

function setInitSegment(
frag: Fragment,
mapAttrs: AttrList,
id: number,
levelkey: LevelKey | undefined
) {
frag.relurl = mapAttrs.URI;
if (mapAttrs.BYTERANGE) {
frag.setByteRange(mapAttrs.BYTERANGE);
}
frag.level = id;
frag.sn = 'initSegment';
if (levelkey) {
frag.levelkey = levelkey;
}
frag.initSegment = null;
}

0 comments on commit 3a0dfe2

Please sign in to comment.