Skip to content

Commit

Permalink
fix(MSS): Fix timeline repetitions (#7484)
Browse files Browse the repository at this point in the history
Fixes #7483
  • Loading branch information
avelad authored and joeyparrish committed Nov 12, 2024
1 parent 00f4763 commit 9fea5f6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/mss/mss_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,12 @@ shaka.mss.MssParser = class {
let startTime = t != null ? t : lastEndTime;

let repeat = r || 0;
// Unlike in DASH, in MSS r does not start counting repetitions at 0 but
// at 1, to maintain the code equivalent to DASH if r exists we
// subtract 1.
if (repeat) {
repeat--;
}
if (repeat < 0) {
if (next) {
const nextStartTime =
Expand Down
21 changes: 21 additions & 0 deletions test/mss/mss_parser_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,27 @@ describe('MssParser Manifest', () => {
expect(stream).toBeUndefined();
});

it('support for repetitions', async () => {
const manifestText = [
'<SmoothStreamingMedia Duration="3600000000">',
' <StreamIndex Name="audio" Type="audio" Url="{bitrate}/{start time}">',
' <QualityLevel Bitrate="128000" Channels="2" CodecPrivateData="',
aacCodecPrivateData,
'" FourCC="AACL"/>',
' <c t="0" d="30000000" r="12"/>',
' </StreamIndex>',
'</SmoothStreamingMedia>',
].join('\n');

fakeNetEngine.setResponseText('dummy://foo', manifestText);

const manifest = await parser.start('dummy://foo', playerInterface);
expect(manifest.variants.length).toBe(1);
await manifest.variants[0].audio.createSegmentIndex();
const segmentIndex = manifest.variants[0].audio.segmentIndex;
expect(segmentIndex.getNumReferences()).toBe(12);
});

it('generate a fake init segment', async () => {
const manifestText = [
'<SmoothStreamingMedia Duration="3600000000">',
Expand Down

0 comments on commit 9fea5f6

Please sign in to comment.