Skip to content

Commit

Permalink
feat: add support for #EXT-X-SKIP (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonocasey authored Jan 20, 2021
1 parent 0823ea8 commit 9cebc86
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/parse-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
*/
import Stream from '@videojs/vhs-utils/es/stream.js';

const TAB = String.fromCharCode(0x09);

/**
* "forgiving" attribute list psuedo-grammar:
* attributes -> keyvalue (',' keyvalue)*
Expand Down Expand Up @@ -442,6 +444,26 @@ export default class ParseStream extends Stream {
this.trigger('data', event);
return;
}
match = (/^#EXT-X-SKIP:(.*)$/).exec(newLine);
if (match && match[1]) {
event = {
type: 'tag',
tagType: 'skip'
};
event.attributes = parseAttributes(match[1]);

if (event.attributes.hasOwnProperty('SKIPPED-SEGMENTS')) {
event.attributes['SKIPPED-SEGMENTS'] = parseInt(event.attributes['SKIPPED-SEGMENTS'], 10);
}

if (event.attributes.hasOwnProperty('RECENTLY-REMOVED-DATERANGES')) {
event.attributes['RECENTLY-REMOVED-DATERANGES'] =
event.attributes['RECENTLY-REMOVED-DATERANGES'].split(TAB);
}

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

// unknown tag type
this.trigger('data', {
Expand Down
3 changes: 3 additions & 0 deletions src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,9 @@ export default class Parser extends Stream {
},
'cue-in'() {
currentUri.cueIn = entry.data;
},
'skip'() {
this.manifest.skip = entry.attributes;
}
})[entry.tagType] || noop).call(self);
},
Expand Down
7 changes: 7 additions & 0 deletions test/fixtures/m3u8/llhlsDelta.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,12 @@
"uri": "fileSequence272.mp4"
}
],
"skip": {
"SKIPPED-SEGMENTS": 3,
"RECENTLY-REMOVED-DATERANGES": [
"foo",
"bar"
]
},
"targetDuration": 4
}

0 comments on commit 9cebc86

Please sign in to comment.