From eb74611d1e58f2967175dadcaf7479a7c632f876 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?A=CC=81lvaro=20Velad=20Galva=CC=81n?= Date: Thu, 2 Jan 2025 10:57:49 +0100 Subject: [PATCH] fix(HLS): Fix timestamp offset for raw formats when using segments mode --- lib/media/media_source_engine.js | 11 ++++++++++- test/transmuxer/transmuxer_integration.js | 12 +++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/media/media_source_engine.js b/lib/media/media_source_engine.js index f37a6159009..102282999b5 100644 --- a/lib/media/media_source_engine.js +++ b/lib/media/media_source_engine.js @@ -1233,7 +1233,16 @@ shaka.media.MediaSourceEngine = class { this.audioCompensation_.resolve(compensation); } } - const calculatedTimestampOffset = reference.startTime - timestamp; + let realTimestamp = timestamp; + const RAW_FORMATS = shaka.util.MimeUtils.RAW_FORMATS; + // For formats without containers and using segments mode, we need to + // adjust TimestampOffset relative to 0 because segments do not have + // any timestamp information. + if (!this.sequenceMode_ && + RAW_FORMATS.includes(this.sourceBufferTypes_[contentType])) { + realTimestamp = 0; + } + const calculatedTimestampOffset = reference.startTime - realTimestamp; const timestampOffsetDifference = Math.abs(timestampOffset - calculatedTimestampOffset); if ((timestampOffsetDifference >= 0.001 || seeked || adaptation) && diff --git a/test/transmuxer/transmuxer_integration.js b/test/transmuxer/transmuxer_integration.js index 3b5806058db..9db69221ecf 100644 --- a/test/transmuxer/transmuxer_integration.js +++ b/test/transmuxer/transmuxer_integration.js @@ -76,8 +76,9 @@ describe('Transmuxer Player', () => { }); it('raw MP3', async () => { - if (!await Util.isTypeSupported('audio/mp4; codecs="mp3"')) { - pending('Codec MP3 in MP4 is not supported by the platform.'); + if (!await Util.isTypeSupported('audio/mp4; codecs="mp3"') && + !await Util.isTypeSupported('audio/mpeg')) { + pending('Codec MP3 is not supported by the platform.'); } await player.load('/base/test/test/assets/hls-raw-mp3/playlist.m3u8'); await video.play(); @@ -171,10 +172,6 @@ describe('Transmuxer Player', () => { !await Util.isTypeSupported('audio/mpeg')) { pending('Codec MP3 is not supported by the platform.'); } - // This tests is flaky in some Tizen devices, so we need omit it for now. - if (shaka.util.Platform.isTizen()) { - return; - } await player.load('/base/test/test/assets/hls-ts-mp3/manifest.m3u8'); await video.play(); expect(player.isLive()).toBe(false); @@ -377,9 +374,6 @@ describe('Transmuxer Player', () => { !await Util.isTypeSupported('audio/mpeg')) { pending('Codec MP3 is not supported by the platform.'); } - if (!shaka.util.Platform.supportsSequenceMode()) { - pending('Sequence mode is not supported by the platform.'); - } // eslint-disable-next-line max-len await player.load('/base/test/test/assets/hls-ts-muxed-mp3-h264/index.m3u8');