Skip to content

Commit fd1312d

Browse files
committed
unify getProperty functions
1 parent a0a5e8f commit fd1312d

File tree

5 files changed

+32
-138
lines changed

5 files changed

+32
-138
lines changed

src/dash/DashAdapter.js

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -405,39 +405,13 @@ function DashAdapter() {
405405
}
406406

407407
/**
408-
* Return all EssentialProperties of an AdaptationSet
409-
* @param {object} adaptationSet
408+
* Return all EssentialProperties of an AdaptationSet, Representation or Preselection
409+
* @param {object} element
410410
* @return {array}
411411
*/
412-
function getEssentialPropertiesForAdaptationSet(adaptationSet) {
412+
function getEssentialProperties(element) {
413413
try {
414-
return dashManifestModel.getEssentialPropertiesForRepresentation(adaptationSet);
415-
} catch (e) {
416-
return [];
417-
}
418-
}
419-
420-
/**
421-
* Return all EssentialProperties of a Representation
422-
* @param {object} representation
423-
* @return {array}
424-
*/
425-
function getEssentialPropertiesForRepresentation(representation) {
426-
try {
427-
return dashManifestModel.getEssentialPropertiesForRepresentation(representation);
428-
} catch (e) {
429-
return [];
430-
}
431-
}
432-
433-
/**
434-
* Return all EssentialProperties of a Preselection
435-
* @param {object} preselection
436-
* @return {array}
437-
*/
438-
function getEssentialPropertiesForPreselection(preselection) {
439-
try {
440-
return dashManifestModel.getEssentialPropertiesForRepresentation(preselection);
414+
return dashManifestModel.getEssentialProperties(element);
441415
} catch (e) {
442416
return [];
443417
}
@@ -1341,9 +1315,7 @@ function DashAdapter() {
13411315
getCodecForPreselection,
13421316
getContentSteering,
13431317
getDuration,
1344-
getEssentialPropertiesForAdaptationSet,
1345-
getEssentialPropertiesForPreselection,
1346-
getEssentialPropertiesForRepresentation,
1318+
getEssentialProperties,
13471319
getEvent,
13481320
getEventsFor,
13491321
getFramerate,

src/dash/models/DashManifestModel.js

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ function DashManifestModel() {
8585

8686
// Check for thumbnail images
8787
if (adaptation.Representation && adaptation.Representation.length) {
88-
const essentialProperties = getEssentialPropertiesForRepresentation(adaptation.Representation[0]);
88+
const essentialProperties = getEssentialProperties(adaptation.Representation[0]);
8989
if (essentialProperties && essentialProperties.some(essentialProperty => Constants.THUMBNAILS_SCHEME_ID_URIS.indexOf(essentialProperty.schemeIdUri) >= 0)) {
9090
return (type === Constants.IMAGE);
9191
}
@@ -719,30 +719,22 @@ function DashManifestModel() {
719719
});
720720
}
721721

722-
function getEssentialPropertiesForAdaptationSet(adaptation) {
723-
return _getProperties(DashConstants.ESSENTIAL_PROPERTY, adaptation);
722+
function getEssentialProperties(element) {
723+
return _getProperties(DashConstants.ESSENTIAL_PROPERTY, element);
724724
}
725725

726726
function getCombinedEssentialPropertiesForAdaptationSet(adaptation) {
727727
return _getCombinedPropertiesForAdaptationSet(DashConstants.ESSENTIAL_PROPERTY, adaptation);
728728
}
729729

730-
function getEssentialPropertiesForRepresentation(realRepresentation) {
731-
return _getProperties(DashConstants.ESSENTIAL_PROPERTY, realRepresentation);
732-
}
733-
734-
function getSupplementalPropertiesForAdaptationSet(adaptation) {
735-
return _getProperties(DashConstants.SUPPLEMENTAL_PROPERTY, adaptation);
730+
function getSupplementalProperties(element) {
731+
return _getProperties(DashConstants.SUPPLEMENTAL_PROPERTY, element);
736732
}
737733

738734
function getCombinedSupplementalPropertiesForAdaptationSet(adaptation) {
739735
return _getCombinedPropertiesForAdaptationSet(DashConstants.SUPPLEMENTAL_PROPERTY, adaptation);
740736
}
741737

742-
function getSupplementalPropertiesForRepresentation(representation) {
743-
return _getProperties(DashConstants.SUPPLEMENTAL_PROPERTY, representation);
744-
}
745-
746738
function getRepresentationFor(index, adaptation) {
747739
return adaptation && adaptation.Representation && adaptation.Representation.length > 0 &&
748740
isInteger(index) ? adaptation.Representation[index] : null;
@@ -845,8 +837,8 @@ function DashManifestModel() {
845837
voRepresentation.segmentInfoType = DashConstants.BASE_URL;
846838
}
847839

848-
voRepresentation.essentialProperties = getEssentialPropertiesForRepresentation(realRepresentation);
849-
voRepresentation.supplementalProperties = getSupplementalPropertiesForRepresentation(realRepresentation);
840+
voRepresentation.essentialProperties = getEssentialProperties(realRepresentation);
841+
voRepresentation.supplementalProperties = getSupplementalProperties(realRepresentation);
850842

851843
if (segmentInfo) {
852844
if (segmentInfo.hasOwnProperty(DashConstants.INITIALIZATION)) {
@@ -1685,8 +1677,7 @@ function DashManifestModel() {
16851677
getContentProtectionByPeriod,
16861678
getContentSteering,
16871679
getDuration,
1688-
getEssentialPropertiesForAdaptationSet,
1689-
getEssentialPropertiesForRepresentation,
1680+
getEssentialProperties,
16901681
getEventStreamForAdaptationSet,
16911682
getEventStreamForRepresentation,
16921683
getEventsForPeriod,
@@ -1725,8 +1716,7 @@ function DashManifestModel() {
17251716
getServiceDescriptions,
17261717
getSubSegmentAlignment,
17271718
getSuggestedPresentationDelay,
1728-
getSupplementalPropertiesForAdaptationSet,
1729-
getSupplementalPropertiesForRepresentation,
1719+
getSupplementalProperties,
17301720
getUTCTimingSources,
17311721
getViewpointForAdaptation,
17321722
hasProfile,

src/streaming/utils/CapabilitiesFilter.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,15 +389,15 @@ function CapabilitiesFilter() {
389389
return true;
390390
}
391391

392-
const adaptationSetEssentialProperties = adapter.getEssentialPropertiesForAdaptationSet(as);
392+
const adaptationSetEssentialProperties = adapter.getEssentialProperties(as);
393393
const doesSupportEssentialProperties = _doesSupportEssentialProperties(adaptationSetEssentialProperties);
394394

395395
if (!doesSupportEssentialProperties) {
396396
return false;
397397
}
398398

399399
as.Representation = as.Representation.filter((rep) => {
400-
const essentialProperties = adapter.getEssentialPropertiesForRepresentation(rep);
400+
const essentialProperties = adapter.getEssentialProperties(rep);
401401
return _doesSupportEssentialProperties(essentialProperties);
402402
});
403403

@@ -406,7 +406,7 @@ function CapabilitiesFilter() {
406406

407407
if (period.Preselection && period.Preselection.length) {
408408
period.Preselection = period.Preselection.filter(prsl => {
409-
const preselectionEssentialProperties = adapter.getEssentialPropertiesForPreselection(prsl);
409+
const preselectionEssentialProperties = adapter.getEssentialProperties(prsl);
410410
const doesSupportEssentialProperties = _doesSupportEssentialProperties(preselectionEssentialProperties);
411411

412412
if (!doesSupportEssentialProperties) {

test/unit/mocks/AdapterMock.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -179,25 +179,12 @@ function AdapterMock() {
179179
return supplementalCodecs.split(' ').map((codec) => representation.mimeType + ';codecs="' + codec + '"');
180180
}
181181

182-
this.getEssentialPropertiesForRepresentation = function (realRepresentation) {
183-
if (!realRepresentation || !realRepresentation.EssentialProperty || !realRepresentation.EssentialProperty.length) {
182+
this.getEssentialProperties = function (element) {
183+
if (!element || !element.EssentialProperty || !element.EssentialProperty.length) {
184184
return null;
185185
}
186186

187-
return realRepresentation.EssentialProperty.map((prop) => {
188-
return {
189-
schemeIdUri: prop.schemeIdUri,
190-
value: prop.value
191-
};
192-
});
193-
};
194-
195-
this.getEssentialPropertiesForAdaptationSet = function (adaptationSet) {
196-
if (!adaptationSet || !adaptationSet.EssentialProperty || !adaptationSet.EssentialProperty.length) {
197-
return null;
198-
}
199-
200-
return adaptationSet.EssentialProperty.map((prop) => {
187+
return element.EssentialProperty.map((prop) => {
201188
return {
202189
schemeIdUri: prop.schemeIdUri,
203190
value: prop.value

test/unit/test/dash/dash.models.DashManifestModel.js

Lines changed: 12 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -144,22 +144,22 @@ describe('DashManifestModel', function () {
144144
expect(rolesArray[1].value).equals('Main');
145145
});
146146

147-
it('should return an empty array when getEssentialPropertiesForAdaptationSet', () => {
148-
const suppPropArray = dashManifestModel.getEssentialPropertiesForAdaptationSet();
147+
it('should return an empty array when getEssentialProperties', () => {
148+
const suppPropArray = dashManifestModel.getEssentialProperties();
149149

150150
expect(suppPropArray).to.be.instanceOf(Object);
151151
expect(suppPropArray).to.be.empty;
152152
});
153153

154-
it('should return an empty array when getEssentialPropertiesForAdaptationSet', () => {
155-
const suppPropArray = dashManifestModel.getEssentialPropertiesForAdaptationSet();
154+
it('should return an empty array when getEssentialProperties', () => {
155+
const suppPropArray = dashManifestModel.getEssentialProperties();
156156

157157
expect(suppPropArray).to.be.instanceOf(Array);
158158
expect(suppPropArray).to.be.empty;
159159
});
160160

161-
it('should return correct array of DescriptorType when getEssentialPropertiesForAdaptationSet is called', () => {
162-
const essPropArray = dashManifestModel.getEssentialPropertiesForAdaptationSet({
161+
it('should return correct array of DescriptorType when getEssentialProperties is called', () => {
162+
const essPropArray = dashManifestModel.getEssentialProperties({
163163
EssentialProperty: [{ schemeIdUri: 'test.scheme', value: 'testVal' }, {
164164
schemeIdUri: 'test.scheme',
165165
value: 'test2Val'
@@ -175,22 +175,22 @@ describe('DashManifestModel', function () {
175175
expect(essPropArray[1].value).equals('test2Val');
176176
});
177177

178-
it('should return an empty array when getEssentialPropertiesForRepresentation', () => {
179-
const essPropArray = dashManifestModel.getEssentialPropertiesForRepresentation();
178+
it('should return an empty array when getEssentialProperties', () => {
179+
const essPropArray = dashManifestModel.getEssentialProperties();
180180

181181
expect(essPropArray).to.be.instanceOf(Object);
182182
expect(essPropArray).to.be.empty;
183183
});
184184

185-
it('should return an empty array when getEssentialPropertiesForRepresentation', () => {
186-
const essPropArray = dashManifestModel.getEssentialPropertiesForRepresentation();
185+
it('should return an empty array when getEssentialProperties', () => {
186+
const essPropArray = dashManifestModel.getEssentialProperties();
187187

188188
expect(essPropArray).to.be.instanceOf(Array);
189189
expect(essPropArray).to.be.empty;
190190
});
191191

192-
it('should return correct array of DescriptorType when getEssentialPropertiesForRepresentation is called', () => {
193-
const essPropArray = dashManifestModel.getEssentialPropertiesForRepresentation({
192+
it('should return correct array of DescriptorType when getEssentialProperties is called', () => {
193+
const essPropArray = dashManifestModel.getEssentialProperties({
194194
EssentialProperty: [{ schemeIdUri: 'test.scheme', value: 'testVal' }]
195195
});
196196

@@ -200,61 +200,6 @@ describe('DashManifestModel', function () {
200200
expect(essPropArray[0].value).equals('testVal');
201201
});
202202

203-
it('should return an empty array when getSupplementalPropertiesForAdaptationSet', () => {
204-
const suppPropArray = dashManifestModel.getSupplementalPropertiesForAdaptationSet();
205-
206-
expect(suppPropArray).to.be.instanceOf(Object);
207-
expect(suppPropArray).to.be.empty;
208-
});
209-
210-
it('should return an empty array when getSupplementalPropertiesForAdaptationSet', () => {
211-
const suppPropArray = dashManifestModel.getSupplementalPropertiesForAdaptationSet();
212-
213-
expect(suppPropArray).to.be.instanceOf(Array);
214-
expect(suppPropArray).to.be.empty;
215-
});
216-
217-
it('should return correct array of DescriptorType when getSupplementalPropertiesForAdaptationSet is called', () => {
218-
const suppPropArray = dashManifestModel.getSupplementalPropertiesForAdaptationSet({
219-
SupplementalProperty: [{ schemeIdUri: 'test.scheme', value: 'testVal' }, {
220-
schemeIdUri: 'test.scheme',
221-
value: 'test2Val'
222-
}]
223-
});
224-
225-
expect(suppPropArray).to.be.instanceOf(Array);
226-
expect(suppPropArray[0]).to.be.instanceOf(DescriptorType);
227-
expect(suppPropArray[0].schemeIdUri).equals('test.scheme');
228-
expect(suppPropArray[0].value).equals('testVal');
229-
expect(suppPropArray[1].schemeIdUri).equals('test.scheme');
230-
expect(suppPropArray[1].value).equals('test2Val');
231-
});
232-
233-
it('should return an empty array when getSupplementalPropertiesForRepresentation', () => {
234-
const suppPropArray = dashManifestModel.getSupplementalPropertiesForRepresentation();
235-
236-
expect(suppPropArray).to.be.instanceOf(Object);
237-
expect(suppPropArray).to.be.empty;
238-
});
239-
240-
it('should return an empty array when getSupplementalPropertiesForRepresentation', () => {
241-
const suppPropArray = dashManifestModel.getSupplementalPropertiesForRepresentation();
242-
243-
expect(suppPropArray).to.be.instanceOf(Array);
244-
expect(suppPropArray).to.be.empty;
245-
});
246-
247-
it('should return correct array of DescriptorType when getSupplementalPropertiesForRepresentation is called', () => {
248-
const suppPropArray = dashManifestModel.getSupplementalPropertiesForRepresentation({
249-
SupplementalProperty: [{ schemeIdUri: 'test.scheme', value: 'testVal' }]
250-
});
251-
252-
expect(suppPropArray).to.be.instanceOf(Array);
253-
expect(suppPropArray[0]).to.be.instanceOf(DescriptorType);
254-
expect(suppPropArray[0].schemeIdUri).equals('test.scheme');
255-
expect(suppPropArray[0].value).equals('testVal');
256-
});
257-
258203
it('should return null when getAdaptationForId is called and id, manifest and periodIndex are undefined', () => {
259204
const adaptation = dashManifestModel.getAdaptationForId(undefined, undefined, undefined);
260205

0 commit comments

Comments
 (0)