Playing protected content with Conax DRM

Overview

Nearly every license provider requires a few special pieces of information to be sent to the DRM license server or responds with a proprietary format. Instead of integrating a few license providers into the core of our player, we decided to provide necessary configuration options via the player configuration.

Widevine

const source = {
    dash: 'DASH_MANIFEST_URL',
    hls: 'HLS_MANIFEST_URL',
    drm: {
        widevine: {
            LA_URL: 'CONAX_LICENSE_SERVER_URL',
            headers: {
                'Conax-Custom-Data':'{\"Version\":\"1.0.0\",\"CxAuthenticationDataToken\":\"'+ TOKEN +'\",\"CxClientInfo\":{\"DeviceType\":\"Browser\",\"DrmClientType\":\"Widevine-HTML5\",\"DrmClientVersion\":\"1.0.0\",\"CxDeviceId\":\"'+ DEVICE_ID +'\"}}'
            }
        }
    }
};

PlayReady

const source = {
    dash: 'DASH_MANIFEST_URL',
    hls: 'HLS_MANIFEST_URL',
    drm: {
        playready: {
            LA_URL: 'CONAX_LICENSE_SERVER_URL',
            headers: {
                'Conax-Custom-Data':'{\"Version\":\"1.0.0\",\"CxAuthenticationDataToken\":\"'+ TOKEN +'\",\"CxClientInfo\":{\"DeviceType\":\"Browser\",\"DrmClientType\":\"Widevine-HTML5\",\"DrmClientVersion\":\"1.0.0\",\"CxDeviceId\":\"'+ DEVICE_ID +'\"}}'
            }
        }
    }
};

FairPlay

const source = {
    dash: 'DASH_MANIFEST_URL',
    hls: 'HLS_MANIFEST_URL',
    drm: {
        fairplay: {
            LA_URL: 'CONAX_LICENSE_SERVER_URL',
            certificateURL: 'CERTIFICATE-URL',
            prepareMessage: (event, session) => event.message,
            prepareContentId: (initDataAsString) => {
                const base64decoded = window.atob(initDataAsString.split(\"skd://\")[1].split(\"?\")[0]);
                const json = JSON.parse(base64decoded);
                return '{\"contentRef\": \"' + json.ContentRef + '\", \"keyId\": \"' + json.KeyId + '\"}';
            },
            prepareLicense: (license) => JSON.parse(license).CkcMessage;
            useUint16InitData: true,
            headers: [{
                name: 'Content-type',
                value: 'application/octet-stream'
            }, {
                name: 'Conax-Custom-Data',
                value: '{\"Version\":\"1.0.0\",\"CxAuthenticationDataToken\":\"'+ TOKEN +'\",\"CxClientInfo\":{\"DeviceType\":\"Browser\",\"DrmClientType\":\"FairPlay-HTML5\",\"DrmClientVersion\":\"1.0.0\",\"CxDeviceId\":\"'+ DEVICE_ID +'\"}}'
            }]
        }
    }
};

Complete example for Widevine, PlayReady and FairPlay

const source = {
    dash: 'DASH_MANIFEST_URL',
    hls: 'HLS_MANIFEST_URL',
    drm: {
        widevine: {
            LA_URL: 'CONAX_LICENSE_SERVER_URL',
            headers: [{
                name: 'Conax-Custom-Data',
                value: '{\"Version\":\"1.0.0\",\"CxAuthenticationDataToken\":\"'+ TOKEN +'\",\"CxClientInfo\":{\"DeviceType\":\"Browser\",\"DrmClientType\":\"Widevine-HTML5\",\"DrmClientVersion\":\"1.0.0\",\"CxDeviceId\":\"'+ DEVICE_ID +'\"}}'
            }]
        },
        playready: {
            LA_URL: 'CONAX_LICENSE_SERVER_URL',
            headers: [{
                name: 'Conax-Custom-Data',
                value: '{\"Version\":\"1.0.0\",\"CxAuthenticationDataToken\":\"'+ TOKEN +'\",\"CxClientInfo\":{\"DeviceType\":\"Browser\",\"DrmClientType\":\"PlayReady-HTML5\",\"DrmClientVersion\":\"1.0.0\",\"CxDeviceId\":\"'+ DEVICE_ID +'\"}}'
            }]
        },
        fairplay: {
            LA_URL: 'CONAX_LICENSE_SERVER_URL',
            certificateURL: 'CERTIFICATE-URL',
            prepareMessage: (event, session) => event.message,
            prepareContentId: (initDataAsString) => {
                const base64decoded = window.atob(initDataAsString.split(\"skd://\")[1].split(\"?\")[0]);
                const json = JSON.parse(base64decoded);
                return '{\"contentRef\": \"' + json.ContentRef + '\", \"keyId\": \"' + json.KeyId + '\"}';
            },
            prepareLicense: (license) => JSON.parse(license).CkcMessage;
            useUint16InitData: true,
            headers: [{
                name: 'Content-type',
                value: 'application/octet-stream'
            }, {
                name: 'Conax-Custom-Data',
                value: '{\"Version\":\"1.0.0\",\"CxAuthenticationDataToken\":\"'+ TOKEN +'\",\"CxClientInfo\":{\"DeviceType\":\"Browser\",\"DrmClientType\":\"FairPlay-HTML5\",\"DrmClientVersion\":\"1.0.0\",\"CxDeviceId\":\"'+ DEVICE_ID +'\"}}'
            }]
        }
    }
}

Please replace the following placeholders in the code:

  • HLS_MANIFEST_URL: The URL to the HLS manifest (M3U8) file.
  • DASH_MANIFEST_URL: The URL to the DASH manifest (mpd) file.
  • CONAX_LICENSE_SERVER_URL: The URL to your DRM License Server for the respective DRM Solution.
  • CERTIFICATE-URL: The URL to the Fairplay certificate. This needs to be accessible for the player.
  • TOKEN: The provided by Conax
  • DEVICE_ID: The device ID provided by Conax