Skip to content

Commit 0c299c8

Browse files
committed
add check for schemeIdUri in getIsMain()
1 parent d8ed19d commit 0c299c8

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

src/dash/DashAdapter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ function DashAdapter() {
126126
*/
127127
function getIsMain(adaptation) {
128128
return dashManifestModel.getRolesForAdaptation(adaptation).filter(function (role) {
129-
return role.value === DashConstants.MAIN;
129+
return role.schemeIdUri === Constants.DASH_ROLE_SCHEME_ID && role.value === DashConstants.MAIN;
130130
})[0];
131131
}
132132

test/unit/test/dash/dash.DashAdapter.js

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import DashAdapter from '../../../../src/dash/DashAdapter.js';
22
import Constants from '../../../../src/streaming/constants/Constants.js';
33
import DashConstants from '../../../../src/dash/constants/DashConstants.js';
4-
import {Cta608Parser} from '@svta/common-media-library/cta/608/Cta608Parser';
4+
import { Cta608Parser } from '@svta/common-media-library/cta/608/Cta608Parser';
55
import VoHelper from '../../helpers/VOHelper.js';
66
import PatchHelper from '../../helpers/PatchHelper.js';
77
import ErrorHandlerMock from '../../mocks/ErrorHandlerMock.js';
88
import DescriptorType from '../../../../src/dash/vo/DescriptorType.js';
9-
import {expect} from 'chai';
9+
import { expect } from 'chai';
1010

1111
const context = {};
1212
const voHelper = new VoHelper();
@@ -509,6 +509,34 @@ describe('DashAdapter', function () {
509509
expect(voRepresentations).to.be.empty;
510510
});
511511

512+
it('should return the adaptation with Role Main when getMainAdaptationForType is called', () => {
513+
const manifest_with_video = {
514+
loadedTime: new Date(),
515+
mediaPresentationDuration: 10,
516+
Period: [{
517+
AdaptationSet: [
518+
{
519+
id: 1,
520+
mimeType: Constants.VIDEO,
521+
Role: [{ schemeIdUri: Constants.DASH_ROLE_SCHEME_ID, value: 'alternate' }]
522+
},
523+
{
524+
id: 2,
525+
mimeType: Constants.VIDEO,
526+
Role: [
527+
{ schemeIdUri: Constants.DASH_ROLE_SCHEME_ID, value: DashConstants.MAIN },
528+
{ schemeIdUri: Constants.DASH_ROLE_SCHEME_ID, value: 'dub' }
529+
]
530+
}
531+
]
532+
}]
533+
};
534+
dashAdapter.updatePeriods(manifest_with_video);
535+
const adaptation = dashAdapter.getMainAdaptationForType(Constants.VIDEO, { index: 0 });
536+
537+
expect(adaptation.id).to.equal(2);
538+
});
539+
512540
it('should return the first adaptation when getMainAdaptationForType is called and streamInfo is undefined', () => {
513541
const manifest_with_video = {
514542
loadedTime: new Date(),

0 commit comments

Comments
 (0)