Skip to content

Commit

Permalink
Use app provided EME config flags.
Browse files Browse the repository at this point in the history
This allows an applications to set distinctiveIdentifier,
persistentState, and robustness when the player calls
requestMediaKeySystemAccess().

Change-Id: I1c2f035cfacbf45c8e718fb31c5c0c9a8e55d72b
  • Loading branch information
Timothy Drews authored and Gerrit Code Review committed Jun 5, 2015
1 parent 1e400f5 commit 4f54a10
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 17 deletions.
46 changes: 37 additions & 9 deletions lib/media/eme_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,8 @@ shaka.media.EmeManager.prototype.buildKeySystemQueries_ =
var keySystem = cfg.drmScheme.keySystem;
var mksc = mediaKeySystemConfigs[keySystem];
if (!mksc) {
mksc = mediaKeySystemConfigs[keySystem] = {
audioCapabilities: undefined,
videoCapabilities: undefined,
initDataTypes: undefined,
distinctiveIdentifier: 'optional',
persistentState: this.videoSource_.isOffline() ? 'required' : 'optional'
};
mksc = this.createMediaKeySystemConfig_(cfg.drmScheme);
mediaKeySystemConfigs[keySystem] = mksc;
}

// Only check for an empty MIME type after creating mksc.
Expand All @@ -251,13 +246,19 @@ shaka.media.EmeManager.prototype.buildKeySystemQueries_ =
if (!cfg.fullMimeType) continue;

var capName = cfg.contentType + 'Capabilities';
if (!(capName in mksc)) continue; // not a capability we can check for!
if (!(capName in mksc)) continue; // Not a capability we can check for!

anythingSpecified = true;
if (!mksc[capName]) {
mksc[capName] = [];
}
mksc[capName].push({ contentType: cfg.fullMimeType });

mksc[capName].push({
contentType: cfg.fullMimeType,
robustness: cfg.drmScheme[cfg.contentType + 'Robustness']
});

shaka.log.info('MKSC', mksc);
}

// If nothing is specified, we will never match anything up later.
Expand All @@ -278,6 +279,33 @@ shaka.media.EmeManager.prototype.buildKeySystemQueries_ =
};


/**
* Creates a MediaKeySystemConfiguration from the given DrmSchemeInfo.
*
* @param {!shaka.player.DrmSchemeInfo} drmScheme
* @return {!MediaKeySystemConfiguration}
* @private
*/
shaka.media.EmeManager.prototype.createMediaKeySystemConfig_ = function(
drmScheme) {
var distinctiveIdentifier =
drmScheme.distinctiveIdentifierRequired ? 'required' : 'optional';

var persistentState =
(drmScheme.persistentStateRequired || this.videoSource_.isOffline()) ?
'required' :
'optional';

return {
audioCapabilities: undefined,
videoCapabilities: undefined,
initDataTypes: undefined,
distinctiveIdentifier: distinctiveIdentifier,
persistentState: persistentState
};
};


/**
* Build a promise chain to check each MediaKey configuration. If the first
* config fails, the next will be checked as a series of fallbacks.
Expand Down
68 changes: 60 additions & 8 deletions lib/player/drm_scheme_info.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,34 +37,86 @@ goog.require('shaka.util.Uint8ArrayUtils');
* {@link http://goo.gl/hKBdff specified here}.
* @param {?shaka.player.DrmSchemeInfo.LicensePostProcessor}
* licensePostProcessor An optional post-processor for license responses.
* @param {shaka.player.DrmSchemeInfo.DistinctiveIdentifier=}
* opt_distinctiveIdentifier True indicates that the key system must
* support distinctive identifiers.
* @param {shaka.player.DrmSchemeInfo.PersistentState=}
* opt_persistentState True indicates that the key system must
* support access to persistent storage.
* @param {string=} opt_audioRobustness A key system specific string that
* specifies an audio decryption security level.
* @param {string=} opt_videoRobustness A key system specific string that
* specifies a video decryption security level.
* @constructor
* @struct
* @export
*/
shaka.player.DrmSchemeInfo =
function(keySystem, licenseServerUrl, withCredentials, initData,
licensePostProcessor) {
/** @type {string} */
shaka.player.DrmSchemeInfo = function(
keySystem,
licenseServerUrl,
withCredentials,
initData,
licensePostProcessor,
opt_distinctiveIdentifier,
opt_persistentState,
opt_audioRobustness,
opt_videoRobustness) {
/** @const {string} */
this.keySystem = keySystem;

/** @type {string} */
/** @const {string} */
this.licenseServerUrl = licenseServerUrl;

/** @type {boolean} */
/** @const {boolean} */
this.withCredentials = withCredentials;

/** @type {!Array.<{initData: !Uint8Array, initDataType: string}>} */
this.initDatas = [];

/** @type {?shaka.player.DrmSchemeInfo.LicensePostProcessor} */
/** @const {?shaka.player.DrmSchemeInfo.LicensePostProcessor} */
this.licensePostProcessor = licensePostProcessor;

/** @const {boolean} */
this.distinctiveIdentifierRequired =
opt_distinctiveIdentifier ==
shaka.player.DrmSchemeInfo.DistinctiveIdentifier.REQUIRED;

/** @const {boolean} */
this.persistentStateRequired =
opt_persistentState ==
shaka.player.DrmSchemeInfo.PersistentState.REQUIRED;

/** @const {string} */
this.audioRobustness = opt_audioRobustness || '';

/** @const {string} */
this.videoRobustness = opt_videoRobustness || '';

if (initData) {
this.initDatas.push(initData);
}
};


/**
* @enum
* @export
*/
shaka.player.DrmSchemeInfo.DistinctiveIdentifier = {
OPTIONAL: 0,
REQUIRED: 1
};


/**
* @enum
* @export
*/
shaka.player.DrmSchemeInfo.PersistentState = {
OPTIONAL: 0,
REQUIRED: 1
};


/**
* A callback which does application-specific post-processing on license
* responses before they are passed to the CDM.
Expand Down

0 comments on commit 4f54a10

Please sign in to comment.