silvermine / videojs-chromecast

MIT License
148 stars 75 forks source link

Widevine DRM Compatibility #82

Closed samueleastdev closed 3 years ago

samueleastdev commented 3 years ago

Hi All,

I am just wondering what steps would need to be taken to make this plugin support Widevine DRM. I am using Widevine DRM with the videojs plugin https://github.com/videojs/videojs-contrib-eme and from the docs and looking around the web it seems all you need to do us pass your license URL in the custom data.

See here: https://stackoverflow.com/questions/25539054/widevine-drm-playback-on-chromecast

I have tried this with the plugin see setup below.

var customData;

customData = {
    'https://00000000000.cloudfront.net/00000000000/master.mpd': {
        'licenseUrl': 'my license url'
    },
};

options = {
    techOrder: ['chromecast', 'html5'],
    chromecast: {
        requestCustomDataFn: function(source) {
            return customData[source.url];
        }
    },
    plugins: {
        chromecast: {},
    }
};

Is there anything obvious I might be missing has anyone successfully got this working with DRM?

Thanks

jthomerson commented 3 years ago

Sorry, I'm not sure. If you find something that works, please post back here.

dwassing commented 3 years ago

This is about 8 months old, but for anyone looking back here, @samueleastdev is/was fairly correct in his implementation, but he is missing a key part, the receiver.

Snippet from my sample implementation for the chrome sender (written in TypeScript for Angular):

const options = {
      techOrder: [ 'chromecast', 'html5' ],
      plugins: {
            chromecast: {
                  receiverAppID: 'YOUR_APP_ID', // REQUIRED FOR DRM
                  addButtonToControlBar: true
            }
      },
      chromecast: {
            requestTitleFn: () => {
                  return 'your title';
            },
            requestSubtitleFn: () => {
                  return 'your subtitle';
            },
            requestCustomDataFn: () => {
                  const url = 'your DRM license url';
                  return {licenseUrl: url}; // possible to send other metadata here as well
            }
      }
};

To use this code (with your app id), you need to implement a working receiver app as per google's guidelines, and add DRM to the receiver as can be seen here. This also comes with its own set of requirements of course (such as having an available https server).

(Before doing any of this, you may want to confirm that your sender chromecast (this plugin) is working properly, the receiverAppID is only required once you have your own custom device set up).