Class: shaka.player.DrmInfo

Constructor

new DrmInfo()

Creates a DrmInfo, which represents a set of DRM configuration options. DrmInfo is an internal class, please see shaka.player.DashVideoSource.ContentProtectionCallback, shaka.player.HttpVideoSource, and shaka.player.DrmInfo.Config for information on how to configure the key system from the application.
Source:
See:

Members

audioRobustness :string

Type:
  • string
Source:

distinctiveIdentifierRequired :boolean

Type:
  • boolean
Source:

(non-null) initDatas :Array.<shaka.player.DrmInfo.InitData>

Type:
Source:

keySystem :string

An empty string indicates no key system.
Type:
  • string
Source:

(nullable) licensePostProcessor :shaka.player.DrmInfo.LicensePostProcessor

Type:
Source:

(nullable) licensePreProcessor :shaka.player.DrmInfo.LicensePreProcessor

Type:
Source:

licenseServerUrl :string

Type:
  • string
Source:

persistentStateRequired :boolean

Type:
  • boolean
Source:

serverCertificate :Uint8Array

Type:
  • Uint8Array
Source:

videoRobustness :string

Type:
  • string
Source:

withCredentials :boolean

Type:
  • boolean
Source:

Methods

(private, static) compareInitDatas_(initDataAnon-null, initDataBnon-null) → {boolean}

Parameters:
Name Type Description
initDataA shaka.player.DrmInfo.InitData
initDataB shaka.player.DrmInfo.InitData
Source:
Returns:
Type
boolean

(static) createFromConfig(config) → (non-null) {shaka.player.DrmInfo}

Creates a DrmInfo object from a Config object.
Parameters:
Name Type Description
config shaka.player.DrmInfo.Config
Source:
Throws:
  • TypeError if a configuration option has the wrong type.
  • Error if the application fails to provide any required fields.
Returns:
Type
shaka.player.DrmInfo

addInitDatas(otherInitDatasnon-null)

Adds the given initDatas (removing duplicates).
Parameters:
Name Type Description
otherInitDatas Array.<shaka.player.DrmInfo.InitData>
Source:

combine(othernon-null) → (non-null) {shaka.player.DrmInfo}

Combines this DrmInfo object with another DrmInfo object to create a new DrmInfo object.
Parameters:
Name Type Description
other shaka.player.DrmInfo The other DrmInfo object, which should be compatible with this DrmInfo object.
Source:
Returns:
Type
shaka.player.DrmInfo

isCompatible(othernon-null) → {boolean}

Parameters:
Name Type Description
other shaka.player.DrmInfo
Source:
Returns:
True if this DrmInfo is compatible with |other|; otherwise, return false.
Type
boolean

Type Definitions

Config

An object which represents a set of application provided DRM configuration options.

For encrypted content, an application must provide one or more DrmInfo.Config objects to its VideoSource. For DASH content, the application can provide Config objects to shaka.player.DashVideoSource via a callback (see shaka.player.DashVideoSource.ContentProtectionCallback), and for HTTP content, the application can provide a single Config object to shaka.player.HttpVideoSource via HttpVideoSource's constructor.

The following options are supported:
  • keySystem: string (required)
    The key system, e.g., "com.widevine.alpha". A blank string indicates unencrypted content.
  • licenseServerUrl: string (required for streaming encrypted content)
    The license server URL.
  • withCredentials: boolean
    True if license requests should include cookies when sent cross-domain (see http://goo.gl/pzY9F7). Defaults to false.
  • licensePostProcessor: shaka.player.DrmInfo.LicensePostProcessor
    A license post-processor that does application-specific post-processing on license responses.
  • licensePreProcessor: shaka.player.DrmInfo.LicensePreProcessor
    A license pre-processor that does application-specific pre-processing on license requests.
  • distinctiveIdentifierRequired: boolean
    True if the application requires the key system to support distinctive identifiers. Defaults to false.
  • persistentStateRequired: boolean
    True if the application requires the key system to support persistent state, e.g., for persistent license storage. Defaults to false.
  • audioRobustness: string
    A key system specific string that specifies an audio decrypt/decode security level.
  • videoRobustness: string
    A key system specific string that specifies a video decrypt/decode security level.
  • serverCertificate: Uint8Array
    An key system specific server certificate for authenticating license requests.
  • initData: shaka.player.DrmInfo.InitData
    Explicit key system initialization data (initData value), which overrides both the initData given in the manifest, if any, and the initData in the actual content (which may be inspected via an EME 'encrypted' event). The initDataType values and the formats that they correspond to are specified here.
Type:
  • Object.<string, *>
Source:

InitData

Type:
  • {initData: !Uint8Array, initDataType: string}
Source:

LicensePostProcessor

A callback which does application-specific post-processing on license responses before they are passed to the key system. The application can set this callback in a shaka.player.DrmInfo.Config object.

The parameter is the license response from the license server. Must return the raw license.

Type:
  • function(!Uint8Array): !Uint8Array
Source:
Example
// Suppose the license server provides a JSON encoded license response
// with the format {"header": header_string, "license": license_string}.
// The application would need to use a license post-processor like
// the following:
var postProcessor = function(serverResponse) {
  // serverResponse is a Uint8Array, so decode it into an object.
  var json = String.fromCharCode.apply(null, serverResponse);
  var obj = JSON.parse(json);

  var headerString = obj['header'];
  // Do something with the header...

  // obj['license'] is a string, so encode it into a Uint8Array.
  var licenseString = obj['license'];
  var license = new Uint8Array(licenseString.split('').map(
      function(ch) { return ch.charCodeAt(0); }));
  return license;
};

LicensePreProcessor

A callback which does application-specific pre-processing on license requests before they are sent to the license server. The application can set this callback in a shaka.player.DrmInfo.Config object.

The parameter is a shaka.player.DrmInfo.LicenseRequestInfo object. The callback may modify the object's fields as it requires; some fields are set to initial values:

  • The |url| field is initially set to the license server URL provided by the license request pre-processor's corresponding DrmInfo; it may be set to an arbitrary URL, or may be extended with extra query parameters.
  • The |body| field is initially set to the raw license request (an ArrayBuffer) emitted by the browser; it may be replaced (to another ArrayBuffer or string) or be removed entirely (e.g., if the server expects the raw license to be encoded in the URL).
  • The |method| field is initially set to 'POST', but may be set to 'GET'.
  • The |headers| field is initially an empty map; arbitrary request headers may be added as key-value pairs, e.g., headers['Content-Type'] = 'application/x-www-form-urlencoded';

Type:
Source:
Example
// Suppose the license server expects a license request to use a
// base64 encoded payload and include special query parameters.
// The application would need to use a license pre-processor like
// the following:
var preProcessor = function(requestInfo) {
  // Add query parameters.
  requestInfo.url += '?session=123&token=abc'
  // Encode the payload as base64.
  requestInfo.body = window.btoa(
      String.fromCharCode.apply(null, new Uint8Array(requestInfo.body)));
};

LicenseRequestInfo

An object that describes a license request for license request pre-processing (see shaka.player.DrmInfo.LicensePreProcessor).
The following options are supported:
  • url: string (required)
    The license server URL.
  • body: (ArrayBuffer|?string)
    The license request's body.
  • method: string (required)
    The HTTP request method, which must be either 'GET' or 'POST'.
  • headers: Object.
    Extra HTTP request headers as key-value pairs.
Type:
  • Object.<string, *>
Source: