Skip to content

Commit 844aeac

Browse files
committed
add type check prior to merging values
1 parent c1fa287 commit 844aeac

3 files changed

Lines changed: 18 additions & 6 deletions

File tree

src/dash/parser/objectiron.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ import FactoryMaker from '../../core/FactoryMaker.js';
3333
function ObjectIron(mappers) {
3434

3535
function _mergeValues(parentItem, childItem) {
36-
for (let name in parentItem) {
37-
if (!childItem.hasOwnProperty(name)) {
38-
childItem[name] = parentItem[name];
36+
if (typeof parentItem === 'object') {
37+
for (let name in parentItem) {
38+
if (!childItem.hasOwnProperty(name)) {
39+
childItem[name] = parentItem[name];
40+
}
3941
}
4042
}
4143
}
@@ -61,7 +63,9 @@ function ObjectIron(mappers) {
6163
if (propertyIsArray) {
6264
childNode[propertyName].push(propertyElementFromParent);
6365
} else {
64-
// see ISO 23009-1 (6th ed), clause 5.3.9.1
66+
// non-Array Properties can be:
67+
// - certain elements (e.g. SegmentList, see ISO 23009-1 (6th ed), clause 5.3.9.1) or
68+
// - attributes (e.g. codecs)
6569
_mergeValues(propertyElementFromParent, childNode[propertyName]);
6670
}
6771
} else {

test/unit/data/dash/manifest_properties.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<MPD mediaPresentationDuration="PT634.566S" minBufferTime="PT2.00S" profiles="urn:hbbtv:dash:profile:isoff-live:2012,urn:mpeg:dash:profile:isoff-live:2011" type="static" xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:mpeg:DASH:schema:MPD:2011 DASH-MPD.xsd">
22
<BaseURL>./</BaseURL>
33
<Period>
4-
<AdaptationSet mimeType="audio/mp4" contentType="audio" subsegmentAlignment="true" subsegmentStartsWithSAP="1" lang="es">
4+
<AdaptationSet id="as_1" codecs="mp4a.40.2" mimeType="audio/mp4" contentType="audio" subsegmentAlignment="true" subsegmentStartsWithSAP="1" lang="es">
55
<Label lang="en">English Label</Label>
66
<Label lang="fre">French Label</Label>
77
<AudioChannelConfiguration schemeIdUri="urn:mpeg:mpegB:cicp:ChannelConfiguration" value="6"/>

test/unit/test/dash/dash.DashParser.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ describe('DashParser', function () {
9090
expect(rawRepresentation.SupplementalProperty.length).to.equal(4);
9191
});
9292

93-
it('should map only allowed attributes SegmentTemplate from AdaptationSet to Representation', async () => {
93+
it('should map only allowed non-Array attributes from AdaptationSet to Representation', async () => {
9494
let parsedMpd = dashParser.parse(manifest_prop);
9595
let rawAdaptationSet = parsedMpd.Period[0].AdaptationSet[0];
9696
let rawRepresentation = rawAdaptationSet.Representation[0];
@@ -102,6 +102,14 @@ describe('DashParser', function () {
102102
expect(rawRepresentation.SegmentTemplate.duration).to.equal(300000);
103103
});
104104

105+
it('should not map attributes', async () => {
106+
let parsedMpd = dashParser.parse(manifest_prop);
107+
let rawAdaptationSet = parsedMpd.Period[0].AdaptationSet[0];
108+
let rawRepresentation = rawAdaptationSet.Representation[0];
109+
110+
expect(rawRepresentation.codecs).to.equal('mp4a.40.5');
111+
});
112+
105113
});
106114
})
107115

0 commit comments

Comments
 (0)