Constructor
new DrmEngine(playerInterface)
Parameters:
Name | Type | Description |
---|---|---|
playerInterface |
shaka.media.DrmEngine.PlayerInterface |
- Implements:
- Source:
Members
(private, static) CLOSE_TIMEOUT_ :number
The amount of time, in seconds, we wait to consider a session closed.
This allows us to work around Chrome bug https://crbug.com/690583.
Type:
- number
- Source:
(private, static) KEY_STATUS_BATCH_TIME_ :number
The amount of time, in seconds, we wait to batch up rapid key status changes.
This allows us to avoid multiple expiration events in most cases.
Type:
- number
- Source:
(private, static) SESSION_LOAD_TIMEOUT_ :number
The amount of time, in seconds, we wait to consider session loaded even if no
key status information is available. This allows us to support browsers/CDMs
without key statuses.
Type:
- number
- Source:
(private, non-null) announcedKeyStatusByKeyId_ :Object.<string, string>
The key statuses most recently announced to other classes.
We may have more up-to-date information being collected in
this.keyStatusByKeyId_, which has not been batched up and released yet.
Type:
- Object.<string, string>
- Source:
(private, non-null) finishedDestroyingPromise_ :shaka.util.PublicPromise
A promise that will only resolve once we have finished destroying
ourselves, this is used to ensure that subsequent calls to |destroy| don't
resolve before the first call to |destroy|.
Type:
- Source:
(private) isDestroying_ :boolean
A flag to signal when have started destroying ourselves. This will:
1. Stop later calls to |destroy| from trying to destroy the already
destroyed (or currently destroying) DrmEngine.
2. Stop in-progress async operations from continuing.
Type:
- boolean
- Source:
(private, non-null) keyStatusByKeyId_ :Object.<string, string>
The most recent key status information we have.
We may not have announced this information to the outside world yet,
which we delay to batch up changes and avoid spurious "missing key" errors.
Type:
- Object.<string, string>
- Source:
(private, non-null) mediaKeyMessageEvents_ :Array.<!MediaKeyMessageEvent>
Type:
- Array.<!MediaKeyMessageEvent>
- Source:
(private, non-null) offlineSessionIds_ :Array.<string>
Type:
- Array.<string>
- Source:
(private, nullable) onError_ :?function(!shaka.util.Error)
Type:
- ?function(!shaka.util.Error)
- Source:
(private) supportedTypes_ :Array.<string>
Type:
- Array.<string>
- Source:
Methods
(static) areDrmCompatible(drms1non-null, drms2non-null) → {boolean}
Checks if two DrmInfos can be decrypted using the same key system.
Clear content is considered compatible with every key system.
Parameters:
Name | Type | Description |
---|---|---|
drms1 |
Array.<!shakaExtern.DrmInfo> | |
drms2 |
Array.<!shakaExtern.DrmInfo> |
- Source:
Returns:
- Type
- boolean
(private, static) closeSession_(sessionnon-null) → (non-null) {Promise}
Close a drm session while accounting for a bug in Chrome. Sometimes the
Promise returned by close() never resolves.
See issue #1093 and https://crbug.com/690583.
Parameters:
Name | Type | Description |
---|---|---|
session |
MediaKeySession |
- Source:
Returns:
- Type
- Promise
(static) getCommonDrmInfos(drms1non-null, drms2non-null) → (non-null) {Array.<!shakaExtern.DrmInfo>}
Returns an array of drm infos that are present in both input arrays.
If one of the arrays is empty, returns the other one since clear
content is considered compatible with every drm info.
Parameters:
Name | Type | Description |
---|---|---|
drms1 |
Array.<!shakaExtern.DrmInfo> | |
drms2 |
Array.<!shakaExtern.DrmInfo> |
- Source:
Returns:
- Type
- Array.<!shakaExtern.DrmInfo>
(static) isBrowserSupported() → {boolean}
Returns true if the browser has recent EME APIs.
- Source:
Returns:
- Type
- boolean
(static) probeSupport() → (non-null) {Promise.<!Object.<string, ?shakaExtern.DrmSupportType>>}
Returns a Promise to a map of EME support for well-known key systems.
- Source:
Returns:
- Type
- Promise.<!Object.<string, ?shakaExtern.DrmSupportType>>
attach(video) → (non-null) {Promise}
Attach MediaKeys to the video element and start processing events.
Parameters:
Name | Type | Description |
---|---|---|
video |
HTMLMediaElement |
- Source:
Returns:
- Type
- Promise
configure(config)
Called by the Player to provide an updated configuration any time it changes.
Must be called at least once before init().
Parameters:
Name | Type | Description |
---|---|---|
config |
shakaExtern.DrmConfiguration |
- Source:
(private) configureClearKey_() → (nullable) {shakaExtern.DrmInfo}
Create a DrmInfo using configured clear keys.
The server URI will be a data URI which decodes to a clearkey license.
- Source:
- See:
Returns:
or null if clear keys are not configured.
- Type
- shakaExtern.DrmInfo
(private) createCurrentDrmInfo_(keySystem, config, drmInfosnon-null)
Creates a DrmInfo object describing the settings used to initialize the
engine.
Parameters:
Name | Type | Description |
---|---|---|
keySystem |
string | |
config |
MediaKeySystemConfiguration | |
drmInfos |
Array.<shakaExtern.DrmInfo> |
- Source:
createOrLoad() → (non-null) {Promise}
Creates the sessions for the init data and waits for them to become ready.
- Source:
Returns:
- Type
- Promise
(private) createTemporarySession_(initDataType, initDatanon-null)
Parameters:
Name | Type | Description |
---|---|---|
initDataType |
string | |
initData |
Uint8Array |
- Source:
(private) delayLicenseRequest_() → {boolean}
- Source:
Returns:
- Type
- boolean
(export) destroy() → (non-null) {Promise}
Destroys the object, releasing all resources and shutting down all
operations. Returns a Promise which is resolved when destruction is
complete. This Promise should never be rejected.
- Implements:
- Source:
Returns:
- Type
- Promise
(private) destroyNow_()
Destroy this instance of DrmEngine. This assumes that all other checks about
"if it should" have passed.
- Source:
(private) fillInDrmInfoDefaults_(drmInfo)
Use this.config_ to fill in missing values in drmInfo.
Parameters:
Name | Type | Description |
---|---|---|
drmInfo |
shakaExtern.DrmInfo |
- Source:
getDrmInfo() → (nullable) {shakaExtern.DrmInfo}
Returns the DrmInfo that was used to initialize the current key system.
- Source:
Returns:
- Type
- shakaExtern.DrmInfo
(private) getDrmInfosByConfig_(manifestnon-null) → {Array.<{shakaExtern.DrmInfo}>}
Returns the DrmInfo that is generated by drm configation.
It activates DrmEngine if drm configs have keySystems.
Parameters:
Name | Type | Description |
---|---|---|
manifest |
shakaExtern.Manifest |
- Source:
Returns:
- Type
- Array.<{shakaExtern.DrmInfo}>
getExpiration() → {number}
Returns the next expiration time, or Infinity.
- Source:
Returns:
- Type
- number
getKeyStatuses() → (non-null) {Object.<string, string>}
Returns the current key statuses.
- Source:
Returns:
- Type
- Object.<string, string>
getSessionIds() → (non-null) {Array.<string>}
Returns the ID of the sessions currently active.
- Source:
Returns:
- Type
- Array.<string>
getSupportedTypes() → {Array.<string>}
Returns an array of the media types supported by the current key system.
These will be full mime types (e.g. 'video/webm; codecs="vp8"').
- Source:
Returns:
- Type
- Array.<string>
init(manifestnon-null, offline) → (non-null) {Promise}
Negotiate for a key system and set up MediaKeys.
Parameters:
Name | Type | Description |
---|---|---|
manifest |
shakaExtern.Manifest | The manifest is read for MIME type and DRM information to query EME. If the 'clearKeys' configuration is used, the manifest will be modified to force the use of Clear Key. |
offline |
boolean | True if we are storing or loading offline content. |
- Source:
Returns:
Resolved if/when a key system has been chosen.
- Type
- Promise
isSupportedByKeySystem(variantnon-null) → {boolean}
Checks if a variant is compatible with the key system.
Parameters:
Name | Type | Description |
---|---|---|
variant |
shakaExtern.Variant |
- Source:
Returns:
- Type
- boolean
(private) loadOfflineSession_(sessionId) → (non-null) {Promise.<MediaKeySession>}
Parameters:
Name | Type | Description |
---|---|---|
sessionId |
string |
- Source:
Returns:
- Type
- Promise.<MediaKeySession>
newInitData(initDataType, initDatanon-null)
Called when new initialization data is encountered. If this data hasn't
been seen yet, this will create a new session for it.
Parameters:
Name | Type | Description |
---|---|---|
initDataType |
string | |
initData |
Uint8Array |
- Source:
(private) onKeyStatusesChange_(eventnon-null)
Parameters:
Name | Type | Description |
---|---|---|
event |
Event |
- Source:
(private) onPlay_()
- Source:
(private) onSessionMessage_(eventnon-null)
Parameters:
Name | Type | Description |
---|---|---|
event |
MediaKeyMessageEvent |
- Source:
(private) pollExpiration_()
Called in an interval timer to poll the expiration times of the sessions. We
don't get an event from EME when the expiration updates, so we poll it so we
can fire an event when it happens.
- Source:
(private) prepareMediaKeyConfigs_(manifestnon-null, offline, configsByKeySystemnon-null, keySystemsInOrdernon-null)
Parameters:
Name | Type | Description |
---|---|---|
manifest |
shakaExtern.Manifest | |
offline |
boolean | True if we are storing or loading offline content. |
configsByKeySystem |
Object.<string, MediaKeySystemConfiguration> | (Output parameter.) A dictionary of configs, indexed by key system. |
keySystemsInOrder |
Array.<string> | (Output parameter.) A list of key systems in the order in which we encounter them. |
(private) processDrmInfos_(drmInfosnon-null, licenseServersnon-null, serverCertsnon-null, initDatasnon-null, keyIdsnon-null)
Extract license server, server cert, and init data from DrmInfos, taking
care to eliminate duplicates.
Parameters:
Name | Type | Description |
---|---|---|
drmInfos |
Array.<shakaExtern.DrmInfo> | |
licenseServers |
Array.<string> | |
serverCerts |
Array.<!Uint8Array> | |
initDatas |
Array.<!shakaExtern.InitDataOverride> | |
keyIds |
Array.<string> |
- Source:
(private) processKeyStatusChanges_()
- Source:
(private) queryMediaKeys_(configsByKeySystemnon-null, keySystemsInOrdernon-null, isEncryptedContent) → (non-null) {Promise}
Parameters:
Name | Type | Description |
---|---|---|
configsByKeySystem |
Object.<string, MediaKeySystemConfiguration> | A dictionary of configs, indexed by key system. |
keySystemsInOrder |
Array.<string> | A list of key systems in the order in which we should query them. On a browser which supports multiple key systems, the order may indicate a real preference for the application. |
isEncryptedContent |
boolean | True if the content is encrypted, false otherwise. |
- Source:
Returns:
Resolved if/when a key system has been chosen.
- Type
- Promise
removeSessions(sessionsnon-null) → (non-null) {Promise}
Removes the given offline sessions and deletes their data. Must call init()
before this. This will wait until the 'license-release' message is handled
and the resulting Promise will be rejected if there is an error with that.
Parameters:
Name | Type | Description |
---|---|---|
sessions |
Array.<string> |
- Source:
Returns:
- Type
- Promise
(private) sendLicenseRequest_(eventnon-null)
Sends a license request.
Parameters:
Name | Type | Description |
---|---|---|
event |
MediaKeyMessageEvent |
- Source:
(private) unpackPlayReadyRequest_(request)
Unpacks PlayReady license requests. Modifies the request object.
Parameters:
Name | Type | Description |
---|---|---|
request |
shakaExtern.Request |
- Source:
Type Definitions
ActiveSession
A record to track sessions and suppress duplicate init data.
Type:
- {loaded: boolean, initData: Uint8Array, session: !MediaKeySession, oldExpiration: number, updatePromise: shaka.util.PublicPromise}
Properties:
Name | Type | Description |
---|---|---|
loaded |
boolean | True once the key status has been updated (to a non-pending state). This does not mean the session is 'usable'. |
initData |
Uint8Array | The init data used to create the session. |
session |
MediaKeySession | The session object. |
oldExpiration |
number | The expiration of the session on the last check. This is used to fire an event when it changes. |
updatePromise |
shaka.util.PublicPromise | An optional Promise that will be resolved/rejected on the next update() call. This is used to track the 'license-release' message when calling remove(). |
- Source:
PlayerInterface
Type:
- {netEngine: !shaka.net.NetworkingEngine, onError: function(!shaka.util.Error), onKeyStatus: function(!Object.<string, string>), onExpirationUpdated: function(string, number), onEvent: function(!Event)}
Properties:
Name | Type | Description |
---|---|---|
netEngine |
shaka.net.NetworkingEngine | The NetworkingEngine instance to use. The caller retains ownership. |
onError |
function | Called when an error occurs. If the error is recoverable (see shaka.util.Error) then the caller may invoke either StreamingEngine.switch*() or StreamingEngine.seeked() to attempt recovery. |
onKeyStatus |
function | Called when key status changes. The argument is a map of hex key IDs to statuses. |
onExpirationUpdated |
function | Called when the session expiration value changes. |
onEvent |
function | Called when an event occurs that should be sent to the app. |
- Source: