Check if PlayReady license message is wrapped (#815)

Closes #814
This commit is contained in:
Chris Fillmore
2017-05-18 11:37:45 -04:00
committed by Joey Parrish
parent 2f5e2dbc5b
commit 4352c0bbc7
2 changed files with 15 additions and 4 deletions
+1
View File
@@ -24,6 +24,7 @@
Andy Hochhaus <ahochhaus@samegoal.com>
Chad Assareh <assareh@google.com>
Chris Fillmore <fillmore.chris@gmail.com>
Costel Madalin Grecu <madalin.grecu@adswizz.com>
Donato Borrello <donato@jwplayer.com>
Duc Pham <duc.pham@edgeware.tv>
+14 -4
View File
@@ -1106,9 +1106,19 @@ shaka.media.DrmEngine.prototype.sendLicenseRequest_ = function(event) {
* @private
*/
shaka.media.DrmEngine.prototype.unpackPlayReadyRequest_ = function(request) {
// The PlayReady license message as it comes from the CDM can't be directly
// delivered to a license server. Other CDMs do not seem to need this kind
// of special handling.
// PlayReady CDMs in some clients (e.g. IE11, Edge) wrap the license message
// in UTF-16 encoded XML which can't be directly delivered to a license
// server. However, not all clients exhibit this behaviour. The Tizen
// PlayReady CDM message is UTF-8 encoded and can be passed to the license
// server as-is. Other CDMs do not seem to need this kind of special
// handling.
var xml = String.fromCharCode.apply(null, new Uint8Array(request.body));
if (xml.indexOf('<PlayReadyKeyMessage') !== 0) {
// The message is not wrapped.
request.headers['Content-Type'] = 'text/xml; charset=utf-8';
return;
}
// The raw license message is UTF-16-encoded XML. We need to unpack the
// Challenge element (base64-encoded string containing the actual license
@@ -1132,7 +1142,7 @@ shaka.media.DrmEngine.prototype.unpackPlayReadyRequest_ = function(request) {
// </LicenseAcquisition>
// </PlayReadyKeyMessage>
var xml = shaka.util.StringUtils.fromUTF16(
xml = shaka.util.StringUtils.fromUTF16(
request.body, true /* littleEndian */);
var dom = new DOMParser().parseFromString(xml, 'application/xml');