Skip to content

Commit

Permalink
Check if PlayReady license message is wrapped (#815)
Browse files Browse the repository at this point in the history
Closes #814
  • Loading branch information
chrisfillmore authored and joeyparrish committed May 23, 2017
1 parent e5fd67d commit a8f50f3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
18 changes: 14 additions & 4 deletions lib/media/drm_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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');

Expand Down

0 comments on commit a8f50f3

Please sign in to comment.