androidandroid-mediaplayerandroid-mediacodecdrmandroid-drm

How to handle multikey DRM with MediaDrm


Android MediaDrm documentation only has a sequence diagram for the simplest use case. It does not say how a DASH stream with multiple consecutive encryption key should work. (for example, first 10s are encrypted with keyA and the next 20s with keyB)

Considering that each DRM session can only holds one key and each MediaCodec can only be configured with one DRM session. How can I do the following:


Solution

  • While looking at another implementation, I found the following property string being used.

    mediaDrm.setPropertyString("sessionSharing", "enable");
    

    Apparently setting this allows the DRM implementation to use keys from any session created by the MediaDrm object if needed, without having to reconfigure the MediaCodec.

    Frustratingly, there is no mention of that property string in the Android documentation or anywhere else online either. I see it's used in the Chromium MediaDrmBridge code too, that's all there is.