本文整理汇总了PHP中kFileSyncUtils::getReadyExternalFileSyncForKey方法的典型用法代码示例。如果您正苦于以下问题:PHP kFileSyncUtils::getReadyExternalFileSyncForKey方法的具体用法?PHP kFileSyncUtils::getReadyExternalFileSyncForKey怎么用?PHP kFileSyncUtils::getReadyExternalFileSyncForKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kFileSyncUtils
的用法示例。
在下文中一共展示了kFileSyncUtils::getReadyExternalFileSyncForKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addParseCaptionAssetJob
/**
* @param CaptionAsset $captionAsset
* @param BatchJob $parentJob
* @throws kCoreException FILE_NOT_FOUND
* @return BatchJob
*/
public function addParseCaptionAssetJob(CaptionAsset $captionAsset, BatchJob $parentJob = null)
{
$syncKey = $captionAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET);
$fileSync = kFileSyncUtils::getReadyInternalFileSyncForKey($syncKey);
if (!$fileSync) {
if (!PermissionPeer::isValidForPartner(CaptionPermissionName::IMPORT_REMOTE_CAPTION_FOR_INDEXING, $captionAsset->getPartnerId())) {
throw new kCoreException("File sync not found: {$syncKey}", kCoreException::FILE_NOT_FOUND);
}
$fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($syncKey);
if (!$fileSync) {
throw new kCoreException("File sync not found: {$syncKey}", kCoreException::FILE_NOT_FOUND);
}
$fullPath = myContentStorage::getFSUploadsPath() . '/' . $captionAsset->getId() . '.tmp';
if (!kFile::downloadUrlToFile($fileSync->getExternalUrl($captionAsset->getEntryId()), $fullPath)) {
throw new kCoreException("File sync not found: {$syncKey}", kCoreException::FILE_NOT_FOUND);
}
kFileSyncUtils::moveFromFile($fullPath, $syncKey, true, false, true);
}
$jobData = new kParseCaptionAssetJobData();
$jobData->setCaptionAssetId($captionAsset->getId());
$batchJob = null;
if ($parentJob) {
$batchJob = $parentJob->createChild();
} else {
$batchJob = new BatchJob();
$batchJob->setEntryId($captionAsset->getEntryId());
$batchJob->setPartnerId($captionAsset->getPartnerId());
}
return kJobsManager::addJob($batchJob, $jobData, CaptionSearchPlugin::getBatchJobTypeCoreValue(CaptionSearchBatchJobType::PARSE_CAPTION_ASSET));
}
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:36,代码来源:kCaptionSearchFlowManager.php
示例2: serveAsset
/**
* @param asset $asset
* @param string $fileName
* @param bool $forceProxy
* @param int $version
* @throws KalturaErrors::FILE_DOESNT_EXIST
*/
protected function serveAsset(asset $asset, $fileName, $forceProxy = false, $version = null)
{
$syncKey = $asset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET, $version);
$fileSync = null;
$serveRemote = false;
$partner = PartnerPeer::retrieveByPK($asset->getPartnerId());
switch ($partner->getStorageServePriority()) {
case StorageProfile::STORAGE_SERVE_PRIORITY_EXTERNAL_ONLY:
$serveRemote = true;
$fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($syncKey);
if (!$fileSync || $fileSync->getStatus() != FileSync::FILE_SYNC_STATUS_READY) {
throw new KalturaAPIException(KalturaErrors::FILE_DOESNT_EXIST);
}
break;
case StorageProfile::STORAGE_SERVE_PRIORITY_EXTERNAL_FIRST:
$fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($syncKey);
if ($fileSync && $fileSync->getStatus() == FileSync::FILE_SYNC_STATUS_READY) {
$serveRemote = true;
}
break;
case StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_FIRST:
$fileSync = kFileSyncUtils::getReadyInternalFileSyncForKey($syncKey);
if ($fileSync) {
break;
}
$fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($syncKey);
if (!$fileSync || $fileSync->getStatus() != FileSync::FILE_SYNC_STATUS_READY) {
throw new KalturaAPIException(KalturaErrors::FILE_DOESNT_EXIST);
}
$serveRemote = true;
break;
case StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_ONLY:
$fileSync = kFileSyncUtils::getReadyInternalFileSyncForKey($syncKey);
if (!$fileSync) {
throw new KalturaAPIException(KalturaErrors::FILE_DOESNT_EXIST);
}
break;
}
if ($serveRemote && $fileSync) {
header("Location: " . $fileSync->getExternalUrl($asset->getEntryId()));
die;
}
return $this->serveFile($asset, asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET, $fileName, $asset->getEntryId(), $forceProxy);
}
示例3: getExternalStorageUrl
private static function getExternalStorageUrl(Partner $partner, asset $asset, FileSyncKey $key, $servePlayManifest = false, $playManifestClientTag = null, $storageId = null)
{
if (!$partner->getStorageServePriority() || $partner->getStorageServePriority() == StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_ONLY) {
return null;
}
if (is_null($storageId) && $partner->getStorageServePriority() == StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_FIRST) {
if (kFileSyncUtils::getReadyInternalFileSyncForKey($key)) {
// check if having file sync on kaltura dcs
return null;
}
}
$fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($key, $storageId);
if (!$fileSync) {
return null;
}
$storage = StorageProfilePeer::retrieveByPK($fileSync->getDc());
if (!$storage) {
return null;
}
if ($servePlayManifest) {
// in case of an https request, if a delivery profile which supports https doesn't exist use an http cdn api host
if (infraRequestUtils::getProtocol() == infraRequestUtils::PROTOCOL_HTTPS && DeliveryProfilePeer::getRemoteDeliveryByStorageId(DeliveryProfileDynamicAttributes::init($fileSync->getDc(), $asset->getEntryId(), PlaybackProtocol::HTTP, "https"))) {
$url = requestUtils::getApiCdnHost();
} else {
$url = infraRequestUtils::PROTOCOL_HTTP . "://" . kConf::get("cdn_api_host");
}
$url .= $asset->getPlayManifestUrl($playManifestClientTag, $storageId);
} else {
$urlManager = DeliveryProfilePeer::getRemoteDeliveryByStorageId(DeliveryProfileDynamicAttributes::init($fileSync->getDc(), $asset->getEntryId()));
if ($urlManager) {
$dynamicAttrs = new DeliveryProfileDynamicAttributes();
$dynamicAttrs->setFileExtension($asset->getFileExt());
$dynamicAttrs->setStorageId($fileSync->getDc());
$urlManager->setDynamicAttributes($dynamicAttrs);
$url = ltrim($urlManager->getFileSyncUrl($fileSync), '/');
if (strpos($url, "://") === false) {
$url = rtrim($urlManager->getUrl(), "/") . "/" . $url;
}
} else {
KalturaLog::debug("Couldn't determine delivery profile for storage id");
$url = null;
}
}
return $url;
}
示例4: getDownloadUrl
public function getDownloadUrl($useCdn = false, $forceProxy = false, $preview = null, $fileName = null)
{
$syncKey = $this->getSyncKey(self::FILE_SYNC_ASSET_SUB_TYPE_ASSET);
$fileSync = null;
$serveRemote = false;
$partner = PartnerPeer::retrieveByPK($this->getPartnerId());
switch ($partner->getStorageServePriority()) {
case StorageProfile::STORAGE_SERVE_PRIORITY_EXTERNAL_ONLY:
$serveRemote = true;
$fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($syncKey);
if (!$fileSync || $fileSync->getStatus() != FileSync::FILE_SYNC_STATUS_READY) {
throw new kCoreException("File sync not found: {$syncKey}", kCoreException::FILE_NOT_FOUND);
}
break;
case StorageProfile::STORAGE_SERVE_PRIORITY_EXTERNAL_FIRST:
$fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($syncKey);
if ($fileSync && $fileSync->getStatus() == FileSync::FILE_SYNC_STATUS_READY) {
$serveRemote = true;
break;
}
case StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_ONLY:
$fileSync = kFileSyncUtils::getReadyInternalFileSyncForKey($syncKey);
if (!$fileSync) {
throw new kCoreException("File sync not found: {$syncKey}", kCoreException::FILE_NOT_FOUND);
}
break;
case StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_FIRST:
$fileSync = kFileSyncUtils::getReadyInternalFileSyncForKey($syncKey);
if ($fileSync) {
break;
}
$fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($syncKey);
if (!$fileSync || $fileSync->getStatus() != FileSync::FILE_SYNC_STATUS_READY) {
throw new kCoreException("File sync not found: {$syncKey}", kCoreException::FILE_NOT_FOUND);
}
$serveRemote = true;
break;
}
if ($serveRemote && $fileSync) {
$downloadUrl = $fileSync->getExternalUrl($this->getEntryId());
} else {
$downloadUrl = $this->getDownloadUrlWithExpiry(86400, $useCdn, $forceProxy, $preview);
}
$downloadUrl = $this->finalizeDownloadUrl($fileSync, $downloadUrl, $fileName, $serveRemote);
return $downloadUrl;
}
示例5: getFileSyncForKey
private static function getFileSyncForKey(FileSyncKey $srcSyncKey, flavorParamsOutput $flavor, asset $flavorAsset, Partner $partner, &$addImportJob)
{
$addImportJob = false;
$isLocal = $flavor->getSourceRemoteStorageProfileId() == StorageProfile::STORAGE_KALTURA_DC;
if ($isLocal) {
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($srcSyncKey, true, false);
} else {
$fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($srcSyncKey, $flavor->getSourceRemoteStorageProfileId());
}
if (!$fileSync) {
kBatchManager::updateEntry($flavorAsset->getEntryId(), entryStatus::ERROR_CONVERTING);
if ($isLocal) {
$description = "Source file sync not found: {$srcSyncKey}";
} else {
$description = "Remote source file sync not found {$srcSyncKey}, storage profile id [" . $flavor->getSourceRemoteStorageProfileId() . "]";
}
$flavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_ERROR);
$flavorAsset->setDescription($description);
$flavorAsset->save();
KalturaLog::err($description);
return null;
}
if ($isLocal && !$local) {
if ($fileSync->getFileType() == FileSync::FILE_SYNC_FILE_TYPE_URL && $partner && $partner->getImportRemoteSourceForConvert()) {
$addImportJob = true;
} else {
throw new kCoreException("Source file not found for flavor conversion [{$flavorAsset->getId}()]", kCoreException::SOURCE_FILE_NOT_FOUND);
}
}
return $fileSync;
}
示例6: initSmilManifest
protected function initSmilManifest($flavorAssets)
{
$key = $this->getFlavorKeyByTag($flavorAssets, assetParams::TAG_SMIL_MANIFEST, flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET);
if (!$key) {
return false;
}
$localFileSync = kFileSyncUtils::getReadyInternalFileSyncForKey($key);
$remoteFileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($key);
if ($this->shouldUseLocalFlavors($localFileSync, $remoteFileSync)) {
$this->deliveryAttributes->setStorageId(null);
$this->deliveryAttributes->setManifestFileSync($localFileSync);
} else {
if ($remoteFileSync) {
$this->deliveryAttributes->setStorageId($remoteFileSync->getDc());
}
$this->deliveryAttributes->setManifestFileSync($remoteFileSync);
}
return !is_null($this->deliveryAttributes->getManifestFileSync());
}
示例7: getExternalStorageUrl
private function getExternalStorageUrl(Partner $partner, flavorAsset $flavorAsset, FileSyncKey $key)
{
if (!$partner->getStorageServePriority() || $partner->getStorageServePriority() == StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_ONLY) {
return null;
}
if ($partner->getStorageServePriority() == StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_FIRST) {
if (kFileSyncUtils::getReadyInternalFileSyncForKey($key)) {
// check if having file sync on kaltura dcs
return null;
}
}
$fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($key);
if (!$fileSync) {
return null;
}
$storage = StorageProfilePeer::retrieveByPK($fileSync->getDc());
if (!$storage) {
return null;
}
if ($this->syndicationFeedDb->getServePlayManifest()) {
$deliveryProfile = DeliveryProfilePeer::getRemoteDeliveryByStorageId(DeliveryProfileDynamicAttributes::init($storage->getId(), $flavorAsset->getEntryId(), PlaybackProtocol::HTTP, "https"));
$clientTag = 'feed:' . $this->syndicationFeedDb->getId();
if (is_null($deliveryProfile)) {
$url = infraRequestUtils::PROTOCOL_HTTP . "://" . kConf::get("cdn_api_host");
} else {
$url = requestUtils::getApiCdnHost();
}
$url .= $flavorAsset->getPlayManifestUrl($clientTag, $storage->getId());
} else {
$dpda = new DeliveryProfileDynamicAttributes();
$urlManager = DeliveryProfilePeer::getRemoteDeliveryByStorageId(DeliveryProfileDynamicAttributes::init($fileSync->getDc(), $flavorAsset->getEntryId()), null, $flavorAsset);
$url = ltrim($urlManager->getFileSyncUrl($fileSync), '/');
if (strpos($url, "://") === false) {
$url = rtrim($urlManager->getUrl(), "/") . "/" . $url;
}
}
return $url;
}
示例8: shouldExport
/**
* @param FileSyncKey $key
* @return bool
*/
protected function shouldExport(FileSyncKey $key, StorageProfile $externalStorage)
{
KalturaLog::log(__METHOD__ . " - key [{$key}], externalStorage id[" . $externalStorage->getId() . "]");
list($kalturaFileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($key, false, false);
if (!$kalturaFileSync) {
KalturaLog::log(__METHOD__ . " key [{$key}] not found localy");
return false;
}
KalturaLog::log(__METHOD__ . " validating file size [" . $kalturaFileSync->getFileSize() . "] is between min [" . $externalStorage->getMinFileSize() . "] and max [" . $externalStorage->getMaxFileSize() . "]");
if ($externalStorage->getMaxFileSize() && $kalturaFileSync->getFileSize() > $externalStorage->getMaxFileSize()) {
KalturaLog::log(__METHOD__ . " key [{$key}] file too big");
return false;
}
if ($externalStorage->getMinFileSize() && $kalturaFileSync->getFileSize() < $externalStorage->getMinFileSize()) {
KalturaLog::log(__METHOD__ . " key [{$key}] file too small");
return false;
}
$storageFileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($key, $externalStorage->getId());
if ($storageFileSync) {
KalturaLog::log(__METHOD__ . " key [{$key}] already exported");
return false;
}
return true;
}
示例9: addIsmLink
private static function addIsmLink(entry $entry, SimpleXMLElement $mrss)
{
if (self::$addedIsmUrl) {
return;
}
self::$addedIsmUrl = true;
$syncKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM);
$kalturaFileSync = kFileSyncUtils::getReadyInternalFileSyncForKey($syncKey);
$urlManager = DeliveryProfilePeer::getDeliveryProfile($entry->getId(), PlaybackProtocol::SILVER_LIGHT);
if (!$urlManager) {
return;
}
$urlManager->initDeliveryDynamicAttributes($kalturaFileSync);
$partner = $entry->getPartner();
if (!$partner->getStorageServePriority() || $partner->getStorageServePriority() == StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_ONLY || $partner->getStorageServePriority() == StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_FIRST) {
if ($kalturaFileSync) {
$urlPrefix = $urlManager->getUrl();
$url = $urlManager->getFileSyncUrl($kalturaFileSync, false);
$mrss->addChild('ismUrl', $urlPrefix . $url);
return;
}
}
if (!$partner->getStorageServePriority() || $partner->getStorageServePriority() == StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_ONLY) {
return null;
}
$externalFileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($syncKey);
if ($externalFileSync) {
$urlManager = DeliveryProfilePeer::getRemoteDeliveryByStorageId(DeliveryProfileDynamicAttributes::init($externalFileSync->getDc(), $entry->getId(), PlaybackProtocol::SILVER_LIGHT));
if (is_null($urlManager)) {
return;
}
$url = $urlManager->getFileSyncUrl($externalFileSync, false);
$urlPrefix = $urlManager->getUrl();
$mrss->addChild('ismUrl', $urlPrefix . $url);
return;
}
if ($partner->getStorageServePriority() != StorageProfile::STORAGE_SERVE_PRIORITY_EXTERNAL_ONLY) {
if ($kalturaFileSync) {
$url = $urlManager->getFileSyncUrl($kalturaFileSync, false);
$mrss->addChild('ismUrl', $urlPrefix . $url);
return;
}
}
}
示例10: getExternalStorageUrl
private function getExternalStorageUrl(Partner $partner, flavorAsset $flavorAsset, FileSyncKey $key)
{
if (!$partner->getStorageServePriority() || $partner->getStorageServePriority() == StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_ONLY) {
return null;
}
if ($partner->getStorageServePriority() == StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_FIRST) {
if (kFileSyncUtils::getReadyInternalFileSyncForKey($key)) {
// check if having file sync on kaltura dcs
return null;
}
}
$fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($key);
if (!$fileSync) {
return null;
}
$storage = StorageProfilePeer::retrieveByPK($fileSync->getDc());
if (!$storage) {
return null;
}
$urlManager = kUrlManager::getUrlManagerByStorageProfile($fileSync->getDc(), $flavorAsset->getEntryId());
$urlManager->setFileExtension($flavorAsset->getFileExt());
$url = $storage->getDeliveryHttpBaseUrl() . '/' . $urlManager->getFileSyncUrl($fileSync);
return $url;
}
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:24,代码来源:KalturaSyndicationFeedRenderer.php
示例11: deleteLocalContentAction
/**
* delete all local file syncs for this asset
*
* @action deleteLocalContent
* @param string $assetId
* @validateUser asset::entry assetId edit
* @throws KalturaAPIException
*/
public function deleteLocalContentAction($assetId)
{
// Retrieve required
$asset = assetPeer::retrieveById($assetId);
if (is_null($asset)) {
throw new KalturaAPIException(KalturaErrors::ASSET_ID_NOT_FOUND, $assetId);
}
$srcSyncKey = $asset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET);
$externalFileSyncs = kFileSyncUtils::getReadyExternalFileSyncForKey($srcSyncKey);
if (!$externalFileSyncs) {
throw new KalturaAPIException(KalturaErrors::NO_EXTERNAL_CONTENT_EXISTS);
}
$fileSyncs = kFileSyncUtils::getReadyInternalFileSyncsForKey($srcSyncKey);
foreach ($fileSyncs as $fileSync) {
/* @var $fileSync FileSync*/
$fileSync->setStatus(FileSync::FILE_SYNC_STATUS_DELETED);
$fileSync->save();
}
}
示例12: addFlavorConvertJob
/**
* addFlavorConvertJob adds a single flavor conversion
*
* @param FileSyncKey $srcSyncKey
* @param flavorParamsOutput $flavor
* @param int $flavorAssetId
* @param int $mediaInfoId
* @param BatchJob $parentJob
* @param int $lastEngineType
* @param BatchJob $dbConvertFlavorJob
* @return BatchJob
*/
public static function addFlavorConvertJob(FileSyncKey $srcSyncKey, flavorParamsOutput $flavor, $flavorAssetId, $mediaInfoId = null, BatchJob $parentJob = null, $lastEngineType = null, BatchJob $dbConvertFlavorJob = null)
{
$localPath = null;
$remoteUrl = null;
$flavorAsset = assetPeer::retrieveById($flavorAssetId);
if (!$flavorAsset) {
KalturaLog::err("No flavor asset found for id [{$flavorAssetId}]");
return null;
}
if ($flavor->getSourceRemoteStorageProfileId() == StorageProfile::STORAGE_KALTURA_DC) {
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($srcSyncKey, true, false);
$partner = PartnerPeer::retrieveByPK($flavorAsset->getPartnerId());
if (!$fileSync) {
kBatchManager::updateEntry($flavorAsset->getEntryId(), entryStatus::ERROR_CONVERTING);
$flavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_ERROR);
$flavorAsset->setDescription("Source file sync not found: {$srcSyncKey}");
$flavorAsset->save();
KalturaLog::err("Source file sync not found: {$srcSyncKey}");
return null;
}
if (!$local) {
if ($fileSync->getFileType() == FileSync::FILE_SYNC_FILE_TYPE_URL && $partner && $partner->getImportRemoteSourceForConvert()) {
KalturaLog::debug("Creates import job for remote file sync");
$flavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_WAIT_FOR_CONVERT);
$flavorAsset->setDescription("Source file sync is importing: {$srcSyncKey}");
$flavorAsset->save();
$originalFlavorAsset = assetPeer::retrieveOriginalByEntryId($flavorAsset->getEntryId());
$url = $fileSync->getExternalUrl($flavorAsset->getEntryId());
return kJobsManager::addImportJob($parentJob, $flavorAsset->getEntryId(), $partner->getId(), $url, $originalFlavorAsset, null, null, true);
}
throw new kCoreException("Source file not found for flavor conversion [{$flavorAssetId}]", kCoreException::SOURCE_FILE_NOT_FOUND);
}
if ($fileSync->getFileType() != FileSync::FILE_SYNC_FILE_TYPE_URL) {
$localPath = $fileSync->getFullPath();
}
$remoteUrl = $fileSync->getExternalUrl($flavorAsset->getEntryId());
} else {
$fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($srcSyncKey, $flavor->getSourceRemoteStorageProfileId());
if (!$fileSync) {
kBatchManager::updateEntry($flavorAsset->getEntryId(), entryStatus::ERROR_CONVERTING);
$description = "Remote source file sync not found {$srcSyncKey}, storage profile id [" . $flavor->getSourceRemoteStorageProfileId() . "]";
KalturaLog::err($description);
$flavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_ERROR);
$flavorAsset->setDescription($description);
$flavorAsset->save();
return null;
}
$localPath = $fileSync->getFilePath();
$remoteUrl = $fileSync->getExternalUrl($flavorAsset->getEntryId());
}
$wamsAssetId = $fileSync->getWamsAssetId();
// creates convert data
$convertData = new kConvertJobData();
$convertData->setSrcFileSyncLocalPath($localPath);
$convertData->setSrcFileSyncRemoteUrl($remoteUrl);
$convertData->setMediaInfoId($mediaInfoId);
$convertData->setFlavorParamsOutputId($flavor->getId());
$convertData->setFlavorAssetId($flavorAssetId);
$convertData->setSrcFileSyncWamsAssetId($wamsAssetId);
KalturaLog::log("Conversion engines string: '" . $flavor->getConversionEngines() . "'");
$currentConversionEngine = null;
// TODO remove after all old version flavors migrated
// parse supported engine types
$conversionEngines = array();
if (!$flavor->getEngineVersion()) {
$conversionEngines = explode(',', $flavor->getConversionEngines());
KalturaLog::log(count($conversionEngines) . " conversion engines found for the flavor");
$currentConversionEngine = reset($conversionEngines);
// gets the first engine type
}
// remove until here
if (is_null($lastEngineType)) {
KalturaLog::log("Last Engine Type is null, engine version [" . $flavor->getEngineVersion() . "]");
if ($flavor->getEngineVersion()) {
$operatorSet = new kOperatorSets();
$operatorSet->setSerialized($flavor->getOperators());
$nextOperator = $operatorSet->getOperator();
if (!$nextOperator) {
KalturaLog::err("First operator is invalid");
return null;
}
KalturaLog::log("Set first operator in first set");
$currentConversionEngine = $nextOperator->id;
}
} else {
if ($parentJob && $flavor->getEngineVersion() && ($parentJob->getJobType() == BatchJobType::CONVERT || $parentJob->getJobType() == BatchJobType::POSTCONVERT)) {
// using next oprator
KalturaLog::log("Adding next conversion operator");
//.........这里部分代码省略.........
示例13: addIsmLink
private static function addIsmLink(entry $entry, SimpleXMLElement $mrss)
{
if (self::$addedIsmUrl) {
return;
}
self::$addedIsmUrl = true;
$syncKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM);
$kalturaFileSync = kFileSyncUtils::getReadyInternalFileSyncForKey($syncKey);
$urlPrefix = myPartnerUtils::getIisHost($entry->getPartnerId(), StorageProfile::PLAY_FORMAT_HTTP);
$iisHost = parse_url($urlPrefix, PHP_URL_HOST);
$matches = null;
if (preg_match('/(https?:\\/\\/[^\\/]+)(.*)/', $urlPrefix, $matches)) {
$urlPrefix = $matches[1];
}
$urlPrefix = rtrim($urlPrefix, '/') . '/';
$urlManager = kUrlManager::getUrlManagerByCdn($iisHost, $entry->getId());
if ($kalturaFileSync) {
$urlManager->setFileExtension(pathinfo($kalturaFileSync->getFilePath(), PATHINFO_EXTENSION));
}
$urlManager->setProtocol(StorageProfile::PLAY_FORMAT_SILVER_LIGHT);
$partner = $entry->getPartner();
if (!$partner->getStorageServePriority() || $partner->getStorageServePriority() == StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_ONLY || $partner->getStorageServePriority() == StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_FIRST) {
if ($kalturaFileSync) {
$url = $urlManager->getFileSyncUrl($kalturaFileSync, false);
$mrss->addChild('ismUrl', $urlPrefix . $url);
return;
}
}
if (!$partner->getStorageServePriority() || $partner->getStorageServePriority() == StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_ONLY) {
return null;
}
$externalFileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($syncKey);
if ($externalFileSync) {
$urlManager = kUrlManager::getUrlManagerByStorageProfile($externalFileSync->getDc(), $entry->getId());
$urlManager->setFileExtension(pathinfo($externalFileSync->getFilePath(), PATHINFO_EXTENSION));
$urlManager->setProtocol(StorageProfile::PLAY_FORMAT_SILVER_LIGHT);
$url = $urlManager->getFileSyncUrl($externalFileSync, false);
$url = ltrim($url, '/');
if (strpos($url, "://") !== false) {
$urlPrefix = '';
}
$mrss->addChild('ismUrl', $urlPrefix . $url);
return;
}
if ($partner->getStorageServePriority() != StorageProfile::STORAGE_SERVE_PRIORITY_EXTERNAL_ONLY) {
if ($kalturaFileSync) {
$url = $urlManager->getFileSyncUrl($kalturaFileSync, false);
$mrss->addChild('ismUrl', $urlPrefix . $url);
return;
}
}
}
示例14: getThumbnailUrl
public function getThumbnailUrl($version = null, $protocol = null)
{
if (PermissionPeer::isValidForPartner(PermissionName::FEATURE_DISABLE_KMC_DRILL_DOWN_THUMB_RESIZE, $this->getPartnerId())) {
$subType = entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA;
if ($this->getType() == entryType::MEDIA_CLIP && $this->getMediaType() != entry::ENTRY_MEDIA_TYPE_IMAGE) {
$subType = entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB;
}
$syncKey = $this->getSyncKey($subType);
$fileSync = null;
$serveRemote = false;
$partner = PartnerPeer::retrieveByPK($this->getPartnerId());
switch ($partner->getStorageServePriority()) {
case StorageProfile::STORAGE_SERVE_PRIORITY_EXTERNAL_ONLY:
$serveRemote = true;
$fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($syncKey);
if (!$fileSync) {
return null;
}
break;
case StorageProfile::STORAGE_SERVE_PRIORITY_EXTERNAL_FIRST:
$fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($syncKey);
if ($fileSync) {
$serveRemote = true;
}
break;
case StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_FIRST:
$fileSync = kFileSyncUtils::getReadyInternalFileSyncForKey($syncKey);
if ($fileSync) {
break;
}
$fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($syncKey);
if (!$fileSync) {
return null;
}
$serveRemote = true;
break;
case StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_ONLY:
$fileSync = kFileSyncUtils::getReadyInternalFileSyncForKey($syncKey);
if (!$fileSync) {
return null;
}
break;
}
if ($serveRemote && $fileSync) {
$url = $fileSync->getExternalUrl($this->getId());
if (!is_null($protocol)) {
$url = preg_replace('/^https?/', $protocol, $url);
}
return $url;
}
}
//$path = $this->getThumbnailPath ( $version );
$path = myPartnerUtils::getUrlForPartner($this->getPartnerId(), $this->getSubpId()) . "/thumbnail/entry_id/" . $this->getId();
$current_version = $this->getThumbnailVersion();
if ($version) {
$path .= "/version/{$version}";
} else {
$path .= "/version/{$current_version}";
}
$url = myPartnerUtils::getThumbnailHost($this->getPartnerId(), $protocol) . $path;
return $url;
}
示例15: 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);
//.........这里部分代码省略.........