Skip to content

Commit

Permalink
fix(HLS): Fix timestamp offset for raw formats when using segments mode
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad committed Jan 2, 2025
1 parent 77c4251 commit 674e357
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
11 changes: 10 additions & 1 deletion lib/media/media_source_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) &&
Expand Down
16 changes: 11 additions & 5 deletions test/transmuxer/transmuxer_integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,13 @@ 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.');
}
// This tests is flaky in some Tizen devices, so we need omit it for now.
if (shaka.util.Platform.isTizen()) {
pending('Disabled on Tizen.');
}
await player.load('/base/test/test/assets/hls-raw-mp3/playlist.m3u8');
await video.play();
Expand Down Expand Up @@ -173,7 +178,7 @@ describe('Transmuxer Player', () => {
}
// This tests is flaky in some Tizen devices, so we need omit it for now.
if (shaka.util.Platform.isTizen()) {
return;
pending('Disabled on Tizen.');
}
await player.load('/base/test/test/assets/hls-ts-mp3/manifest.m3u8');
await video.play();
Expand Down Expand Up @@ -377,8 +382,9 @@ 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.');
// This tests is flaky in some Tizen devices, so we need omit it for now.
if (shaka.util.Platform.isTizen()) {
pending('Disabled on Tizen.');
}

// eslint-disable-next-line max-len
Expand Down

0 comments on commit 674e357

Please sign in to comment.