Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add custom getLicense function? #384

Open
AkashYadav00 opened this issue Jul 10, 2023 · 0 comments
Open

How to add custom getLicense function? #384

AkashYadav00 opened this issue Jul 10, 2023 · 0 comments

Comments

@AkashYadav00
Copy link

Description

videojs-contrib-eme enables us to add custom getLicense function
How to achieve the same using videojs-contrib-dash?

This is my getLicense function:

public async getKeySystems(licenseHeaders, sourceUrl) {

return {
"com.widevine.alpha": {
    supportedConfigurations: [{
                    audioCapabilities: [{
                        initDataTypes: ["cenc"],
                            sessionTypes: ["temporary"],
                        contentType: "audio/mp4; codecs=\"opus\"",
                        robustness: "SW_SECURE_CRYPTO"
                    }]
        }],
        async getLicense(_emeOptions: Object, keyMessage: ArrayBuffer, callback: ICallBackType) {
                    let startTime = window.performance.now();
                    videojs.xhr(
                        {
                            uri: licenseServerUrl,
                            method: HTTP_METHOD_POST,
                            responseType: "arraybuffer",
                            body: JSON.stringify({
                                licenseChallenge: btoa(convertArrayBufferToString(keyMessage)),
                            }),
                            headers: licenseHeaders,
                        },
                        (err, response, responseBody) => {
                         
                            if (err || !response || response.statusCode < 200 || response.statusCode >= 300) {
                                LOG.error(`error`);
                                if (err) {
                                    callback(err);
                                }
                                return;
                            }
                            LOG.info("License fetched successfully");
                          
                            const drmProxyResponse = JSON.parse(
                                convertArrayBufferToString(responseBody)
                            );
                            let key = convertStringToArrayBuffer(atob(drmProxyResponse.license));
                            callback(null, key);
                        }
                    );
                },
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant