Shaka-player: AssetID and registerRequestFilter

Created on 1 Oct 2019  路  4Comments  路  Source: google/shaka-player

Fairplay DRM with https://www.ezdrm.com
Shaka drm configuration:

{
  drm: {
    servers: {
       fairplay: "https://fps.ezdrm.com/api/licenses/"
    },
    advanced: {
       fairplay: new Uint8Array(cert)
    }
  }
}

License request url has to be:
https://fps.ezdrm.com/api/licenses/<>?myToken=1234...

Two questions:

Thanks in advance

archived question

All 4 comments

First, please note that your example is not correct. Instead of fairplay, you must use the key system ID, which is com.apple.fps.1_0. Follow the examples in the FairPlay tutorial: https://shaka-player-demo.appspot.com/docs/api/tutorial-fairplay.html

Please take special note that the certificate in the advanced section looks like this:

{
  drm: {
    advanced: {
      'com.apple.fps.1_0': {
        serverCertificate: new Uint8Array(cert),
      },
    },
  },
}

If you know the asset ID and token in advance, just configure them in the server URL upfront. For example:

{
  drm: {
    servers: {
       'com.apple.fps.1_0': "https://fps.ezdrm.com/api/licenses/FOO?myToken=BAR"
    },
  },
}

If you need to wait to get those, use registerRequestFilter.

As for getting the asset ID, please read the "Content ID" section of the tutorial and consult the ezdrm.com documentation. If you still have questions, I'll be happy to help.

@joeyparrish Thanks for answering
You're right about drm configuration. Thas was an example code handwritten but my real code was right, sorry.

I'm already using initDataTransform as pointed out in the tutorial, but I'm not sure what initalData returned is used for. For now I get assetId in initDataTransform and save it on a variable out of function scope so it can be used later inside registerRequestFilter . It's working but I just want to know if this is the proper way of doing it

let assetId = null;
player.configure({
  drm: {
    ...myDRMConfig,
    fairPlayTransform: false,
    initDataTransform: initData => {
      const contentId = customExtractContentId(initData);
      if (!assetId) {
        assetId = contentId;
      }
      const cert = player.drmInfo().serverCertificate;
      return customConcatInitDataIdAndCertificate(initData, contentId, cert);
    }
  }
});

player
  .getNetworkingEngine()
  .registerRequestFilter((type, request) => {
    if (type !== shaka.net.NetworkingEngine.RequestType.LICENSE) {
      return;
    }
    // Modify url request to include assetId, token, ....
    request.uris[0] = `${request.uris[0]}${assetId}?token=${token}`;
  });

@EstebanBP, the returned init data is given to the browser to generate a license request. I believe what you're doing to capture the asset ID and use it in the request filter makes sense to me.

@TheModMaker, since you worked on Fairplay recently, do you have anything to add?

I don't really have anything to add, your code looks good. Remember that if you use the same content ID format and concat formats, you can use our shaka.util.FairPlayUtils.

If you have any more questions, feel free to ask or comment with @shaka-bot reopen to re-open the issue.

Was this page helpful?
0 / 5 - 0 ratings