From afca6af230685a0c9b556fddb46341380b611923 Mon Sep 17 00:00:00 2001 From: Joey Parrish Date: Wed, 4 Jan 2023 11:36:35 -0800 Subject: [PATCH] fix: Fix parsing error on Chromecast when resyncing HLS (#4869) Setting the timestampOffset requires an abort() in some cases on Chromecast. Issue #4589 --- lib/media/media_source_engine.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/media/media_source_engine.js b/lib/media/media_source_engine.js index 50ac6a7a55..466a142b7d 100644 --- a/lib/media/media_source_engine.js +++ b/lib/media/media_source_engine.js @@ -906,7 +906,18 @@ shaka.media.MediaSourceEngine = class { */ async resync(contentType, timestampOffset) { goog.asserts.assert(this.sequenceMode_, - 'resyncAudio only used with sequence mode!'); + 'resync only used with sequence mode!'); + // Queue an abort() to help MSE splice together overlapping segments. + // We set appendWindowEnd when we change periods in DASH content, and the + // period transition may result in overlap. + // + // An abort() also helps with MPEG2-TS. When we append a TS segment, we + // always enter a PARSING_MEDIA_SEGMENT state and we can't change the + // timestamp offset. By calling abort(), we reset the state so we can + // set it. + this.enqueueOperation_( + contentType, + () => this.abort_(contentType)); await this.enqueueOperation_( contentType, () => this.setTimestampOffset_(contentType, timestampOffset));