Skip to content

Commit

Permalink
code review: add test for muxed segment.
Browse files Browse the repository at this point in the history
  • Loading branch information
dzianis-dashkevich committed Feb 12, 2022
1 parent c6f6dab commit 6e4bc7c
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/segment-loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1217,6 +1217,42 @@ QUnit.module('SegmentLoader', function(hooks) {
});
});

QUnit.test('should use video DTS value as primary for muxed segments (eg: audio and video together) for timestamp offset calculation when useDtsForTimestampOffset set as true', function(assert) {
loader = new SegmentLoader(LoaderCommonSettings.call(this, {
loaderType: 'main',
segmentMetadataTrack: this.segmentMetadataTrack,
useDtsForTimestampOffset: true
}), {});

const playlist = playlistWithDuration(20, { uri: 'playlist.m3u8' });

return this.setupMediaSource(loader.mediaSource_, loader.sourceUpdater_).then(() => {
return new Promise((resolve, reject) => {
loader.one('appended', resolve);
loader.one('error', reject);

loader.playlist(playlist);
loader.load();

this.clock.tick(100);

standardXHRResponse(this.requests.shift(), muxedSegment());
});
}).then(() => {
assert.equal(
loader.sourceUpdater_.videoTimestampOffset(),
-playlist.segments[0].videoTimingInfo.transmuxedDecodeStart,
'set video timestampOffset'
);

assert.equal(
loader.sourceUpdater_.audioTimestampOffset(),
-playlist.segments[0].videoTimingInfo.transmuxedDecodeStart,
'set audio timestampOffset'
);
});
});

QUnit.test('should use audio DTS value for timestamp offset calculation when useDtsForTimestampOffset set as true and only audio', function(assert) {
loader = new SegmentLoader(LoaderCommonSettings.call(this, {
loaderType: 'main',
Expand Down

0 comments on commit 6e4bc7c

Please sign in to comment.