gpt4 book ai didi

google-cast - 如何在 google cast 中获取 widevine 有效载荷(挑战)?

转载 作者:行者123 更新时间:2023-12-05 06:50:42 25 4
gpt4 key购买 nike

我正在开发我自己的自定义接收器应用程序,我想播放的流受 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 上实现了它,实现了我自己的 MediaDrmCallback 并且类 KeyRequest 包含所需的信息,但是对象 requestInfo 的参数内容不提供该信息

最佳答案

我通过做来让它工作

   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 );
}

关于google-cast - 如何在 google cast 中获取 widevine 有效载荷(挑战)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66351516/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com