Skip to main content
Skip table of contents

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:

JAVA
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:

JAVA
callback.setKeyRequestProperty("nv-authorizations", "--device_token--");

The token should contain the device id:

JS
{
  "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.

Click here to view the code.
JAVA
OTVConnectLicensePreDeliveryListener connectPreDeliveryListener = new OTVConnectLicensePreDeliveryListener() {
    @Override
    public void onSuccess(int numLicense) {
        String message = "number of license of pre-delivery :" + numLicense;
        Log.i(TAG,message);
        mActivity.runOnUiThread(() -> {
            Toast.makeText(mActivity, message, Toast.LENGTH_LONG).show();
        });
    }

    @Override
    public void onFailure(int what, int extra) {
        String message = ErrorCodeTranslator.translate(what,extra);
        Log.i(TAG, message);
        mActivity.runOnUiThread(() -> {
            Toast.makeText(mActivity, message, Toast.LENGTH_LONG).show();
        });
    } 

    @Override
    public void onRenewal() {
      String message = "Receive renewal message.";
      OTVLog.i(TAG, message);
      Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
      handleRenewPreDeliveryLicense();
    }
};

OTVConnectLicensePreDelivery

An OTVConnectLicensePreDelivery class supporting pre-delivery of CONNECT licences is instantiated using the DRM callback and the listener objects:

JAVA
OTVConnectLicensePreDelivery connectLicensePreDelivery = new OTVConnectLicensePreDelivery(callback, connectPreDeliveryListener);

To pre-fetch the license asynchronously:

JAVA
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:

JAVA
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:

JAVA
  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:

JAVA
connectLicensePreDelivery.release();
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.