Skip to content

Commit

Permalink
feat(HLS): Add support to BYTERANGE-LENGTH in EXT-X-PRELOAD-HINT (sha…
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad committed Jun 8, 2023
1 parent 236dacb commit ea97a5a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions lib/hls/hls_parser.js
Expand Up @@ -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] =
Expand Down
7 changes: 4 additions & 3 deletions test/hls/hls_live_unit.js
Expand Up @@ -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(
Expand All @@ -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]);
Expand Down

0 comments on commit ea97a5a

Please sign in to comment.