Skip to content

Commit

Permalink
feat: add support for #EXT-X-PART-INF
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonocasey committed Jan 20, 2021
1 parent 7f82f53 commit 437f78f
Show file tree
Hide file tree
Showing 4 changed files with 25 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 @@ -520,6 +520,22 @@ export default class ParseStream extends Stream {
this.trigger('data', event);
return;
}
match = (/^#EXT-X-PART-INF:(.*)$/).exec(newLine);
if (match && match[1]) {
event = {
type: 'tag',
tagType: 'part-inf'
};
event.attributes = parseAttributes(match[1]);
['PART-TARGET'].forEach(function(key) {
if (event.attributes.hasOwnProperty(key)) {
event.attributes[key] = parseFloat(event.attributes[key]);
}
});

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

match = (/^#EXT-X-PRELOAD-HINT:(.*)$/).exec(newLine);
if (match && match[1]) {
Expand Down
3 changes: 3 additions & 0 deletions src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,9 @@ export default class Parser extends Stream {
'preload-hint'() {
this.manifest.preloadHints = this.manifest.preloadHints || [];
this.manifest.preloadHints.push(entry.attributes);
},
'part-inf'() {
this.manifest.partInf = entry.attributes;
}
})[entry.tagType] || noop).call(self);
},
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/m3u8/llhls.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
{"TYPE": "PART", "URI": "filePart273.3.mp4"},
{"TYPE": "PART", "URI": "filePart273.4.mp4"}
],
"partInf": {
"PART-TARGET": 0.33334
},
"parts": [
{
"DURATION": 0.33334,
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/m3u8/llhlsDelta.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
{"TYPE": "PART", "URI": "filePart273.4.mp4"},
{"TYPE": "PART", "URI": "filePart273.5.mp4"}
],
"partInf": {
"PART-TARGET": 0.33334
},
"parts": [
{
"DURATION": 0.33334,
Expand Down

0 comments on commit 437f78f

Please sign in to comment.