Playing protected content with Kaltura
Overview
Nearly every license provider, such as Irdeto, EZDRM, or Kaltura, requires a few special information being 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's source configuration.
Kaltura provides all required details in a success call to /kaltura/api_v3/service/asset/action/getPlaybackContext
, which enables an easy and seamless integration:
Widevine
// `playbackContext` contains the full JSON response from
// `/kaltura/api_v3/service/asset/action/getPlaybackContext`
const kalturaSourcePrWv = playbackContext.result.sources.find(src => src.type === 'Dash_widevine');
const source = {
dash: kalturaSourcePrWv.url,
drm: {
widevine: {
LA_URL: kalturaSourcePrWv.drm.find(drmObj => drmObj.scheme === 'WIDEVINE_CENC').licenseURL
}
};
PlayReady
// `playbackContext` contains the full JSON response from
// `/kaltura/api_v3/service/asset/action/getPlaybackContext`
const kalturaSourcePrWv = playbackContext.result.sources.find(src => src.type === 'Dash_widevine');
const source = {
dash: kalturaSourcePrWv.url,
drm: {
playready: {
LA_URL: kalturaSourcePrWv.drm.find(drmObj => drmObj.scheme === 'PLAYREADY_CENC').licenseURL
}
}
};
FairPlay
// `playbackContext` contains the full JSON response from
// `/kaltura/api_v3/service/asset/action/getPlaybackContext`
const kalturaSourceFps = playbackContext.result.sources.find(src => src.format === 'applehttp');
const source = {
hls: kalturaSourceFps.url,
drm: {
fairplay: {
LA_URL: kalturaSourceFps.drm[0].licenseURL,
serverCertificate: Uint8Array.from(window.atob(kalturaSourceFps.drm[0].certificate), (c) => c.charCodeAt(0)).buffer,
prepareContentId: contentId => contentId,
prepareMessage: data => data.messageBase64Encoded,
prepareLicense: data => JSON.parse(data).ckc,
useUint16InitData: true,
}
}
};
Complete example for Widevine, PlayReady and FairPlay
// `playbackContext` contains the full JSON response from
// `/kaltura/api_v3/service/asset/action/getPlaybackContext`
const kalturaSourcePrWv = playbackContext.result.sources.find(src => src.type === 'Dash_widevine');
const kalturaSourceFps = playbackContext.result.sources.find(src => src.format === 'applehttp');
const source = {
dash: kalturaSourcePrWv.url,
hls: kalturaSourceFps.url,
drm: {
widevine: {
LA_URL: kalturaSourcePrWv.drm.find(drmObj => drmObj.scheme === 'WIDEVINE_CENC').licenseURL,
},
playready: {
LA_URL: kalturaSourcePrWv.drm.find(drmObj => drmObj.scheme === 'PLAYREADY_CENC').licenseURL,
},
fairplay: {
LA_URL: kalturaSourceFps.drm[0].licenseURL,
serverCertificate: Uint8Array.from(window.atob(kalturaSourceFps.drm[0].certificate), (c) => c.charCodeAt(0)).buffer,
prepareContentId: contentId => contentId,
prepareMessage: data => data.messageBase64Encoded,
prepareLicense: data => JSON.parse(data).ckc,
useUint16InitData: true,
}
}
};
Updated 10 months ago