当前位置: 首页>>代码示例>>PHP>>正文


PHP kFileSyncUtils::getReadyFileSyncForKey方法代码示例

本文整理汇总了PHP中kFileSyncUtils::getReadyFileSyncForKey方法的典型用法代码示例。如果您正苦于以下问题:PHP kFileSyncUtils::getReadyFileSyncForKey方法的具体用法?PHP kFileSyncUtils::getReadyFileSyncForKey怎么用?PHP kFileSyncUtils::getReadyFileSyncForKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kFileSyncUtils的用法示例。


在下文中一共展示了kFileSyncUtils::getReadyFileSyncForKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: export

 /**
  * @param entry $entry
  * @param FileSyncKey $key
  */
 protected static function export(entry $entry, StorageProfile $externalStorage, FileSyncKey $key, $force = false)
 {
     /* @var $fileSync FileSync */
     list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($key, true, false);
     if (!$fileSync || $fileSync->getFileType() == FileSync::FILE_SYNC_FILE_TYPE_URL) {
         KalturaLog::info("no ready fileSync was found for key [{$key}]");
         return;
     }
     $externalFileSync = kFileSyncUtils::createPendingExternalSyncFileForKey($key, $externalStorage, $fileSync->getIsDir());
     $parent_file_sync = kFileSyncUtils::resolve($fileSync);
     $srcFileSyncPath = $parent_file_sync->getFileRoot() . $parent_file_sync->getFilePath();
     kJobsManager::addStorageExportJob(null, $entry->getId(), $entry->getPartnerId(), $externalStorage, $externalFileSync, $srcFileSyncPath, $force, $fileSync->getDc());
     return true;
 }
开发者ID:DBezemer,项目名称:server,代码行数:18,代码来源:kStorageExporter.php

示例2: getDownloadFileSyncAndLocal

 /**
  * 
  * @param $version
  * @param $format
  * @return FileSync
  */
 public function getDownloadFileSyncAndLocal($version = NULL, $format = null, $sub_type = null)
 {
     $flavorParams = myConversionProfileUtils::getFlavorParamsFromFileFormat($this->getPartnerId(), $format);
     if (!$flavorParams) {
         return null;
     }
     $flavorAssets = assetPeer::retrieveByEntryIdAndParams($this->getId(), $flavorParams->getId());
     if (!$flavorAssets) {
         return null;
     }
     $syncKey = $flavorAssets->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     if (!$syncKey) {
         return null;
     }
     return kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
 }
开发者ID:DBezemer,项目名称:server,代码行数:22,代码来源:DocumentEntry.php

示例3: getFileName

 /**
  * @param asset $asset
  * @params entry $entry
  * @return string
  */
 public static function getFileName(entry $entry, flavorAsset $flavorAsset = null)
 {
     $fileExt = "";
     $fileBaseName = $entry->getName();
     if ($flavorAsset) {
         $flavorParams = $flavorAsset->getFlavorParams();
         if ($flavorParams) {
             $fileBaseName = $fileBaseName . " (" . $flavorParams->getName() . ")";
         }
         $fileExt = $flavorAsset->getFileExt();
     } else {
         $syncKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
         list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
         if ($fileSync) {
             $fileExt = $fileSync->getFileExt();
         }
     }
     return array($fileBaseName, $fileExt);
 }
开发者ID:kubrickfr,项目名称:server,代码行数:24,代码来源:kAssetUtils.class.php

示例4: getFaspUrlAction

 /**
  *
  * @action getFaspUrl
  * @param string $flavorAssetId
  * @throws KalturaAPIException
  * @return string
  */
 function getFaspUrlAction($flavorAssetId)
 {
     KalturaResponseCacher::disableCache();
     $assetDb = assetPeer::retrieveById($flavorAssetId);
     if (!$assetDb || !$assetDb instanceof flavorAsset) {
         throw new KalturaAPIException(KalturaErrors::FLAVOR_ASSET_ID_NOT_FOUND, $flavorAssetId);
     }
     if (!$assetDb->isLocalReadyStatus()) {
         throw new KalturaAPIException(KalturaErrors::FLAVOR_ASSET_IS_NOT_READY);
     }
     $syncKey = $assetDb->getSyncKey(flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET);
     /* @var $fileSync FileSync */
     list($fileSync, $isFileSyncLocal) = kFileSyncUtils::getReadyFileSyncForKey($syncKey);
     $filePath = $fileSync->getFilePath();
     $transferUser = $this->getFromAsperaConfig('transfer_user');
     $transferHost = $this->getFromAsperaConfig('transfer_host');
     $asperaNodeApi = new AsperaNodeApi($this->getFromAsperaConfig('node_api_user'), $this->getFromAsperaConfig('node_api_password'), $this->getFromAsperaConfig('node_api_host'), $this->getFromAsperaConfig('node_api_port'));
     $options = array('transfer_requests' => array('transfer_request' => array('remote_host' => $transferHost)));
     $tokenResponse = $asperaNodeApi->getToken($filePath, $options);
     $token = $tokenResponse->transfer_spec->token;
     $urlParams = array('auth' => 'no', 'token' => $token);
     return 'fasp://' . $transferUser . '@' . $transferHost . $filePath . '?' . http_build_query($urlParams, '', '&');
 }
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:30,代码来源:AsperaService.php

示例5: execute

 public function execute()
 {
     //entitlement should be disabled to serveFlavor action as we do not get ks on this action.
     KalturaCriterion::disableTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY);
     requestUtils::handleConditionalGet();
     $flavorId = $this->getRequestParameter("flavorId");
     $shouldProxy = $this->getRequestParameter("forceproxy", false);
     $fileName = $this->getRequestParameter("fileName");
     $fileParam = $this->getRequestParameter("file");
     $fileParam = basename($fileParam);
     $pathOnly = $this->getRequestParameter("pathOnly", false);
     $referrer = base64_decode($this->getRequestParameter("referrer"));
     if (!is_string($referrer)) {
         // base64_decode can return binary data
         $referrer = '';
     }
     $flavorAsset = assetPeer::retrieveById($flavorId);
     if (is_null($flavorAsset)) {
         KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
     }
     $entryId = $this->getRequestParameter("entryId");
     if (!is_null($entryId) && $flavorAsset->getEntryId() != $entryId) {
         KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
     }
     if ($fileName) {
         header("Content-Disposition: attachment; filename=\"{$fileName}\"");
         header("Content-Type: application/force-download");
         header("Content-Description: File Transfer");
     }
     $clipTo = null;
     $entry = $flavorAsset->getentry();
     if (!$entry) {
         KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
     }
     KalturaMonitorClient::initApiMonitor(false, 'extwidget.serveFlavor', $flavorAsset->getPartnerId());
     myPartnerUtils::enforceDelivery($entry, $flavorAsset);
     $version = $this->getRequestParameter("v");
     if (!$version) {
         $version = $flavorAsset->getVersion();
     }
     $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET, $version);
     if ($pathOnly && kIpAddressUtils::isInternalIp($_SERVER['REMOTE_ADDR'])) {
         $path = null;
         list($file_sync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, false, false);
         if ($file_sync) {
             $parent_file_sync = kFileSyncUtils::resolve($file_sync);
             $path = $parent_file_sync->getFullPath();
             if ($fileParam && is_dir($path)) {
                 $path .= "/{$fileParam}";
             }
         }
         $renderer = new kRendererString('{"sequences":[{"clips":[{"type":"source","path":"' . $path . '"}]}]}', 'application/json');
         if ($path) {
             $this->storeCache($renderer, $flavorAsset->getPartnerId());
         }
         $renderer->output();
         KExternalErrors::dieGracefully();
     }
     if (kConf::hasParam('serve_flavor_allowed_partners') && !in_array($flavorAsset->getPartnerId(), kConf::get('serve_flavor_allowed_partners'))) {
         KExternalErrors::dieError(KExternalErrors::ACTION_BLOCKED);
     }
     if (!kFileSyncUtils::file_exists($syncKey, false)) {
         list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
         if (is_null($fileSync)) {
             KalturaLog::log("Error - no FileSync for flavor [" . $flavorAsset->getId() . "]");
             KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND);
         }
         // always dump remote urls so they will be cached by the cdn transparently
         $remoteUrl = kDataCenterMgr::getRedirectExternalUrl($fileSync);
         kFileUtils::dumpUrl($remoteUrl);
     }
     $path = kFileSyncUtils::getReadyLocalFilePathForKey($syncKey);
     $isFlv = false;
     if (!$shouldProxy) {
         $flvWrapper = new myFlvHandler($path);
         $isFlv = $flvWrapper->isFlv();
     }
     $clipFrom = $this->getRequestParameter("clipFrom", 0);
     // milliseconds
     if (is_null($clipTo)) {
         $clipTo = $this->getRequestParameter("clipTo", self::NO_CLIP_TO);
     }
     // milliseconds
     if ($clipTo == 0) {
         $clipTo = self::NO_CLIP_TO;
     }
     if (!is_numeric($clipTo) || $clipTo < 0) {
         KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'clipTo must be a positive number');
     }
     $seekFrom = $this->getRequestParameter("seekFrom", -1);
     if ($seekFrom <= 0) {
         $seekFrom = -1;
     }
     $seekFromBytes = $this->getRequestParameter("seekFromBytes", -1);
     if ($seekFromBytes <= 0) {
         $seekFromBytes = -1;
     }
     if ($fileParam && is_dir($path)) {
         $path .= "/{$fileParam}";
         kFileUtils::dumpFile($path, null, null);
//.........这里部分代码省略.........
开发者ID:DBezemer,项目名称:server,代码行数:101,代码来源:serveFlavorAction.class.php

示例6: appendFlavorAssetMrss

 /**
  * @param flavorAsset $flavorAsset
  * @param SimpleXMLElement $mrss
  * @return SimpleXMLElement
  */
 protected static function appendFlavorAssetMrss(flavorAsset $flavorAsset, SimpleXMLElement $mrss = null, kMrssParameters $mrssParams = null)
 {
     if (!$mrss) {
         $mrss = new SimpleXMLElement('<item/>');
     }
     $servePlayManifest = false;
     $playManifestClientTag = null;
     $storageId = null;
     if ($mrssParams) {
         $servePlayManifest = $mrssParams->getServePlayManifest();
         $playManifestClientTag = $mrssParams->getPlayManifestClientTag();
         $storageId = $mrssParams->getStorageId();
     }
     $content = $mrss->addChild('content');
     $content->addAttribute('url', kAssetUtils::getAssetUrl($flavorAsset, $servePlayManifest, $playManifestClientTag, $storageId));
     $content->addAttribute('flavorAssetId', $flavorAsset->getId());
     $content->addAttribute('isSource', $flavorAsset->getIsOriginal() ? 'true' : 'false');
     $content->addAttribute('containerFormat', $flavorAsset->getContainerFormat());
     $content->addAttribute('extension', $flavorAsset->getFileExt());
     $content->addAttribute('createdAt', $flavorAsset->getCreatedAt());
     // get the file size
     $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
     $fileSize = $fileSync && $fileSync->getFileSize() > 0 ? $fileSync->getFileSize() : $flavorAsset->getSize() * 1024;
     $mediaParams = array('format' => $flavorAsset->getContainerFormat(), 'videoBitrate' => $flavorAsset->getBitrate(), 'fileSize' => $fileSize, 'videoCodec' => $flavorAsset->getVideoCodecId(), 'audioBitrate' => 0, 'audioCodec' => '', 'frameRate' => $flavorAsset->getFrameRate(), 'height' => $flavorAsset->getHeight(), 'width' => $flavorAsset->getWidth());
     if (!is_null($flavorAsset->getFlavorParamsId())) {
         $content->addAttribute('flavorParamsId', $flavorAsset->getFlavorParamsId());
         $flavorParams = assetParamsPeer::retrieveByPK($flavorAsset->getFlavorParamsId());
         if ($flavorParams) {
             $content->addAttribute('flavorParamsName', $flavorParams->getName());
             $flavorParamsDetails = array('format' => $flavorParams->getFormat(), 'videoBitrate' => $flavorParams->getVideoBitrate(), 'videoCodec' => $flavorParams->getVideoCodec(), 'audioBitrate' => $flavorParams->getAudioBitrate(), 'audioCodec' => $flavorParams->getAudioCodec(), 'frameRate' => $flavorParams->getFrameRate(), 'height' => $flavorParams->getHeight(), 'width' => $flavorParams->getWidth());
             // merge the flavar param details with the flavor asset details
             // the flavor asset details take precedence whenever they exist
             $mediaParams = array_merge($flavorParamsDetails, array_filter($mediaParams));
         }
     }
     foreach ($mediaParams as $key => $value) {
         $content->addAttribute($key, $value);
     }
     $tags = $content->addChild('tags');
     foreach (explode(',', $flavorAsset->getTags()) as $tag) {
         $tags->addChild('tag', self::stringToSafeXml($tag));
     }
     if ($flavorAsset->hasTag(assetParams::TAG_SLWEB)) {
         self::addIsmLink($flavorAsset->getentry(), $mrss);
     }
 }
开发者ID:DBezemer,项目名称:server,代码行数:52,代码来源:kMrssManager.php

示例7: handleFileSyncRedirection

 private function handleFileSyncRedirection(FileSyncKey $syncKey)
 {
     list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
     if (is_null($fileSync)) {
         KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND);
     }
     if (!$local) {
         $remote_url = kDataCenterMgr::getRedirectExternalUrl($fileSync);
         $this->redirect($remote_url);
     }
 }
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:11,代码来源:downloadAction.class.php

示例8: serveAction

 /**
  * serve action returns the original file.
  * 
  * @action serve
  * @param int $id job id
  * @return file
  * 
  */
 function serveAction($id)
 {
     $c = new Criteria();
     $c->addAnd(BatchJobPeer::ID, $id);
     $c->addAnd(BatchJobPeer::PARTNER_ID, $this->getPartnerId());
     $c->addAnd(BatchJobPeer::JOB_TYPE, BatchJobType::BULKUPLOAD);
     $batchJob = BatchJobPeer::doSelectOne($c);
     if (!$batchJob) {
         throw new KalturaAPIException(KalturaErrors::BULK_UPLOAD_NOT_FOUND, $id);
     }
     KalturaLog::info("Batch job found for jobid [{$id}] bulk upload type [" . $batchJob->getJobSubType() . "]");
     $syncKey = $batchJob->getSyncKey(BatchJob::FILE_SYNC_BATCHJOB_SUB_TYPE_BULKUPLOAD);
     list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
     header("Content-Type: text/plain; charset=UTF-8");
     if ($local) {
         $filePath = $fileSync->getFullPath();
         $mimeType = kFile::mimeType($filePath);
         return $this->dumpFile($filePath, $mimeType);
     } else {
         $remoteUrl = kDataCenterMgr::getRedirectExternalUrl($fileSync);
         KalturaLog::info("Redirecting to [{$remoteUrl}]");
         header("Location: {$remoteUrl}");
         die;
     }
 }
开发者ID:DBezemer,项目名称:server,代码行数:33,代码来源:BulkService.php

示例9: generateThumbnail

 private static function generateThumbnail(asset $srcAsset, thumbParamsOutput $destThumbParamsOutput, &$errDescription, $rotate = null)
 {
     $srcSyncKey = $srcAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($srcSyncKey, true, false);
     if (!$fileSync || $fileSync->getFileType() == FileSync::FILE_SYNC_FILE_TYPE_URL) {
         $errDescription = 'Source asset could has no valid file sync';
         return false;
     }
     $srcPath = $fileSync->getFullPath();
     $uniqid = uniqid('thumb_');
     $tempDir = kConf::get('cache_root_path') . DIRECTORY_SEPARATOR . 'thumb';
     if (!file_exists($tempDir)) {
         mkdir($tempDir, 0700, true);
     }
     $destPath = $tempDir . DIRECTORY_SEPARATOR . $uniqid . '.jpg';
     $logPath = $destPath . '.log';
     if (!file_exists($srcPath)) {
         $errDescription = "Source file [{$srcPath}] does not exist";
         return false;
     }
     if (!is_file($srcPath)) {
         $errDescription = "Source file [{$srcPath}] is not a file";
         return false;
     }
     try {
         if ($srcAsset->getType() == assetType::FLAVOR) {
             /* @var $srcAsset flavorAsset */
             $dar = null;
             $mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($srcAsset->getId());
             if ($mediaInfo) {
                 $dar = $mediaInfo->getVideoDar();
             }
             // generates the thumbnail
             $thumbMaker = new KFFMpegThumbnailMaker($srcPath, $destPath, kConf::get('bin_path_ffmpeg'));
             $created = $thumbMaker->createThumnail($destThumbParamsOutput->getVideoOffset(), $srcAsset->getWidth(), $srcAsset->getHeight(), null, null, $dar);
             if (!$created || !file_exists($destPath)) {
                 $errDescription = "Thumbnail not captured";
                 return false;
             }
             $srcPath = $destPath;
             $uniqid = uniqid('thumb_');
             $tempDir = kConf::get('cache_root_path') . DIRECTORY_SEPARATOR . 'thumb';
             if (!file_exists($tempDir)) {
                 mkdir($tempDir, 0700, true);
             }
             $destPath = $tempDir . DIRECTORY_SEPARATOR . $uniqid . '.jpg';
         }
         if ($srcAsset->getType() == assetType::THUMBNAIL) {
             $tempDir = kConf::get('cache_root_path') . DIRECTORY_SEPARATOR . 'thumb';
             if (!file_exists($tempDir)) {
                 mkdir($tempDir, 0700, true);
             }
             $destPath = $tempDir . DIRECTORY_SEPARATOR . $uniqid . "." . $srcAsset->getFileExt();
         }
         $quality = $destThumbParamsOutput->getQuality();
         $cropType = $destThumbParamsOutput->getCropType();
         $cropX = $destThumbParamsOutput->getCropX();
         $cropY = $destThumbParamsOutput->getCropY();
         $cropWidth = $destThumbParamsOutput->getCropWidth();
         $cropHeight = $destThumbParamsOutput->getCropHeight();
         $bgcolor = $destThumbParamsOutput->getBackgroundColor();
         $width = $destThumbParamsOutput->getWidth();
         $height = $destThumbParamsOutput->getHeight();
         $scaleWidth = $destThumbParamsOutput->getScaleWidth();
         $scaleHeight = $destThumbParamsOutput->getScaleHeight();
         $density = $destThumbParamsOutput->getDensity();
         $stripProfiles = $destThumbParamsOutput->getStripProfiles();
         $cropper = new KImageMagickCropper($srcPath, $destPath, kConf::get('bin_path_imagemagick'), true);
         $cropped = $cropper->crop($quality, $cropType, $width, $height, $cropX, $cropY, $cropWidth, $cropHeight, $scaleWidth, $scaleHeight, $bgcolor, $density, $rotate, $stripProfiles);
         if (!$cropped || !file_exists($destPath)) {
             $errDescription = "Crop failed";
             return false;
         }
         return $destPath;
     } catch (Exception $ex) {
         $errDescription = $ex->getMessage();
         return false;
     }
 }
开发者ID:DBezemer,项目名称:server,代码行数:79,代码来源:kBusinessPreConvertDL.php

示例10: convert

 /**
  * Convert entry
  * 
  * @param string $entryId Media entry id
  * @param int $conversionProfileId
  * @param KalturaConversionAttributeArray $dynamicConversionAttributes
  * @return bigint job id
  * @throws KalturaErrors::ENTRY_ID_NOT_FOUND
  * @throws KalturaErrors::CONVERSION_PROFILE_ID_NOT_FOUND
  * @throws KalturaErrors::FLAVOR_PARAMS_NOT_FOUND
  */
 protected function convert($entryId, $conversionProfileId = null, KalturaConversionAttributeArray $dynamicConversionAttributes = null)
 {
     $entry = entryPeer::retrieveByPK($entryId);
     if (!$entry) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     $srcFlavorAsset = assetPeer::retrieveOriginalByEntryId($entryId);
     if (!$srcFlavorAsset) {
         throw new KalturaAPIException(KalturaErrors::ORIGINAL_FLAVOR_ASSET_IS_MISSING);
     }
     if (is_null($conversionProfileId) || $conversionProfileId <= 0) {
         $conversionProfile = myPartnerUtils::getConversionProfile2ForEntry($entryId);
         if (!$conversionProfile) {
             throw new KalturaAPIException(KalturaErrors::CONVERSION_PROFILE_ID_NOT_FOUND, $conversionProfileId);
         }
         $conversionProfileId = $conversionProfile->getId();
     } else {
         //The search is with the entry's partnerId. so if conversion profile wasn't found it means that the
         //conversionId is not exist or the conversion profileId does'nt belong to this partner.
         $conversionProfile = conversionProfile2Peer::retrieveByPK($conversionProfileId);
         if (is_null($conversionProfile)) {
             throw new KalturaAPIException(KalturaErrors::CONVERSION_PROFILE_ID_NOT_FOUND, $conversionProfileId);
         }
     }
     $srcSyncKey = $srcFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     // if the file sync isn't local (wasn't synced yet) proxy request to other datacenter
     list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($srcSyncKey, true, false);
     if (!$fileSync) {
         throw new KalturaAPIException(KalturaErrors::FILE_DOESNT_EXIST);
     } else {
         if (!$local) {
             kFileUtils::dumpApiRequest(kDataCenterMgr::getRemoteDcExternalUrl($fileSync));
         }
     }
     // even if it null
     $entry->setConversionQuality($conversionProfileId);
     $entry->save();
     if ($dynamicConversionAttributes) {
         $flavors = assetParamsPeer::retrieveByProfile($conversionProfileId);
         if (!count($flavors)) {
             throw new KalturaAPIException(KalturaErrors::FLAVOR_PARAMS_NOT_FOUND);
         }
         $srcFlavorParamsId = null;
         $flavorParams = $entry->getDynamicFlavorAttributes();
         foreach ($flavors as $flavor) {
             if ($flavor->hasTag(flavorParams::TAG_SOURCE)) {
                 $srcFlavorParamsId = $flavor->getId();
             }
             $flavorParams[$flavor->getId()] = $flavor;
         }
         $dynamicAttributes = array();
         foreach ($dynamicConversionAttributes as $dynamicConversionAttribute) {
             if (is_null($dynamicConversionAttribute->flavorParamsId)) {
                 $dynamicConversionAttribute->flavorParamsId = $srcFlavorParamsId;
             }
             if (is_null($dynamicConversionAttribute->flavorParamsId)) {
                 continue;
             }
             $dynamicAttributes[$dynamicConversionAttribute->flavorParamsId][trim($dynamicConversionAttribute->name)] = trim($dynamicConversionAttribute->value);
         }
         if (count($dynamicAttributes)) {
             $entry->setDynamicFlavorAttributes($dynamicAttributes);
             $entry->save();
         }
     }
     $srcFilePath = kFileSyncUtils::getLocalFilePathForKey($srcSyncKey);
     $job = kJobsManager::addConvertProfileJob(null, $entry, $srcFlavorAsset->getId(), $srcFilePath);
     if (!$job) {
         return null;
     }
     return $job->getId();
 }
开发者ID:DBezemer,项目名称:server,代码行数:83,代码来源:KalturaEntryService.php

示例11: compareContent

 /**
  * @param FileSyncKey $syncKey
  * @param string $contentMd5
  * @param bool $isFile
  * @return bool
  */
 public static function compareContent($syncKey, $contentMd5, $isFile = false)
 {
     list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, false, false);
     if (!$fileSync || !$fileSync->getContentMd5()) {
         return false;
     }
     if ($isFile) {
         return $fileSync->getContentMd5() == md5_file($contentMd5);
     } else {
         return $fileSync->getContentMd5() == md5($contentMd5);
     }
 }
开发者ID:DBezemer,项目名称:server,代码行数:18,代码来源:kFileSyncUtils.class.php

示例12: execute


//.........这里部分代码省略.........
     } elseif (!is_null($flavor)) {
         $flavorAsset = flavorAssetPeer::retrieveById($flavor);
         // when specific asset was request, we don't validate its tags
         if ($flavorAsset && ($flavorAsset->getEntryId() != $entry->getId() || $flavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_READY)) {
             $flavorAsset = null;
         }
         // we will throw an error later
     } elseif (is_null($flavor) && !is_null($flavor_param_id)) {
         $flavorAsset = flavorAssetPeer::retrieveByEntryIdAndFlavorParams($entry->getId(), $flavor_param_id);
         if ($flavorAsset && $flavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_READY) {
             $flavorAsset = null;
         }
         // we will throw an error later
     } else {
         if ($entry->getSource() == entry::ENTRY_MEDIA_SOURCE_WEBCAM) {
             $flavorAsset = flavorAssetPeer::retrieveOriginalByEntryId($entry->getId());
         } else {
             $flavorAsset = flavorAssetPeer::retrieveBestPlayByEntryId($entry->getId());
         }
         if (!$flavorAsset) {
             $flavorAssets = flavorAssetPeer::retreiveReadyByEntryIdAndTag($entry->getId(), flavorParams::TAG_WEB);
             if (count($flavorAssets) > 0) {
                 $flavorAsset = $flavorAssets[0];
             }
         }
     }
     if (is_null($flavorAsset)) {
         KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
     }
     $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     if (kFileSyncUtils::file_exists($syncKey, false)) {
         $path = kFileSyncUtils::getReadyLocalFilePathForKey($syncKey);
     } else {
         list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
         if (is_null($fileSync)) {
             KalturaLog::log("Error - no FileSync for flavor [" . $flavorAsset->getId() . "]");
             KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND);
         }
         $remoteUrl = kDataCenterMgr::getRedirectExternalUrl($fileSync);
         $this->redirect($remoteUrl);
     }
     $flv_wrapper = new myFlvHandler($path);
     $isFlv = $flv_wrapper->isFlv();
     // scrubbing is not allowed within mp4 files
     if (!$isFlv) {
         $seek_from = $seek_from_bytes = -1;
     }
     if ($seek_from !== -1 && $seek_from !== 0) {
         if ($audio_only === '0') {
             // audio_only was explicitly set to 0 - don't attempt to make further automatic investigations
         } elseif ($flv_wrapper->getFirstVideoTimestamp() < 0) {
             $audio_only = true;
         }
         list($bytes, $duration, $first_tag_byte, $to_byte) = $flv_wrapper->clip(0, -1, $audio_only);
         list($bytes, $duration, $from_byte, $to_byte, $seek_from_timestamp) = $flv_wrapper->clip($seek_from, -1, $audio_only);
         $seek_from_bytes = myFlvHandler::FLV_HEADER_SIZE + $flv_wrapper->getMetadataSize($audio_only) + $from_byte - $first_tag_byte;
     }
     // the direct path without a cdn is "http://s3kaltura.s3.amazonaws.com".$entry->getDataPath();
     $extStorageUrl = $entry->getExtStorageUrl();
     if ($extStorageUrl && substr_count($extStorageUrl, 's3kaltura')) {
         // if for some reason we didnt set our accurate $seek_from_timestamp reset it to the requested seek_from
         if ($seek_from_timestamp == -1) {
             $seek_from_timestamp = $seek_from;
         }
         $request_host = parse_url($extStorageUrl, PHP_URL_HOST);
         $akamai_url = str_replace($request_host, "cdns3akmi.kaltura.com", $extStorageUrl);
开发者ID:richhl,项目名称:kalturaCE,代码行数:67,代码来源:flvclipperAction.class.php

示例13: resizeEntryImage

 public static function resizeEntryImage(entry $entry, $version, $width, $height, $type, $bgcolor = "ffffff", $crop_provider = null, $quality = 0, $src_x = 0, $src_y = 0, $src_w = 0, $src_h = 0, $vid_sec = -1, $vid_slice = 0, $vid_slices = -1, $orig_image_path = null, $density = 0, $stripProfiles = false, $thumbParams = null, $format = null)
 {
     if (is_null($thumbParams) || !$thumbParams instanceof kThumbnailParameters) {
         $thumbParams = new kThumbnailParameters();
     }
     $contentPath = myContentStorage::getFSContentRootPath();
     $entry_status = $entry->getStatus();
     $thumbName = $entry->getId() . "_{$width}_{$height}_{$type}_{$crop_provider}_{$bgcolor}_{$quality}_{$src_x}_{$src_y}_{$src_w}_{$src_h}_{$vid_sec}_{$vid_slice}_{$vid_slices}_{$entry_status}";
     if ($orig_image_path) {
         $thumbName .= '_oip_' . basename($orig_image_path);
     }
     if ($density) {
         $thumbName .= "_dns_{$density}";
     }
     if ($stripProfiles) {
         $thumbName .= "_stp_{$stripProfiles}";
     }
     $entryThumbFilename = $entry->getThumbnail() ? $entry->getThumbnail() : "0.jpg";
     if ($entry->getStatus() != entryStatus::READY || @$entryThumbFilename[0] == '&') {
         $thumbName .= "_NOCACHE_";
     }
     // we remove the & from the template thumb otherwise getGeneralEntityPath will drop $tempThumbName from the final path
     $entryThumbFilename = str_replace("&", "", $entryThumbFilename);
     //create final path for thumbnail created
     $finalBasePath = myContentStorage::getGeneralEntityPath("entry/tempthumb", $entry->getIntId(), $thumbName, $entryThumbFilename, $version);
     $finalThumbPath = $contentPath . $finalBasePath;
     //Add unique id to the proccesing file path to avoid file being overwritten when several identical (with same parameters) calls are made before the final thumbnail is created
     $thumbName .= "_" . uniqid() . "_";
     //create path for processing thumbnail request
     $processingBasePath = myContentStorage::getGeneralEntityPath("entry/tempthumb", $entry->getIntId(), $thumbName, $entryThumbFilename, $version);
     $processingThumbPath = $contentPath . $processingBasePath;
     if (!is_null($format)) {
         $finalThumbPath = kFile::replaceExt($finalThumbPath, $format);
         $processingThumbPath = kFile::replaceExt($processingThumbPath, $format);
     }
     if (file_exists($finalThumbPath) && @filesize($finalThumbPath)) {
         header("X-Kaltura:cached-thumb-exists," . md5($finalThumbPath));
         return $finalThumbPath;
     }
     if ($orig_image_path === null || !file_exists($orig_image_path)) {
         $orig_image_path = self::getLocalImageFilePathByEntry($entry, $version);
     }
     // remark added so ffmpeg will try to load the thumbnail from the original source
     if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE && !file_exists($orig_image_path)) {
         throw new kFileSyncException('no ready filesync on current DC', kFileSyncException::FILE_DOES_NOT_EXIST_ON_CURRENT_DC);
     }
     // check a request for animated thumbs without a concrete vid_slice
     // in which case we'll create all the frames as one wide image
     $multi = $vid_slice == -1 && $vid_slices != -1;
     $count = $multi ? $vid_slices : 1;
     $im = null;
     if ($multi) {
         $vid_slice = 0;
     }
     while ($count--) {
         if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_VIDEO && ($vid_sec != -1 || $vid_slices != -1) || !file_exists($orig_image_path)) {
             if ($vid_sec != -1) {
                 $calc_vid_sec = min($vid_sec, floor($entry->getLengthInMsecs() / 1000));
             } else {
                 if ($vid_slices != -1) {
                     $calc_vid_sec = floor($entry->getLengthInMsecs() / $vid_slices * min($vid_slice, $vid_slices) / 1000);
                 } else {
                     if ($entry->getStatus() != entryStatus::READY && $entry->getLengthInMsecs() == 0) {
                         $calc_vid_sec = $entry->getPartner() && $entry->getPartner()->getDefThumbOffset() ? $entry->getPartner()->getDefThumbOffset() : 3;
                     } else {
                         $calc_vid_sec = $entry->getBestThumbOffset();
                     }
                 }
             }
             $capturedThumbName = $entry->getId() . "_sec_{$calc_vid_sec}";
             $capturedThumbPath = $contentPath . myContentStorage::getGeneralEntityPath("entry/tempthumb", $entry->getIntId(), $capturedThumbName, $entry->getThumbnail(), $version);
             $orig_image_path = $capturedThumbPath . "temp_1.jpg";
             // if we already captured the frame at that second, dont recapture, just use the existing file
             if (!file_exists($orig_image_path)) {
                 // limit creation of more than XX ffmpeg image extraction processes
                 if (kConf::hasParam("resize_thumb_max_processes_ffmpeg") && trim(exec("ps -e -ocmd|awk '{print \$1}'|grep -c " . kConf::get("bin_path_ffmpeg"))) > kConf::get("resize_thumb_max_processes_ffmpeg")) {
                     KExternalErrors::dieError(KExternalErrors::TOO_MANY_PROCESSES);
                 }
                 // creating the thumbnail is a very heavy operation
                 // prevent calling it in parallel for the same thubmnail for 5 minutes
                 $cache = new myCache("thumb-processing", 5 * 60);
                 // 5 minutes
                 $processing = $cache->get($orig_image_path);
                 if ($processing) {
                     KExternalErrors::dieError(KExternalErrors::PROCESSING_CAPTURE_THUMBNAIL);
                 }
                 $cache->put($orig_image_path, true);
                 $flavorAsset = assetPeer::retrieveHighestBitrateByEntryId($entry->getId(), flavorParams::TAG_THUMBSOURCE);
                 if (is_null($flavorAsset)) {
                     $flavorAsset = assetPeer::retrieveOriginalReadyByEntryId($entry->getId());
                     if ($flavorAsset) {
                         $flavorSyncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
                         list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($flavorSyncKey, false, false);
                         if (!$fileSync) {
                             $flavorAsset = null;
                         }
                     }
                     if (is_null($flavorAsset) || !($flavorAsset->hasTag(flavorParams::TAG_MBR) || $flavorAsset->hasTag(flavorParams::TAG_WEB))) {
                         // try the best playable
                         $flavorAsset = assetPeer::retrieveHighestBitrateByEntryId($entry->getId(), null, flavorParams::TAG_SAVE_SOURCE);
//.........这里部分代码省略.........
开发者ID:DBezemer,项目名称:server,代码行数:101,代码来源:myEntryUtils.class.php

示例14: serveFlavorAsset

 /**
  * Serves the file content
  * 
  * @action serve
  * @param flavorAsset $flavorAsset
  * @param string $fileName
  * @param bool $forceProxy
  * @return file
  * 
  * @throws KalturaErrors::FLAVOR_ASSET_IS_NOT_READY
  */
 protected function serveFlavorAsset(flavorAsset $flavorAsset, $fileName, $forceProxy = false)
 {
     $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
     if (!$fileSync) {
         throw new KalturaAPIException(KalturaErrors::FLAVOR_ASSET_IS_NOT_READY, $flavorAsset->getId());
     }
     /* @var $fileSync FileSync */
     if ($fileSync->getFileExt() != assetParams::CONTAINER_FORMAT_SWF) {
         header("Content-Disposition: attachment; filename=\"{$fileName}\"");
     }
     if ($local) {
         $filePath = $fileSync->getFullPath();
         $mimeType = kFile::mimeType($filePath);
         return $this->dumpFile($filePath, $mimeType);
     } else {
         $remoteUrl = kDataCenterMgr::getRedirectExternalUrl($fileSync);
         KalturaLog::info("Redirecting to [{$remoteUrl}]");
         if ($forceProxy) {
             kFileUtils::dumpUrl($remoteUrl);
         } else {
             // or redirect if no proxy
             header("Location: {$remoteUrl}");
             die;
         }
     }
 }
开发者ID:DBezemer,项目名称:server,代码行数:38,代码来源:DocumentsService.php

示例15: getReplacedAndReplacingFileNames

 private function getReplacedAndReplacingFileNames($asset, $fileSyncObjectSubType)
 {
     $replacingFileName = null;
     $fileName = null;
     $syncKey = $asset->getSyncKey($fileSyncObjectSubType);
     list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true);
     if ($fileSync) {
         $replacingFileName = basename($fileSync->getFilePath());
         $fileExt = pathinfo($fileSync->getFilePath(), PATHINFO_EXTENSION);
         $fileName = $asset->getEntryId() . '_' . $asset->getId() . '_' . $fileSync->getVersion() . '.' . $fileExt;
     }
     return array($replacingFileName, $fileName);
 }
开发者ID:kubrickfr,项目名称:server,代码行数:13,代码来源:serveIsmAction.class.php


注:本文中的kFileSyncUtils::getReadyFileSyncForKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。