Callback mode
To test this feature and view the example code, please see the Browsers and Connected TV SDK 5 Example Code Quick Start guide.
To define custom actions during DRM licence acquisition, you can initialise the otvtoolkit in callback mode. This is an alternative form of integrating DRM to providing details of the system with subsequent licenceServer and tenantId attributes. Here the CONNECT Player SDK handles all this with a finite set of DRM systems and modes of operation, allowing much greater flexibility.
Configuration
Indicate the system as "customer" and provide configuration of requestLicenceCallback as a function triggered when DRM licencing is acquired ahead of playback.
plugins: {
otvtoolkit: {
drm: {
system: "customer",
config: {
requestLicenceCallback: myLicenceRetrievalFunction
}
}
}
}
Adaption for FPS
A minor variation to the above is required for FairPlay in the Safari browser. Here the drm.config needs provision of the FairPlay certificate.
plugins: {
otvtoolkit: {
drm: {
system: "customer",
config: {
fairplayServerCertificate: certificate,
requestLicenceCallback: myLicenceRetrievalFunction
}
}
}
}
Requirements of your implementation
requestLicenceCallback
The requestLicenceCallback function defined must:
Accept arguments where the following can be provided:
Key system
An object with details of the asset to be played back
The payload of the request message
Message type (e.g.
license-requestorlicence-renewal)
Return a
Promisewhich will resolve on the completion of the delivery of the message.
The basic outline of how your requestLicenceCallback function should look is shown below.
function myLicenceRetrievalFunction(keySystem, source, requestPayload, messageType) {
var url;
var headers;
if (messageType === "license-renewal") {
...
} else {
...
}
if (keySystem === "com.widevine.alpha") {
...
} else if (keySystem === "com.microsoft.playready") {
...
} else {
...
}
return new Promise(function resolver(resolve, reject) {
...
fairplayServerCertificate (fps only)
The fairplayServerCertificate configuration must contain either:
The server certificate in the form of a
Uint8Array, orA callback function that will be called whenever the certificate is required.
Where a callback is provided, the outline of how it should look is shown below.
function certificate() {
return new Promise(function resolver(resolve, reject) {
...
resolve(new Uint8Array(certificate));
...
});
}