Пример #1
0
 /**
  * This action delivers entry-related data, based on the user's context: access control, restriction, playback format and storage information.
  * @action getContextData
  * @param string $entryId
  * @param KalturaEntryContextDataParams $contextDataParams
  * @return KalturaEntryContextDataResult
  */
 public function getContextData($entryId, KalturaEntryContextDataParams $contextDataParams)
 {
     $dbEntry = entryPeer::retrieveByPK($entryId);
     if (!$dbEntry) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     $asset = null;
     if ($contextDataParams->flavorAssetId) {
         $asset = assetPeer::retrieveById($contextDataParams->flavorAssetId);
         if (!$asset) {
             throw new KalturaAPIException(KalturaErrors::FLAVOR_ASSET_ID_NOT_FOUND, $contextDataParams->flavorAssetId);
         }
     }
     $contextDataHelper = new kContextDataHelper($dbEntry, $this->getPartner(), $asset);
     if ($dbEntry->getAccessControl() && $dbEntry->getAccessControl()->hasRules()) {
         $accessControlScope = $dbEntry->getAccessControl()->getScope();
     } else {
         $accessControlScope = new accessControlScope();
     }
     $contextDataParams->toObject($accessControlScope);
     $contextDataHelper->buildContextDataResult($accessControlScope, $contextDataParams->flavorTags, $contextDataParams->streamerType, $contextDataParams->mediaProtocol);
     if ($contextDataHelper->getDisableCache()) {
         KalturaResponseCacher::disableCache();
     }
     $result = new KalturaEntryContextDataResult();
     $result->fromObject($contextDataHelper->getContextDataResult());
     $result->flavorAssets = KalturaFlavorAssetArray::fromDbArray($contextDataHelper->getAllowedFlavorAssets());
     $result->streamerType = $contextDataHelper->getStreamerType();
     $result->mediaProtocol = $contextDataHelper->getMediaProtocol();
     $result->storageProfilesXML = $contextDataHelper->getStorageProfilesXML();
     $result->isAdmin = $contextDataHelper->getIsAdmin();
     $parentEntryId = $dbEntry->getParentEntryId();
     if ($parentEntryId) {
         $dbEntry = $dbEntry->getParentEntry();
         if (!$dbEntry) {
             throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $parentEntryId);
         }
     }
     $result->isScheduledNow = $dbEntry->isScheduledNow($contextDataParams->time);
     $result->pluginData = new KalturaPluginDataArray();
     $pluginInstances = KalturaPluginManager::getPluginInstances('IKalturaEntryContextDataContributor');
     foreach ($pluginInstances as $pluginInstance) {
         $pluginInstance->contributeToEntryContextDataResult($entryId, $contextDataParams, $result);
     }
     return $result;
 }
Пример #2
0
 /**
  * This action delivers entry-related data, based on the user's context: access control, restriction, playback format and storage information.
  * @action getContextData
  * @param string $entryId
  * @param KalturaEntryContextDataParams $contextDataParams
  * @return KalturaEntryContextDataResult
  */
 public function getContextData($entryId, KalturaEntryContextDataParams $contextDataParams)
 {
     $dbEntry = entryPeer::retrieveByPK($entryId);
     if (!$dbEntry) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     if ($dbEntry->getStatus() != entryStatus::READY) {
         // the purpose of this is to solve a case in which a player attempts to play a non-ready entry,
         // and the request becomes cached for a long time, preventing playback even after the entry
         // becomes ready
         kApiCache::setExpiry(60);
     }
     $asset = null;
     if ($contextDataParams->flavorAssetId) {
         $asset = assetPeer::retrieveById($contextDataParams->flavorAssetId);
         if (!$asset) {
             throw new KalturaAPIException(KalturaErrors::FLAVOR_ASSET_ID_NOT_FOUND, $contextDataParams->flavorAssetId);
         }
     }
     $contextDataHelper = new kContextDataHelper($dbEntry, $this->getPartner(), $asset);
     if ($dbEntry->getAccessControl() && $dbEntry->getAccessControl()->hasRules()) {
         $accessControlScope = $dbEntry->getAccessControl()->getScope();
     } else {
         $accessControlScope = new accessControlScope();
     }
     $contextDataParams->toObject($accessControlScope);
     $contextDataHelper->buildContextDataResult($accessControlScope, $contextDataParams->flavorTags, $contextDataParams->streamerType, $contextDataParams->mediaProtocol);
     if ($contextDataHelper->getDisableCache()) {
         KalturaResponseCacher::disableCache();
     }
     $result = new KalturaEntryContextDataResult();
     $result->fromObject($contextDataHelper->getContextDataResult());
     $result->flavorAssets = KalturaFlavorAssetArray::fromDbArray($contextDataHelper->getAllowedFlavorAssets());
     $result->streamerType = $contextDataHelper->getStreamerType();
     $result->mediaProtocol = $contextDataHelper->getMediaProtocol();
     $result->storageProfilesXML = $contextDataHelper->getStorageProfilesXML();
     $result->isAdmin = $contextDataHelper->getIsAdmin();
     $parentEntryId = $dbEntry->getParentEntryId();
     if ($parentEntryId) {
         $dbEntry = $dbEntry->getParentEntry();
         if (!$dbEntry) {
             throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $parentEntryId);
         }
     }
     $result->isScheduledNow = $dbEntry->isScheduledNow($contextDataParams->time);
     if (!$result->isScheduledNow && $this->getKs()) {
         // in case the sview is defined in the ks simulate schedule now true to allow player to pass verification
         if ($this->getKs()->verifyPrivileges(ks::PRIVILEGE_VIEW, ks::PRIVILEGE_WILDCARD) || $this->getKs()->verifyPrivileges(ks::PRIVILEGE_VIEW, $entryId)) {
             $result->isScheduledNow = true;
         }
     }
     $result->pluginData = new KalturaPluginDataArray();
     $pluginInstances = KalturaPluginManager::getPluginInstances('IKalturaEntryContextDataContributor');
     foreach ($pluginInstances as $pluginInstance) {
         $pluginInstance->contributeToEntryContextDataResult($dbEntry, $contextDataParams, $result);
     }
     return $result;
 }