Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(HLS): Add support to BYTERANGE-LENGTH in EXT-X-PRELOAD-HINT #5267

Merged
merged 1 commit into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/hls/hls_parser.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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