Skip to content

Commit

Permalink
feat: add support for #EXT-X-RENDITION-REPORT (#124)
Browse files Browse the repository at this point in the history
brandonocasey authored Jan 20, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 7f82f53 commit 03f4345
Showing 4 changed files with 28 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/parse-stream.js
Original file line number Diff line number Diff line change
@@ -537,6 +537,22 @@ export default class ParseStream extends Stream {
this.trigger('data', event);
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', {
4 changes: 4 additions & 0 deletions src/parser.js
Original file line number Diff line number Diff line change
@@ -397,6 +397,10 @@ export default class Parser extends Stream {
'preload-hint'() {
this.manifest.preloadHints = this.manifest.preloadHints || [];
this.manifest.preloadHints.push(entry.attributes);
},
'rendition-report'() {
this.manifest.renditionReports = this.manifest.renditionReports || [];
this.manifest.renditionReports.push(entry.attributes);
}
})[entry.tagType] || noop).call(self);
},
4 changes: 4 additions & 0 deletions test/fixtures/m3u8/llhls.json
Original file line number Diff line number Diff line change
@@ -9,6 +9,10 @@
{"TYPE": "PART", "URI": "filePart273.3.mp4"},
{"TYPE": "PART", "URI": "filePart273.4.mp4"}
],
"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,
4 changes: 4 additions & 0 deletions test/fixtures/m3u8/llhlsDelta.json
Original file line number Diff line number Diff line change
@@ -9,6 +9,10 @@
{"TYPE": "PART", "URI": "filePart273.4.mp4"},
{"TYPE": "PART", "URI": "filePart273.5.mp4"}
],
"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,

0 comments on commit 03f4345

Please sign in to comment.