예제 #1
0
 public function objectReplaced(BaseObject $object, BaseObject $replacingObject, BatchJob $raisedJob = null)
 {
     KalturaLog::debug("check for DRM key replacement");
     try {
         $replacingDrmKey = $this->getDrmKey($replacingObject);
         if ($replacingDrmKey) {
             $newKeyId = $replacingDrmKey->getDrmKey();
             KalturaLog::debug("replacing drm key with: " . $newKeyId);
             $entryDrmKey = $this->getDrmKey($object);
             if (!$entryDrmKey) {
                 $entryDrmKey = new DrmKey();
                 $entryDrmKey->setPartnerId($object->getPartnerId());
                 $entryDrmKey->setObjectId($object->getId());
                 $entryDrmKey->setObjectType(DrmKeyObjectType::ENTRY);
                 $entryDrmKey->setProvider(PlayReadyPlugin::getPlayReadyProviderCoreValue());
             }
             $entryDrmKey->setDrmKey($newKeyId);
             $entryDrmKey->save();
             $object->putInCustomData(PlayReadyPlugin::ENTRY_CUSTOM_DATA_PLAY_READY_KEY_ID, $newKeyId);
             $object->save();
         }
     } catch (Exception $e) {
         KalturaLog::err("Failed to update drm key for entry " . $object->getId());
     }
     return true;
 }
예제 #2
0
 /**
  * Get content key and key id for the given entry
  * 
  * @action getEntryContentKey
  * @param string $entryId 
  * @param bool $createIfMissing
  * @return KalturaPlayReadyContentKey $response
  * 
  */
 public function getEntryContentKeyAction($entryId, $createIfMissing = false)
 {
     $entry = entryPeer::retrieveByPK($entryId);
     if (!$entry) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     $keySeed = $this->getPartnerKeySeed();
     $keyId = $this->getEntryKeyId($entry->getId());
     if (!$keyId && $createIfMissing) {
         $drmKey = new DrmKey();
         $drmKey->setPartnerId($entry->getPartnerId());
         $drmKey->setObjectId($entryId);
         $drmKey->setObjectType(DrmKeyObjectType::ENTRY);
         $drmKey->setProvider(PlayReadyPlugin::getPlayReadyProviderCoreValue());
         $keyId = kPlayReadyAESContentKeyGenerator::generatePlayReadyKeyId();
         $drmKey->setDrmKey($keyId);
         try {
             $drmKey->save();
             $entry->putInCustomData(PlayReadyPlugin::ENTRY_CUSTOM_DATA_PLAY_READY_KEY_ID, $keyId);
             $entry->save();
         } catch (PropelException $e) {
             if ($e->getCause() && $e->getCause()->getCode() == self::MYSQL_CODE_DUPLICATE_KEY) {
                 $keyId = $this->getEntryKeyId($entry->getId());
             } else {
                 throw $e;
                 // Rethrow the unfamiliar exception
             }
         }
     }
     if (!$keyId) {
         throw new KalturaAPIException(KalturaPlayReadyErrors::FAILED_TO_GET_ENTRY_KEY_ID, $entryId);
     }
     $contentKey = $this->createContentKeyObject($keySeed, $keyId);
     $response = new KalturaPlayReadyContentKey();
     $response->fromObject($contentKey, $this->getResponseProfile());
     return $response;
 }