Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some DRM providers require default KID in wrapped license requests #529

Merged
merged 9 commits into from
Sep 26, 2016
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Itay Kinnrot <Itay.Kinnrot@Kaltura.com>
Jason Palmer <jason@jason-palmer.com>
Jesper Haug Karsrud <jesper.karsrud@gmail.com>
Johan Sundström <oyasumi@gmail.com>
Jonas Birmé <jonas.birme@eyevinn.se>
JW Player <*@jwplayer.com>
Mattias Wadman <mattias.wadman@gmail.com>
Nick Desaulniers <nick@mozilla.com>
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Jason Palmer <jason@jason-palmer.com>
Jesper Haug Karsrud <jesper.karsrud@gmail.com>
Joey Parrish <joeyparrish@google.com>
Johan Sundström <oyasumi@gmail.com>
Jonas Birmé <jonas.birme@eyevinn.se>
Jono Ward <jonoward@gmail.com>
Mattias Wadman <mattias.wadman@gmail.com>
Natalie Harris <natalieharris@google.com>
Expand Down
3 changes: 2 additions & 1 deletion demo/assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ shakaAssets.YouTubeCallback = function(node) {
audioRobustness: '',
videoRobustness: '',
serverCertificate: null,
initData: null
initData: null,
keyIds: []
});
}
}
Expand Down
7 changes: 5 additions & 2 deletions externs/shaka/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ shakaExtern.InitDataOverride;
* audioRobustness: string,
* videoRobustness: string,
* serverCertificate: Uint8Array,
* initData: Array.<!shakaExtern.InitDataOverride>
* initData: Array.<!shakaExtern.InitDataOverride>,
* keyIds: Array.<string>
* }}
*
* @description
Expand Down Expand Up @@ -174,7 +175,9 @@ shakaExtern.InitDataOverride;
* <i>Defaults to [], e.g., no override.</i> <br>
* A list of initialization data which override any initialization data found
* in the content. See also shakaExtern.InitDataOverride.
*
* @property {Array.<string>} keyIds
* <i>Defaults to []</i> <br>
* If not empty, contains the default key IDs for this key system.
* @exportDoc
*/
shakaExtern.DrmInfo;
Expand Down
3 changes: 2 additions & 1 deletion lib/dash/content_protection.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ shaka.dash.ContentProtection.createDrmInfo_ = function(keySystem, initData) {
audioRobustness: '',
videoRobustness: '',
serverCertificate: null,
initData: initData || []
initData: initData || [],
keyIds: []
};
};

Expand Down
34 changes: 30 additions & 4 deletions lib/media/drm_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,13 @@ shaka.media.DrmEngine.prototype.prepareMediaKeyConfigs_ =
fullMimeType += '; codecs="' + stream.codecs + '"';
}

// Some DRM license providers requires that we have a default
// KID from manifest in the wrapped license request
// and needs to be accessible in a request filter
if (stream.keyId) {
drmInfo.keyIds.push(stream.keyId);
}

// Edge 13 fails this negotiation with NotSupportedError if more than
// one entry is given, even if each entry individually would be
// supported. Bug filed: https://goo.gl/vr2Vle
Expand Down Expand Up @@ -585,6 +592,10 @@ shaka.media.DrmEngine.prototype.fillInDrmInfoDefaults_ = function(drmInfo) {
}
}

if (!drmInfo.keyIds) {
drmInfo.keyIds = [];
}

var advanced = this.config_.advanced[keySystem];
if (advanced) {
if (!drmInfo.distinctiveIdentifierRequired) {
Expand Down Expand Up @@ -660,7 +671,8 @@ shaka.media.DrmEngine.prototype.configureClearKey_ = function() {
audioRobustness: '',
videoRobustness: '',
serverCertificate: null,
initData: initDatas
initData: initDatas,
keyIds: []
};
};

Expand All @@ -685,7 +697,11 @@ shaka.media.DrmEngine.prototype.createCurrentDrmInfo_ = function(
/** @type {!Array.<!shakaExtern.InitDataOverride>} */
var initDatas = [];

this.processDrmInfos_(drmInfos, licenseServers, serverCerts, initDatas);
/** @type {!Array.<string>} */
var keyIds = [];

this.processDrmInfos_(drmInfos, licenseServers, serverCerts, initDatas,
keyIds);

if (serverCerts.length > 1) {
shaka.log.warning('Multiple unique server certificates found! ' +
Expand All @@ -710,7 +726,8 @@ shaka.media.DrmEngine.prototype.createCurrentDrmInfo_ = function(
audioRobustness: audioRobustness,
videoRobustness: videoRobustness,
serverCertificate: serverCerts[0],
initData: initDatas
initData: initDatas,
keyIds: keyIds
};
};

Expand All @@ -723,10 +740,11 @@ shaka.media.DrmEngine.prototype.createCurrentDrmInfo_ = function(
* @param {!Array.<string>} licenseServers
* @param {!Array.<!Uint8Array>} serverCerts
* @param {!Array.<!shakaExtern.InitDataOverride>} initDatas
* @param {!Array.<string>} keyIds
* @private
*/
shaka.media.DrmEngine.prototype.processDrmInfos_ =
function(drmInfos, licenseServers, serverCerts, initDatas) {
function(drmInfos, licenseServers, serverCerts, initDatas, keyIds) {
/**
* @param {shakaExtern.InitDataOverride} a
* @param {shakaExtern.InitDataOverride} b
Expand Down Expand Up @@ -764,6 +782,14 @@ shaka.media.DrmEngine.prototype.processDrmInfos_ =
}
});
}

if (drmInfo.keyIds) {
for (var i = 0; i < drmInfo.keyIds.length; ++i) {
if (keyIds.indexOf(drmInfo.keyIds[i]) == -1) {
keyIds.push(drmInfo.keyIds[i]);
}
}
}
});
};

Expand Down
3 changes: 2 additions & 1 deletion test/test/util/manifest_generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ shaka.test.ManifestGenerator.prototype.addDrmInfo = function(keySystem) {
audioRobustness: '',
videoRobustness: '',
serverCertificate: null,
initData: null
initData: null,
keyIds: []
});
return this;
};
Expand Down