Skip to main content
Skip table of contents

Importing licences

This step is for encrypted content only. For clear content go straight to Download content.

The client application must get pre-delivered licences for offline consumption of protected content, for example, downloaded content. It can either get them in indirect mode or direct mode. The configuration for each mode is outlined below. The two modes are mutually exclusive; you must always get licenses in the same mode.

The client application can query the PAK for existing persisted or volatile licences present in the PAK. The query can be run using filtering to return:

  • All licences
  • All expired licences
  • Licences corresponding to a given PRM content ID
  • Licence corresponding to a given PRM syntax

The client application can browse through licences and decide which ones it wants to persist. The way to request the licence from the server is at the client application and portal’s discretion – the way to identify contents is likely to be specific to the portal. The import licences operation must take place each time a licence needs to be predelivered.

Using third-party offline playback modules

For third-party offline playback modules, to prefetch the licence, the application must get the contentID from the offline playback module, or from another module such as the EPG. For example, the offline playback module can get the contentID from the playlist as follows:

JAVA
#EXT-X-KEY:METHOD=AES-128,URI="http://keys.example.com/199707888?k=1000012581"

Indirect mode

The following code shows how to prefetch licenses in indirect mode:

JAVA
public boolean checkLicense(String xContentId) {
  PakCoreDrmAgent drmAgent = getDrmAgent();
  List<PakCoreDrmEntitlement> list =
    drmAgent.generateListOfStoredDrmEntitlements(null, xContentId);
  if (!list.isEmpty()){
    for(int i=0; i< list.size(); i++){
      PakCoreDrmEntitlement entitlement = list.get(i);
      if (entitlement != null) {
        Calendar cal = entitlement.getExpirationDate();
        if (cal.getTimeInMillis() > System.currentTimeMillis()) {
          return true;
        }
      }
}
  }
  return false;
}
public void prefetchLicense(){
  //Get the challenge data needed to prefetch the licence from the server.
  String challengePayload = drmAgent
        .getPrefetchLicensesPayloadForServer(mClientProtectedPrivateData);
  callGetLicenseWebServices(challengePayload);
}

public void onGetLicenseSuccess(String xResponse){
  //Parse the xResponse to get DCM&DMM.
  //PakCoreLicense is concrete data class implements IPakCoreLicense.
  PakCoreLicense license = new PakCoreLicense(DCM, DMM);

  List<IPakCoreLicense> licensesList = new ArrayList<IPakCoreLicense>();
  licensesList.add(license);

  PakCoreDrmAgent drmAgent = getDrmAgent();
  //Register listener to listen a group of licence start or finish and no more.
  //Licences are pending.
  drmAgent.addLicenseImportationStateChangedListener(mLicenseImportationStateChangedListener);
  //Import licences and persist licences.
  drmAgent.importLicenses(licensesList, true);
}

Direct mode

In direct mode, once the PAK is in a state of READY, the application can call prefetchLicenses() prefetch the licence selected by DVS. Because this method is asynchronous, the application registers a listener to be informed when the request is finished.

When the application is informed of the LICENSE_PREFETCHING_IN_PROGRESS state, no action is required. Once communication with the DVS has been completed and no errors have occurred, the new state is LICENSE_PREFETCHING_DONE. At this point, the licences are queued for processing in the background.

The following code shows how to prefetch licenses in direct mode:

JAVA
//Silent initialize the PAK.
drmAgent.silentInitialize(mServer.getUrl(),
                          mServer.getProtectedPrivateData(),
                          mServer.getClearPrivateData(),
                          true);

//Register a listener to be notified that the prefetch state changed.      
drmAgent.addPrefetchLicensesStateChangedListener(
                      mPrefetchLicensesStateChangedListener);

//Prefetch licence and store in persisted storage.
drmAgent.prefetchLicenses(xObject.getContentId(),
                                                  mServer.getLicenseClearPrivateData(),
                                                  mServer.getUrl(),
                                                  true);

To enable the persistence of content licences, the PAK has been initialised with the persist content parameter set to true.

Next step: Download content

JavaScript errors detected

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

If this problem persists, please contact our support.