From d4f3f5c0686f0a6304bafbd86f9baf8a2bc6b9fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Mon, 12 Jun 2023 12:48:48 +0200 Subject: [PATCH] fix(HLS): Fix seek on LL streams when using segments mode (#5283) --- lib/media/media_source_engine.js | 13 +++++-------- lib/media/streaming_engine.js | 7 +++++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/media/media_source_engine.js b/lib/media/media_source_engine.js index bf680b874c..98da2620aa 100644 --- a/lib/media/media_source_engine.js +++ b/lib/media/media_source_engine.js @@ -1030,8 +1030,8 @@ shaka.media.MediaSourceEngine = class { * @param {number} appendWindowEnd The timestamp to set the append window end * to. For future appends, frames/samples with timestamps greater than this * value will be dropped. - * @param {boolean} sequenceMode If true, the timestampOffset will not be - * applied in this step. + * @param {boolean} ignoreTimestampOffset If true, the timestampOffset will + * not be applied in this step. * @param {shaka.extern.Stream} stream The current stream. * @param {!Map.} streamsByType @@ -1042,10 +1042,10 @@ shaka.media.MediaSourceEngine = class { */ async setStreamProperties( contentType, timestampOffset, appendWindowStart, appendWindowEnd, - sequenceMode, stream, streamsByType) { + ignoreTimestampOffset, stream, streamsByType) { const ContentType = shaka.util.ManifestParserUtils.ContentType; if (contentType == ContentType.TEXT) { - if (!sequenceMode) { + if (!ignoreTimestampOffset) { this.textEngine_.setTimestampOffset(timestampOffset); } this.textEngine_.setAppendWindow(appendWindowStart, appendWindowEnd); @@ -1066,10 +1066,7 @@ shaka.media.MediaSourceEngine = class { hasChangedCodecs ? Promise.resolve() : this.enqueueOperation_( contentType, () => this.abort_(contentType)), - // Don't set the timestampOffset here when in sequenceMode, since we - // use timestampOffset for a different purpose in that mode (e.g. to - // indicate where the current segment is). - sequenceMode ? Promise.resolve() : this.enqueueOperation_( + ignoreTimestampOffset ? Promise.resolve() : this.enqueueOperation_( contentType, () => this.setTimestampOffset_(contentType, timestampOffset)), this.enqueueOperation_( diff --git a/lib/media/streaming_engine.js b/lib/media/streaming_engine.js index b438fbc648..ead1d24937 100644 --- a/lib/media/streaming_engine.js +++ b/lib/media/streaming_engine.js @@ -1728,9 +1728,12 @@ shaka.media.StreamingEngine = class { mediaState.lastMimeType = mimeType; mediaState.lastTimestampOffset = timestampOffset; + const ignoreTimestampOffset = this.manifest_.sequenceMode || + this.manifest_.type == shaka.media.ManifestParser.HLS; + await this.playerInterface_.mediaSourceEngine.setStreamProperties( mediaState.type, timestampOffset, appendWindowStart, - appendWindowEnd, this.manifest_.sequenceMode, + appendWindowEnd, ignoreTimestampOffset, mediaState.stream, streamsByType); } catch (error) { mediaState.lastAppendWindowStart = null; @@ -1801,7 +1804,7 @@ shaka.media.StreamingEngine = class { operations.push(this.playerInterface_.mediaSourceEngine.resync( mediaState.type, reference.startTime)); } - } else { + } else if (this.manifest_.ignoreManifestTimestampsInSegmentsMode) { // In segments mode, we need to resync to set the timestampOffset // to the start of the current discontinuity sequence. This is // because individual discontinuity sequences may have internal