Skip to content

Commit

Permalink
feat(HLS): Ignore EXT-X-DATERANGE in the past (#6757)
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad authored Jun 5, 2024
1 parent b500799 commit 8d7dd37
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/hls/hls_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -3684,7 +3684,11 @@ shaka.hls.HlsParser = class {
const endDate = shaka.util.TXml.parseDate(endDateValue);
if (!isNaN(endDate)) {
goog.asserts.assert(endDate != null, 'End date should not be null!');
endTime = Math.max(0, endDate - initialProgramDateTime);
endTime = endDate - initialProgramDateTime;
if (endTime < 0) {
// Date range in the past
continue;
}
}
}
if (endTime == null) {
Expand All @@ -3694,6 +3698,11 @@ shaka.hls.HlsParser = class {
if (!isNaN(duration)) {
endTime = startTime + duration;
}
const realEndTime = startDate - initialProgramDateTime + duration;
if (realEndTime < 0) {
// Date range in the past
continue;
}
}
}
const type = tag.getAttributeValue('CLASS') || 'com.apple.quicktime.HLS';
Expand Down
22 changes: 22 additions & 0 deletions test/hls/hls_parser_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -5638,6 +5638,28 @@ describe('HlsParser', () => {
expect(onMetadataSpy).not.toHaveBeenCalled();
});

it('ignores if date ranges are in the past', async () => {
const mediaPlaylist = [
'#EXTM3U\n',
'#EXT-X-TARGETDURATION:5\n',
'#EXT-X-PROGRAM-DATE-TIME:2000-01-01T00:00:00.00Z\n',
'#EXTINF:5,\n',
'video1.ts\n',
'#EXT-X-DATERANGE:ID="0",START-DATE="1999-01-01T00:00:00.00Z",',
'DURATION=1,X-SHAKA="FOREVER"\n',
'#EXT-X-DATERANGE:ID="1",START-DATE="2000-01-01T00:00:05.00Z",',
'END-DATE="1999-01-01T00:00:06.00Z",X-SHAKA="FOREVER"\n',
].join('');

fakeNetEngine
.setResponseText('test:/master', mediaPlaylist)
.setResponseValue('test:/video1.ts', tsSegmentData);

await parser.start('test:/master', playerInterface);

expect(onMetadataSpy).not.toHaveBeenCalled();
});

it('supports interstitial', async () => {
const mediaPlaylist = [
'#EXTM3U\n',
Expand Down

0 comments on commit 8d7dd37

Please sign in to comment.