我正在开发自己的自定义接收器应用程序,我想要播放的流是用widevine保护的,我需要从我自己的服务器获得许可证,我需要传递content_id和有效负载。这是我的代码:
playbackConfig.protectionSystem = cast.framework.ContentProtection.WIDEVINE;
playbackConfig.licenseRequestHandler = requestInfo => {
requestInfo.headers["Authorization"] = token;
requestInfo.headers["Content-Type"] = "application/json";
requestInfo.content = JSON.stringify({
type: "widevine",
type_request: "license",
content_id: content_id,
payload: <<missing_data>>
});
return requestInfo
};我在Android my上实现了它,实现了我自己的MediaDrmCallback,KeyRequest类包含了所需的信息,但是来自object requestInfo的参数内容没有提供这些信息
发布于 2021-09-14 15:53:30
我通过做一些事情来让它工作
playbackConfig.licenseRequestHandler = requestInfo => {
requestInfo.headers["Authorization"] = token
requestInfo.headers["Content-Type"] = "application/json"
const wrapped = {}
wrapped.payload = arrayBufferToBase64(requestInfo.content)
wrapped.type = 'widevine'
wrapped.type_request = "license"
wrapped.content_id = content_id
const wrappedJson = JSON.stringify(wrapped)
requestInfo.content = shaka.util.StringUtils.toUTF8(wrappedJson)
return requestInfo
}
function arrayBufferToBase64(buffer) {
var binary = '';
var bytes = new Uint8Array( buffer );
var len = bytes.byteLength;
for (var i = 0; i < len; i++) {
binary += String.fromCharCode( bytes[ i ] );
}
return window.btoa( binary );
}https://stackoverflow.com/questions/66351516
复制相似问题