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

How to obtain widevine payload (challenge) in google cast?

我正在开发我自己的自定义接收器应用程序,我想播放的流受 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 并且 class 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 );
}