Checking for immersive audio capability

Even when the codec of choice is supported, your system may not be equipped with spatial playback, so we need to check for it.

Now that we have reliable fallback audio and understand how to provide alternatives in the manifest file, let's use this knowledge to provide a premium tier with immersive audio. We will learn how to probe a device for immersive capabilities.

Some operators require that immersive audio is only delivered when there is a guarantee of immersive playback. This may be because of bandwidth constraints, or artistic concerns.

A common use case is that content is available in a premium immersive version at a somewhat higher bit rate. While the content will play just fine on 5.1 or even stereo devices, the additional bits for immersive audio would go wasted. You might want to pick the immersive content only if it can actually be rendered spatially; otherwise, you might want to pick a 5.1 or stereo version.

Note that it is not sufficient to query whether Dolby Atmos can be decoded, for two reasons.

  • Dolby Atmos is backwards-compatible with Dolby Digital Plus; even devices that merely support Dolby Digital Plus decoding will report a capability to decode Dolby Atmos .
  • Even when the decoder can decode Dolby Atmos, an immersive experience will only be provided if the decoder is connected to an audio output capable of creating one.

Therefore, we need to test whether Dolby Atmos can be decoded and rendered. Let's see some code using the media capabilities API for this purpose.

Figure 1. Probe for Dolby Atmos with Dolby Digital Plus. When starting the example on a system that supports Dolby Atmos, you should get a Dolby Atmos playback and spatial rendering supported message on screen.
async function Mca() {
    var mediaConfig = {
        type: 'media-source',
        audio: {
            contentType: 'audio/mp4;codecs=ec-3',
            channels: 16,
            spatialRendering: true
        }
    }
    
    var mediacap = {
        results: null,
        message: "n/a"
    };
    
    if ("mediaCapabilities" in navigator) {
        mediacap.results = await navigator.mediaCapabilities.decodingInfo(mediaConfig);
        mediacap.message = (mediacap.results.supported ? '' : 'not ') + "supported";
    }
    
    return mediacap;
}

var p = document.getElementById('pMediaCap');

Mca().then(
    value => p.innerHTML =  "Dolby Atmos playback and spatial rendering " + value.message
)
  1. Use channels:16 to check whether the system can decode Dolby Atmos (as opposed to just decoding the Dolby Digital Plus core).
  2. Use spatialRendering: true to additionally query the system for spatial rendering capabilities.

In the following lesson, we'll integrate this filtering into dash.js.