1

Let's assume we have an encrypted stream (SmoothStreaming + Playready) and a custom receiver build on googlecast/cast-custom-receiver.

I can see that device tries to get the license from the LA_URL (license acquisition URL) - extracted from stream PlayReady ProtectionHeader.

I wonder is there a way to override this behaviour? I want receiver to delegate license acquisition to sender - iOS app in my case.

trnl
  • 514
  • 3
  • 20

2 Answers2

1

When you are setting up a Host, you can pass a licenseUrl (see here), I think if that is present, it will be used for license acquisition.

Ali Naddaf
  • 16,951
  • 2
  • 21
  • 28
  • Yes, I can also update the headers and content of the request in the `Host#updateLicenseRequestInfo`, but that means that I need to move user session and other information that sender already have to chromecast. – trnl Apr 21 '14 at 06:26
  • is it possible just to delegate the license acquisition to sender? – trnl Apr 28 '14 at 08:18
  • Sender SDKs don't have any knowledge of license, DRM, etc. SO there is no API to that effect, if that is what you are looking for. I still don't understand why simply setting the url when you setup the Host isn't enough for you. – Ali Naddaf Apr 28 '14 at 14:53
  • I'm looking at the following scenario: **1** - receiver understands that it needs license to play a content, **2** - receiver passes SOAP license request to sender, **3** - sender requests license from server, **4** - sender passes SOAP license response to receiver, **5** - receiver applies the license and continues playback. We need this because our license acquisition procedure is customised, we are passing userToken, deviceId, contentId and several other things to DRM server and I don't copy them to receiver. – trnl Apr 29 '14 at 08:29
  • You need to write your own sender and receiver, this is a highly unusual flow which, IMHO, is unnecessary (in my opinion, sender should provide details that are needed to the receiver and receiver should contact the license server directly). – Ali Naddaf Apr 29 '14 at 14:13
  • You can customize your license server URL and opt to use credentials but this is all done on receiver side. DRM is tied to hardware so for Chromecast devices specific CDM has to validate content availability for that user. You cannot just use the CDM on sender e.g. iOS side and automatically transfer DRM rights to receiver. For receiver side customization check out this sample: https://github.com/googlecast/CastMediaPlayerStreamingDRM. – ssgg Google Developer Platform Apr 30 '14 at 15:44
  • @Google Developer Platform https://github.com/googlecast/CastMediaPlayerStreamingDRM doesn't exists – hariszaman Jul 25 '16 at 14:43
0

You can achieve this by modifying the Media Player Library. The only thing that needs to be done - exposing challenge, key system, init data & sessionId though prepareLicenseRequest().

<    this.c.prepareLicenseRequest && !this.c.prepareLicenseRequest() || this.gb()
---
>    this.c.prepareLicenseRequest && !this.c.prepareLicenseRequest(this.ef, Df[this.vc], this.qb, this.hf) || this.gb()

Please verify the variable names cause they can be different (they can be found in webkitAddKey() call later in the media_player.js code).

In your receiver just define the your own prepareLicenseRequest implementation:

window.mediaHost.prepareLicenseRequest = function(challenge,keySystem, initData, sessionId) {
  debug('drm', 'prepareLicenseRequest');
  window.initData = initData;
  window.sessionId = sessionId;
  window.keySystem = keySystem;

  var base64challenge = window.btoa(pack(challenge));
  window.messageBus.broadcast(base64challenge); // TODO send only to initiator
  return false // receiver will stop not request license by itself
}                 

When license acquired by sender it can send it back via the same channel. In this case receiver needs to add the license to the env:

window.messageBus.onMessage = function(event) {
    var base64key = event['data'];
    var key = unpack(window.atob(base64key));
    window.mediaElement.webkitAddKey(window.keySystem, new Uint8Array(unpack(unbase64)), window.initData, window.sessionId);
    window.mediaElement.play(); 
}

window.messageBus in this case is a custom channel (urn:x-cast:me.trnl.cast.key)

That's it. It works for us and it's quite fast.

trnl
  • 514
  • 3
  • 20