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 9f5a224 commit 7b79ce7
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 @@ -499,6 +499,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 @@ -390,6 +390,10 @@ export default class Parser extends Stream {
'part'() {
this.manifest.parts = this.manifest.parts || [];
this.manifest.parts.push(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"}
],
"parts": [
{
"DURATION": 0.33334,
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"}
],
"parts": [
{
"DURATION": 0.33334,
Expand Down

0 comments on commit 7b79ce7

Please sign in to comment.