我基于以下内容开发自定义 Cast Receiver 应用程序Google Cast 应用程序框架 https://developers.google.com/cast/docs/caf_receiver/接收器应用程序负责播放 Widevine 加密流。我们支持的解决方案需要添加DRM令牌 to PreAuthorization
许可证请求中的标头。我需要执行几个授权请求来检索DRM令牌。我认为检索 DRM 令牌的最佳位置是使用消息拦截器 https://developers.google.com/cast/docs/caf_receiver/advanced:
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;
});;
});
然后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. 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 https://github.com/google/shaka-player/blob/76f78187b6533c4fdabb505451f603313b1d474d/lib/util/error.js
所以我的问题是:
- Cast Receiver API 是否支持许可证续订?接收方会触发 CAST API 中的哪些回调来通知会话已过期?我没有收到任何消息,我只收到错误:(并且播放停止。
- 我如何向播放器提供新的许可证以防止其失败?
我们通过使用 PlaybackConfig 的 manifestHandler 方法实现了这一点。它可以返回一个 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);
};
);
每次接收器获取清单时(在每个广告中断后或在动态清单的每个更新周期),都会调用 manifestHandler 方法。
我希望我有所帮助,从谷歌获得一些帮助/答案是相当复杂的......
最好的,
文森特.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)