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.

- 11,211
- 2
- 27
- 38
1 Answers
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/):
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.

- 24,231
- 1
- 54
- 120
-
I understand that, but the CDM API doesn't provide any interface for playback and I thought maybe I would at least be able to get audio. But reading the linked repo, I guess there is some digital signature verification going on where the CDM won't work correctly if it's not running in a properly signed process. So that led me to change course and try a different approach so I'll accept this answer. – Luke Jul 18 '23 at 10:29
-
@Luke Just a note - if it is the audio in a video you want to play, you may actually find that sometimes this is not encrypted, even when the video stream is. – Mick Jul 19 '23 at 10:52
-
Good to know, but in my specific case the audio is actually encrypted. – Luke Jul 19 '23 at 11:25