From 20b4abf81674e17fe5557d2cce58611faff7094c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Fri, 27 Oct 2023 10:15:49 +0200 Subject: [PATCH] feat: Improve latency in LL DASH streams (#5820) This change causes the prefetch to be called much earlier, which improves latency in DASH streams in around 500ms. --- lib/media/streaming_engine.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/media/streaming_engine.js b/lib/media/streaming_engine.js index 16f8be75d1..47802a74d0 100644 --- a/lib/media/streaming_engine.js +++ b/lib/media/streaming_engine.js @@ -1381,6 +1381,10 @@ shaka.media.StreamingEngine = class { await this.append_( mediaState, presentationTime, stream, reference, dataToAppend, /* isChunkedData= */ true); + + if (mediaState.segmentPrefetch && mediaState.segmentIterator) { + mediaState.segmentPrefetch.prefetchSegments(reference); + } } }; @@ -1411,6 +1415,10 @@ shaka.media.StreamingEngine = class { await this.append_( mediaState, presentationTime, stream, reference, result); } + + if (mediaState.segmentPrefetch && mediaState.segmentIterator) { + mediaState.segmentPrefetch.prefetchSegments(reference); + } } else { if (this.config_.lowLatencyMode && !isReadableStreamSupported) { shaka.log.warning('Low latency streaming mode is enabled, but ' +