加密媒体扩展 (EME)


// 不能 captureStream

Digital Rights Management (DRM)
Common Encryption (CENC)
Content Decryption Module (CDM)

  1. A web application attempts to play audio or video that has one or more encrypted streams.
  2. The browser recognizes that the media is encrypted (see box below for how that happens) and fires an encrypted event with metadata (initData) obtained from the media about the encryption.
  3. The application handles the encrypted event:
    1. If no MediaKeys object has been associated with the media element, first select an available Key System by using navigator.requestMediaKeySystemAccess() to check what Key Systems are available, then create a MediaKeys object for an available Key System via a MediaKeySystemAccess object. Note that initialization of the MediaKeys object should happen before the first encrypted event. Getting a license server URL is done by the app independently of selecting an available key system. A MediaKeys object represents all the keys available to decrypt the media for an audio or video element. It represents a CDM instance and provides access to the CDM, specifically for creating key sessions, which are used to obtain keys from a license server.
    2. Once the MediaKeys object has been created, assign it to the media element: setMediaKeys() associates the MediaKeys object with an HTMLMediaElement, so that its keys can be used during playback, i.e. during decoding.
  4. The app creates a MediaKeySession by calling createSession() on the MediaKeys. This creates a MediaKeySession, which represents the lifetime of a license and its key(s).
  5. The app generates a license request by passing the media data obtained in the encrypted handler to the CDM, by calling generateRequest() on the MediaKeySession.
  6. The CDM fires a message event: a request to acquire a key from a license server.
  7. The MediaKeySession object receives the message event and the application sends a message to the license server (via XHR, for example).
  8. The application receives a response from the license server and passes the data to the CDM using the update() method of the MediaKeySession.
  9. The CDM decrypts the media using the keys in the license. A valid key may be used, from any session within the MediaKeys associated with the media element. The CDM will access the key and policy, indexed by Key ID.
  10. Media playback resumes.

// 由 CDM 模块来解密,所以用户拿不到解密后的媒体

// 除非加密的时候就注入 License (Key) server 地址到加密内容元数据中,这样 CDM 可以还可以自己和 License server 通信,但是看 bento4webp_crypt 加密媒体时并不能这么做啊

KeySystem:规范中要求支持 ClearKey,还有其他