Skip to content

Commit 66ca230

Browse files
authored
fix(DASH): Fix DASH_DUPLICATE_REPRESENTATION_ID error when using supplemental codec (#7961)
Fixes #7948
1 parent 1825266 commit 66ca230

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

lib/dash/dash_parser.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -1983,6 +1983,10 @@ shaka.dash.DashParser = class {
19831983
// Duplicate representations with their supplementalCodecs
19841984
const obj = shaka.util.ObjectUtils.cloneObject(rep);
19851985
obj.attributes['codecs'] = supplementalCodecs.split(' ').join(',');
1986+
if (obj.attributes['id']) {
1987+
obj.attributes['supplementalId'] =
1988+
obj.attributes['id'] + '_supplementalCodecs';
1989+
}
19861990
supplementalRepresentations.push(obj);
19871991
}
19881992
}
@@ -2048,8 +2052,9 @@ shaka.dash.DashParser = class {
20482052
}
20492053

20502054
const repIds = representations
2051-
.map((node) => { return node.attributes['id']; })
2052-
.filter(shaka.util.Functional.isNotNull);
2055+
.map((node) => {
2056+
return node.attributes['supplementalId'] || node.attributes['id'];
2057+
}).filter(shaka.util.Functional.isNotNull);
20532058

20542059
return {
20552060
id: adaptationId,
@@ -2580,6 +2585,7 @@ shaka.dash.DashParser = class {
25802585
const evalDivision = TXml.evalDivision;
25812586

25822587
const id = elem.attributes['id'];
2588+
const supplementalId = elem.attributes['supplementalId'];
25832589
const uriObjs = TXml.findChildren(elem, 'BaseURL');
25842590
let calculatedBaseUris;
25852591
let someLocationValid = false;
@@ -2694,7 +2700,8 @@ shaka.dash.DashParser = class {
26942700
frameRate: frameRate,
26952701
pixelAspectRatio: pixelAspectRatio,
26962702
emsgSchemeIdUris: emsgSchemeIdUris,
2697-
id: id,
2703+
id: supplementalId || id,
2704+
originalId: id,
26982705
language: elem.attributes['lang'],
26992706
numChannels: numChannels,
27002707
audioSamplingRate: audioSamplingRate,
@@ -3243,6 +3250,7 @@ shaka.dash.DashParser.RequestSegmentCallback;
32433250
* pixelAspectRatio: (string|undefined),
32443251
* emsgSchemeIdUris: !Array<string>,
32453252
* id: ?string,
3253+
* originalId: ?string,
32463254
* position: (number|undefined),
32473255
* language: ?string,
32483256
* numChannels: ?number,
@@ -3284,6 +3292,8 @@ shaka.dash.DashParser.RequestSegmentCallback;
32843292
* emsg registered schemeIdUris.
32853293
* @property {?string} id
32863294
* The ID of the element.
3295+
* @property {?string} originalId
3296+
* The original ID of the element.
32873297
* @property {number|undefined} position
32883298
* Position of the element used for indexing in case of no id
32893299
* @property {?string} language

lib/dash/segment_template.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ shaka.dash.SegmentTemplate = class {
135135
shaka.log.debug(`Creating TSI with end ${periodEnd}`);
136136
segmentIndex = new TimelineSegmentIndex(
137137
info,
138-
context.representation.id,
138+
context.representation.originalId,
139139
context.bandwidth,
140140
context.representation.getBaseUris,
141141
context.urlParams,
@@ -348,7 +348,7 @@ shaka.dash.SegmentTemplate = class {
348348

349349
goog.asserts.assert(info.indexTemplate, 'must be using index template');
350350
const filledTemplate = MpdUtils.fillUriTemplate(
351-
info.indexTemplate, context.representation.id,
351+
info.indexTemplate, context.representation.originalId,
352352
null, null, context.bandwidth || null, null);
353353

354354
const resolvedUris = ManifestParserUtils.resolveUris(
@@ -677,7 +677,7 @@ shaka.dash.SegmentTemplate = class {
677677
}
678678
initialization = shaka.util.StringUtils.htmlUnescape(initialization);
679679

680-
const repId = context.representation.id;
680+
const repId = context.representation.originalId;
681681
const bandwidth = context.bandwidth || null;
682682
const getBaseUris = context.representation.getBaseUris;
683683
const urlParams = context.urlParams;

0 commit comments

Comments
 (0)