コード例 #1
0
ファイル: kFlowHelper.php プロジェクト: GElkayam/server
 private static function handleOperatorsProcessingFinished(flavorAsset $flavorAsset, flavorParamsOutput $flavorParamsOutput, entry $entry, BatchJob $dbBatchJob, kConvertJobData $data, $rootBatchJob = null)
 {
     $offset = $entry->getThumbOffset();
     // entry getThumbOffset now takes the partner DefThumbOffset into consideration
     $createThumb = $entry->getCreateThumb();
     $extractMedia = true;
     if ($entry->getType() != entryType::MEDIA_CLIP) {
         // e.g. document
         $extractMedia = false;
     }
     if (!kFileSyncUtils::fileSync_exists($flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET))) {
         $extractMedia = false;
         $createThumb = false;
     }
     $rootBatchJob = $dbBatchJob->getRootJob();
     if ($extractMedia && $rootBatchJob && $rootBatchJob->getJobType() == BatchJobType::CONVERT_PROFILE) {
         $rootBatchJobData = $rootBatchJob->getData();
         if ($rootBatchJobData instanceof kConvertProfileJobData) {
             $extractMedia = $rootBatchJobData->getExtractMedia();
         }
     }
     // For apple http flavors do not attempt to get thumbs and media info,
     // It is up to the operator to provide that kind of data, rather than hardcoded check
     // To-fix
     if ($flavorParamsOutput->getFormat() == assetParams::CONTAINER_FORMAT_APPLEHTTP) {
         $createThumb = false;
         $extractMedia = false;
     }
     if ($flavorParamsOutput->getFormat() == assetParams::CONTAINER_FORMAT_WIDEVINE) {
         $createThumb = false;
     }
     if ($createThumb && in_array($flavorParamsOutput->getVideoCodec(), self::$thumbUnSupportVideoCodecs)) {
         $createThumb = false;
     }
     if ($createThumb || $extractMedia) {
         $postConvertAssetType = BatchJob::POSTCONVERT_ASSET_TYPE_FLAVOR;
         if ($flavorAsset->getIsOriginal()) {
             $postConvertAssetType = BatchJob::POSTCONVERT_ASSET_TYPE_SOURCE;
         }
         kJobsManager::addPostConvertJob($dbBatchJob, $postConvertAssetType, $data->getDestFileSyncLocalPath(), $data->getFlavorAssetId(), $flavorParamsOutput->getId(), $createThumb, $offset);
     } else {
         $flavorAsset = kBusinessPostConvertDL::handleFlavorReady($dbBatchJob, $data->getFlavorAssetId());
         if ($flavorAsset) {
             if ($flavorAsset->hasTag(flavorParams::TAG_SOURCE)) {
                 kBusinessPreConvertDL::continueProfileConvert($dbBatchJob);
             }
             if ($flavorAsset->getType() == assetType::FLAVOR) {
                 $flavorAsset->setBitrate($flavorParamsOutput->getVideoBitrate() + $flavorParamsOutput->getAudioBitrate());
                 $flavorAsset->setWidth($flavorParamsOutput->getWidth());
                 $flavorAsset->setHeight($flavorParamsOutput->getHeight());
                 $flavorAsset->setFrameRate($flavorParamsOutput->getFrameRate());
                 $flavorAsset->setIsOriginal(0);
                 $flavorAsset->save();
             }
             kBusinessPostConvertDL::handleConvertFinished($dbBatchJob, $flavorAsset);
         }
     }
 }
コード例 #2
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;
 }
コード例 #3
0
ファイル: kFlowHelper.php プロジェクト: kubrickfr/server
 /**
  * @param BatchJob $dbBatchJob
  * @param kConvertJobData $data
  * @return BatchJob
  */
 public static function handleConvertFailed(BatchJob $dbBatchJob, kConvertJobData $data)
 {
     KalturaLog::debug("Convert failed with destination file: " . $data->getDestFileSyncLocalPath());
     if ($dbBatchJob->getExecutionStatus() == BatchJobExecutionStatus::ABORTED) {
         return $dbBatchJob;
     }
     // verifies that flavor asset created
     if (!$data->getFlavorAssetId()) {
         throw new APIException(APIErrors::INVALID_FLAVOR_ASSET_ID, $data->getFlavorAssetId());
     }
     $flavorAsset = assetPeer::retrieveById($data->getFlavorAssetId());
     // verifies that flavor asset exists
     if (!$flavorAsset) {
         throw new APIException(APIErrors::INVALID_FLAVOR_ASSET_ID, $data->getFlavorAssetId());
     }
     if (!is_null($data->getEngineMessage())) {
         $flavorAsset->setDescription($flavorAsset->getDescription() . "\n" . $data->getEngineMessage());
         $flavorAsset->save();
     }
     // creats the file sync
     if (file_exists($data->getLogFileSyncLocalPath())) {
         $logSyncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_CONVERT_LOG);
         try {
             kFileSyncUtils::moveFromFile($data->getLogFileSyncLocalPath(), $logSyncKey);
         } catch (Exception $e) {
             $err = 'Saving conversion log: ' . $e->getMessage();
             KalturaLog::err($err);
             $desc = $dbBatchJob->getDescription() . "\n" . $err;
             $dbBatchJob->getDescription($desc);
         }
     }
     //		$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 = assetParamsOutputPeer::retrieveByPK($flavorParamsId);
             $fileFormat = $flavorParamsOutput->getFileExt();
             $entry = $dbBatchJob->getEntry();
             if (!$entry) {
                 return $dbBatchJob;
             }
             $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->getExecutionStatus() == BatchJobExecutionStatus::ABORTED, "message" => $dbBatchJob->getMessage(), "description" => $dbBatchJob->getDescription(), "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;
 }