Licence pre-delivery/pre-fetching and renewal
To test this feature and view the connect-predelivery-license example code, please see the Android SDK 5 Example Code Quick Start guide.
Licence pre-fetching is when the application gets the licence from the licence server ahead of playback so that when playback is required, no licence requests are sent from the callback object.
Licence pre-delivery, also called pre-fetching, is not the same as Temporal key pre-delivery, which is an attribute of Key Rotation streams. Multi-session mode is not required for pre-fetching.
The connect-dash example code shows how the OTVConnectMediaDrmCallback
is instantiated and configured with an OpVault and DRM request properties. The connect-predelivery-license code is built on this to handle pre-fetching of a licence.
OTVConnectMediaDrmCallback
Note that although the same OTVConnectMediaDrmCallback
is used as for normal fetches, the URL for pre-fetch is slightly different:
OTVConnectMediaDrmCallback callback = new OTVConnectMediaDrmCallback("https://<server-domain>/prmls/contentlicenseservice/v1/predelivery/licenses/");
A one-time or fixed content token must be provided for normal playback (where the licence is fetched during playback). To pre-fetch the licence, the request needs to be sent with a device token that permits pre-fetching:
callback.setKeyRequestProperty("nv-authorizations", "--device_token--");
The token should contain the device id:
{
"ver": "1.0",
"typ": "DevAuthN",
"deviceId": "Device_ID2"
}
The device id is required when generating the device token. for example prm.NAGRA/C220/FAS.Android-DeviceId-01
.
Pre-delivery callbacks for success and failure (implementing the OTVConnectLicensePreDeliveryListener
interface) now need to be created. Another callback method should be provided for renewal.
OTVConnectLicensePreDelivery
An OTVConnectLicensePreDelivery
class supporting pre-delivery of CONNECT licences is instantiated using the DRM callback and the listener objects:
OTVConnectLicensePreDelivery connectLicensePreDelivery = new OTVConnectLicensePreDelivery(callback, connectPreDeliveryListener);
To pre-fetch the license asynchronously:
connectLicensePreDelivery.fetchLicense();
You can fetch the license in two alternative modes when calling fetchLicense()
. The default mode (as per the code above) is force-fetching, meaning the license would be renewed even if you already have a valid licence. In renewal mode, renewal takes place only if required through the onRenewal()
callback method:
boolean forceFetchLicense = false; // true = force renewal, false = renew through onRenewal()
connectLicensePreDelivery.fetchLicense( forceFetchLicense );
The onRenewal()
callback method in the example calls handleRenewPreDeliveryLicense()
, which in turn makes use of the
OTVConnectLicensePreDelivery
instance to perform the license renewal request:
private void handleRenewPreDeliveryLicense() {
connectLicensePreDelivery.renewLicense();
}
If the pre-fetch is successful, the OTVConnectLicensePreDeliveryListener.onSuccess(int numLicense)
will be called.
OTVConnectLicensePreDelivery will provision the device automatically before pre-fetching if it has not yet been provisioned.
Once the licence is fetched, the connectLicensePreDelivery
object should be released:
connectLicensePreDelivery.release();