From 7553ab0c947699f6ecf9180620fe82131bb8ebc3 Mon Sep 17 00:00:00 2001 From: Rob Walch Date: Thu, 15 Apr 2021 19:58:03 -0400 Subject: [PATCH] Request LL-HLS playlists with _HLS_part param starting at 0 for next sn Resolves #3571 #3771 --- src/controller/base-playlist-controller.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/controller/base-playlist-controller.ts b/src/controller/base-playlist-controller.ts index 7c4b94c9ae6..3ec854fedbf 100644 --- a/src/controller/base-playlist-controller.ts +++ b/src/controller/base-playlist-controller.ts @@ -138,16 +138,18 @@ export default class BasePlaylistController implements NetworkComponentAPI { if (details.canBlockReload && details.endSN && details.advanced) { // Load level with LL-HLS delivery directives const lowLatencyMode = this.hls.config.lowLatencyMode; + const lastPartSn = details.lastPartSn; + const endSn = details.endSN; const lastPartIndex = details.lastPartIndex; - if (lowLatencyMode) { - msn = lastPartIndex !== -1 ? details.lastPartSn : details.endSN + 1; - part = lastPartIndex !== -1 ? lastPartIndex + 1 : undefined; + const hasParts = lastPartIndex !== -1; + const lastPart = lastPartSn === endSn; + // When low latency mode is disabled, we'll skip part requests once the last part index is found + const nextSnStartIndex = lowLatencyMode ? 0 : lastPartIndex; + if (hasParts) { + msn = lastPart ? endSn + 1 : lastPartSn; + part = lastPart ? nextSnStartIndex : lastPartIndex + 1; } else { - // This playlist update will be late by one part (0). There is no way to know the last part number, - // or request just the next sn without a part in most implementations. - msn = - lastPartIndex !== -1 ? details.lastPartSn + 1 : details.endSN + 1; - part = lastPartIndex !== -1 ? 0 : undefined; + msn = endSn + 1; } // Low-Latency CDN Tune-in: "age" header and time since load indicates we're behind by more than one part // Update directives to obtain the Playlist that has the estimated additional duration of media