简体   繁体   English

如何在Cast Receiver Player中续订过期的DRM许可证?

[英]How to renew expired DRM license in Cast Receiver Player?

I develop custom Cast Receiver application based on Google Cast Application Framework The receiver app is responsible for playback Widevine encrypted streams. 我基于Google Cast应用程序框架开发了自定义的Cast Receiver应用程序 。接收器应用程序负责播放Widevine加密流。 Our backed solution requires to add DRM token to PreAuthorization header in license request. 我们支持的解决方案要求在许可请求中将DRM令牌添加到PreAuthorization标头中。 I need to perform a couple of authorized requests to retrieve the DRM token . 我需要执行几个授权请求才能检索DRM令牌 I assumed that the best place to retrieve DRM token is to use Message Interceptor : 我假设检索DRM令牌的最佳位置是使用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: 然后,CAST Player自动调用licenseRequestHandler ,我轻松地将所需的DRM令牌添加到许可证请求的标头中:

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. 在我们的后端许可证上,寿命约为30分钟。 After that time the receiver player generates error [cast.framework.media.ShakaPlayer] category: 6 code: 6014 and playback stops. 在那之后,接收方播放器生成错误[cast.framework.media.ShakaPlayer] category: 6 code: 6014并且播放停止。 I found that this error means 我发现此错误意味着 在此处输入图片说明

So my questions are: 所以我的问题是:

  1. Does Cast Receiver API support license renewing? Cast Receiver API是否支持续订许可证? What callbacks in CAST API does receiver trigger to notify that session has expired? 接收方会触发CAST API中的哪些回调来通知会话已过期? 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? 我如何向播放器提供新许可证以防止其失败?

We've achieved this by using the manifestHandler method of the PlaybackConfig. 我们通过使用PlaybackConfig的manifest清单处理程序方法实现了这一点。 It can return a Promise, so we've been able to detect whether the token could be expired or not, and renew it accordingly. 它可以返回一个Promise,因此我们已经能够检测到令牌是否可以过期,并相应地对其进行更新。

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). 每当Receiver提取清单时(每个广告中断之后或动态清单的每个更新周期),都会调用manifestHandler方法。

I hope I've been helpful, this is quite complicated to get some help/answers from Google... 希望我能对您有所帮助,这很难从Google获得帮助/答案。

Best, Vincent. 最好,文森特。

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. 如果此属性未设置为true,则无法续订许可证。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM