Skip to content

Commit

Permalink
feat(HLS): Optimize LL-HLS with byterange (shaka-project#5342)
Browse files Browse the repository at this point in the history
- Mark the the full segment as preload if it has some partial preload
segment
- Request _HLS_part=0 when using LL-HLS byterange optimization
  • Loading branch information
avelad committed Jun 22, 2023
1 parent db73e1f commit 53d6378
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/hls/hls_parser.js
Expand Up @@ -2360,6 +2360,9 @@ shaka.hls.HlsParser = class {
const partialReferences = lastSegment.partialReferences;
if (!lastSegment.partialReferences.length) {
nextMediaSequence++;
if (lastSegment.hasByterangeOptimization()) {
nextPart = 0;
}
return {
nextMediaSequence,
nextPart,
Expand Down Expand Up @@ -2844,6 +2847,7 @@ shaka.hls.HlsParser = class {
let segmentWithByteRangeOptimization = false;
let getUrisOptimization = null;
let somePartialSegmentWithGap = false;
let isPreloadSegment = false;

if (this.lowLatencyMode_ && hlsSegment.partialSegments.length) {
const byterangeOptimizationSupport = (mimeType == 'video/mp4' ||
Expand Down Expand Up @@ -2937,6 +2941,7 @@ shaka.hls.HlsParser = class {
hlsAes128Key);
if (item.name == 'EXT-X-PRELOAD-HINT') {
partial.markAsPreload();
isPreloadSegment = true;
}
// The spec doesn't say that we can assume INDEPENDENT=YES for the
// first partial segment. It does call the flag "optional", though, and
Expand Down Expand Up @@ -3043,6 +3048,10 @@ shaka.hls.HlsParser = class {

if (segmentWithByteRangeOptimization) {
reference.markAsByterangeOptimization();

if (isPreloadSegment) {
reference.markAsPreload();
}
}

return reference;
Expand Down
1 change: 1 addition & 0 deletions test/hls/hls_live_unit.js
Expand Up @@ -722,6 +722,7 @@ describe('HlsParser live', () => {
/* baseUri= */ '', /* startByte= */ 0, /* endByte= */ null,
/* timestampOffset= */ 0);
ref2.markAsByterangeOptimization();
ref2.markAsPreload();

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

0 comments on commit 53d6378

Please sign in to comment.