Filter AdaptationSets with unsupported codecs
Created by: dsilhavy
Environment
- Link to playable MPD file:
- Dash.js version: 3.2.0
- Browser name/version: all
- OS name/version: all
Steps to reproduce
- Try to play an MPD that contains AdaptationSets with an unsupported codec, for instance audio ec-3
Observed behavior
dash.js will not filter the complete AdaptationSet and tries to create a SourceBuffer for an unsupported codec
Console output
[6303][BufferController][audio] Caught error on create SourceBuffer: NotSupportedError: Failed to execute 'addSourceBuffer' on 'MediaSource': The type provided ('audio/mp4;codecs="ec-3"') is unsupported.
Expected behavior
dash.js should filter unsupported AdaptationSets prior to creating the SourceBuffer. Currently filtering is only done on Representation level
function filterCodecs(type) {
const realAdaptation = adapter.getAdaptationForType(streamInfo ? streamInfo.index : null, type, streamInfo);
if (!realAdaptation || !Array.isArray(realAdaptation.Representation_asArray)) return;
// Filter codecs that are not supported
realAdaptation.Representation_asArray = realAdaptation.Representation_asArray.filter((_, i) => {
// keep at least codec from lowest representation
if (i === 0) return true;
const codec = adapter.getCodec(realAdaptation, i, true);
if (!capabilities.supportsCodec(codec)) {
logger.error('[Stream] codec not supported: ' + codec);
return false;
}
return true;
});
}