Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(DASH): Avoid adding originalId when it is not necessary #7281

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/util/periods.js
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,10 @@ shaka.util.PeriodCombiner = class {
if (output.originalId == null) {
output.originalId = input.originalId;
} else {
output.originalId += ',' + (input.originalId || '');
const newOriginalId = (input.originalId || '');
if (newOriginalId && !output.originalId.endsWith(newOriginalId)) {
output.originalId += ',' + newOriginalId;
}
avelad marked this conversation as resolved.
Show resolved Hide resolved
}

const commonDrmInfos = shaka.util.DrmUtils.getCommonDrmInfos(
Expand Down
44 changes: 22 additions & 22 deletions test/util/periods_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@ describe('PeriodCombiner', () => {
expect(h1080Surround.audio.originalId).toBe('en-6c,en');
expect(h720Surround.video.originalId).toBe('720,480');
expect(h720Surround.audio.originalId).toBe('en-6c,en');
expect(h480Surround.video.originalId).toBe('480,480');
expect(h480Surround.video.originalId).toBe('480');
expect(h480Surround.audio.originalId).toBe('en-6c,en');

expect(h1080Stereo.video.originalId).toBe('1080,480');
expect(h1080Stereo.audio.originalId).toBe('en,en');
expect(h1080Stereo.audio.originalId).toBe('en');
expect(h720Stereo.video.originalId).toBe('720,480');
expect(h720Stereo.audio.originalId).toBe('en,en');
expect(h480Stereo.video.originalId).toBe('480,480');
expect(h480Stereo.audio.originalId).toBe('en,en');
expect(h720Stereo.audio.originalId).toBe('en');
expect(h480Stereo.video.originalId).toBe('480');
expect(h480Stereo.audio.originalId).toBe('en');
});

it('Ad insertion - join during ad', async () => {
Expand Down Expand Up @@ -178,15 +178,15 @@ describe('PeriodCombiner', () => {
expect(h1080Surround.audio.originalId).toBe('en,en-6c');
expect(h720Surround.video.originalId).toBe('480,720');
expect(h720Surround.audio.originalId).toBe('en,en-6c');
expect(h480Surround.video.originalId).toBe('480,480');
expect(h480Surround.video.originalId).toBe('480');
expect(h480Surround.audio.originalId).toBe('en,en-6c');

expect(h1080Stereo.video.originalId).toBe('480,1080');
expect(h1080Stereo.audio.originalId).toBe('en,en');
expect(h1080Stereo.audio.originalId).toBe('en');
expect(h720Stereo.video.originalId).toBe('480,720');
expect(h720Stereo.audio.originalId).toBe('en,en');
expect(h480Stereo.video.originalId).toBe('480,480');
expect(h480Stereo.audio.originalId).toBe('en,en');
expect(h720Stereo.audio.originalId).toBe('en');
expect(h480Stereo.video.originalId).toBe('480');
expect(h480Stereo.audio.originalId).toBe('en');
});

it('Ad insertion - smaller ad, res not found in main content', async () => {
Expand Down Expand Up @@ -690,8 +690,8 @@ describe('PeriodCombiner', () => {

const imageIds = imageStreams.map((i) => i.originalId);
expect(imageIds).toEqual([
'240,240',
'480,480',
'240',
'480',
]);
});

Expand Down Expand Up @@ -756,9 +756,9 @@ describe('PeriodCombiner', () => {
// Both tracks are composed of the same things.
const spanish = textStreams.find((s) => s.language == 'es');
const english = textStreams.find((s) => s.language == 'en');
expect(spanish.originalId).toBe(',,es');
expect(spanish.originalId).toBe(',es');
expect(spanish.originalLanguage).toBe('spa');
expect(english.originalId).toBe('en,,en');
expect(english.originalId).toBe('en');
expect(english.originalLanguage).toBe('en');
});

Expand Down Expand Up @@ -822,8 +822,8 @@ describe('PeriodCombiner', () => {

const i240 = imageStreams.find((s) => s.height == 240);
const i480 = imageStreams.find((s) => s.height == 480);
expect(i240.originalId).toBe('240,,240');
expect(i480.originalId).toBe('240,,480');
expect(i240.originalId).toBe('240');
expect(i480.originalId).toBe('240,480');
});

it('Disjoint audio channels', async () => {
Expand Down Expand Up @@ -1363,10 +1363,10 @@ describe('PeriodCombiner', () => {
]));

// We can use the originalId field to see what each track is composed of.
expect(variants[0].audio.originalId).toBe('stream1,stream1');
expect(variants[1].audio.originalId).toBe('stream1,stream1');
expect(variants[2].audio.originalId).toBe('stream2,stream2');
expect(variants[3].audio.originalId).toBe('stream2,stream2');
expect(variants[0].audio.originalId).toBe('stream1');
expect(variants[1].audio.originalId).toBe('stream1');
expect(variants[2].audio.originalId).toBe('stream2');
expect(variants[3].audio.originalId).toBe('stream2');
});

it('Matches streams based on bandwidth when roles are equal', async () => {
Expand Down Expand Up @@ -1508,10 +1508,10 @@ describe('PeriodCombiner', () => {

// We can use the originalId field to see what each track is composed of.
expect(variants[0].audio.originalId)
.toBe('stream1,stream1,stream1,stream1');
.toBe('stream1');

expect(variants[1].audio.originalId)
.toBe('stream1,stream1,stream1,stream1');
.toBe('stream1');

expect(variants[2].audio.originalId)
.toBe('stream1,stream2,stream1,stream2');
Expand Down
Loading