From 49115399f2100ededb761e37c67f985c14c6a5f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Mon, 21 Aug 2023 14:45:09 +0200 Subject: [PATCH] feat(HLS): Fix update time when using LL-HLS and byterange optimization (#5495) --- lib/hls/hls_parser.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/hls/hls_parser.js b/lib/hls/hls_parser.js index 85bf68fadf..5954c6bcfb 100644 --- a/lib/hls/hls_parser.js +++ b/lib/hls/hls_parser.js @@ -2706,8 +2706,17 @@ shaka.hls.HlsParser = class { if (this.lowLatencyMode_ && this.partialTargetDuration_) { // For low latency streaming, use the partial segment target duration. if (this.lowLatencyByterangeOptimization_) { - this.lastTargetDuration_ = Math.min( - lastTargetDuration, this.lastTargetDuration_); + // We always have at least 1 partial segment part, and most servers + // allow you to make a request with _HLS_msn=X&_HLS_part=0 with a + // distance of 4 partial segments. With this we ensure that we + // obtain the minimum latency in this type of case. + if (this.partialTargetDuration_ * 5 <= lastTargetDuration) { + this.lastTargetDuration_ = Math.min( + this.partialTargetDuration_, this.lastTargetDuration_); + } else { + this.lastTargetDuration_ = Math.min( + lastTargetDuration, this.lastTargetDuration_); + } } else { this.lastTargetDuration_ = Math.min( this.partialTargetDuration_, this.lastTargetDuration_);