rx-player icon indicating copy to clipboard operation
rx-player copied to clipboard

feat: detect codecs supported by the CDM to choose appropriate representation.

Open Florent-Bouisset opened this issue 8 months ago • 0 comments

This PR intend to better detect the capabilities of the device (and in particular of the CDM) to be able to choose a representation (a quality) that is playable for the device.

Recent Chrome version can play HEVC (i.e H.265), however the CDM needs to be Widevine L1 to decrypt HEVC. That is not the case on a windows computer. So the browser support HEVC, but the CDM does not. As a result the content will be playable or not depending if it is encrypted (i.e it uses the CDM).

Chrome on a Window desktop:

Codec Encrypted Not encrypted
avc ✅ Supported ✅ Supported
hevc ❌ Not Supported ✅ Supported

Codec support for the CDM can be detect as so:


try {
  await navigator.requestMediaKeySystemAccess('com.widevine.alpha', [
    {
      initDataTypes: ['cenc'],
      distinctiveIdentifier: 'required',
      persistentState: 'required',
      sessionTypes: ['temporary'],
      videoCapabilities: [
        {
          robustness: 'HW_SECURE_ALL',
          contentType: 'video/mp4; codecs="hev1.1.6.L120.90"',
        },
      ],
    },
  ]);
  console.log('Widevine L1 HEVC main profile is supported!');
} catch (e) {
  console.log('Widevine L1 HEVC main profile is not supported!');
}

More infos on https://github.com/StaZhu/enable-chromium-hevc-hardware-decoding

For the RxPlayer the detection is done by checking what are the codecs supported by the CDM with mediaKeySystemAccess.getConfiguration and finding out what are the codecs remaining in the configuration from what was originally provided.

Florent-Bouisset avatar Jun 21 '24 16:06 Florent-Bouisset