コード例 #1
0
 public function toObject($dbCaptureThumbJobData = null, $props_to_skip = array())
 {
     if (is_null($dbCaptureThumbJobData)) {
         $dbCaptureThumbJobData = new kCaptureThumbJobData();
     }
     if ($this->thumbParamsOutput instanceof KalturaThumbParams) {
         $dbThumbParams = new thumbParamsOutput();
         $dbThumbParams = $this->thumbParamsOutput->toObject($dbThumbParams);
         $dbCaptureThumbJobData->setThumbParamsOutput($dbThumbParams);
     }
     return parent::toObject($dbCaptureThumbJobData, $props_to_skip);
 }
コード例 #2
0
ファイル: kFlowHelper.php プロジェクト: richhl/kalturaCE
 /**
  * @param BatchJob $dbBatchJob
  * @param kCaptureThumbJobData $data
  * @param BatchJob $twinJob
  * @return BatchJob
  */
 public static function handleCaptureThumbFailed(BatchJob $dbBatchJob, kCaptureThumbJobData $data, BatchJob $twinJob = null)
 {
     KalturaLog::debug("Captura thumbnail failed with destination file: " . $data->getThumbPath());
     if ($dbBatchJob->getAbort()) {
         return $dbBatchJob;
     }
     // verifies that thumb asset created
     if (!$data->getThumbAssetId()) {
         throw new APIException(APIErrors::INVALID_THUMB_ASSET_ID, $data->getThumbAssetId());
     }
     $thumbAsset = flavorAssetPeer::retrieveById($data->getThumbAssetId());
     // verifies that thumb asset exists
     if (!$thumbAsset) {
         throw new APIException(APIErrors::INVALID_THUMB_ASSET_ID, $data->getThumbAssetId());
     }
     $thumbAsset->incrementVersion();
     $thumbAsset->setStatus(thumbAsset::FLAVOR_ASSET_STATUS_ERROR);
     $thumbAsset->save();
     return $dbBatchJob;
 }
コード例 #3
0
ファイル: kJobsManager.php プロジェクト: ace3535/server
 /**
  * @param BatchJob $parentJob
  * @param int $partnerId
  * @param string $entryId
  * @param string $thumbAssetId
  * @param FileSyncKey $srcSyncKey
  * @param string $srcAssetId
  * @param int $srcAssetType enum of assetType
  * @param thumbParamsOutput $thumbParams
  * @return BatchJob
  */
 public static function addCapturaThumbJob(BatchJob $parentJob = null, $partnerId, $entryId, $thumbAssetId, FileSyncKey $srcSyncKey, $srcAssetId, $srcAssetType, thumbParamsOutput $thumbParams = null)
 {
     $thumbAsset = assetPeer::retrieveById($thumbAssetId);
     if (!$thumbAsset) {
         KalturaLog::err("No thumbnail asset found for id [{$thumbAssetId}]");
         return null;
     }
     $partner = PartnerPeer::retrieveByPK($thumbAsset->getPartnerId());
     list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($srcSyncKey, true, false);
     if (!$fileSync) {
         $thumbAsset->setStatus(asset::ASSET_STATUS_ERROR);
         $thumbAsset->setDescription("Source file sync not found: {$srcSyncKey}");
         $thumbAsset->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()) {
             $url = $fileSync->getExternalUrl($entryId);
             $originalAsset = kFileSyncUtils::retrieveObjectForSyncKey($srcSyncKey);
             if ($originalAsset instanceof flavorAsset) {
                 KalturaLog::debug("Creates import job for remote file sync [{$url}]");
                 if ($thumbParams) {
                     $thumbParams->setSourceParamsId($originalAsset->getFlavorParamsId());
                     $thumbParams->save();
                 }
                 $thumbAsset->setStatus(asset::ASSET_STATUS_WAIT_FOR_CONVERT);
                 $thumbAsset->setDescription("Source file sync is importing: {$srcSyncKey}");
                 $thumbAsset->save();
                 return kJobsManager::addImportJob($parentJob, $thumbAsset->getEntryId(), $partner->getId(), $url, $originalAsset, null, null, true);
             }
             KalturaLog::debug("Downloading remote file sync [{$url}]");
             $downloadPath = myContentStorage::getFSUploadsPath() . '/' . $thumbAsset->getId() . '.jpg';
             if (KCurlWrapper::getDataFromFile($url, $downloadPath)) {
                 kFileSyncUtils::moveFromFile($downloadPath, $srcSyncKey);
                 list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($srcSyncKey, false, false);
                 if (!$fileSync) {
                     throw new kCoreException("Source file not found for thumbnail capture [{$thumbAssetId}]", kCoreException::SOURCE_FILE_NOT_FOUND);
                 }
             }
         } else {
             throw new kCoreException("Source file not found for thumbnail capture [{$thumbAssetId}]", kCoreException::SOURCE_FILE_NOT_FOUND);
         }
     }
     $localPath = $fileSync->getFullPath();
     $remoteUrl = $fileSync->getExternalUrl($entryId);
     // creates convert data
     $data = new kCaptureThumbJobData();
     $data->setThumbAssetId($thumbAssetId);
     $data->setSrcAssetId($srcAssetId);
     $data->setSrcAssetType($srcAssetType);
     $data->setSrcFileSyncLocalPath($localPath);
     $data->setSrcFileSyncRemoteUrl($remoteUrl);
     $data->setThumbParamsOutputId($thumbParams->getId());
     $batchJob = null;
     if ($parentJob) {
         $batchJob = $parentJob->createChild(BatchJobType::CAPTURE_THUMB);
     } else {
         $batchJob = new BatchJob();
         $batchJob->setEntryId($entryId);
         $batchJob->setPartnerId($partnerId);
     }
     $batchJob->setObjectId($thumbAssetId);
     $batchJob->setObjectType(BatchJobObjectType::ASSET);
     return kJobsManager::addJob($batchJob, $data, BatchJobType::CAPTURE_THUMB);
 }
コード例 #4
0
ファイル: kFlowHelper.php プロジェクト: GElkayam/server
 /**
  * @param BatchJob $dbBatchJob
  * @param kCaptureThumbJobData $data
  * @return BatchJob
  */
 public static function handleCaptureThumbFailed(BatchJob $dbBatchJob, kCaptureThumbJobData $data)
 {
     if ($dbBatchJob->getExecutionStatus() == BatchJobExecutionStatus::ABORTED) {
         return $dbBatchJob;
     }
     // verifies that thumb asset created
     if (!$data->getThumbAssetId()) {
         throw new APIException(APIErrors::INVALID_THUMB_ASSET_ID, $data->getThumbAssetId());
     }
     $thumbAsset = assetPeer::retrieveById($data->getThumbAssetId());
     // verifies that thumb asset exists
     if (!$thumbAsset) {
         throw new APIException(APIErrors::INVALID_THUMB_ASSET_ID, $data->getThumbAssetId());
     }
     $thumbAsset->incrementVersion();
     $thumbAsset->setStatus(thumbAsset::FLAVOR_ASSET_STATUS_ERROR);
     $thumbAsset->save();
     self::handleLocalFileSyncDeletion($dbBatchJob->getEntryId(), $dbBatchJob->getPartner());
     return $dbBatchJob;
 }
コード例 #5
0
ファイル: kJobsManager.php プロジェクト: richhl/kalturaCE
 /**
  * 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 addCapturaThumbJob(BatchJob $parentJob = null, $partnerId, $entryId, $thumbAssetId, FileSyncKey $srcSyncKey, $srcAssetType, thumbParamsOutput $thumbParams = null)
 {
     list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($srcSyncKey, true, false);
     $localPath = null;
     $remoteUrl = null;
     if ($fileSync) {
         if ($fileSync->getFileType() != FileSync::FILE_SYNC_FILE_TYPE_URL) {
             $localPath = $fileSync->getFullPath();
         }
         $remoteUrl = $fileSync->getExternalUrl();
     }
     // creates convert data
     $data = new kCaptureThumbJobData();
     $data->setThumbAssetId($thumbAssetId);
     $data->setSrcAssetType($srcAssetType);
     $data->setSrcFileSyncLocalPath($localPath);
     $data->setSrcFileSyncRemoteUrl($remoteUrl);
     $data->setThumbParamsOutputId($thumbParams->getId());
     $batchJob = null;
     if ($parentJob) {
         $batchJob = $parentJob->createChild();
     } else {
         $batchJob = new BatchJob();
         $batchJob->setEntryId($entryId);
         $batchJob->setPartnerId($partnerId);
     }
     return kJobsManager::addJob($batchJob, $data, BatchJobType::CAPTURE_THUMB);
 }