Exemplo n.º 1
0
 /**
  * Gets an array of assetParamsOutput objects which contain a foreign key that references this object.
  *
  * If this collection has already been initialized with an identical Criteria, it returns the collection.
  * Otherwise if this asset has previously been saved, it will retrieve
  * related assetParamsOutputs from storage. If this asset is new, it will return
  * an empty collection or the current collection, the criteria is ignored on a new object.
  *
  * @param      PropelPDO $con
  * @param      Criteria $criteria
  * @return     array flavorParamsOutput[]
  * @throws     PropelException
  */
 public function getflavorParamsOutputs($criteria = null, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(assetPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collassetParamsOutputs === null) {
         if ($this->isNew()) {
             $this->collassetParamsOutputs = array();
         } else {
             $criteria->add(flavorParamsOutputPeer::FLAVOR_ASSET_ID, $this->id);
             flavorParamsOutputPeer::addSelectColumns($criteria);
             $this->collassetParamsOutputs = flavorParamsOutputPeer::doSelect($criteria, $con);
         }
     } else {
         // criteria has no effect for a new object
         if (!$this->isNew()) {
             // the following code is to determine if a new query is
             // called for.  If the criteria is the same as the last
             // one, just return the collection.
             $criteria->add(flavorParamsOutputPeer::FLAVOR_ASSET_ID, $this->id);
             flavorParamsOutputPeer::addSelectColumns($criteria);
             if (!isset($this->lastassetParamsOutputCriteria) || !$this->lastassetParamsOutputCriteria->equals($criteria)) {
                 $this->collassetParamsOutputs = flavorParamsOutputPeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastassetParamsOutputCriteria = $criteria;
     return $this->collassetParamsOutputs;
 }
Exemplo n.º 2
0
 public function clearMemory()
 {
     accessControlPeer::clearInstancePool();
     BatchJobPeer::clearInstancePool();
     BulkUploadResultPeer::clearInstancePool();
     categoryPeer::clearInstancePool();
     EmailIngestionProfilePeer::clearInstancePool();
     entryPeer::clearInstancePool();
     FileSyncPeer::clearInstancePool();
     flavorAssetPeer::clearInstancePool();
     flavorParamsConversionProfilePeer::clearInstancePool();
     flavorParamsOutputPeer::clearInstancePool();
     flavorParamsPeer::clearInstancePool();
     kshowPeer::clearInstancePool();
     mediaInfoPeer::clearInstancePool();
     moderationFlagPeer::clearInstancePool();
     moderationPeer::clearInstancePool();
     notificationPeer::clearInstancePool();
     roughcutEntryPeer::clearInstancePool();
     SchedulerConfigPeer::clearInstancePool();
     SchedulerPeer::clearInstancePool();
     SchedulerStatusPeer::clearInstancePool();
     SchedulerWorkerPeer::clearInstancePool();
     StorageProfilePeer::clearInstancePool();
     syndicationFeedPeer::clearInstancePool();
     TrackEntryPeer::clearInstancePool();
     uiConfPeer::clearInstancePool();
     UploadTokenPeer::clearInstancePool();
     // TODO clear default filters
     // TODO call all memory cleaner plugins
     if (function_exists('gc_collect_cycles')) {
         // php 5.3 and above
         gc_collect_cycles();
     }
 }
Exemplo n.º 3
0
 public function initService($serviceId, $serviceName, $actionName)
 {
     parent::initService($serviceId, $serviceName, $actionName);
     parent::applyPartnerFilterForClass(flavorAssetPeer::getInstance());
     parent::applyPartnerFilterForClass(flavorParamsPeer::getInstance());
     parent::applyPartnerFilterForClass(flavorParamsOutputPeer::getInstance());
     parent::applyPartnerFilterForClass(new entryPeer());
     parent::applyPartnerFilterForClass(new syndicationFeedPeer());
 }
Exemplo n.º 4
0
 public static function handleFlavorReady(BatchJob $dbBatchJob, $flavorAssetId)
 {
     // verifies that flavor asset created
     if (!$flavorAssetId) {
         throw new APIException(APIErrors::INVALID_FLAVOR_ASSET_ID, $flavorAssetId);
     }
     $currentFlavorAsset = flavorAssetPeer::retrieveById($flavorAssetId);
     // verifies that flavor asset exists
     if (!$currentFlavorAsset) {
         throw new APIException(APIErrors::INVALID_FLAVOR_ASSET_ID, $flavorAssetId);
     }
     // if the flavor deleted then it shouldn't be taken into ready calculations
     if ($currentFlavorAsset->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_DELETED) {
         return $currentFlavorAsset;
     }
     //		Remarked because we want the original flavor ready behavior to work the same as other flavors
     //
     //		$rootBatchJob = $dbBatchJob->getRootJob();
     //
     //		// happens in case of post convert on the original (in case of bypass)
     //		if($rootBatchJob && $currentFlavorAsset->getIsOriginal())
     //		{
     //			kJobsManager::updateBatchJob($rootBatchJob, BatchJob::BATCHJOB_STATUS_FINISHED);
     //			return $dbBatchJob;
     //		}
     $sourceMediaInfo = mediaInfoPeer::retrieveOriginalByEntryId($dbBatchJob->getEntryId());
     $productMediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($currentFlavorAsset->getId());
     $targetFlavor = flavorParamsOutputPeer::retrieveByFlavorAssetId($currentFlavorAsset->getId());
     // don't validate in case of bypass, in case target flavor or media info are null
     if ($dbBatchJob->getJobSubType() != BatchJob::BATCHJOB_SUB_TYPE_POSTCONVERT_BYPASS && $targetFlavor && $productMediaInfo) {
         try {
             $productFlavor = KDLWrap::CDLValidateProduct($sourceMediaInfo, $targetFlavor, $productMediaInfo);
         } catch (Exception $e) {
             KalturaLog::err('KDL Error: ' . print_r($e, true));
         }
         $err = kBusinessConvertDL::parseFlavorDescription($productFlavor);
         KalturaLog::debug("BCDL: job id [" . $dbBatchJob->getId() . "] flavor params output id [" . $targetFlavor->getId() . "] flavor asset id [" . $currentFlavorAsset->getId() . "] desc: {$err}");
         if (!$productFlavor->IsValid()) {
             $description = $currentFlavorAsset->getDescription() . "\n{$err}";
             // mark the asset as ready
             $currentFlavorAsset->setDescription($description);
             $currentFlavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_ERROR);
             $currentFlavorAsset->save();
             if (!kConf::get('ignore_cdl_failure')) {
                 kJobsManager::failBatchJob($dbBatchJob, $err);
                 return null;
             }
         }
     }
     // mark the asset as ready
     $currentFlavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_READY);
     $currentFlavorAsset->save();
     kFlowHelper::generateThumbnailsFromFlavor($dbBatchJob->getEntryId(), $dbBatchJob, $currentFlavorAsset->getFlavorParamsId());
     return $currentFlavorAsset;
 }
Exemplo n.º 5
0
 /**
  * 
  * @param $flavorAssetId
  * @param $flavorAssetVersion
  * @param $con
  * 
  * @return flavorParamsOutput
  */
 public static function retrieveByFlavorAssetId($flavorAssetId, $flavorAssetVersion = null, $con = null)
 {
     $criteria = new Criteria();
     $criteria->add(flavorParamsOutputPeer::FLAVOR_ASSET_ID, $flavorAssetId);
     if ($flavorAssetVersion) {
         $criteria->add(flavorParamsOutputPeer::FLAVOR_ASSET_VERSION, $flavorAssetVersion);
     } else {
         $criteria->addDescendingOrderByColumn(flavorParamsOutputPeer::FLAVOR_ASSET_VERSION);
     }
     return flavorParamsOutputPeer::doSelectOne($criteria, $con);
 }
Exemplo n.º 6
0
 public function initService($serviceId, $serviceName, $actionName)
 {
     parent::initService($serviceId, $serviceName, $actionName);
     parent::applyPartnerFilterForClass(new conversionProfile2Peer());
     parent::applyPartnerFilterForClass(flavorParamsOutputPeer::getInstance());
     parent::applyPartnerFilterForClass(flavorAssetPeer::getInstance());
     $partnerGroup = null;
     if ($actionName == 'get' || $actionName == 'list' || $actionName == 'getByEntryId' || $actionName == 'getDownloadUrl' || $actionName == 'getWebPlayableByEntryId' || $actionName == 'getFlavorAssetsWithParams' || $actionName == 'convert' || $actionName == 'reconvert') {
         $partnerGroup = $this->partnerGroup . ',0';
     }
     parent::applyPartnerFilterForClass(flavorParamsPeer::getInstance(), $partnerGroup);
 }
Exemplo n.º 7
0
 public function initService($serviceId, $serviceName, $actionName)
 {
     parent::initService($serviceId, $serviceName, $actionName);
     parent::applyPartnerFilterForClass(flavorAssetPeer::getInstance());
     parent::applyPartnerFilterForClass(flavorParamsOutputPeer::getInstance());
     parent::applyPartnerFilterForClass(new conversionProfile2Peer());
     $partnerGroup = null;
     if ($actionName == 'add' || $actionName == 'update') {
         $partnerGroup = $this->partnerGroup . ',0';
     }
     parent::applyPartnerFilterForClass(flavorParamsPeer::getInstance(), $partnerGroup);
 }
Exemplo n.º 8
0
 /**
  * @param string $entryId
  * @param string $tag
  * @param $con
  * @return array<flavorParamsOutput>
  */
 public static function retrieveByEntryIdAndTag($entryId, $tag, $con = null)
 {
     $criteria = new Criteria();
     $criteria->add(flavorParamsOutputPeer::ENTRY_ID, $entryId);
     $criteria->addDescendingOrderByColumn(flavorParamsOutputPeer::FLAVOR_ASSET_VERSION);
     $flavorParamsOutputs = flavorParamsOutputPeer::doSelect($criteria, $con);
     $ret = array();
     foreach ($flavorParamsOutputs as $flavorParamsOutput) {
         if ($flavorParamsOutput->hasTag($tag)) {
             $ret[] = $flavorParamsOutput;
         }
     }
     return $ret;
 }
 /**
  * List flavor params output objects by filter and pager
  * 
  * @action list
  * @param KalturaFlavorParamsOutputFilter $filter
  * @param KalturaFilterPager $pager
  * @return KalturaFlavorParamsOutputListResponse
  */
 function listAction(KalturaFlavorParamsOutputFilter $filter = null, KalturaFilterPager $pager = null)
 {
     if (!$filter) {
         $filter = new KalturaFlavorParamsOutputFilter();
     }
     if (!$pager) {
         $pager = new KalturaFilterPager();
     }
     $flavorParamsOutputFilter = new assetParamsOutputFilter();
     $filter->toObject($flavorParamsOutputFilter);
     $c = new Criteria();
     $flavorParamsOutputFilter->attachToCriteria($c);
     $totalCount = flavorParamsOutputPeer::doCount($c);
     $pager->attachToCriteria($c);
     $dbList = flavorParamsOutputPeer::doSelect($c);
     $list = KalturaFlavorParamsOutputArray::fromDbArray($dbList);
     $response = new KalturaFlavorParamsOutputListResponse();
     $response->objects = $list;
     $response->totalCount = $totalCount;
     return $response;
 }
Exemplo n.º 10
0
 /**
  * @param entry $entry
  */
 protected function entryDeleted(entry $entry)
 {
     $this->syncableDeleted($entry->getId(), FileSyncObjectType::ENTRY);
     // delete flavor assets
     $c = new Criteria();
     $c->add(assetPeer::ENTRY_ID, $entry->getId());
     $c->add(assetPeer::STATUS, asset::FLAVOR_ASSET_STATUS_DELETED, Criteria::NOT_EQUAL);
     $c->add(assetPeer::DELETED_AT, null, Criteria::ISNULL);
     assetPeer::resetInstanceCriteriaFilter();
     $assets = assetPeer::doSelect($c);
     foreach ($assets as $asset) {
         $asset->setStatus(asset::FLAVOR_ASSET_STATUS_DELETED);
         $asset->setDeletedAt(time());
         $asset->save();
     }
     $c = new Criteria();
     $c->add(flavorParamsOutputPeer::ENTRY_ID, $entry->getId());
     $c->add(flavorParamsOutputPeer::DELETED_AT, null, Criteria::ISNULL);
     $flavorParamsOutputs = flavorParamsOutputPeer::doSelect($c);
     foreach ($flavorParamsOutputs as $flavorParamsOutput) {
         $flavorParamsOutput->setDeletedAt(time());
         $flavorParamsOutput->save();
     }
 }
Exemplo n.º 11
0
 /**
  * batch decideAddEntryFlavor is the decision layer for adding a single flavor conversion to an entry 
  *
  * @param BatchJob $parentJob
  * @param int $entryId 
  * @param int $flavorParamsId
  * @param string $errDescription
  * @param string $flavorAssetId
  * @return BatchJob 
  */
 public static function decideAddEntryFlavor(BatchJob $parentJob = null, $entryId, $flavorParamsId, &$errDescription)
 {
     KalturaLog::log("entryId [{$entryId}], flavorParamsId [{$flavorParamsId}]");
     $originalFlavorAsset = flavorAssetPeer::retrieveOriginalByEntryId($entryId);
     if (is_null($originalFlavorAsset)) {
         $errDescription = 'Original flavor asset not found';
         KalturaLog::log(__METHOD__ . " - " . $errDescription);
         return null;
     }
     if ($originalFlavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_READY) {
         $errDescription = 'Original flavor asset not ready';
         KalturaLog::log(__METHOD__ . " - " . $errDescription);
         return null;
     }
     $mediaInfoId = null;
     $mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($originalFlavorAsset->getId());
     if ($mediaInfo) {
         $mediaInfoId = $mediaInfo->getId();
     }
     $flavorParams = flavorParamsPeer::retrieveByPK($flavorParamsId);
     $flavor = self::validateFlavorAndMediaInfo($flavorParams, $mediaInfo, $errDescription);
     if (is_null($flavor)) {
         KalturaLog::log(__METHOD__ . " - Failed to validate media info [{$errDescription}]");
         return null;
     }
     if ($parentJob) {
         // prefer the partner id from the parent job, although it should be the same
         $partnerId = $parentJob->getPartnerId();
     } else {
         $partnerId = $originalFlavorAsset->getPartnerId();
     }
     $flavorAssetId = null;
     $flavorAsset = flavorAssetPeer::retrieveByEntryIdAndFlavorParams($entryId, $flavorParamsId);
     if ($flavorAsset) {
         $flavorAssetId = $flavorAsset->getId();
     }
     $srcSyncKey = $originalFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     $flavor->_force = true;
     // force to convert the flavor, even if none complied
     $flavor->setReadyBehavior(flavorParamsConversionProfile::READY_BEHAVIOR_IGNORE);
     // should not be taken in completion rules check
     $flavorAsset = kBatchManager::createFlavorAsset($flavor, $partnerId, $entryId, $flavorAssetId);
     if (!$flavorAsset) {
         KalturaLog::err(__METHOD__ . " - Failed to create flavor asset");
         return null;
     }
     $flavorAssetId = $flavorAsset->getId();
     $collectionTag = $flavor->getCollectionTag();
     if ($collectionTag) {
         $entry = entryPeer::retrieveByPK($entryId);
         if (!$entry) {
             throw new APIException(APIErrors::INVALID_ENTRY, $parentJob, $entryId);
         }
         $dbConvertCollectionJob = null;
         if ($parentJob) {
             $dbConvertCollectionJob = $parentJob->createChild(false);
             $dbConvertCollectionJob->setEntryId($entryId);
             $dbConvertCollectionJob->save();
         }
         $flavorAssets = flavorAssetPeer::retrieveByEntryId($entryId);
         $flavorAssets = flavorAssetPeer::filterByTag($flavorAssets, $collectionTag);
         $flavors = array();
         foreach ($flavorAssets as $tagedFlavorAsset) {
             if ($tagedFlavorAsset->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_NOT_APPLICABLE || $tagedFlavorAsset->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_DELETED) {
                 continue;
             }
             $flavorParamsOutput = flavorParamsOutputPeer::retrieveByFlavorAssetId($tagedFlavorAsset->getId());
             if (is_null($flavorParamsOutput)) {
                 KalturaLog::log("Creating flavor params output for asset [" . $tagedFlavorAsset->getId() . "]");
                 $flavorParams = flavorParamsPeer::retrieveByPK($tagedFlavorAsset->getId());
                 $flavorParamsOutput = self::validateFlavorAndMediaInfo($flavorParams, $mediaInfo, $errDescription);
                 if (is_null($flavorParamsOutput)) {
                     KalturaLog::log(__METHOD__ . " - Failed to validate media info [{$errDescription}]");
                     continue;
                 }
             }
             if ($flavorParamsOutput) {
                 KalturaLog::log("Adding Collection flavor [" . $flavorParamsOutput->getId() . "] for asset [" . $tagedFlavorAsset->getId() . "]");
                 $flavors[$tagedFlavorAsset->getId()] = flavorParamsOutputPeer::retrieveByFlavorAssetId($tagedFlavorAsset->getId());
             }
         }
         if ($flavorAssetId) {
             KalturaLog::log("Updating Collection flavor [" . $flavor->getId() . "] for asset [" . $tagedFlavorAsset->getId() . "]");
             $flavors[$flavorAssetId] = $flavor;
         }
         switch ($collectionTag) {
             case flavorParams::TAG_ISM:
                 KalturaLog::log("Calling addConvertIsmCollectionJob with [" . count($flavors) . "] flavor params");
                 return kJobsManager::addConvertIsmCollectionJob($collectionTag, $srcSyncKey, $entry, $parentJob, $flavors, $dbConvertCollectionJob);
             default:
                 KalturaLog::log("Error: Invalid collection tag [{$collectionTag}]");
                 return null;
         }
     }
     $dbConvertFlavorJob = null;
     if ($parentJob) {
         $dbConvertFlavorJob = $parentJob->createChild(false);
         $dbConvertFlavorJob->setEntryId($entryId);
         $dbConvertFlavorJob->save();
     }
     return kJobsManager::addFlavorConvertJob($srcSyncKey, $flavor, $flavorAsset->getId(), $mediaInfoId, $parentJob, null, $dbConvertFlavorJob);
 }
Exemplo n.º 12
0
 /**
  * @param BatchJob $dbBatchJob
  * @param kConvertCollectionJobData $data
  * @param BatchJob $twinJob
  * @return BatchJob
  */
 public static function handleConvertCollectionFinished(BatchJob $dbBatchJob, kConvertCollectionJobData $data, BatchJob $twinJob = null)
 {
     KalturaLog::debug("Convert Collection finished for entry id: " . $dbBatchJob->getEntryId());
     if ($dbBatchJob->getAbort()) {
         return $dbBatchJob;
     }
     $entry = $dbBatchJob->getEntry();
     if (!$entry) {
         throw new APIException(APIErrors::INVALID_ENTRY, $dbBatchJob, $dbBatchJob->getEntryId());
     }
     $ismPath = $data->getDestDirLocalPath() . DIRECTORY_SEPARATOR . $data->getDestFileName() . '.ism';
     $ismcPath = $data->getDestDirLocalPath() . DIRECTORY_SEPARATOR . $data->getDestFileName() . '.ismc';
     $logPath = $data->getDestDirLocalPath() . DIRECTORY_SEPARATOR . $data->getDestFileName() . '.log';
     $thumbPath = $data->getDestDirLocalPath() . DIRECTORY_SEPARATOR . $data->getDestFileName() . '_Thumb.jpg';
     $ismContent = file_get_contents($ismPath);
     $offset = $entry->getThumbOffset();
     // entry getThumbOffset now takes the partner DefThumbOffset into consideration
     $finalFlavors = array();
     $addedFlavorParamsOutputsIds = array();
     foreach ($data->getFlavors() as $flavor) {
         // verifies that flavor asset created
         if (!$flavor->getFlavorAssetId()) {
             throw new APIException(APIErrors::INVALID_FLAVOR_ASSET_ID, $data->getFlavorAssetId());
         }
         $flavorAsset = flavorAssetPeer::retrieveById($flavor->getFlavorAssetId());
         // verifies that flavor asset exists
         if (!$flavorAsset) {
             throw new APIException(APIErrors::INVALID_FLAVOR_ASSET_ID, $flavor->getFlavorAssetId());
         }
         // increment flavor asset version (for file sync)
         $flavorAsset->incrementVersion();
         $flavorAsset->save();
         // syncing the media file
         $destFileSyncLocalPath = $flavor->getDestFileSyncLocalPath();
         if (!file_exists($destFileSyncLocalPath)) {
             continue;
         }
         $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
         kFileSyncUtils::moveFromFile($destFileSyncLocalPath, $syncKey);
         // replacing the file name in the ism file
         $oldName = basename($flavor->getDestFileSyncLocalPath());
         $flavor->setDestFileSyncLocalPath(kFileSyncUtils::getLocalFilePathForKey($syncKey));
         KalturaLog::debug("Convert archived file to: " . $flavor->getDestFileSyncLocalPath());
         $newName = basename($flavor->getDestFileSyncLocalPath());
         KalturaLog::debug("Editing ISM [{$oldName}] to [{$newName}]");
         $ismContent = str_replace("src=\"{$oldName}\"", "src=\"{$newName}\"", $ismContent);
         // creating post convert job (without thumb)
         $jobSubType = BatchJob::BATCHJOB_SUB_TYPE_POSTCONVERT_FLAVOR;
         kJobsManager::addPostConvertJob($dbBatchJob, $jobSubType, $flavor->getDestFileSyncLocalPath(), $flavor->getFlavorAssetId(), $flavor->getFlavorParamsOutputId(), file_exists($thumbPath), $offset);
         $finalFlavors[] = $flavor;
         $addedFlavorParamsOutputsIds[] = $flavor->getFlavorParamsOutputId();
     }
     // adding flavor params ids to the entry
     $addedFlavorParamsOutputs = flavorParamsOutputPeer::retrieveByPKs($addedFlavorParamsOutputsIds);
     foreach ($addedFlavorParamsOutputs as $addedFlavorParamsOutput) {
         $entry->addFlavorParamsId($addedFlavorParamsOutput->getFlavorParamsId());
     }
     $ismVersion = $entry->getIsmVersion();
     // syncing the ismc file
     if (file_exists($ismcPath)) {
         $syncKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISMC, $ismVersion);
         kFileSyncUtils::moveFromFile($ismcPath, $syncKey);
     }
     // replacing the ismc file name in the ism file
     $oldName = basename($ismcPath);
     $newName = basename(kFileSyncUtils::getLocalFilePathForKey($syncKey));
     KalturaLog::debug("Editing ISM [{$oldName}] to [{$newName}]");
     $ismContent = str_replace("content=\"{$oldName}\"", "content=\"{$newName}\"", $ismContent);
     $ismPath .= '.tmp';
     $bytesWritten = file_put_contents($ismPath, $ismContent);
     if (!$bytesWritten) {
         KalturaLog::err("Failed to update file [{$ismPath}]");
     }
     // syncing ism and lig files
     if (file_exists($ismPath)) {
         kFileSyncUtils::moveFromFile($ismPath, $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM, $ismVersion));
     }
     if (file_exists($logPath)) {
         kFileSyncUtils::moveFromFile($logPath, $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_CONVERSION_LOG, $ismVersion));
     }
     // saving entry changes
     $entry->save();
     // save the data changes to the db
     $data->setFlavors($finalFlavors);
     $dbBatchJob->setData($data);
     $dbBatchJob->save();
     // send notification if needed
     $rootBatchJob = $dbBatchJob->getRootJob();
     if ($rootBatchJob && $rootBatchJob->getJobType() == BatchJobType::BULKDOWNLOAD) {
         $localPath = kFileSyncUtils::getLocalFilePathForKey($syncKey);
         $downloadUrl = $flavorAsset->getDownloadUrl();
         $notificationData = array("puserId" => $entry->getPuserId(), "entryId" => $entry->getId(), "entryIntId" => $entry->getIntId(), "entryVersion" => $entry->getVersion(), "archivedFile" => $localPath, "downoladPath" => $localPath, "conversionQuality" => $entry->getConversionQuality(), "downloadUrl" => $downloadUrl);
         $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(), "file_format" => $flavorAsset->getFileExt(), "archived_file" => $localPath, "downolad_path" => $localPath, "target" => $localPath, "conversion_quality" => $entry->getConversionQuality(), "download_url" => $downloadUrl, "status" => $entry->getStatus(), "abort" => $dbBatchJob->getAbort(), "progress" => $dbBatchJob->getProgress(), "message" => $dbBatchJob->getMessage(), "description" => $dbBatchJob->getDescription(), "updates_count" => $dbBatchJob->getUpdatesCount(), "job_type" => BatchJobType::DOWNLOAD, "status" => BatchJob::BATCHJOB_STATUS_FINISHED, "progress" => 100, "debug" => __LINE__);
         myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_BATCH_JOB_SUCCEEDED, $dbBatchJob, $dbBatchJob->getPartnerId(), null, null, $extraData, $dbBatchJob->getEntryId());
     }
     return $dbBatchJob;
 }
Exemplo n.º 13
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;
 }
Exemplo n.º 14
0
 /**
  * @return flavorParamsOutput
  */
 public function getFlavorParamsOutput()
 {
     return flavorParamsOutputPeer::retrieveByFlavorAsset($this);
 }
Exemplo n.º 15
0
 /**
  * @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);
 }