Skip to content

Working example with Widevine Modular #4

@asgvard

Description

@asgvard

Hi!

We are having some issues with the integration of Widevine Modular DRM using avplay.
Followed the example from this page: DRM Contents Playback Sequence, but even with the testing streams from Shaka demo samples we are getting "Invalid license challenge" 500 errors from the license servers. Same content works with Shaka player. There is some difference in how EME in the browser constructs the Challenge body and how avplay does it in "ondrmevent" callback, but it's hard to understand since it's base64 encoded (even after decoding it's still not readable).

Please provide working updated example of Widevine Modular integration.

Sample Dash Manifest URL: https://storage.googleapis.com/shaka-demo-assets/angel-one-widevine/dash.mpd
Sample Widevine License URL: https://cwip-shaka-proxy.appspot.com/no_auth
No custom headers needed, everything works with Shaka on this combination.

Brief example of how we do it in the code:

// Before prepareAsync
        drmParam.AppSession = uniqueId(); // random number
        drmParam.DataType = 'MPEG-DASH';

        if (parseInt(platformVersion, 10) >= 5) { // const {platformVersion} = tizen.systeminfo.getCapabilities();
          const STRINGIFIED_PARAMS = JSON.stringify(drmParam);

          webapis.avplay.setDrm(DRM_WIDEVINE, 'SetProperties', STRINGIFIED_PARAMS);
        } else {
          webapis.avplay.setDrm(DRM_WIDEVINE, 'Initialize', '');
          webapis.avplay.setDrm(DRM_WIDEVINE, 'widevine_app_session', drmParam.AppSession);
          webapis.avplay.setDrm(DRM_WIDEVINE, 'widevine_data_type', drmParam.DataType);
        }

// inside ondrmevent callback
            const decodedMessage = atob(drmData.challenge);

            const drmChallengeRequest = new XMLHttpRequest();

            drmChallengeRequest.responseType = 'arraybuffer';
            drmChallengeRequest.open('POST', this.licenseUrl, true);

            drmChallengeRequest.onload = function() {
              if (this.status === 200 && this.response) {
                const licenseParam = `${drmData.session_id}PARAM_START_POSITION${btoa(this.response)}PARAM_START_POSITION`;

                webapis.avplay.setDrm(DRM_WIDEVINE, 'widevine_license_data', licenseParam);
              } else {
                console.log('Error in license request');
              }
            };
            
            drmChallengeRequest.send(decodedMessage);

Here is the Diff of how Shaka player constructs license challenge request body, and how Tizen native player does that. First of all Tizen player doesn't detect TV model properly, and then there is a difference at the bottom of the request, but since it's unique at each request and encoded, it's impossible to understand which part of it is incorrect:
https://www.diffchecker.com/h8CZ5Y3X

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions