本文整理汇总了PHP中StorageProfilePeer::retrieveExternalByPartnerId方法的典型用法代码示例。如果您正苦于以下问题:PHP StorageProfilePeer::retrieveExternalByPartnerId方法的具体用法?PHP StorageProfilePeer::retrieveExternalByPartnerId怎么用?PHP StorageProfilePeer::retrieveExternalByPartnerId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StorageProfilePeer
的用法示例。
在下文中一共展示了StorageProfilePeer::retrieveExternalByPartnerId方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: die
<?php
require_once __DIR__ . '/../bootstrap.php';
if ($argc == 3) {
$partner_id = $argv[1];
$path_format = $argv[2];
} else {
die('usage: php ' . $_SERVER['SCRIPT_NAME'] . " [partner id] [date format]" . PHP_EOL);
}
$storages = StorageProfilePeer::retrieveExternalByPartnerId($partner_id);
if (!$storages) {
die('no such partner.' . PHP_EOL);
}
foreach ($storages as $storage) {
$storage->setPathFormat($path_format);
$storage->save();
}
echo "Done.";
示例2: serveRtmp
private function serveRtmp()
{
switch ($this->entry->getType()) {
case entryType::MEDIA_CLIP:
$duration = $this->entry->getDurationInt();
$flavorAssets = array();
if ($this->flavorId) {
$flavorAsset = flavorAssetPeer::retrieveById($this->flavorId);
if (!$flavorAsset->hasTag(flavorParams::TAG_WEB)) {
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
}
if (!$flavorAsset->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_READY) {
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
}
$flavorAssets[] = $flavorAsset;
} else {
$flavorAssets = flavorAssetPeer::retreiveReadyByEntryIdAndTag($this->entryId, flavorParams::TAG_MBR);
if (!count($flavorAssets)) {
$flavorAssets = flavorAssetPeer::retreiveReadyByEntryIdAndTag($this->entryId, flavorParams::TAG_WEB);
}
}
$flavorAssets = $this->removeMaxBitrateFlavors($flavorAssets);
if (!$this->storageId) {
$partner = $this->entry->getPartner();
$finalFlavors = array();
if ($partner->getStorageServePriority() == StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_FIRST) {
foreach ($flavorAssets as $flavorAsset) {
$key = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$fileSync = kFileSyncUtils::getReadyInternalFileSyncForKey($key);
if ($fileSync) {
$finalFlavors[] = $flavorAsset;
}
}
}
if (!count($finalFlavors) && $partner->getStorageServePriority() && $partner->getStorageServePriority() != StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_ONLY) {
$storages = StorageProfilePeer::retrieveExternalByPartnerId($partner->getId());
if (count($storages) == 1) {
$this->storageId = $storages[0]->getId();
} elseif (count($storages)) {
$storagesFlavors = array();
foreach ($storages as $storage) {
$storagesFlavors[$storage->getId()] = array();
foreach ($flavorAssets as $flavorAsset) {
$key = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($key, $storage->getId());
if ($fileSync) {
$storagesFlavors[$storage->getId()][] = $flavorAsset;
}
}
}
$maxCount = 0;
foreach ($storagesFlavors as $storageId => $storageFlavors) {
$count = count($storageFlavors);
if ($count > $maxCount) {
$maxCount = $count;
$this->storageId = $storageId;
$finalFlavors = $storageFlavors;
}
}
$flavorAssets = $finalFlavors;
} else {
foreach ($flavorAssets as $flavorAsset) {
$key = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$fileSync = kFileSyncUtils::getReadyInternalFileSyncForKey($key);
if ($fileSync) {
$finalFlavors[] = $flavorAsset;
}
}
}
}
}
foreach ($flavorAssets as $flavorAsset) {
$mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($flavorAsset->getId());
if ($mediaInfo && ($mediaInfo->getVideoDuration() || $mediaInfo->getAudioDuration() || $mediaInfo->getContainerDuration())) {
$duration = $mediaInfo->getVideoDuration() ? $mediaInfo->getVideoDuration() : ($mediaInfo->getAudioDuration() ? $mediaInfo->getAudioDuration() : $mediaInfo->getContainerDuration());
$duration /= 1000;
break;
}
}
$baseUrl = null;
$flavors = array();
if ($this->storageId) {
$storage = StorageProfilePeer::retrieveByPK($this->storageId);
if (!$storage) {
die;
}
$baseUrl = $storage->getDeliveryRmpBaseUrl();
// get all flavors with external urls
foreach ($flavorAssets as $flavorAsset) {
$key = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($key, $this->storageId);
if (!$fileSync) {
continue;
}
$urlManager = kUrlManager::getUrlManagerByStorageProfile($fileSync->getDc());
$urlManager->setClipTo($this->clipTo);
$urlManager->setFileExtension($flavorAsset->getFileExt());
$urlManager->setProtocol(StorageProfile::PLAY_FORMAT_RTMP);
$url = $urlManager->getFileSyncUrl($fileSync);
$url = preg_replace('/^\\//', '', $url);
//.........这里部分代码省略.........
示例3: initFlavorAssetArray
protected function initFlavorAssetArray()
{
if (!$this->shouldInitFlavorAssetsArray()) {
return;
}
$oneOnly = false;
if ($this->deliveryAttributes->getFormat() == PlaybackProtocol::HTTP || $this->deliveryAttributes->getFormat() == "url" || $this->deliveryAttributes->getFormat() == "rtsp") {
$oneOnly = true;
}
// get initial flavor list by input
$flavorAssets = array();
if ($this->flavorIds) {
$flavorAssets = assetPeer::retrieveReadyByEntryId($this->entryId, $this->flavorIds);
$flavorAssets = $this->removeNotAllowedFlavors($flavorAssets);
$flavorAssets = $this->removeMaxBitrateFlavors($flavorAssets);
}
if (!$flavorAssets || !count($flavorAssets)) {
$flavorAssets = assetPeer::retrieveReadyFlavorsByEntryId($this->entryId);
$flavorAssets = $this->deliveryAttributes->filterFlavorsByTags($flavorAssets);
$flavorAssets = $this->removeNotAllowedFlavors($flavorAssets);
$flavorAssets = $this->removeMaxBitrateFlavors($flavorAssets);
}
if ($this->deliveryAttributes->getFormat() == PlaybackProtocol::SILVER_LIGHT) {
$this->initSilverLightManifest($flavorAssets);
return;
}
if ($this->deliveryAttributes->getFormat() == PlaybackProtocol::HDS || $this->deliveryAttributes->getFormat() == PlaybackProtocol::APPLE_HTTP) {
// try to look for a smil manifest, if it was found, we will use it for hds and hls
if ($this->initSmilManifest($flavorAssets)) {
return;
}
}
// get flavors availability
$servePriority = $this->entry->getPartner()->getStorageServePriority();
$localFlavors = array();
$remoteFlavorsByDc = array();
$remoteFileSyncs = array();
foreach ($flavorAssets as $flavorAsset) {
$flavorId = $flavorAsset->getId();
$key = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$c = new Criteria();
$c = FileSyncPeer::getCriteriaForFileSyncKey($key);
$c->addAnd(FileSyncPeer::STATUS, FileSync::FILE_SYNC_STATUS_READY);
switch ($servePriority) {
case StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_ONLY:
$c->addAnd(FileSyncPeer::FILE_TYPE, FileSync::FILE_SYNC_FILE_TYPE_URL, Criteria::NOT_EQUAL);
break;
case StorageProfile::STORAGE_SERVE_PRIORITY_EXTERNAL_ONLY:
$c->add(FileSyncPeer::FILE_TYPE, FileSync::FILE_SYNC_FILE_TYPE_URL);
break;
}
if ($this->deliveryAttributes->getStorageId()) {
$c->addAnd(FileSyncPeer::DC, $this->deliveryAttributes->getStorageId());
}
$fileSyncs = FileSyncPeer::doSelect($c);
foreach ($fileSyncs as $fileSync) {
if ($fileSync->getFileType() == FileSync::FILE_SYNC_FILE_TYPE_URL) {
$dc = $fileSync->getDc();
$remoteFlavorsByDc[$dc][$flavorId] = $flavorAsset;
$remoteFileSyncs[$dc][$flavorId] = $fileSync;
} else {
$localFlavors[$flavorId] = $flavorAsset;
}
}
}
// filter out any invalid / disabled storage profiles
if ($remoteFileSyncs) {
$storageProfileIds = array_keys($remoteFileSyncs);
$storageProfiles = StorageProfilePeer::retrieveExternalByPartnerId($this->entry->getPartnerId(), $storageProfileIds);
$activeStorageProfileIds = array();
foreach ($storageProfiles as $storageProfile) {
$activeStorageProfileIds[] = $storageProfile->getId();
}
foreach ($storageProfileIds as $storageProfileId) {
if (in_array($storageProfileId, $activeStorageProfileIds)) {
continue;
}
unset($remoteFlavorsByDc[$storageProfileId]);
unset($remoteFileSyncs[$storageProfileId]);
}
}
// choose the storage profile with the highest number of flavors
$maxDc = null;
$maxDcFlavorCount = 0;
$remoteFlavors = array();
foreach ($remoteFlavorsByDc as $dc => $curDcFlavors) {
$curDcFlavorCount = count($curDcFlavors);
if ($curDcFlavorCount <= $maxDcFlavorCount) {
continue;
}
$maxDc = $dc;
$maxDcFlavorCount = $curDcFlavorCount;
$remoteFlavors = $curDcFlavors;
}
// choose the flavor set according to the serve priority
if ($this->shouldUseLocalFlavors($localFlavors, $remoteFlavors)) {
$this->deliveryAttributes->setStorageId(null);
$this->deliveryAttributes->setFlavorAssets($localFlavors);
} else {
if ($maxDc) {
//.........这里部分代码省略.........
示例4: setStatusLocalReady
/**
* (non-PHPdoc)
* @see asset::setStatusLocalReady()
*/
public function setStatusLocalReady()
{
$newStatus = asset::ASSET_STATUS_READY;
$externalStorages = StorageProfilePeer::retrieveExternalByPartnerId($this->getPartnerId());
foreach ($externalStorages as $externalStorage) {
if ($this->requiredToExportFlavor($externalStorage)) {
KalturaLog::info('Asset id [' . $this->getId() . '] is required to export to profile [' . $externalStorage->getId() . '] - setting status to [EXPORTING]');
$newStatus = asset::ASSET_STATUS_EXPORTING;
break;
}
}
KalturaLog::info('Setting status to [' . $newStatus . ']');
$this->setStatus($newStatus);
}
示例5: setStatusLocalReady
/**
* (non-PHPdoc)
* @see asset::setStatusLocalReady()
*/
public function setStatusLocalReady()
{
KalturaLog::debug('Setting local ready status for asset id [' . $this->getId() . ']');
$newStatus = asset::ASSET_STATUS_READY;
$externalStorages = StorageProfilePeer::retrieveExternalByPartnerId($this->getPartnerId());
foreach ($externalStorages as $externalStorage) {
// check if storage profile should affect the asset ready status
if ($externalStorage->getReadyBehavior() != StorageProfileReadyBehavior::REQUIRED) {
// current storage profile is not required for asset readiness - skipping
continue;
}
// check if export should happen now or wait for another trigger
if (!$externalStorage->triggerFitsReadyAsset($this->getEntryId())) {
KalturaLog::debug('Asset id [' . $this->getId() . '] is not ready to export to profile [' . $externalStorage->getId() . ']');
continue;
}
// check if asset needs to be exported to the remote storage
if (!$externalStorage->shouldExportFlavorAsset($this)) {
// check if asset is currently being exported to the remote storage
if (!$externalStorage->isPendingExport($this)) {
KalturaLog::debug('Should not export asset id [' . $this->getId() . '] to profile [' . $externalStorage->getId() . ']');
continue;
} else {
KalturaLog::debug('Asset id [' . $this->getId() . '] is currently being exported to profile [' . $externalStorage->getId() . ']');
}
}
KalturaLog::debug('Asset id [' . $this->getId() . '] is required to export to profile [' . $externalStorage->getId() . '] - setting status to [EXPORTING]');
$newStatus = asset::ASSET_STATUS_EXPORTING;
break;
}
KalturaLog::debug('Setting status to [' . $newStatus . ']');
$this->setStatus($newStatus);
}
示例6: reExportEntry
/**
* for each storage profile check if it still fulfills the export rules and decide if it should be exported or deleted
*
* @param entry $entry
*
*/
public static function reExportEntry(entry $entry)
{
if (!PermissionPeer::isValidForPartner(PermissionName::FEATURE_REMOTE_STORAGE_RULE, $entry->getPartnerId())) {
return;
}
if ($entry->getStatus() == entryStatus::NO_CONTENT) {
return;
}
$storageProfiles = StorageProfilePeer::retrieveExternalByPartnerId($entry->getPartnerId());
foreach ($storageProfiles as $profile) {
/* @var $profile StorageProfile */
KalturaLog::debug('Checking entry [' . $entry->getId() . ']re-export to storage [' . $profile->getId() . ']');
$scope = $profile->getScope();
$scope->setEntryId($entry->getId());
if ($profile->triggerFitsReadyAsset($entry->getId()) && $profile->fulfillsRules($scope)) {
self::tryExportEntry($entry, $profile);
} else {
self::deleteExportedEntry($entry, $profile);
}
}
}
示例7: buildRtmpFlavorAssetArray
/**
* @return array
*/
private function buildRtmpFlavorAssetArray()
{
// get initial flavor list according to tags / specific flavor request
$flavorAssets = array();
if ($this->flavorId) {
$flavorAsset = assetPeer::retrieveById($this->flavorId);
if (!$this->assetMatchesTags($flavorAsset)) {
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
}
if ($flavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_READY) {
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
}
$flavorAssets[] = $flavorAsset;
} else {
$flavorAssets = $this->getReadyFlavorsByTags();
}
$flavorAssets = $this->removeMaxBitrateFlavors($flavorAssets);
if ($this->storageId) {
// no need to further check the flavors - caller will try this storageId and fall back to local flavors if needed
return $flavorAssets;
}
$partner = $this->entry->getPartner();
// try using local flavors if they have the higher priority
if (!$partner->getStorageServePriority() || $partner->getStorageServePriority() == StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_FIRST || $partner->getStorageServePriority() == StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_ONLY) {
$localFlavors = $this->getLocalFlavors($flavorAssets);
if (count($localFlavors) || !$partner->getStorageServePriority() || $partner->getStorageServePriority() == StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_ONLY) {
return $localFlavors;
}
}
// try using remote flavors
$storages = StorageProfilePeer::retrieveExternalByPartnerId($partner->getId());
if (count($storages) == 1) {
// no need to further check the flavors - caller will try this storageId and fall back to local flavors if needed
$this->storageId = $storages[0]->getId();
return $flavorAssets;
}
if (count($storages)) {
// use the storage profile with the highest number of flavors
$storagesFlavors = array();
foreach ($storages as $storage) {
$storagesFlavors[$storage->getId()] = $this->getRemoteFlavors($flavorAssets, $storage->getId());
}
$remoteFlavors = array();
$maxCount = 0;
foreach ($storagesFlavors as $storageId => $storageFlavors) {
$count = count($storageFlavors);
if ($count > $maxCount) {
$this->storageId = $storageId;
$remoteFlavors = $storageFlavors;
$maxCount = $count;
}
}
if (count($remoteFlavors)) {
return $remoteFlavors;
}
}
if ($partner->getStorageServePriority() == StorageProfile::STORAGE_SERVE_PRIORITY_EXTERNAL_ONLY) {
// could not find any external flavors and the serve priority is external only
return array();
}
// could not find any external flavors, try local flavors
return $this->getLocalFlavors($flavorAssets);
}