Home Reference Source
import EMEController from 'hls.js/src/controller/eme-controller.ts'
public class | source

EMEController

Extends:

src/event-handler.js~EventHandler → EMEController

Controller to deal with encrypted media extensions (EME)

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public
public get
Private Members
private

_config: *

private
private
private
private
private

_media: *

private
private
private
private
private

Method Summary

Public Methods
public
public
public
public
Private Methods
private

_attemptKeySystemAccess(keySystem: KeySystems, audioCodecs: undefined, videoCodecs: undefined)

Requests access object and adds it to our list upon success

private

_attemptSetMediaKeys(mediaKeys: *)

private

_createLicenseXhr(url: string, keyMessage: ArrayBuffer, callback: function): XMLHttpRequest

private

_generateLicenseRequestChallenge(keysListItem: MediaKeysListItem, keyMessage: ArrayBuffer): ArrayBuffer

private

_generateRequestWithPreferredKeySession(initDataType: *, initData: *)

private

_onKeySessionMessage(keySession: MediaKeySession, message: ArrayBuffer)

private

_onLicenseRequestReadyStageChange(xhr: XMLHttpRequest, url: string, keyMessage: ArrayBuffer, callback: function)

private

_onMediaKeySystemAccessObtained(keySystem: KeySystems, mediaKeySystemAccess: MediaKeySystemAccess): Promise

Handles obtaining access to a key-system

private

Handles key-creation (represents access to CDM).

private

_onNewMediaKeySession(keySession: *)

private

_requestLicense(keyMessage: *, callback: *)

Public Constructors

public constructor(hls: Hls) source

Params:

NameTypeAttributeDescription
hls Hls

Our Hls.js instance

Public Members

public mediaKeysPromise: * source

public get requestMediaKeySystemAccess: * source

Private Members

private _config: * source

private _drmSystemOptions: * source

private _emeEnabled: * source

private _hasSetMediaKeys: boolean source

private _licenseXhrSetup: * source

private _media: * source

private _mediaKeysList: *[] source

private _onMediaEncrypted(e: *): * source

private _requestLicenseFailureCount: number source

private _requestMediaKeySystemAccess: * source

private _widevineLicenseUrl: * source

Public Methods

public getLicenseServerUrl(keySystem: string): string source

Params:

NameTypeAttributeDescription
keySystem string

Identifier for the key-system, see KeySystems enum

Return:

string

License server URL for key-system (if any configured, otherwise causes error)

Throw:

*

if a unsupported keysystem is passed

public onManifestParsed(data: undefined) source

Params:

NameTypeAttributeDescription
data undefined

public onMediaAttached(data: undefined) source

Params:

NameTypeAttributeDescription
data undefined

public onMediaDetached() source

Private Methods

private _attemptKeySystemAccess(keySystem: KeySystems, audioCodecs: undefined, videoCodecs: undefined) source

Requests access object and adds it to our list upon success

Params:

NameTypeAttributeDescription
keySystem KeySystems
audioCodecs undefined
videoCodecs undefined

private _attemptSetMediaKeys(mediaKeys: *) source

Params:

NameTypeAttributeDescription
mediaKeys *

private _createLicenseXhr(url: string, keyMessage: ArrayBuffer, callback: function): XMLHttpRequest source

Params:

NameTypeAttributeDescription
url string

License server URL

keyMessage ArrayBuffer

Message data issued by key-system

callback function

Called when XHR has succeeded

Return:

XMLHttpRequest

Unsent (but opened state) XHR object

Throw:

*

if XMLHttpRequest construction failed

private _generateLicenseRequestChallenge(keysListItem: MediaKeysListItem, keyMessage: ArrayBuffer): ArrayBuffer source

Params:

NameTypeAttributeDescription
keysListItem MediaKeysListItem
keyMessage ArrayBuffer

Return:

ArrayBuffer

Challenge data posted to license server

Throw:

*

if KeySystem is unsupported

private _generateRequestWithPreferredKeySession(initDataType: *, initData: *) source

Params:

NameTypeAttributeDescription
initDataType *
initData *

private _onKeySessionMessage(keySession: MediaKeySession, message: ArrayBuffer) source

Params:

NameTypeAttributeDescription
keySession MediaKeySession
message ArrayBuffer

private _onLicenseRequestReadyStageChange(xhr: XMLHttpRequest, url: string, keyMessage: ArrayBuffer, callback: function) source

Params:

NameTypeAttributeDescription
xhr XMLHttpRequest
url string

License server URL

keyMessage ArrayBuffer

Message data issued by key-system

callback function

Called when XHR has succeeded

private _onMediaKeySystemAccessObtained(keySystem: KeySystems, mediaKeySystemAccess: MediaKeySystemAccess): Promise source

Handles obtaining access to a key-system

Params:

NameTypeAttributeDescription
keySystem KeySystems
mediaKeySystemAccess MediaKeySystemAccess

Return:

Promise

private _onMediaKeysCreated() source

Handles key-creation (represents access to CDM). We are going to create key-sessions upon this for all existing keys where no session exists yet.

private _onNewMediaKeySession(keySession: *) source

Params:

NameTypeAttributeDescription
keySession *

private _requestLicense(keyMessage: *, callback: *) source

Params:

NameTypeAttributeDescription
keyMessage *
callback *