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

EMEController

Extends:

EventHandler → EMEController

Controller to deal with encrypted media extensions (EME)

See:

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public get
Private Members
private
private
private
private
private

_media: *

private
private
private
private
private
private

Method Summary

Public Methods
public
public

onManifestParsed(data: *)

public

onMediaAttached(data: *)

Private Methods
private

_attemptKeySystemAccess(keySystem: string, audioCodecs: Array<string>, videoCodecs: Array<string>)

Requests access object and adds it to our list upon success

private
private

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

private
private
private

_onKeySessionMessage(keySession: *, message: *)

private

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

private

_onMediaEncrypted(initDataType: *, initData: *)

private

_onMediaKeySystemAccessObtained(keySystem: string, mediaKeySystemAccess: MediaKeySystemAccess)

Handles obtaining access to a key-system

private

Handles key-creation (represents access to CDM).

private

_onNewMediaKeySession(keySession: *)

private

_requestLicense(keyMessage: *, callback: *)

Inherited Summary

From class EventHandler
public
public

hls: *

public
public
public
public

onEvent(event: *, data: *)

arguments: event (string), data (any)

public

onEventGeneric(event: *, data: *)

public
public
public
public

Public Constructors

public constructor(hls: Hls) source

Override:

EventHandler#constructor

Params:

NameTypeAttributeDescription
hls Hls

Our Hls.js instance

Public Members

public get requestMediaKeySystemAccess: * source

Private Members

private _emeEnabled: * source

private _hasSetMediaKeys: boolean source

private _isMediaEncrypted: boolean source

private _licenseXhrSetup: * source

private _media: * source

private _mediaEncryptionInitData: * source

private _mediaEncryptionInitDataType: * source

private _mediaKeysList: *[] 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)

public onManifestParsed(data: *) source

Params:

NameTypeAttributeDescription
data *

public onMediaAttached(data: *) source

Params:

NameTypeAttributeDescription
data *

Private Methods

private _attemptKeySystemAccess(keySystem: string, audioCodecs: Array<string>, videoCodecs: Array<string>) source

Requests access object and adds it to our list upon success

Params:

NameTypeAttributeDescription
keySystem string

System ID (see KeySystems)

audioCodecs Array<string>

List of required audio codecs to support

videoCodecs Array<string>

List of required video codecs to support

private _attemptSetMediaKeys() source

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

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

Params:

NameTypeAttributeDescription
keysListItem object
keyMessage ArrayBuffer

Return:

ArrayBuffer

Challenge data posted to license server

private _generateRequestWithPreferredKeySession() source

private _onKeySessionMessage(keySession: *, message: *) source

Params:

NameTypeAttributeDescription
keySession *
message *

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 _onMediaEncrypted(initDataType: *, initData: *) source

Params:

NameTypeAttributeDescription
initDataType *
initData *

private _onMediaKeySystemAccessObtained(keySystem: string, mediaKeySystemAccess: MediaKeySystemAccess) source

Handles obtaining access to a key-system

Params:

NameTypeAttributeDescription
keySystem string
mediaKeySystemAccess MediaKeySystemAccess

https://developer.mozilla.org/en-US/docs/Web/API/MediaKeySystemAccess

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 *