chromiumdrmmpeg-dashwidevine

How can I play Widevine-encrypted content out of the browser?


I'm trying to playback Widevine-encrypted content outside of the browser. I'm trying to use the Content Decryption Module that ships with Chrome, which exports this API. After a lot of trial-and-error and research, I'm able to successfully initialize the CDM and obtain a Widevine license from the content server. The problem is that I'm not quite sure how the API is to be invoked for playback. I've got some DASH segments with encrypted samples, and I'm able to parse the sample information out of the boxes (number of samples, size of samples, sample IVs, and sample data). I thought I could decrypt audio via ContentDecryptionModule_10::Decrypt(); the call returns kSuccess but gives me decrypted buffers full of zeros. My next attempt was to try to use the CDM audio decoder via InitializeAudioDecoder() but that always returns kInitializationError. So I'm not quite sure where I'm going wrong. I realize I'm glossing over a lot of detail, but if anyone is familiar with any of this I can provide more data and code.


Solution

  • At a very high level, without going into detail of the code etc, if you were able to use the CDM to decrypt the content and receive back unencrypted content that you or your app could view, then this would be a loophole or an error in the content protection system as it should not allow this.

    This does not mean it is not possible, just that it's not the intent and you could not rely on the loophole or error not being fixed over time.

    The CDM is usually intended to either decrypt and play the content securely itself, or to pass it back to a secure media path that will play it back without the app or even the OS being able to see the decrypted media.

    This is sort of shown in the diagram below in the EME spec - the content, or frames, never get back to the app itself (https://www.w3.org/TR/encrypted-media/):

    enter image description here

    However, in your case, I think you just want to play back the content and you are not trying to actually view or access the decrypted content. If so, the cross platform Electron framework has a fork which supports CDM based playback for apps. This may meet your needs, although it is still using chromium and web technologies. Even if it does not it may give you useful insight into how the guys at Castlabs, the ones who created the fork, achieved this.