Skip to content

Commit

Permalink
feat: add support for #EXT-X-PRELOAD-HINT
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonocasey committed Jan 20, 2021
1 parent 9cebc86 commit aa951e6
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/parse-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,22 @@ export default class ParseStream extends Stream {
this.trigger('data', event);
return;
}
match = (/^#EXT-X-PRELOAD-HINT:(.*)$/).exec(newLine);
if (match && match[1]) {
event = {
type: 'tag',
tagType: 'preload-hint'
};
event.attributes = parseAttributes(match[1]);
['BYTERANGE-START', 'BYTERANGE-LENGTH'].forEach(function(key) {
if (event.attributes.hasOwnProperty(key)) {
event.attributes[key] = parseInt(event.attributes[key], 10);
}
});

this.trigger('data', event);
return;
}

// unknown tag type
this.trigger('data', {
Expand Down
6 changes: 6 additions & 0 deletions src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,14 @@ export default class Parser extends Stream {
'cue-in'() {
currentUri.cueIn = entry.data;
},
<<<<<<< HEAD
'skip'() {
this.manifest.skip = entry.attributes;
=======
'preload-hint'() {
this.manifest.preloadHints = this.manifest.preloadHints || [];
this.manifest.preloadHints.push(entry.attributes);
>>>>>>> dc2f8b5... feat: add support for #EXT-X-PRELOAD-HINT
}
})[entry.tagType] || noop).call(self);
},
Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/m3u8/llhls.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"discontinuitySequence": 0,
"discontinuityStarts": [],
"mediaSequence": 266,
"preloadHints": [
{"TYPE": "PART", "URI": "filePart273.3.mp4"},
{"TYPE": "PART", "URI": "filePart273.4.mp4"}
],
"segments": [
{
"dateTimeObject": new Date("2019-02-14T02:13:36.106Z"),
Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/m3u8/llhlsDelta.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"discontinuitySequence": 0,
"discontinuityStarts": [],
"mediaSequence": 266,
"preloadHints": [
{"TYPE": "PART", "URI": "filePart273.4.mp4"},
{"TYPE": "PART", "URI": "filePart273.5.mp4"}
],
"segments": [
{
"duration": 4.00008,
Expand Down

0 comments on commit aa951e6

Please sign in to comment.