Skip to content

Commit

Permalink
feat(HLS): Add support to BYTERANGE-LENGTH in EXT-X-PRELOAD-HINT (#5267)
Browse files Browse the repository at this point in the history
avelad authored Jun 8, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 236dacb commit ea97a5a
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions lib/hls/hls_parser.js
Original file line number Diff line number Diff line change
@@ -2846,6 +2846,11 @@ shaka.hls.HlsParser = class {
// A preload hinted partial segment may have byterange start info.
const pByterangeStart = item.getAttributeValue('BYTERANGE-START');
pStartByte = pByterangeStart ? Number(pByterangeStart) : 0;
// A preload hinted partial segment may have byterange length info.
const pByterangeLength = item.getAttributeValue('BYTERANGE-LENGTH');
if (pByterangeLength) {
pEndByte = pStartByte + Number(pByterangeLength) - 1;
}
} else {
const pByterange = item.getAttributeValue('BYTERANGE');
[pStartByte, pEndByte] =
7 changes: 4 additions & 3 deletions test/hls/hls_live_unit.js
Original file line number Diff line number Diff line change
@@ -643,7 +643,8 @@ describe('HlsParser live', () => {
// partialRef3
'#EXT-X-PART:DURATION=2,URI="partial.mp4",BYTERANGE=210@0\n',
// preloadRef
'#EXT-X-PRELOAD-HINT:TYPE=PART,URI="partial.mp4",BYTERANGE-START=210\n',
'#EXT-X-PRELOAD-HINT:TYPE=PART,URI="partial.mp4",BYTERANGE-START=210,',
'BYTERANGE-LENGTH=210\n',
].join('');

const partialRef = makeReference(
@@ -665,13 +666,13 @@ describe('HlsParser live', () => {

const preloadRef = makeReference(
'test:/partial.mp4', 6, 7.5, /* syncTime= */ null,
/* baseUri= */ '', /* startByte= */ 210, /* endByte= */ null);
/* baseUri= */ '', /* startByte= */ 210, /* endByte= */ 419);
preloadRef.markAsPreload();

// ref2 is not fully published yet, so it doesn't have a segment uri.
const ref2 = makeReference(
'', 4, 7.5, /* syncTime= */ null,
/* baseUri= */ '', /* startByte= */ 0, /* endByte= */ null,
/* baseUri= */ '', /* startByte= */ 0, /* endByte= */ 419,
/* timestampOffset= */ 0, [partialRef3, preloadRef]);

await testInitialManifest(master, mediaWithPartialSegments, [ref, ref2]);

0 comments on commit ea97a5a

Please sign in to comment.