Skip to content

Commit e3c7af5

Browse files
authored
Add support for scte214:supplementalCodecs (Dash-Industry-Forum#4585)
* Add support for supplementalCodecs. * Add scte214:supplementalCodecs to DashConstants.js * Create configurations for early capabilities detection. * Change logic so that either the base codec or the supplementalCodec with ensure the representation is accepted. * Keep track of array of supplemental codecs and display warning when only the first is selected. * Fix tests; add stub for getSupplementalCodecs()
1 parent 9cb12cc commit e3c7af5

File tree

4 files changed

+52
-5
lines changed

4 files changed

+52
-5
lines changed

src/dash/DashAdapter.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,19 @@ function DashAdapter() {
413413
}
414414
}
415415

416+
/**
417+
* Return supplementalCodecs of a Representation
418+
* @param {object} representation
419+
* @returns {array}
420+
*/
421+
function getSupplementalCodecs(representation) {
422+
const supplementalCodecs = representation[DashConstants.SUPPLEMENTAL_CODECS];
423+
if (!supplementalCodecs) {
424+
return [];
425+
}
426+
return supplementalCodecs.split(' ').map((codec) => representation.mimeType + ';codecs="' + codec + '"');
427+
}
428+
416429
/**
417430
* Returns the period as defined in the DashManifestModel for a given index
418431
* @param {number} index
@@ -1233,6 +1246,7 @@ function DashAdapter() {
12331246
getRepresentationSortFunction,
12341247
getStreamsInfo,
12351248
getSuggestedPresentationDelay,
1249+
getSupplementalCodecs,
12361250
getUTCTimingSources,
12371251
getVoRepresentations,
12381252
isPatchValid,

src/dash/constants/DashConstants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ export default {
183183
SUB_SEGMENT_ALIGNMENT: 'subsegmentAlignment',
184184
SUGGESTED_PRESENTATION_DELAY: 'suggestedPresentationDelay',
185185
SUPPLEMENTAL_PROPERTY: 'SupplementalProperty',
186+
SUPPLEMENTAL_CODECS: 'scte214:supplementalCodecs',
186187
TIMESCALE: 'timescale',
187188
TIMESHIFT_BUFFER_DEPTH: 'timeShiftBufferDepth',
188189
TTL: 'ttl',

src/streaming/utils/CapabilitiesFilter.js

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,31 @@ function CapabilitiesFilter() {
128128
as.Representation = as.Representation.filter((rep, i) => {
129129
const codec = adapter.getCodec(as, i, false);
130130
const config = _createConfiguration(type, rep, codec);
131-
132131
configurations.push(config);
133-
const supported = capabilities.isCodecSupportedBasedOnTestedConfigurations(config, type);
134-
if (!supported) {
135-
logger.debug(`[CapabilitiesFilter] Codec ${configurations[i].codec} not supported. Removing Representation with ID ${rep.id}`);
132+
const isCodecSupported = capabilities.isCodecSupportedBasedOnTestedConfigurations(config, type);
133+
134+
let isSupplementalCodecSupported = false;
135+
const supplementalCodecs = adapter.getSupplementalCodecs(rep);
136+
if (supplementalCodecs.length > 0) {
137+
if (supplementalCodecs.length > 1) {
138+
logger.warn(`[CapabilitiesFilter] Multiple supplemental codecs not supported; using first in list`);
139+
}
140+
const supplementalCodec = supplementalCodecs[0];
141+
const supplementalCodecConfig = _createConfiguration(type, rep, supplementalCodec);
142+
configurations.push(supplementalCodecConfig);
143+
isSupplementalCodecSupported = capabilities.isCodecSupportedBasedOnTestedConfigurations(supplementalCodecConfig, type);
144+
if (isSupplementalCodecSupported) {
145+
logger.debug(`[CapabilitiesFilter] Codec ${supplementalCodec} supported. Upgrading Representation with ID ${rep.id}`);
146+
// overriding default codec
147+
rep.codecs = rep[DashConstants.SUPPLEMENTAL_CODECS]
148+
}
136149
}
137-
return supported
150+
151+
if (!isCodecSupported && !isSupplementalCodecSupported) {
152+
logger.debug(`[CapabilitiesFilter] Codec ${codec} not supported. Removing Representation with ID ${rep.id}`);
153+
}
154+
155+
return isCodecSupported || isSupplementalCodecSupported;
138156
});
139157
}
140158

@@ -158,6 +176,16 @@ function CapabilitiesFilter() {
158176
configurationsSet.add(configString);
159177
configurations.push(config);
160178
}
179+
180+
const supplementalCodecs = adapter.getSupplementalCodecs(rep)
181+
if (supplementalCodecs.length > 0) {
182+
const config = _createConfiguration(type, rep, supplementalCodecs[0]);
183+
const configString = JSON.stringify(config);
184+
if (!configurationsSet.has(configString)) {
185+
configurationsSet.add(configString);
186+
configurations.push(config);
187+
}
188+
}
161189
});
162190
}
163191
});

test/unit/mocks/AdapterMock.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ function AdapterMock() {
161161
return codec;
162162
};
163163

164+
this.getSupplementalCodecs = function () {
165+
return [];
166+
}
167+
164168
this.getEssentialPropertiesForRepresentation = function (realRepresentation) {
165169
if (!realRepresentation || !realRepresentation.EssentialProperty || !realRepresentation.EssentialProperty.length) {
166170
return null;

0 commit comments

Comments
 (0)