コード例 #1
0
 /**
  * batch redecideFlavorConvert is the decision layer for a single flavor conversion 
  * 
  * @param string $srcFileSyncLocalPath
  * @param int $flavorAssetId
  * @param int $flavorParamsOutputId
  * @param int $mediaInfoId
  * @param BatchJob $parentJob
  * @param BatchJob $remoteConvertJob
  * @param int $lastEngineType
  * @return BatchJob 
  */
 public static function redecideFlavorConvert($flavorAssetId, $flavorParamsOutputId, $mediaInfoId, BatchJob $parentJob, $lastEngineType)
 {
     $originalFlavorAsset = flavorAssetPeer::retrieveOriginalByEntryId($parentJob->getEntryId());
     if (is_null($originalFlavorAsset)) {
         KalturaLog::log('Original flavor asset not found');
         return null;
     }
     $srcSyncKey = $originalFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     $flavor = flavorParamsOutputPeer::retrieveByPK($flavorParamsOutputId);
     if (is_null($flavor)) {
         KalturaLog::log("Flavor params output not found [{$flavorParamsOutputId}]");
         return null;
     }
     return kJobsManager::addFlavorConvertJob($srcSyncKey, $flavor, $flavorAssetId, $mediaInfoId, $parentJob, $lastEngineType);
 }
コード例 #2
0
 /**
  * @return the ready behavior
  */
 public function getReadyBehavior()
 {
     $flavorParamsOutput = $this->getFlavorParamsOutput();
     if (!$flavorParamsOutput) {
         $flavorParamsOutput = flavorParamsOutputPeer::retrieveByPK($this->getFlavorParamsOutputId());
     }
     if ($flavorParamsOutput) {
         return $flavorParamsOutput->getReadyBehavior();
     }
     return null;
 }
コード例 #3
0
ファイル: kFlowHelper.php プロジェクト: richhl/kalturaCE
 /**
  * @param BatchJob $dbBatchJob
  * @param kConvertJobData $data
  * @param BatchJob $twinJob
  * @return BatchJob
  */
 public static function handleConvertFailed(BatchJob $dbBatchJob, kConvertJobData $data, BatchJob $twinJob = null)
 {
     KalturaLog::debug("Convert failed with destination file: " . $data->getDestFileSyncLocalPath());
     if ($dbBatchJob->getAbort()) {
         return $dbBatchJob;
     }
     // verifies that flavor asset created
     if (!$data->getFlavorAssetId()) {
         throw new APIException(APIErrors::INVALID_FLAVOR_ASSET_ID, $data->getFlavorAssetId());
     }
     $flavorAsset = flavorAssetPeer::retrieveById($data->getFlavorAssetId());
     // verifies that flavor asset exists
     if (!$flavorAsset) {
         throw new APIException(APIErrors::INVALID_FLAVOR_ASSET_ID, $data->getFlavorAssetId());
     }
     $flavorAsset->incrementVersion();
     $flavorAsset->save();
     $fallbackCreated = kBusinessPostConvertDL::handleConvertFailed($dbBatchJob, $dbBatchJob->getJobSubType(), $data->getFlavorAssetId(), $data->getFlavorParamsOutputId(), $data->getMediaInfoId());
     if (!$fallbackCreated) {
         $rootBatchJob = $dbBatchJob->getRootJob();
         if ($rootBatchJob && $rootBatchJob->getJobType() == BatchJobType::BULKDOWNLOAD) {
             $entryId = $dbBatchJob->getEntryId();
             $flavorParamsId = $data->getFlavorParamsOutputId();
             $flavorParamsOutput = flavorParamsOutputPeer::retrieveByPK($flavorParamsId);
             $fileFormat = $flavorParamsOutput->getFileExt();
             $entry = $dbBatchJob->getEntry();
             $notificationData = array("puserId" => $entry->getPuserId(), "entryId" => $entry->getId(), "entryIntId" => $entry->getIntId(), "entryVersion" => $entry->getVersion(), "fileFormat" => $flavorAsset->getFileExt(), "conversionQuality" => $entry->getConversionQuality());
             $extraData = array("data" => json_encode($notificationData), "partner_id" => $entry->getPartnerId(), "puser_id" => $entry->getPuserId(), "entry_id" => $entry->getId(), "entry_int_id" => $entry->getIntId(), "entry_version" => $entry->getVersion(), "conversion_quality" => $entry->getConversionQuality(), "status" => $entry->getStatus(), "abort" => $dbBatchJob->getAbort(), "progress" => $dbBatchJob->getProgress(), "message" => $dbBatchJob->getMessage(), "description" => $dbBatchJob->getDescription(), "updates_count" => $dbBatchJob->getUpdatesCount(), "job_type" => BatchJobType::DOWNLOAD, "conversion_error" => "Error while converting [{$entryId}] [{$fileFormat}]", "status" => BatchJob::BATCHJOB_STATUS_FAILED, "progress" => 0, "debug" => __LINE__);
             myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_BATCH_JOB_FAILED, $dbBatchJob, $dbBatchJob->getPartnerId(), null, null, $extraData, $entryId);
         }
     }
     return $dbBatchJob;
 }
コード例 #4
0
ファイル: kJobsManager.php プロジェクト: richhl/kalturaCE
 /**
  * @param BatchJob $parentJob
  * @param int $jobSubType
  * @param string $srcFileSyncLocalPath
  * @param int $flavorAssetId
  * @param int $flavorParamsOutputId
  * @param bool $createThumb
  * @param int $thumbOffset
  * @return BatchJob
  */
 public static function addPostConvertJob(BatchJob $parentJob, $jobSubType, $srcFileSyncLocalPath, $flavorAssetId, $flavorParamsOutputId, $createThumb = false, $thumbOffset = 3)
 {
     $postConvertData = new kPostConvertJobData();
     $postConvertData->setSrcFileSyncLocalPath($srcFileSyncLocalPath);
     $postConvertData->setFlavorParamsOutputId($flavorParamsOutputId);
     $postConvertData->setFlavorAssetId($flavorAssetId);
     $postConvertData->setThumbOffset($thumbOffset);
     $postConvertData->setCreateThumb($createThumb);
     $parentData = $parentJob->getData();
     if ($parentData instanceof kConvartableJobData) {
         $postConvertData->setCurrentOperationSet($parentData->getCurrentOperationSet());
         $postConvertData->setCurrentOperationIndex($parentData->getCurrentOperationIndex());
     }
     if ($createThumb) {
         $flavorParamsOutput = flavorParamsOutputPeer::retrieveByPK($flavorParamsOutputId);
         if (!$flavorParamsOutput) {
             $flavorAsset = flavorAssetPeer::retrieveById($flavorAssetId);
             if ($flavorAsset) {
                 $postConvertData->setThumbHeight($flavorAsset->getHeight());
                 $postConvertData->setThumbBitrate($flavorAsset->getBitrate());
             } else {
                 $postConvertData->setCreateThumb(false);
             }
         } elseif (!$flavorParamsOutput->getVideoBitrate()) {
             $postConvertData->setCreateThumb(false);
         } else {
             $entry = $parentJob->getEntry();
             $rootBatchJob = $parentJob->getRootJob();
             if ($rootBatchJob && $rootBatchJob->getJobType() == BatchJobType::CONVERT_PROFILE) {
                 $thisFlavorHeight = $flavorParamsOutput->getHeight();
                 $thisFlavorBitrate = $flavorParamsOutput->getVideoBitrate();
                 $rootBatchJobData = $rootBatchJob->getData();
                 $createThumb = false;
                 if ($rootBatchJobData->getThumbBitrate() < $thisFlavorBitrate) {
                     $createThumb = true;
                 } elseif ($rootBatchJobData->getThumbBitrate() == $thisFlavorBitrate && $rootBatchJobData->getThumbHeight() < $thisFlavorHeight) {
                     $createThumb = true;
                 }
                 if ($createThumb) {
                     $postConvertData->setCreateThumb(true);
                     $postConvertData->setThumbHeight($thisFlavorHeight);
                     $postConvertData->setThumbBitrate($thisFlavorBitrate);
                 }
             } elseif (!$entry->getThumbnailVersion()) {
                 $thisFlavorHeight = $flavorParamsOutput->getHeight();
                 $thisFlavorBitrate = $flavorParamsOutput->getVideoBitrate();
                 $postConvertData->setCreateThumb(true);
                 $postConvertData->setThumbHeight($thisFlavorHeight);
                 $postConvertData->setThumbBitrate($thisFlavorBitrate);
             }
         }
     }
     KalturaLog::log("Post Convert created with file: " . $postConvertData->getSrcFileSyncLocalPath());
     return kJobsManager::addJob($parentJob->createChild(), $postConvertData, BatchJobType::POSTCONVERT, $jobSubType);
 }