本文整理汇总了PHP中assetPeer::retrieveAllFlavorsTypes方法的典型用法代码示例。如果您正苦于以下问题:PHP assetPeer::retrieveAllFlavorsTypes方法的具体用法?PHP assetPeer::retrieveAllFlavorsTypes怎么用?PHP assetPeer::retrieveAllFlavorsTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类assetPeer
的用法示例。
在下文中一共展示了assetPeer::retrieveAllFlavorsTypes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: servePlaylist
protected function servePlaylist($entry)
{
// allow only manual playlist
if ($entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_TEXT) {
KExternalErrors::dieError(KExternalErrors::INVALID_ENTRY_TYPE);
}
// get request parameters
$flavorParamIds = $this->getRequestParameter("flavorParamIds");
if ($flavorParamIds) {
$flavorParamIds = explode(',', $flavorParamIds);
}
$version = $this->getRequestParameter("v");
// execute the playlist
if ($version) {
$entry->setDesiredVersion($version);
}
list($entryIds, $durations, $referenceEntry) = myPlaylistUtils::executeStitchedPlaylist($entry);
if (!$referenceEntry) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
// load the flavor assets
// Note: not filtering by $flavorParamIds here, so that in case some flavor is missing
// we can fill in the gap using some other flavor params
$c = new Criteria();
$c->add(assetPeer::ENTRY_ID, $entryIds, Criteria::IN);
$c->add(assetPeer::STATUS, flavorAsset::FLAVOR_ASSET_STATUS_READY);
$flavorTypes = assetPeer::retrieveAllFlavorsTypes();
$c->add(assetPeer::TYPE, $flavorTypes, Criteria::IN);
$flavorAssets = assetPeer::doSelect($c);
// group the flavors by entry and flavor params
$groupedFlavors = array();
foreach ($flavorAssets as $flavor) {
if (!isset($groupedFlavors[$flavor->getEntryId()])) {
$groupedFlavors[$flavor->getEntryId()] = array();
}
$groupedFlavors[$flavor->getEntryId()][$flavor->getFlavorParamsId()] = $flavor;
}
// remove entries that don't have flavors
for ($i = count($entryIds) - 1; $i >= 0; $i--) {
$entryId = $entryIds[$i];
if (isset($groupedFlavors[$entryId])) {
continue;
}
unset($entryIds[$i]);
unset($durations[$i]);
}
// get the flavor params of the reference entry that should be returned
$referenceEntryFlavorParamsIds = array_keys($groupedFlavors[$referenceEntry->getId()]);
if ($flavorParamIds) {
$flavorParamIds = array_intersect($referenceEntryFlavorParamsIds, $flavorParamIds);
} else {
$flavorParamIds = $referenceEntryFlavorParamsIds;
}
if (!$flavorParamIds) {
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
}
// build the sequences
$storeCache = true;
$sequences = array();
foreach ($flavorParamIds as $flavorParamsId) {
$referenceFlavor = $groupedFlavors[$referenceEntry->getId()][$flavorParamsId];
// build the clips of the current sequence
$clips = array();
foreach ($entryIds as $entryId) {
if (isset($groupedFlavors[$entryId][$flavorParamsId])) {
$flavor = $groupedFlavors[$entryId][$flavorParamsId];
} else {
// don't have a flavor for this entry in the desired flavor params,
// choose the one with the closest bitrate
$flavor = null;
foreach ($groupedFlavors[$entryId] as $curFlavor) {
if (!$flavor || abs($curFlavor->getBitrate() - $referenceFlavor->getBitrate()) < abs($flavor->getBitrate() - $referenceFlavor->getBitrate())) {
$flavor = $curFlavor;
}
}
}
// get the file path of the flavor
$syncKey = $flavor->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, false, false);
if ($fileSync) {
$resolvedFileSync = kFileSyncUtils::resolve($fileSync);
$path = $resolvedFileSync->getFullPath();
} else {
error_log('missing file sync for flavor ' . $flavor->getId() . ' version ' . $flavor->getVersion());
$path = '';
$storeCache = false;
}
$clips[] = array('type' => 'source', 'path' => $path);
}
$sequences[] = array('clips' => $clips);
}
// build the json
$mediaSet = array('durations' => $durations, 'sequences' => $sequences);
$json = json_encode($mediaSet);
$renderer = new kRendererString($json, self::JSON_CONTENT_TYPE);
if ($storeCache) {
$this->storeCache($renderer, $entry->getPartnerId());
}
$renderer->output();
KExternalErrors::dieGracefully();
//.........这里部分代码省略.........
示例2: getListResponse
public function getListResponse(KalturaFilterPager $pager, KalturaDetachedResponseProfile $responseProfile = null)
{
$types = assetPeer::retrieveAllFlavorsTypes();
return $this->getTypeListResponse($pager, $responseProfile, $types);
}
示例3: validateForSubmission
public function validateForSubmission(EntryDistribution $entryDistribution, $action)
{
$validationErrors = parent::validateForSubmission($entryDistribution, $action);
// make sure that all flavor assets marked for distribution have a flavor params id assigned to them
$flavorAssetIds = explode(',', $entryDistribution->getFlavorAssetIds());
if (count($flavorAssetIds)) {
$c = new Criteria();
$c->addAnd(assetPeer::ID, $flavorAssetIds, Criteria::IN);
$flavorTypes = assetPeer::retrieveAllFlavorsTypes();
$c->add(assetPeer::TYPE, $flavorTypes, Criteria::IN);
$flavorAssets = assetPeer::doSelect($c);
foreach ($flavorAssets as $asset) {
/* @var $asset flavorAsset */
if (strlen($asset->getFlavorParamsId()) <= 0) {
$validationErrors[] = $this->createValidationError($action, DistributionErrorType::INVALID_DATA, 'flavor asset', 'flavor asset must be assigned to a flavor params id');
}
}
}
return $validationErrors;
}
示例4: getFlavorAssetsWithParamsAction
/**
* Get Flavor Asset with the relevant Flavor Params (Flavor Params can exist without Flavor Asset & vice versa)
*
* @action getFlavorAssetsWithParams
* @param string $entryId
* @return KalturaFlavorAssetWithParamsArray
*/
public function getFlavorAssetsWithParamsAction($entryId)
{
$dbEntry = entryPeer::retrieveByPK($entryId);
if (!$dbEntry) {
throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
}
// get all the flavor params of partner 0 and the current partner (note that partner 0 is defined as partner group in service.ct)
$c = new Criteria();
$flavorTypes = assetParamsPeer::retrieveAllFlavorParamsTypes();
$c->add(assetParamsPeer::TYPE, $flavorTypes, Criteria::IN);
$partnerIds = array($dbEntry->getPartnerId(), PartnerPeer::GLOBAL_PARTNER);
$c->add(assetParamsPeer::PARTNER_ID, array_map('strval', $partnerIds), Criteria::IN);
$flavorParamsDb = assetParamsPeer::doSelect($c);
// get the flavor assets for this entry
$c = new Criteria();
$flavorTypes = assetPeer::retrieveAllFlavorsTypes();
$c->add(assetPeer::TYPE, $flavorTypes, Criteria::IN);
$c->add(assetPeer::ENTRY_ID, $entryId);
$c->add(assetPeer::STATUS, array(flavorAsset::FLAVOR_ASSET_STATUS_DELETED, flavorAsset::FLAVOR_ASSET_STATUS_TEMP), Criteria::NOT_IN);
$flavorAssetsDb = assetPeer::doSelect($c);
// find what flavot params are required
$requiredFlavorParams = array();
foreach ($flavorAssetsDb as $item) {
$requiredFlavorParams[$item->getFlavorParamsId()] = true;
}
// now merge the results, first organize the flavor params in an array with the id as the key
$flavorParamsArray = array();
foreach ($flavorParamsDb as $item) {
$flavorParams = $item->getId();
$flavorParamsArray[$flavorParams] = $item;
if (isset($requiredFlavorParams[$flavorParams])) {
unset($requiredFlavorParams[$flavorParams]);
}
}
// adding missing required flavors params to the list
if (count($requiredFlavorParams)) {
$flavorParamsDb = assetParamsPeer::retrieveByPKsNoFilter(array_keys($requiredFlavorParams));
foreach ($flavorParamsDb as $item) {
$flavorParamsArray[$item->getId()] = $item;
}
}
$usedFlavorParams = array();
// loop over the flavor assets and add them, if it has flavor params add them too
$flavorAssetWithParamsArray = new KalturaFlavorAssetWithParamsArray();
foreach ($flavorAssetsDb as $flavorAssetDb) {
$flavorParamsId = $flavorAssetDb->getFlavorParamsId();
$flavorAssetWithParams = new KalturaFlavorAssetWithParams();
$flavorAssetWithParams->entryId = $entryId;
$flavorAsset = KalturaFlavorAsset::getInstance($flavorAssetDb, $this->getResponseProfile());
$flavorAssetWithParams->flavorAsset = $flavorAsset;
if (isset($flavorParamsArray[$flavorParamsId])) {
$flavorParamsDb = $flavorParamsArray[$flavorParamsId];
$flavorParams = KalturaFlavorParamsFactory::getFlavorParamsInstance($flavorParamsDb->getType());
$flavorParams->fromObject($flavorParamsDb, $this->getResponseProfile());
$flavorAssetWithParams->flavorParams = $flavorParams;
// we want to log which flavor params are in use, there could be more
// than one flavor asset using same params
$usedFlavorParams[$flavorParamsId] = $flavorParamsId;
}
// else if ($flavorAssetDb->getIsOriginal())
// {
// // create a dummy flavor params
// $flavorParams = new KalturaFlavorParams();
// $flavorParams->name = "Original source";
// $flavorAssetWithParams->flavorParams = $flavorParams;
// }
$flavorAssetWithParamsArray[] = $flavorAssetWithParams;
}
// copy the remaining params
foreach ($flavorParamsArray as $flavorParamsId => $flavorParamsDb) {
if (isset($usedFlavorParams[$flavorParamsId])) {
// flavor params already exists for a flavor asset, not need
// to list it one more time
continue;
}
$flavorParams = KalturaFlavorParamsFactory::getFlavorParamsInstance($flavorParamsDb->getType());
$flavorParams->fromObject($flavorParamsDb, $this->getResponseProfile());
$flavorAssetWithParams = new KalturaFlavorAssetWithParams();
$flavorAssetWithParams->entryId = $entryId;
$flavorAssetWithParams->flavorParams = $flavorParams;
$flavorAssetWithParamsArray[] = $flavorAssetWithParams;
}
return $flavorAssetWithParamsArray;
}