OpenTV Player SDK for Apple (PRM)

Importing the licences

The client application must get pre-delivered licences for offline consumption of protected content, for example, downloaded content. With direct initialisation, the PAK handles the predelivery of licences between the server and the PAK. These will be available for both online and offline content.

If the client application needs to import the licenses again, it must request a call to prefetchLicenses and listen for the LICENSE_PREFETCHING_DONE notification.

Example code

The following code samples show how to prefetch licenses in direct mode.

- (id)init
{
  if (self = [super init])
  {
       // set up notification for the listener
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(prefetchStateChanged)   name:@"PreDeliveryStateChanged"  object:nil];
     
    PakCore *pPakCore = PakCore :: pgGetInstance();
    IPakCoreDrmAgent *pDrmAgent = pPakCore->pGetDrmAgent();
    _prefetchListener = new NMPPakCoreNotifListener(@"PreDeliveryStateChanged");
    pDrmAgent->addPrefetchLicensesStateChangedListener(*_prefetchListener);
  }
  return  self;
}
- (void) prefetchStateChanged
{
  PakCore *pPakCore = PakCore :: pgGetInstance();
  IPakCoreDrmAgent *pDrmAgent = pPakCore->pGetDrmAgent();
  if (pDrmAgent->getLicensePrefetchingState() == NMP::LICENSE_PREFETCHING_DONE &&
    pDrmAgent->getLastCommunicationStatus() == NMP::COMMUNICATION_STATUS_OK)
  {
    // Success!
  }
}
// prefetchLicenses parameters are string, string, string, bool

- (void) someMethod

{
  PakCore *pPakCore = PakCore :: pgGetInstance();
  IPakCoreDrmAgent *pDrmAgent = pPakCore->pGetDrmAgent();
  if (pDrmAgent->getState()== IPakCoreDrmAgent::PAK_READY)
    pDrmAgent->prefetchLicenses(protectedPrivateData,
                                   clearPrivateData,
                                                    serverURL,
                                                    willPersist);
       // method is asynchronous. Prefetch state available via prefetchStateChanged
}

Next step: You can start the download.