Skip to content

Commit

Permalink
feat: add support for #EXT-X-RENDITION-REPORT
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonocasey committed Jan 20, 2021
1 parent 9cebc86 commit 97f5bc3
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/parse-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,23 @@ export default class ParseStream extends Stream {
return;
}

match = (/^#EXT-X-RENDITION-REPORT:(.*)$/).exec(newLine);
if (match && match[1]) {
event = {
type: 'tag',
tagType: 'rendition-report'
};
event.attributes = parseAttributes(match[1]);
['LAST-MSN', 'LAST-PART'].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', {
type: 'tag',
Expand Down
4 changes: 4 additions & 0 deletions src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,10 @@ export default class Parser extends Stream {
},
'skip'() {
this.manifest.skip = entry.attributes;
},
'rendition-report'() {
this.manifest.renditionReports = this.manifest.renditionReports || [];
this.manifest.renditionReports.push(entry.attributes);
}
})[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,
"renditionReports": [
{"LAST-MSN": 273, "LAST-PART": 2, "URI": "../1M/waitForMSN.php"},
{"LAST-MSN": 273, "LAST-PART": 1, "URI": "../4M/waitForMSN.php"}
],
"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,
"renditionReports": [
{"LAST-MSN": 273, "LAST-PART": 3, "URI": "../1M/waitForMSN.php"},
{"LAST-MSN": 273, "LAST-PART": 3, "URI": "../4M/waitForMSN.php"}
],
"segments": [
{
"duration": 4.00008,
Expand Down

0 comments on commit 97f5bc3

Please sign in to comment.