Skip to content

Add support for latest EME APIs (21 Jan 2015)

Created by: greg80303

Support for the latest EME APIs means moving to support Promise-based APIs. Since dash.js has moved away from Promises and chosen events, most Promise-based APIs have associated events in ProtectionModel.js. Here is a summary of the changes:

EME Key System Selection Process

The latest EME APIs have introduced an entirely new process for selecting a key system. The first step is to "request access" to a key system by providing a list of "capabilities" that you would like the key system to support. All of the older EME ProtectionModel objects have been augmented to utilize this new system. Once you have validated that a key system exists that provides the capabilities you require, you are able to "select" that key system.

New EME APIs

Several new EME APIs have been introduced to manage the concept of "persistent" key sessions. These operations are not supported in any of the previous ProtectionModel implementations.

  • loadKeySession() -- This API allows the "loading" of a session (stored keys) that have been persisted by the CDM into an empty key session object. This operation is actually implemented in dash.js as a createKeySession(), but it does not take initData, just a sessionID for a previously persisted session.
  • removeKeySession() -- This API instructs the CDM to remove persisted session data. Also performs the same operations as closeKeySession()
  • setServerCertificate() -- Allows the player to provide a certificate associated with a particular license server. The CDM will use this certificate to sign its license requests.

"needkey" KeySystem Auto-Select

If developer chooses to let the player react to encrypted content by sending encrypted content to a MediaSource, the needkey (old) or encrypted (latest) event is generated. In this case, the initData passed to the event handler is a concatenated list of PSSH boxes. In this case, there will never be a need to process initData from the MPD. Therefore, the auto-selection process in ProtectionExtensions only looks at the initData passed to needkey. The ContentProtection element in the MPD allows the player to "pre-fetch" keys for a piece of content before the media is ever downloaded to the client. The functionality for parsing initData from ContentProtection has been moved to another helper function in ProtectionExtensions. My next pull request will address this "pre-fetch" use case.

initData Data Type

It seems that some browsers (IE11, Windows 8.1) pass initData to the needkey event as a Uint8Array while, according to the spec, Chrome passes it as ArrayBuffer. Added code to ensure proper conversion of this data type. I am using an ECMAScript6 API (ArrayBuffer.isView()) for this, but this API is supported in all browsers that support EME.

ProtectionModel_01b Audio Capabilities Support

Audio support checks are disabled in the 01b version. For some reason, on Chrome (with EME disabled, which enables the 01b version), HTMLMediaElement.canPlayType() returns false for the audio mime type of my test content. This fails ONLY WITH WIDEVINE CDM! Works just fine for ClearKey CDM. Also works just fine with the latest 21Jan2015 version of EME, so I know the mime/codec is supported by the browser. In previous versions of the code, we were not calling canPlayType() on the audio component. Not sure what to do other than comment out this code for now.

Squashed commit of the following:

commit 5579680cc6be658a64d29a59de0d62338ffe82aa Author: Greg Rutz g.rutz@cablelabs.com Date: Tue Jan 27 21:32:00 2015 -0700

Revert changes to protection data

commit 90374ae4a8990e5b1fc1a82328a9fc683abfd447 Author: Greg Rutz g.rutz@cablelabs.com Date: Tue Jan 27 21:25:02 2015 -0700

Fix "this" problem with Promise catch

commit 1109c350b172d826bb85238035b12b2386bb6bfc Author: Greg Rutz g.rutz@cablelabs.com Date: Tue Jan 27 21:16:21 2015 -0700

Add protections for access to pendingSessions list

commit 5dc5bc11a7c799459bd2f6c2f56da9c9f123c79d Author: Greg Rutz g.rutz@cablelabs.com Date: Tue Jan 27 16:52:13 2015 -0700

Final fixes -- all implementations working

Some browsers pass initData as Uint8Array and some as ArrayBuffer,
so added a conversion if necessary.

Several minor fixes to the 3Feb2014 and 01b versions.

Audio support checks are disabled in the 01b version.  For some reason,
on Chrome (with EME disabled, which enables the 01b version),
canPlayType returns false for the audio mime type of my test content.
This fails ONLY WITH WIDEVINE CDM!  Works just fine for ClearKey CDM.
Also works just fine with the latest 21Jan2015 version of EME, so I know
the mime/codec is supported by the browser.  In previous versions of the
code, we were not calling canPlayType on the audio component.  Not
sure what to do other than comment out this code for now.

commit ab86fa090156788cb8fa6ebc42492f1cfa77ec7e Author: Greg Rutz g.rutz@cablelabs.com Date: Tue Jan 27 15:40:26 2015 -0700

Last fixes for 21Jan2015 EME - Working now

Instead of caching sessionID in the sessionToken, we have a method
to retrieve it directly from the EME session.  It seems that the
sessionID is not automatically created when the session is created.
This makes sense since sessions can be created as empty shells to
be "loaded" with the state of a persisted session.

Updated ProtectionController with all new methods.  Updated Stream
to make most calls to ProtectionController instead of ProtectionModel

Moved key system selection process back to ProtectionExtensions
where it belongs

commit dd80f9eb09cc6419c6a862fc4e4fb76e9a352e8f Author: Dan Sparacio dsparaci@akamai.com Date: Mon Jan 26 10:51:37 2015 -0800

Updated the paths in example.html and other files related to webmjs example.
Removed libs from min task in grunt.
Added debug uglify task.
Ran grunt and compiled new min and all files.

commit f5342487847baed76486fb33717e1286b92d1f85 Author: kozhinm mikhail.kozhin@akvelon.com Date: Mon Jan 26 14:44:09 2015 +0300

fixes unused sessionArray argument in ProtectionModel_01b.findSessionByID function

commit f8c9d479ec9dd7ff0c4209f68eb0d395b94f00ae Author: kozhinm mikhail.kozhin@akvelon.com Date: Mon Jan 26 12:46:46 2015 +0300

updates minified files in contrib/webmjs folder

commit 78df1f89d7b2197f77e8abde8ea116fc391690fa Author: kozhinm mikhail.kozhin@akvelon.com Date: Mon Jan 26 12:45:57 2015 +0300

updates Gruntfile.js in contrib/webmjs folder

commit 7646b16243b8be9ea5bdf211ffac3b4077db5a64 Author: kozhinm mikhail.kozhin@akvelon.com Date: Mon Jan 26 12:45:35 2015 +0300

disables an invalid test in WebmURLExtensions_Suite

commit 80ac9d210cd9c9505bd3000b77951e49370af7ab Author: kozhinm mikhail.kozhin@akvelon.com Date: Mon Jan 26 12:41:03 2015 +0300

makes eventList a 'static' member of WebmURLExtensions and updates event signature

commit 089bada1b6ff9f90aac2995fc0e794559bc1941b Author: Greg Rutz g.rutz@cablelabs.com Date: Tue Jan 27 10:46:20 2015 -0700

More bug fixes. Working up to license request now

commit 3ab0c90e6f59c446776e9dc6a5cee3339d068e1c Author: Greg Rutz g.rutz@cablelabs.com Date: Mon Jan 26 16:17:31 2015 -0700

Last of the initial changes.

Now ready for lots of testing.

commit c8d4d88847dd684d23123bbb630952b2a6281a28 Author: Greg Rutz g.rutz@cablelabs.com Date: Mon Jan 26 08:44:17 2015 -0700

Finished with all key system actions up to CreateSession

commit 0dba94c39133049af13088282c36e5a8c84bafde Author: Greg Rutz g.rutz@cablelabs.com Date: Sat Jan 24 23:26:25 2015 -0700

Big refactor to support new async architecture.

ProtectionModel API now mimics the latest EME spec with regard to asynchronous
operations and separate steps for key system access, selection, and session
creation

Initial implementation of 21Jan2015 EME ProtectionModel is underway.  Need to
work on createSession implementation next.

commit 81ab4fde5fc47ca948ae7550a7cd05aa325af4e9 Author: Greg Rutz g.rutz@cablelabs.com Date: Thu Jan 22 16:53:21 2015 -0700

Checkpoint check-in

Merge request reports