Hi ,
I am Trying to load the stream below and getting an error from Dash reference player v2.5.0 .
Stream : https://storage.googleapis.com/shaka-demo-assets/sintel-widevine/dash.mpd
DRM KeySystem : com.widevine.alpha
License Server : https://widevine-proxy.appspot.com/proxy
Platform :
Browser : WPEWebKit master branch
Hardware : ARM based SOC
EME : EME v0.1b (prefixed EME)
The Error is as follows :
dash.all.debug.js:40688:37: CONSOLE ERROR TypeError: Argument 3 ('initData') to HTMLMediaElement.webkitAddKey must be an instance of Uint8Array .
The Call that resulted in the error is as follows :
videoElementapi.addKey;
here sessionToken.initData is an ArrayBuffer and not UInt8Array which is causing the issue .
I would like to know if there is a fix for this already .
https://github.com/Dash-Industry-Forum/dash.js/blob/6f0e8efceff97def90f8474b86907d36b499eb91/src/streaming/protection/controllers/ProtectionController.js#L554 converts all needkey-derived initdata to ArrayBuffer, which was introduced in https://github.com/Dash-Industry-Forum/dash.js/commit/5dc5bc11a7c799459bd2f6c2f56da9c9f123c79d.
It looks like the initData needs to be wrapped in a new UInt8Array somewhere in the protection model (probably updateKeySession as you note). Does that fix the problem? I note that initData handling in 3Feb2014 protection model does convert the initdata in updateKeySession correctly so this certainly looks like a bug.
I don't know if there are implementations which rely on this broken behavior.
According to EME specification (https://w3c.github.io/encrypted-media/#mediakeysession-interface) update method of MediaKeySession should receive an argument whose type should be BufferSource. This is, ArrayBuffer or any TypedArray (Int8Array, Uint8Array, etc..). So this seems to be fine with dash.js implementation and the reason behind this didn't raise any error until now.
However, in the practice, I guess there are browser/devices implementations that require the key
type to be Uint8Array. This could be for historical reasons as for previous specifications of EME, key type was always Uint8Array.
So, to guarantee compatibility across different devices I think make sense modifying dash.js to ensure key type is Uint8Array. This will work with everything: I right tested both scenarios, ArrayBuffer and Uint8Array, in Chrome.
Sorry, right notice I was wrong. Browser that raised this issue is using ProtectionModel_01b so it uses addKey method (first version of EME spec) and it always requires the key to be passed as an Uint8Array.
Line https://github.com/Dash-Industry-Forum/dash.js/blob/77835bec35a73f1ce18a9e8a6bcc50244999a818/src/streaming/protection/models/ProtectionModel_01b.js#L239 should be:
new Uint8Array(message), new Uint8Array(sessionToken.initData), sessionID);
Presumably the ClearKey branch of the surrounding if would need updating (and testing) too.
yep, you are right.
@pavankn, given you have a quick way of reproducing the issue, would it be possible for you to check if above recommendation fix your problem?
Hi @epiclabsDASH and @bbcrddave ,
Thanks for looking into the issue .
Now, I have wrapped intData under uint8Array and the logic works fine for me now .
videoElementapi.addKey;
I will update the bug again after testing the ClearKey branch of the surrounding if . The 3rd argument in the case of clearkey is message.keyPairs[i].keyID which seems to me like a Uint8Array itself but i will test and update
Thanks
Great, many thanks for the feedback
Hi @pavankn,
Do you have any info to share regarding ClearKey and the surrounding if?
Thanks!
Hi,
Sorry for the late reply . I have tested the clearkey implementation and this works with the existing code without any changes . So, no need to change that for now
Pavan
Perfect. I will send a PR with the modification that works for the non ClearKey branch of the if.
Thanks for your help.
Closing this one. @pavankn, thanks for your support.
Thanks @epiclabsDASH .
Pavan
Most helpful comment
Hi,
Sorry for the late reply . I have tested the clearkey implementation and this works with the existing code without any changes . So, no need to change that for now
Pavan