Exemple #1
0
 /**
  * @param BatchJob $dbBatchJob
  * @param kPostConvertJobData $data
  * @return BatchJob|BatchJob
  */
 public static function handlePostConvertFinished(BatchJob $dbBatchJob, kPostConvertJobData $data)
 {
     if ($dbBatchJob->getExecutionStatus() == BatchJobExecutionStatus::ABORTED) {
         return $dbBatchJob;
     }
     if ($data->getCreateThumb()) {
         try {
             self::createThumbnail($dbBatchJob, $data);
         } catch (Exception $e) {
             KalturaLog::err($e->getMessage());
             // sometimes, because of disc IO load, it takes long time for the thumb to be moved.
             // in such cases, the entry thumb version may be increased by other process.
             // retry the job, it solves the issue.
             kJobsManager::retryJob($dbBatchJob->getId(), $dbBatchJob->getJobType(), true);
             $dbBatchJob->reload();
             return $dbBatchJob;
         }
     }
     $currentFlavorAsset = kBusinessPostConvertDL::handleFlavorReady($dbBatchJob, $data->getFlavorAssetId());
     if ($data->getPostConvertAssetType() == BatchJob::POSTCONVERT_ASSET_TYPE_SOURCE) {
         $convertProfileJob = $dbBatchJob->getRootJob();
         if ($convertProfileJob->getJobType() == BatchJobType::CONVERT_PROFILE) {
             try {
                 $currFlavorAsset = assetPeer::retrieveById($data->getFlavorAssetId());
                 //In cases we are returning from intermediate flow need to check maybe if another round is needed
                 //This comes to support the creation of silent audio tracks on source assets such as .arf that require initial inter flow for the source and only than the addition
                 //of the silent audio track
                 if ($currFlavorAsset instanceof flavorAsset && $currFlavorAsset->getIsOriginal() && $currFlavorAsset->getInterFlowCount() != null) {
                     //check if the inter flow count is larger than 2.
                     //In this cases probably something went wrong so we will continue with the original flow and will not check if any additioanl inter flow nneds to be done.
                     if ($currentFlavorAsset && $currFlavorAsset->getInterFlowCount() < self::MAX_INTER_FLOW_ITERATIONS_ALLOWED_ON_SOURCE) {
                         $mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($currentFlavorAsset->getId());
                         kBusinessPreConvertDL::decideProfileConvert($dbBatchJob, $convertProfileJob, $mediaInfo->getId());
                     } else {
                         kBusinessPreConvertDL::continueProfileConvert($dbBatchJob);
                     }
                 } else {
                     kBusinessPreConvertDL::continueProfileConvert($dbBatchJob);
                 }
             } catch (Exception $e) {
                 KalturaLog::err($e->getMessage());
                 kBatchManager::updateEntry($dbBatchJob->getEntryId(), entryStatus::ERROR_CONVERTING);
                 return $dbBatchJob;
             }
         } elseif ($currentFlavorAsset) {
             KalturaLog::log("Root job [" . $convertProfileJob->getId() . "] is not profile conversion");
             $syncKey = $currentFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
             if (kFileSyncUtils::fileSync_exists($syncKey)) {
                 $path = kFileSyncUtils::getLocalFilePathForKey($syncKey);
                 $entry = $dbBatchJob->getEntry();
                 if ($entry) {
                     kJobsManager::addConvertProfileJob(null, $entry, $currentFlavorAsset->getId(), $path);
                 }
             }
             $currentFlavorAsset = null;
         }
     }
     if ($currentFlavorAsset) {
         kBusinessPostConvertDL::handleConvertFinished($dbBatchJob, $currentFlavorAsset);
     }
     return $dbBatchJob;
 }
Exemple #2
0
 /**
  * @param BatchJob $dbBatchJob
  * @param kPostConvertJobData $data
  * @param BatchJob $twinJob
  * @return BatchJob|BatchJob
  */
 public static function handlePostConvertFinished(BatchJob $dbBatchJob, kPostConvertJobData $data, BatchJob $twinJob = null)
 {
     if ($dbBatchJob->getAbort()) {
         return $dbBatchJob;
     }
     if ($data->getCreateThumb()) {
         try {
             self::createThumbnail($dbBatchJob, $data);
         } catch (Exception $e) {
             KalturaLog::err($e->getMessage());
             // sometimes, because of disc IO load, it takes long time for the thumb to be moved.
             // in such cases, the entry thumb version may be increased by other process.
             // retry the job, it solves the issue.
             kJobsManager::retryJob($dbBatchJob->getId(), $dbBatchJob->getJobType(), true);
             $dbBatchJob->reload();
             return $dbBatchJob;
         }
     }
     $currentFlavorAsset = kBusinessPostConvertDL::handleFlavorReady($dbBatchJob, $data->getFlavorAssetId());
     if ($dbBatchJob->getJobSubType() == BatchJob::BATCHJOB_SUB_TYPE_POSTCONVERT_SOURCE) {
         try {
             kBusinessPreConvertDL::continueProfileConvert($dbBatchJob);
         } catch (Exception $e) {
             KalturaLog::err($e->getMessage());
             kBatchManager::updateEntry($dbBatchJob, entryStatus::ERROR_CONVERTING);
             return $dbBatchJob;
         }
     }
     if ($currentFlavorAsset) {
         kBusinessPostConvertDL::handleConvertFinished($dbBatchJob, $currentFlavorAsset);
     }
     return $dbBatchJob;
 }
 /**
  * @param BatchJob $dbBatchJob
  * @param kPostConvertJobData $data
  * @param BatchJob $twinJob
  * @return BatchJob|BatchJob
  */
 public static function handlePostConvertFinished(BatchJob $dbBatchJob, kPostConvertJobData $data, BatchJob $twinJob = null)
 {
     if ($dbBatchJob->getAbort()) {
         return $dbBatchJob;
     }
     if ($data->getCreateThumb()) {
         try {
             self::createThumbnail($dbBatchJob, $data);
         } catch (Exception $e) {
             KalturaLog::err($e->getMessage());
             // sometimes, because of disc IO load, it takes long time for the thumb to be moved.
             // in such cases, the entry thumb version may be increased by other process.
             // retry the job, it solves the issue.
             kJobsManager::retryJob($dbBatchJob->getId(), $dbBatchJob->getJobType(), true);
             $dbBatchJob->reload();
             return $dbBatchJob;
         }
     }
     $currentFlavorAsset = kBusinessPostConvertDL::handleFlavorReady($dbBatchJob, $data->getFlavorAssetId());
     if ($data->getPostConvertAssetType() == BatchJob::POSTCONVERT_ASSET_TYPE_SOURCE) {
         $convertProfileJob = $dbBatchJob->getRootJob();
         if ($convertProfileJob->getJobType() == BatchJobType::CONVERT_PROFILE) {
             try {
                 kBusinessPreConvertDL::continueProfileConvert($dbBatchJob);
             } catch (Exception $e) {
                 KalturaLog::err($e->getMessage());
                 kBatchManager::updateEntry($dbBatchJob->getEntryId(), entryStatus::ERROR_CONVERTING);
                 return $dbBatchJob;
             }
         } elseif ($currentFlavorAsset) {
             KalturaLog::log("Root job [" . $convertProfileJob->getId() . "] is not profile conversion");
             $syncKey = $currentFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
             if (kFileSyncUtils::fileSync_exists($syncKey)) {
                 KalturaLog::debug("Start conversion");
                 $path = kFileSyncUtils::getLocalFilePathForKey($syncKey);
                 $wamsAssetId = kFileSyncUtils::getWamsAssetIdForKey($syncKey);
                 kJobsManager::addConvertProfileJob(null, $dbBatchJob->getEntry(), $currentFlavorAsset->getId(), $path, $wamsAssetId);
             } else {
                 KalturaLog::debug("File sync not created yet");
             }
             $currentFlavorAsset = null;
         }
     }
     if ($currentFlavorAsset) {
         kBusinessPostConvertDL::handleConvertFinished($dbBatchJob, $currentFlavorAsset);
     }
     return $dbBatchJob;
 }