Skip to content

Commit

Permalink
feat: add support for #EXT-X-PART-INF (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonocasey authored Jan 20, 2021
1 parent 03f4345 commit 985ab68
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 @@ -401,6 +401,9 @@ export default class Parser extends Stream {
'rendition-report'() {
this.manifest.renditionReports = this.manifest.renditionReports || [];
this.manifest.renditionReports.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 @@ -13,6 +13,9 @@
{"LAST-MSN": 273, "LAST-PART": 2, "URI": "../1M/waitForMSN.php"},
{"LAST-MSN": 273, "LAST-PART": 1, "URI": "../4M/waitForMSN.php"}
],
"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 @@ -13,6 +13,9 @@
{"LAST-MSN": 273, "LAST-PART": 3, "URI": "../1M/waitForMSN.php"},
{"LAST-MSN": 273, "LAST-PART": 3, "URI": "../4M/waitForMSN.php"}
],
"partInf": {
"PART-TARGET": 0.33334
},
"parts": [
{
"DURATION": 0.33334,
Expand Down

0 comments on commit 985ab68

Please sign in to comment.