Skip to content

Commit

Permalink
Don't use dot notation for bogus properties
Browse files Browse the repository at this point in the history
DrmEngine is adding an extra property to MediaKeySystemConfiguration
objects, knowing that EME will ignore it.  The latest Closure Compiler
won't allow this.

In the future, we should refactor DrmEngine and consider tracking this
in some other way.  For now, this changes the dot to square brackets.

Issue shaka-project#2528

Change-Id: I544c93dfa2534e9d62ac5ea47e20a6dc3cb79e3a
  • Loading branch information
joeyparrish committed Apr 28, 2020
1 parent df0a5f7 commit 8d25186
Showing 1 changed file with 27 additions and 17 deletions.
44 changes: 27 additions & 17 deletions lib/media/drm_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,26 +242,31 @@ shaka.media.DrmEngine = class {
audioCapabilities, videoCapabilities) {
/** @type {!Map.<string, MediaKeySystemConfiguration>} */
const configsByKeySystem = new Map();
configsByKeySystem.set(keySystem, {

/** @type {MediaKeySystemConfiguration} */
const config = {
audioCapabilities: audioCapabilities,
videoCapabilities: videoCapabilities,
distinctiveIdentifier: 'optional',
persistentState: 'required',
sessionTypes: ['persistent-license'],
label: keySystem, // Tracked by us, ignored by EME.
drmInfos: [{
keySystem: keySystem,
licenseServerUri: licenseServerUri,
distinctiveIdentifierRequired: false,
persistentStateRequired: true,
audioRobustness: '', // Not required by queryMediaKeys_
videoRobustness: '', // Same
serverCertificate: serverCertificate,
initData: null,
keyIds: null,
}],
});
};

// TODO: refactor, don't stick drmInfos onto MediaKeySystemConfiguration
config['drmInfos'] = [{ // Non-standard attribute, ignored by EME.
keySystem: keySystem,
licenseServerUri: licenseServerUri,
distinctiveIdentifierRequired: false,
persistentStateRequired: true,
audioRobustness: '', // Not required by queryMediaKeys_
videoRobustness: '', // Same
serverCertificate: serverCertificate,
initData: null,
keyIds: null,
}];

configsByKeySystem.set(keySystem, config);
return this.queryMediaKeys_(configsByKeySystem);
}

Expand Down Expand Up @@ -682,8 +687,9 @@ shaka.media.DrmEngine = class {
persistentState: persistentState,
sessionTypes: sessionTypes,
label: info.keySystem, // Tracked by us, ignored by EME.
drmInfos: [],
};
// TODO: refactor, don't stick drmInfos onto MediaKeySystemConfiguration
config['drmInfos'] = []; // Non-standard attribute, ignored by EME.

// Multiple calls to |set| will still respect the insertion order of the
// first call to |set| for a given key.
Expand Down Expand Up @@ -712,7 +718,9 @@ shaka.media.DrmEngine = class {
config,
'Any missing configs should have be filled in before.');

config.drmInfos.push(info);
// TODO: refactor, don't stick drmInfos onto
// MediaKeySystemConfiguration
config['drmInfos'].push(info);

if (info.distinctiveIdentifierRequired) {
config.distinctiveIdentifier = 'required';
Expand Down Expand Up @@ -778,7 +786,8 @@ shaka.media.DrmEngine = class {
for (const shouldHaveLicenseServer of [true, false]) {
for (const keySystem of configsByKeySystem.keys()) {
const config = configsByKeySystem.get(keySystem);
const hasLicenseServer = config.drmInfos.some((info) => {
// TODO: refactor, don't stick drmInfos onto MediaKeySystemConfiguration
const hasLicenseServer = config['drmInfos'].some((info) => {
return !!info.licenseServerUri;
});
if (hasLicenseServer != shouldHaveLicenseServer) {
Expand Down Expand Up @@ -1749,8 +1758,9 @@ shaka.media.DrmEngine = class {
/** @type {!Set.<string>} */
const keyIds = new Set();

// TODO: refactor, don't stick drmInfos onto MediaKeySystemConfiguration
shaka.media.DrmEngine.processDrmInfos_(
config.drmInfos, licenseServers, serverCerts, initDatas, keyIds);
config['drmInfos'], licenseServers, serverCerts, initDatas, keyIds);

if (serverCerts.length > 1) {
shaka.log.warning('Multiple unique server certificates found! ' +
Expand Down

0 comments on commit 8d25186

Please sign in to comment.