public function getTypeListResponse(KalturaFilterPager $pager, KalturaDetachedResponseProfile $responseProfile = null, array $types = null) { list($list, $totalCount) = $this->doGetListResponse($pager, $types); $response = new KalturaFlavorAssetListResponse(); $response->objects = KalturaFlavorAssetArray::fromDbArray($list, $responseProfile); $response->totalCount = $totalCount; return $response; }
/** * 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; }
/** * Get web playable Flavor Assets for Entry * * @action getWebPlayableByEntryId * @param string $entryId * @return KalturaFlavorAssetArray * * @deprecated use baseEntry.getContextData instead */ public function getWebPlayableByEntryIdAction($entryId) { // entry could be "display_in_search = 2" - in that case we want to pull it although KN is off in services.ct for this action $c = KalturaCriteria::create(entryPeer::OM_CLASS); $c->addAnd(entryPeer::ID, $entryId); $criterionPartnerOrKn = $c->getNewCriterion(entryPeer::PARTNER_ID, $this->getPartnerId()); $criterionPartnerOrKn->addOr($c->getNewCriterion(entryPeer::DISPLAY_IN_SEARCH, mySearchUtils::DISPLAY_IN_SEARCH_KALTURA_NETWORK)); $c->addAnd($criterionPartnerOrKn); // there could only be one entry because the query is by primary key. // so using doSelectOne is safe. $dbEntry = entryPeer::doSelectOne($c); if (!$dbEntry) { throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId); } $flavorAssetsDb = assetPeer::retrieveReadyWebByEntryId($entryId); if (count($flavorAssetsDb) == 0) { throw new KalturaAPIException(KalturaErrors::NO_FLAVORS_FOUND); } $flavorAssets = KalturaFlavorAssetArray::fromDbArray($flavorAssetsDb, $this->getResponseProfile()); return $flavorAssets; }
/** * Get web playable Flavor Assets for Entry * * @action getWebPlayableByEntryId * @param string $entryId * @return KalturaFlavorAssetArray */ public function getWebPlayableByEntryIdAction($entryId) { // entry could be "display_in_search = 2" - in that case we want to pull it although KN is off in services.ct for this action $c = new Criteria(); $c->addAnd(entryPeer::ID, $entryId); $criterionPartnerOrKn = $c->getNewCriterion(entryPeer::PARTNER_ID, $this->getPartnerId()); $criterionPartnerOrKn->addOr($c->getNewCriterion(entryPeer::DISPLAY_IN_SEARCH, mySearchUtils::DISPLAY_IN_SEARCH_KALTURA_NETWORK)); $c->addAnd($criterionPartnerOrKn); // there could only be one entry because the query is by primary key. // so using doSelectOne is safe. $dbEntry = entryPeer::doSelectOne($c); if (!$dbEntry) { throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId); } // if the entry does not belong to the partner but "display_in_search = 2" // we want to turn off the criteria over the flavorAssetPeer if ($dbEntry->getPartnerId() != $this->getPartnerId() && $dbEntry->getDisplayInSearch() == mySearchUtils::DISPLAY_IN_SEARCH_KALTURA_NETWORK) { flavorAssetPeer::setDefaultCriteriaFilter(null); } $flavorAssetsDb = flavorAssetPeer::retrieveReadyWebByEntryId($entryId); if (count($flavorAssetsDb) == 0) { throw new KalturaAPIException(KalturaErrors::NO_FLAVORS_FOUND); } // re-set default criteria to avoid fetching "private" flavors in laetr queries. // this should be also set in baseService, but we better do it anyway. flavorAssetPeer::setDefaultCriteriaFilter(); $flavorAssets = KalturaFlavorAssetArray::fromDbArray($flavorAssetsDb); return $flavorAssets; }
/** * 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; }