2
votes

I develop custom Cast Receiver application based on Google Cast Application Framework The receiver app is responsible for playback Widevine encrypted streams. Our backed solution requires to add DRM token to PreAuthorization header in license request. I need to perform a couple of authorized requests to retrieve the DRM token. I assumed that the best place to retrieve DRM token is to use Message Interceptor:

this.playerManager_.setMessageInterceptor(
cast.framework.messages.MessageType.LOAD, (loadRequestData) => {
  var media = loadRequestData.media;
  var customData = media.customData;
  var licenseUrl = customData.licenseUrl || null;
  var contentId = media.contentId;
  var cdn = customData.cdn || null;
  return this.getOriginMediaURL(contentId, cdn, PlayerApiImp)
  .then(playbackURL => {
    loadRequestData.media.contentId = playbackURL;
    loadRequestData.media.customData.contentUrl = contentId;
    return this.getDRMToken(customData);
  })
  .then(drmToken => {
    this.preAuthToken = drmToken
    this.playbackConfig_.licenseUrl = licenseUrl;
    return loadRequestData
  })
  .catch(error => {
    this.log_({'ERROR': error});
    return loadRequestData;
  });;
});

Then CAST Player automatically calls licenseRequestHandler and I easily add required DRM token to the headers of license request:

this.playbackConfig_.licenseRequestHandler = requestInfo => {
  if (this.preAuthToken) {
    requestInfo.headers = {};
    requestInfo.headers['PreAuthorization'] = this.preAuthToken;
  }
};

Playback works fine but until the time when license key has expired. On our backend license lives ~30min. After that time the receiver player generates error [cast.framework.media.ShakaPlayer] category: 6 code: 6014 and playback stops. I found that this error means enter image description here

So my questions are:

  1. Does Cast Receiver API support license renewing? What callbacks in CAST API does receiver trigger to notify that session has expired? I don't receive any, I only get error :( and playback stops.
  2. How I can provide new license to the player to prevent it from failing?
2
Are you not getting new calls to licenseRequestHandler when the license should be renewed? By that time your preAuthToken might have expired though.colde
@colde I investigated and saw that receiver player doesn't call new 'licenseRequestHandler'. I'm really don't know how to renew licenseIhar Katkavets

2 Answers

0
votes

We've achieved this by using the manifestHandler method of the PlaybackConfig. It can return a Promise, so we've been able to detect whether the token could be expired or not, and renew it accordingly.

castContext
  .getPlayerManager()
  .setMediaPlaybackInfoHandler(
    (loadRequestData, playbackConfig) => {
      playbackConfig.manifestHandler = manifest =>
        retrieveUpfrontToken(loadRequestData)
          .then(token => {
            playbackConfig.licenseRequestHandler = requestInfo => {
              requestInfo.withCredentials = true;
              requestInfo.headers['x-dt-auth-token'] = token;
            };
          })
          .then(() => manifest);
    };
  );

The manifestHandler method is called each time the Receiver is fetching the manifest (after each ad breaks or at each update period for a dynamic manifest).

I hope I've been helpful, this is quite complicated to get some help/answers from Google...

Best, Vincent.

0
votes

Read the properties of the license and see if it is renewable. If this property is not set to true you cant renew the license.