public static function handleFlavorReady(BatchJob $dbBatchJob, $flavorAssetId)
 {
     // verifies that flavor asset created
     if (!$flavorAssetId) {
         throw new APIException(APIErrors::INVALID_FLAVOR_ASSET_ID, $flavorAssetId);
     }
     $currentFlavorAsset = assetPeer::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 = assetParamsOutputPeer::retrieveByAssetId($currentFlavorAsset->getId());
     $postConvertData = $dbBatchJob->getData();
     $postConvertAssetType = BatchJob::POSTCONVERT_ASSET_TYPE_FLAVOR;
     if ($postConvertData instanceof kPostConvertJobData) {
         $postConvertAssetType = $postConvertData->getPostConvertAssetType();
     }
     // don't validate in case of bypass, in case target flavor or media info are null
     if ($postConvertAssetType != BatchJob::POSTCONVERT_ASSET_TYPE_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->setStatusLocalReady();
     $currentFlavorAsset->save();
     kFlowHelper::generateThumbnailsFromFlavor($dbBatchJob->getEntryId(), $dbBatchJob, $currentFlavorAsset->getFlavorParamsId());
     return $currentFlavorAsset;
 }
Esempio n. 2
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(assetParamsOutputPeer::FLAVOR_ASSET_ID, $this->id);
             assetParamsOutputPeer::addSelectColumns($criteria);
             $this->collassetParamsOutputs = assetParamsOutputPeer::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(assetParamsOutputPeer::FLAVOR_ASSET_ID, $this->id);
             assetParamsOutputPeer::addSelectColumns($criteria);
             if (!isset($this->lastassetParamsOutputCriteria) || !$this->lastassetParamsOutputCriteria->equals($criteria)) {
                 $this->collassetParamsOutputs = assetParamsOutputPeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastassetParamsOutputCriteria = $criteria;
     return $this->collassetParamsOutputs;
 }
 /**
  * Get flavor params output object by ID
  * 
  * @action get
  * @param int $id
  * @return KalturaFlavorParamsOutput
  * @throws KalturaErrors::FLAVOR_PARAMS_OUTPUT_ID_NOT_FOUND
  */
 public function getAction($id)
 {
     $flavorParamsOutputDb = assetParamsOutputPeer::retrieveByPK($id);
     if (!$flavorParamsOutputDb) {
         throw new KalturaAPIException(KalturaErrors::FLAVOR_PARAMS_OUTPUT_ID_NOT_FOUND, $id);
     }
     $flavorParamsOutput = KalturaFlavorParamsFactory::getFlavorParamsOutputInstance($flavorParamsOutputDb->getType());
     $flavorParamsOutput->fromObject($flavorParamsOutputDb, $this->getResponseProfile());
     return $flavorParamsOutput;
 }
 /**
  * Get thumb params output object by ID
  * 
  * @action get
  * @param int $id
  * @return KalturaThumbParamsOutput
  * @throws KalturaErrors::THUMB_PARAMS_OUTPUT_ID_NOT_FOUND
  */
 public function getAction($id)
 {
     $thumbParamsOutputDb = assetParamsOutputPeer::retrieveByPK($id);
     if (!$thumbParamsOutputDb) {
         throw new KalturaAPIException(KalturaErrors::THUMB_PARAMS_OUTPUT_ID_NOT_FOUND, $id);
     }
     $thumbParamsOutput = new KalturaThumbParamsOutput();
     $thumbParamsOutput->fromObject($thumbParamsOutputDb, $this->getResponseProfile());
     return $thumbParamsOutput;
 }
Esempio n. 5
0
 /**
  * 
  * @param $assetId
  * @param $assetVersion
  * @param $con
  * 
  * @return flavorParamsOutput
  */
 public static function retrieveByAssetId($assetId, $assetVersion = null, $con = null)
 {
     $criteria = new Criteria();
     $criteria->add(assetParamsOutputPeer::FLAVOR_ASSET_ID, $assetId);
     if ($assetVersion) {
         $criteria->add(assetParamsOutputPeer::FLAVOR_ASSET_VERSION, $assetVersion);
     } else {
         $criteria->addDescendingOrderByColumn(assetParamsOutputPeer::FLAVOR_ASSET_VERSION);
     }
     return assetParamsOutputPeer::doSelectOne($criteria, $con);
 }
 public function objectCreated(BaseObject $object)
 {
     $entry = entryPeer::retrieveByPK($object->getEntryId());
     if ($entry && $entry->getReplacedEntryId()) {
         $entry = entryPeer::retrieveByPK($entry->getReplacedEntryId());
     }
     $wvFlavorParamsOutput = assetParamsOutputPeer::retrieveByPK($object->getId());
     if ($entry && $wvFlavorParamsOutput) {
         $wvFlavorParamsOutput->setWidevineDistributionStartDate($this->getLicenseStartDateFromEntry($entry));
         $wvFlavorParamsOutput->setWidevineDistributionEndDate($this->getLicenseEndDateFromEntry($entry));
         $wvFlavorParamsOutput->save();
     }
     return true;
 }
Esempio n. 7
0
 public static function resetInstanceCriteriaFilter()
 {
     self::$instance = null;
     if (self::$s_criteria_filter == null) {
         self::$s_criteria_filter = new criteriaFilter();
     }
     $c = self::$s_criteria_filter->getFilter();
     if ($c) {
         $c->remove(self::DELETED_AT);
         $c->remove(self::TYPE);
     } else {
         $c = new Criteria();
     }
     $c->add(self::DELETED_AT, null, Criteria::EQUAL);
     self::$s_criteria_filter->setFilter($c);
 }
 /**
  * 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);
     $flavorTypes = KalturaPluginManager::getExtendedTypes(assetParamsOutputPeer::OM_CLASS, assetType::FLAVOR);
     $c->add(assetParamsOutputPeer::TYPE, $flavorTypes, Criteria::IN);
     $totalCount = assetParamsOutputPeer::doCount($c);
     $pager->attachToCriteria($c);
     $dbList = assetParamsOutputPeer::doSelect($c);
     $list = KalturaFlavorParamsOutputArray::fromDbArray($dbList);
     $response = new KalturaFlavorParamsOutputListResponse();
     $response->objects = $list;
     $response->totalCount = $totalCount;
     return $response;
 }
Esempio n. 9
0
 /**
  * batch getExclusiveConvertJob action allows to get a BatchJob of type CONVERT 
  * 
  * @action getExclusiveConvertJobs
  * @param KalturaExclusiveLockKey $lockKey The unique lock key from the batch-process. Is used for the locking mechanism  
  * @param int $maxExecutionTime The maximum time in seconds the job reguarly take. Is used for the locking mechanism when determining an unexpected termination of a batch-process.
  * @param int $numberOfJobs The maximum number of jobs to return. 
  * @param KalturaBatchJobFilter $filter Set of rules to fetch only rartial list of jobs  
  * @return KalturaBatchJobArray 
  */
 function getExclusiveConvertJobsAction(KalturaExclusiveLockKey $lockKey, $maxExecutionTime, $numberOfJobs, KalturaBatchJobFilter $filter = null)
 {
     $jobs = $this->getExclusiveJobs($lockKey, $maxExecutionTime, $numberOfJobs, $filter, BatchJobType::CONVERT);
     if ($jobs) {
         foreach ($jobs as &$job) {
             $data = $job->getData();
             assetParamsOutputPeer::resetInstanceCriteriaFilter();
             $flavorParamsOutput = assetParamsOutputPeer::retrieveByPK($data->getFlavorParamsOutputId());
             $data->setFlavorParamsOutput($flavorParamsOutput);
             $job->setData($data);
         }
     }
     return KalturaBatchJobArray::fromBatchJobArray($jobs);
 }
Esempio 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);
     $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(assetParamsOutputPeer::ENTRY_ID, $entry->getId());
     $c->add(assetParamsOutputPeer::DELETED_AT, null, Criteria::ISNULL);
     $flavorParamsOutputs = assetParamsOutputPeer::doSelect($c);
     foreach ($flavorParamsOutputs as $flavorParamsOutput) {
         $flavorParamsOutput->setDeletedAt(time());
         $flavorParamsOutput->save();
     }
     $filter = new categoryEntryFilter();
     $filter->setEntryIdEqual($entry->getId());
     $c = new Criteria();
     $c->add(categoryEntryPeer::ENTRY_ID, $entry->getId());
     if (!categoryEntryPeer::doSelectOne($c)) {
         return;
     }
     kJobsManager::addDeleteJob($entry->getPartnerId(), DeleteObjectType::CATEGORY_ENTRY, $filter);
 }
Esempio n. 11
0
 public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
 {
     self::getInstance();
     return parent::doSelectStmt($criteria, $con);
 }
Esempio n. 12
0
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's phpname (e.g. 'AuthorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = assetParamsOutputPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setFlavorParamsId($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setFlavorParamsVersion($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setPartnerId($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setEntryId($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setFlavorAssetId($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setFlavorAssetVersion($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setName($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setTags($arr[$keys[8]]);
     }
     if (array_key_exists($keys[9], $arr)) {
         $this->setDescription($arr[$keys[9]]);
     }
     if (array_key_exists($keys[10], $arr)) {
         $this->setReadyBehavior($arr[$keys[10]]);
     }
     if (array_key_exists($keys[11], $arr)) {
         $this->setCreatedAt($arr[$keys[11]]);
     }
     if (array_key_exists($keys[12], $arr)) {
         $this->setUpdatedAt($arr[$keys[12]]);
     }
     if (array_key_exists($keys[13], $arr)) {
         $this->setDeletedAt($arr[$keys[13]]);
     }
     if (array_key_exists($keys[14], $arr)) {
         $this->setIsDefault($arr[$keys[14]]);
     }
     if (array_key_exists($keys[15], $arr)) {
         $this->setFormat($arr[$keys[15]]);
     }
     if (array_key_exists($keys[16], $arr)) {
         $this->setVideoCodec($arr[$keys[16]]);
     }
     if (array_key_exists($keys[17], $arr)) {
         $this->setVideoBitrate($arr[$keys[17]]);
     }
     if (array_key_exists($keys[18], $arr)) {
         $this->setAudioCodec($arr[$keys[18]]);
     }
     if (array_key_exists($keys[19], $arr)) {
         $this->setAudioBitrate($arr[$keys[19]]);
     }
     if (array_key_exists($keys[20], $arr)) {
         $this->setAudioChannels($arr[$keys[20]]);
     }
     if (array_key_exists($keys[21], $arr)) {
         $this->setAudioSampleRate($arr[$keys[21]]);
     }
     if (array_key_exists($keys[22], $arr)) {
         $this->setAudioResolution($arr[$keys[22]]);
     }
     if (array_key_exists($keys[23], $arr)) {
         $this->setWidth($arr[$keys[23]]);
     }
     if (array_key_exists($keys[24], $arr)) {
         $this->setHeight($arr[$keys[24]]);
     }
     if (array_key_exists($keys[25], $arr)) {
         $this->setFrameRate($arr[$keys[25]]);
     }
     if (array_key_exists($keys[26], $arr)) {
         $this->setGopSize($arr[$keys[26]]);
     }
     if (array_key_exists($keys[27], $arr)) {
         $this->setTwoPass($arr[$keys[27]]);
     }
     if (array_key_exists($keys[28], $arr)) {
         $this->setConversionEngines($arr[$keys[28]]);
     }
     if (array_key_exists($keys[29], $arr)) {
         $this->setConversionEnginesExtraParams($arr[$keys[29]]);
     }
     if (array_key_exists($keys[30], $arr)) {
         $this->setCustomData($arr[$keys[30]]);
     }
     if (array_key_exists($keys[31], $arr)) {
         $this->setCommandLines($arr[$keys[31]]);
     }
     if (array_key_exists($keys[32], $arr)) {
         $this->setFileExt($arr[$keys[32]]);
     }
     if (array_key_exists($keys[33], $arr)) {
         $this->setDeinterlice($arr[$keys[33]]);
     }
     if (array_key_exists($keys[34], $arr)) {
         $this->setRotate($arr[$keys[34]]);
     }
     if (array_key_exists($keys[35], $arr)) {
         $this->setOperators($arr[$keys[35]]);
     }
     if (array_key_exists($keys[36], $arr)) {
         $this->setEngineVersion($arr[$keys[36]]);
     }
     if (array_key_exists($keys[37], $arr)) {
         $this->setType($arr[$keys[37]]);
     }
 }
Esempio n. 13
0
 /**
  * @return flavorParamsOutput the $flavorParamsOutput
  */
 public function getFlavorParamsOutput()
 {
     if ($this->flavorParamsOutput) {
         return $this->flavorParamsOutput;
     }
     if (is_null($this->flavorParamsOutputId)) {
         return null;
     }
     assetParamsOutputPeer::resetInstanceCriteriaFilter();
     return assetParamsOutputPeer::retrieveByPK($this->flavorParamsOutputId);
 }
Esempio n. 14
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
  * @param array<kOperationAttributes> $dynamicAttributes
  * @return BatchJob
  */
 public static function decideAddEntryFlavor(BatchJob $parentJob = null, $entryId, $flavorParamsId, &$errDescription, $flavorAssetId = null, array $dynamicAttributes = array(), $priority = 0)
 {
     KalturaLog::log("entryId [{$entryId}], flavorParamsId [{$flavorParamsId}]");
     $originalFlavorAsset = assetPeer::retrieveOriginalByEntryId($entryId);
     if (is_null($originalFlavorAsset)) {
         $errDescription = 'Original flavor asset not found';
         KalturaLog::err($errDescription);
         return null;
     }
     if ($originalFlavorAsset->getId() != $flavorAssetId && !$originalFlavorAsset->isLocalReadyStatus()) {
         $errDescription = 'Original flavor asset not ready';
         KalturaLog::err($errDescription);
         return null;
     }
     // TODO - if source flavor is remote storage, create import job and mark the flavor as FLAVOR_ASSET_STATUS_WAIT_FOR_CONVERT
     $mediaInfoId = null;
     $mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($originalFlavorAsset->getId());
     if ($mediaInfo) {
         $mediaInfoId = $mediaInfo->getId();
     }
     $flavorParams = assetParamsPeer::retrieveByPK($flavorParamsId);
     if (!$flavorParams) {
         KalturaLog::err("Flavor Params Id [{$flavorParamsId}] not found");
         return null;
     }
     $flavorParams->setDynamicAttributes($dynamicAttributes);
     self::adjustAssetParams($entryId, array($flavorParams));
     $flavor = self::validateFlavorAndMediaInfo($flavorParams, $mediaInfo, $errDescription);
     if (is_null($flavor)) {
         KalturaLog::err("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();
     }
     if (is_null($flavorAssetId)) {
         $flavorAsset = assetPeer::retrieveByEntryIdAndParams($entryId, $flavorParamsId);
         if ($flavorAsset) {
             $flavorAssetId = $flavorAsset->getId();
         }
     }
     $flavor->_force = true;
     // force to convert the flavor, even if none complied
     $conversionProfile = myPartnerUtils::getConversionProfile2ForEntry($entryId);
     if ($conversionProfile) {
         $flavorParamsConversionProfile = flavorParamsConversionProfilePeer::retrieveByFlavorParamsAndConversionProfile($flavor->getFlavorParamsId(), $conversionProfile->getId());
         if ($flavorParamsConversionProfile) {
             $flavor->setReadyBehavior($flavorParamsConversionProfile->getReadyBehavior());
         }
     }
     $flavorAsset = kBatchManager::createFlavorAsset($flavor, $partnerId, $entryId, $flavorAssetId);
     if (!$flavorAsset) {
         return null;
     }
     if (!$flavorAsset->getIsOriginal()) {
         $flavor->setReadyBehavior(flavorParamsConversionProfile::READY_BEHAVIOR_IGNORE);
     }
     // should not be taken in completion rules check
     $flavorAssetId = $flavorAsset->getId();
     $collectionTag = $flavor->getCollectionTag();
     /*
      * CHANGE: collection porcessing only for ExpressionEncoder jobs
      * to allow FFmpeg/ISMV processing
      */
     KalturaLog::log("Check for collection case - asset(" . $flavorAssetId . "),engines(" . $flavor->getConversionEngines() . ")");
     if ($collectionTag && $flavor->getConversionEngines() == conversionEngineType::EXPRESSION_ENCODER3) {
         $entry = entryPeer::retrieveByPK($entryId);
         if (!$entry) {
             throw new APIException(APIErrors::INVALID_ENTRY, $parentJob, $entryId);
         }
         $flavorAssets = assetPeer::retrieveFlavorsByEntryId($entryId);
         $flavorAssets = assetPeer::filterByTag($flavorAssets, $collectionTag);
         $flavors = array();
         foreach ($flavorAssets as $tagedFlavorAsset) {
             $errDescription = null;
             if ($tagedFlavorAsset->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_NOT_APPLICABLE || $tagedFlavorAsset->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_DELETED) {
                 continue;
             }
             $flavorParamsOutput = assetParamsOutputPeer::retrieveByAssetId($tagedFlavorAsset->getId());
             if (is_null($flavorParamsOutput)) {
                 KalturaLog::log("Creating flavor params output for asset [" . $tagedFlavorAsset->getId() . "]");
                 $flavorParams = assetParamsPeer::retrieveByPK($tagedFlavorAsset->getId());
                 self::adjustAssetParams($entryId, array($flavorParams));
                 $flavorParamsOutput = self::validateFlavorAndMediaInfo($flavorParams, $mediaInfo, $errDescription);
                 if (is_null($flavorParamsOutput)) {
                     KalturaLog::err("Failed to validate media info [{$errDescription}]");
                     continue;
                 }
             }
             if ($flavorParamsOutput) {
                 KalturaLog::log("Adding Collection flavor [" . $flavorParamsOutput->getId() . "] for asset [" . $tagedFlavorAsset->getId() . "]");
                 $flavors[$tagedFlavorAsset->getId()] = assetParamsOutputPeer::retrieveByAssetId($tagedFlavorAsset->getId());
             }
         }
         if ($flavorAssetId) {
             KalturaLog::log("Updating Collection flavor [" . $flavor->getId() . "] for asset [" . $tagedFlavorAsset->getId() . "]");
             $flavors[$flavorAssetId] = $flavor;
         }
         return self::decideCollectionConvert($collectionTag, $originalFlavorAsset, $entry, $parentJob, $flavors);
     } else {
         return self::decideFlavorConvert($flavorAsset, $flavor, $originalFlavorAsset, $conversionProfile->getId(), $mediaInfoId, $parentJob, null, false, $priority);
     }
 }
Esempio n. 15
0
 /**
  * @param BatchJob $parentJob
  * @param int $postConvertAssetType
  * @param string $srcFileSyncLocalPath
  * @param int $flavorAssetId
  * @param int $flavorParamsOutputId
  * @param bool $createThumb
  * @param int $thumbOffset
  * @param string $customData
  * @return BatchJob
  */
 public static function addPostConvertJob(BatchJob $parentJob = null, $postConvertAssetType, $srcFileSyncLocalPath, $flavorAssetId, $flavorParamsOutputId, $createThumb = false, $thumbOffset = 3)
 {
     $postConvertData = new kPostConvertJobData();
     $postConvertData->setPostConvertAssetType($postConvertAssetType);
     $postConvertData->setSrcFileSyncLocalPath($srcFileSyncLocalPath);
     $postConvertData->setFlavorParamsOutputId($flavorParamsOutputId);
     $postConvertData->setFlavorAssetId($flavorAssetId);
     $postConvertData->setThumbOffset($thumbOffset);
     $postConvertData->setCreateThumb($createThumb);
     if ($parentJob) {
         $parentData = $parentJob->getData();
         if ($parentData instanceof kConvartableJobData) {
             $postConvertData->setCurrentOperationSet($parentData->getCurrentOperationSet());
             $postConvertData->setCurrentOperationIndex($parentData->getCurrentOperationIndex());
         }
     }
     $flavorAsset = assetPeer::retrieveById($flavorAssetId);
     $flavorParamsOutput = null;
     if ($createThumb) {
         $flavorParamsOutput = assetParamsOutputPeer::retrieveByPK($flavorParamsOutputId);
         if (!$flavorParamsOutput) {
             if ($flavorAsset) {
                 $postConvertData->setThumbHeight($flavorAsset->getHeight());
                 $postConvertData->setThumbBitrate($flavorAsset->getBitrate());
             } else {
                 $postConvertData->setCreateThumb(false);
             }
         } elseif (!$flavorParamsOutput->getVideoBitrate()) {
             $postConvertData->setCreateThumb(false);
         } elseif ($flavorParamsOutput->getSourceRemoteStorageProfileId() != StorageProfile::STORAGE_KALTURA_DC) {
             $postConvertData->setCreateThumb(false);
         } elseif ($flavorAsset) {
             $entry = $flavorAsset->getentry();
             if ($entry) {
                 $thisFlavorHeight = $flavorParamsOutput->getHeight();
                 $thisFlavorBitrate = $flavorParamsOutput->getVideoBitrate();
                 $createThumb = false;
                 if ($entry->getThumbBitrate() < $thisFlavorBitrate) {
                     $createThumb = true;
                 } elseif ($entry->getThumbBitrate() == $thisFlavorBitrate && $entry->getThumbHeight() < $thisFlavorHeight) {
                     $createThumb = true;
                 }
                 if ($createThumb) {
                     $postConvertData->setCreateThumb(true);
                     $postConvertData->setThumbHeight($thisFlavorHeight);
                     $postConvertData->setThumbBitrate($thisFlavorBitrate);
                 }
             }
         }
     }
     $batchJob = null;
     $mediaParserType = $flavorParamsOutput ? $flavorParamsOutput->getMediaParserType() : mediaParserType::MEDIAINFO;
     if ($parentJob) {
         //Job will be created with parent job as his root job
         $useSameRoot = true;
         if ($parentJob->getJobType() == BatchJobType::CONVERT_PROFILE) {
             $useSameRoot = false;
         }
         $batchJob = $parentJob->createChild(BatchJobType::POSTCONVERT, $mediaParserType, $useSameRoot);
     } else {
         $batchJob = new BatchJob();
         $batchJob->setEntryId($flavorAsset->getEntryId());
         $batchJob->setPartnerId($flavorAsset->getPartnerId());
     }
     $batchJob->setObjectId($flavorAsset->getId());
     $batchJob->setObjectType(BatchJobObjectType::ASSET);
     KalturaLog::log("Post Convert created with file: " . $postConvertData->getSrcFileSyncLocalPath());
     return kJobsManager::addJob($batchJob, $postConvertData, BatchJobType::POSTCONVERT, $mediaParserType);
 }
 public static function clearMemory()
 {
     accessControlPeer::clearInstancePool();
     kuserPeer::clearInstancePool();
     kshowPeer::clearInstancePool();
     entryPeer::clearInstancePool();
     //	    kvotePeer::clearInstancePool();
     //	    commentPeer::clearInstancePool();
     //	    flagPeer::clearInstancePool();
     //	    favoritePeer::clearInstancePool();
     //	    KshowKuserPeer::clearInstancePool();
     //	    MailJobPeer::clearInstancePool();
     SchedulerPeer::clearInstancePool();
     SchedulerWorkerPeer::clearInstancePool();
     SchedulerStatusPeer::clearInstancePool();
     SchedulerConfigPeer::clearInstancePool();
     ControlPanelCommandPeer::clearInstancePool();
     BatchJobPeer::clearInstancePool();
     //	    PriorityGroupPeer::clearInstancePool();
     BulkUploadResultPeer::clearInstancePool();
     //	    blockedEmailPeer::clearInstancePool();
     //	    conversionPeer::clearInstancePool();
     //	    flickrTokenPeer::clearInstancePool();
     PuserKuserPeer::clearInstancePool();
     //	    PuserRolePeer::clearInstancePool();
     PartnerPeer::clearInstancePool();
     //	    WidgetLogPeer::clearInstancePool();
     //	    adminKuserPeer::clearInstancePool();
     //	    notificationPeer::clearInstancePool();
     moderationPeer::clearInstancePool();
     moderationFlagPeer::clearInstancePool();
     roughcutEntryPeer::clearInstancePool();
     //	    widgetPeer::clearInstancePool();
     uiConfPeer::clearInstancePool();
     //	    PartnerStatsPeer::clearInstancePool();
     //	    PartnerActivityPeer::clearInstancePool();
     ConversionProfilePeer::clearInstancePool();
     //	    ConversionParamsPeer::clearInstancePool();
     //	    KceInstallationErrorPeer::clearInstancePool();
     FileSyncPeer::clearInstancePool();
     accessControlPeer::clearInstancePool();
     mediaInfoPeer::clearInstancePool();
     assetParamsPeer::clearInstancePool();
     assetParamsOutputPeer::clearInstancePool();
     assetPeer::clearInstancePool();
     conversionProfile2Peer::clearInstancePool();
     flavorParamsConversionProfilePeer::clearInstancePool();
     categoryPeer::clearInstancePool();
     syndicationFeedPeer::clearInstancePool();
     TrackEntryPeer::clearInstancePool();
     //	    SystemUserPeer::clearInstancePool();
     StorageProfilePeer::clearInstancePool();
     //	    EmailIngestionProfilePeer::clearInstancePool();
     UploadTokenPeer::clearInstancePool();
     //	    invalidSessionPeer::clearInstancePool();
     DynamicEnumPeer::clearInstancePool();
     UserLoginDataPeer::clearInstancePool();
     PermissionPeer::clearInstancePool();
     UserRolePeer::clearInstancePool();
     PermissionItemPeer::clearInstancePool();
     PermissionToPermissionItemPeer::clearInstancePool();
     KuserToUserRolePeer::clearInstancePool();
     $pluginInstances = KalturaPluginManager::getPluginInstances('IKalturaMemoryCleaner');
     foreach ($pluginInstances as $pluginInstance) {
         $pluginInstance->cleanMemory();
     }
     if (function_exists('gc_collect_cycles')) {
         // php 5.3 and above
         gc_collect_cycles();
     }
 }
Esempio n. 17
0
        switch ($assetParamsOutput->getFormat()) {
            case assetParams::CONTAINER_FORMAT_PDF:
                $assetParamsOutput->setType(DocumentAssetType::get()->coreValue(DocumentAssetType::PDF));
                break;
            case assetParams::CONTAINER_FORMAT_SWF:
                $assetParamsOutput->setType(DocumentAssetType::get()->coreValue(DocumentAssetType::SWF));
                break;
            case thumbParams::CONTAINER_FORMAT_JPG:
                $assetParamsOutput->setType(assetType::THUMBNAIL);
                break;
            default:
                $assetParamsOutput->setType(assetType::FLAVOR);
                $assetParamsOutput->putInCustomData(flavorParams::CUSTOM_DATA_FIELD_VIDEO_CODEC, $assetParamsOutput->getVideoCodec());
                $assetParamsOutput->putInCustomData(flavorParams::CUSTOM_DATA_FIELD_VIDEO_BITRATE, $assetParamsOutput->getVideoBitrate());
                $assetParamsOutput->putInCustomData(flavorParams::CUSTOM_DATA_FIELD_AUDIO_CODEC, $assetParamsOutput->getAudioCodec());
                $assetParamsOutput->putInCustomData(flavorParams::CUSTOM_DATA_FIELD_AUDIO_BITRATE, $assetParamsOutput->getAudioBitrate());
                $assetParamsOutput->putInCustomData(flavorParams::CUSTOM_DATA_FIELD_AUDIO_CHANNELS, $assetParamsOutput->getAudioChannels());
                $assetParamsOutput->putInCustomData(flavorParams::CUSTOM_DATA_FIELD_AUDIO_SAMPLE_RATE, $assetParamsOutput->getAudioSampleRate());
                $assetParamsOutput->putInCustomData(flavorParams::CUSTOM_DATA_FIELD_AUDIO_RESOLUTION, $assetParamsOutput->getAudioResolution());
                $assetParamsOutput->putInCustomData(flavorParams::CUSTOM_DATA_FIELD_FRAME_RATE, $assetParamsOutput->getFrameRate());
                $assetParamsOutput->putInCustomData(flavorParams::CUSTOM_DATA_FIELD_GOP_SIZE, $assetParamsOutput->getGopSize());
                $assetParamsOutput->putInCustomData(flavorParams::CUSTOM_DATA_FIELD_TWO_PASS, $assetParamsOutput->getTwoPass());
                $assetParamsOutput->putInCustomData(flavorParams::CUSTOM_DATA_FIELD_DEINTERLICE, $assetParamsOutput->getDeinterlice());
                $assetParamsOutput->putInCustomData(flavorParams::CUSTOM_DATA_FIELD_ROTATE, $assetParamsOutput->getRotate());
        }
        $assetParamsOutput->save();
    }
    assetParamsOutputPeer::clearInstancePool();
    $assetParamsOutputs = assetParamsOutputPeer::doSelect($c, $con);
}
KalturaLog::log('Done');
 public function getFieldNameFromPeer($field_name)
 {
     $res = assetParamsOutputPeer::translateFieldName($field_name, $this->field_name_translation_type, BasePeer::TYPE_COLNAME);
     return $res;
 }
Esempio n. 19
0
 /**
  * @return flavorParamsOutput
  */
 public function getFlavorParamsOutput()
 {
     return assetParamsOutputPeer::retrieveByAsset($this);
 }
Esempio n. 20
0
 /**
  * @param BatchJob $dbBatchJob
  * @param kConvertJobData $data
  * @return BatchJob
  */
 public static function handleConvertFailed(BatchJob $dbBatchJob, kConvertJobData $data)
 {
     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;
 }
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(assetParamsOutputPeer::DATABASE_NAME);
         $criteria->add(assetParamsOutputPeer::ID, $pks, Criteria::IN);
         $objs = assetParamsOutputPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Esempio n. 22
0
 /**
  * Builds a Criteria object containing the primary key for this object.
  *
  * Unlike buildCriteria() this method includes the primary key values regardless
  * of whether or not they have been modified.
  *
  * @return     Criteria The Criteria object containing value(s) for primary key(s).
  */
 public function buildPkeyCriteria()
 {
     $criteria = new Criteria(assetParamsOutputPeer::DATABASE_NAME);
     $criteria->add(assetParamsOutputPeer::ID, $this->id);
     if ($this->alreadyInSave && count($this->modifiedColumns) == 2 && $this->isColumnModified(assetParamsOutputPeer::UPDATED_AT)) {
         $theModifiedColumn = null;
         foreach ($this->modifiedColumns as $modifiedColumn) {
             if ($modifiedColumn != assetParamsOutputPeer::UPDATED_AT) {
                 $theModifiedColumn = $modifiedColumn;
             }
         }
         $atomicColumns = assetParamsOutputPeer::getAtomicColumns();
         if (in_array($theModifiedColumn, $atomicColumns)) {
             $criteria->add($theModifiedColumn, $this->getByName($theModifiedColumn, BasePeer::TYPE_COLNAME), Criteria::NOT_EQUAL);
         }
     }
     return $criteria;
 }
 /**
  * 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
  * @param array<kOperationAttributes> $dynamicAttributes
  * @return BatchJob 
  */
 public static function decideAddEntryFlavor(BatchJob $parentJob = null, $entryId, $flavorParamsId, &$errDescription, $flavorAssetId = null, array $dynamicAttributes = array())
 {
     KalturaLog::log("entryId [{$entryId}], flavorParamsId [{$flavorParamsId}]");
     $originalFlavorAsset = assetPeer::retrieveOriginalByEntryId($entryId);
     if (is_null($originalFlavorAsset)) {
         $errDescription = 'Original flavor asset not found';
         KalturaLog::err($errDescription);
         return null;
     }
     if ($originalFlavorAsset->getId() != $flavorAssetId && !$originalFlavorAsset->isLocalReadyStatus()) {
         $errDescription = 'Original flavor asset not ready';
         KalturaLog::err($errDescription);
         return null;
     }
     // TODO - if source flavor is remote storage, create import job and mark the flavor as FLAVOR_ASSET_STATUS_WAIT_FOR_CONVERT
     $mediaInfoId = null;
     $mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($originalFlavorAsset->getId());
     if ($mediaInfo) {
         $mediaInfoId = $mediaInfo->getId();
     }
     $flavorParams = assetParamsPeer::retrieveByPK($flavorParamsId);
     if (!$flavorParams) {
         KalturaLog::err("Flavor Params Id [{$flavorParamsId}] not found");
         return null;
     }
     $flavorParams->setDynamicAttributes($dynamicAttributes);
     $flavor = self::validateFlavorAndMediaInfo($flavorParams, $mediaInfo, $errDescription);
     if (is_null($flavor)) {
         KalturaLog::err("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();
     }
     if (is_null($flavorAssetId)) {
         $flavorAsset = assetPeer::retrieveByEntryIdAndParams($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
     $conversionProfile = myPartnerUtils::getConversionProfile2ForEntry($entryId);
     if ($conversionProfile) {
         $flavorParamsConversionProfile = flavorParamsConversionProfilePeer::retrieveByFlavorParamsAndConversionProfile($flavor->getFlavorParamsId(), $conversionProfile->getId());
         if ($flavorParamsConversionProfile) {
             $flavor->setReadyBehavior($flavorParamsConversionProfile->getReadyBehavior());
         }
     }
     $flavorAsset = kBatchManager::createFlavorAsset($flavor, $partnerId, $entryId, $flavorAssetId);
     if (!$flavorAsset) {
         KalturaLog::err("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 = assetPeer::retrieveFlavorsByEntryId($entryId);
         $flavorAssets = assetPeer::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 = assetParamsOutputPeer::retrieveByAssetId($tagedFlavorAsset->getId());
             if (is_null($flavorParamsOutput)) {
                 KalturaLog::log("Creating flavor params output for asset [" . $tagedFlavorAsset->getId() . "]");
                 $flavorParams = assetParamsPeer::retrieveByPK($tagedFlavorAsset->getId());
                 $flavorParamsOutput = self::validateFlavorAndMediaInfo($flavorParams, $mediaInfo, $errDescription);
                 if (is_null($flavorParamsOutput)) {
                     KalturaLog::err("Failed to validate media info [{$errDescription}]");
                     continue;
                 }
             }
             if ($flavorParamsOutput) {
                 KalturaLog::log("Adding Collection flavor [" . $flavorParamsOutput->getId() . "] for asset [" . $tagedFlavorAsset->getId() . "]");
                 $flavors[$tagedFlavorAsset->getId()] = assetParamsOutputPeer::retrieveByAssetId($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);
 }
Esempio n. 24
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 = assetPeer::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());
     /*
      * For intermediate source generation, both the source and the asset have the same asset id.
      * In this case sourceMediaInfo should be retrieved as the first version of source asset mediaInfo 
      */
     if (isset($sourceMediaInfo) && $sourceMediaInfo->getFlavorAssetId() == $flavorAssetId) {
         $productMediaInfo = $sourceMediaInfo;
         $entry = $dbBatchJob->getEntry();
         $operationAttributes = $entry->getOperationAttributes();
         // if in clipping operation - take the latest created mediainfo object
         $ascending = empty($operationAttributes) ? 1 : 0;
         $sourceMediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($flavorAssetId, $ascending);
         KalturaLog::log("Intermediate source generation - assetId(" . $flavorAssetId . "),src MdInf id(" . $sourceMediaInfo->getId() . "),product MdInf id(" . $productMediaInfo->getId()) . ")";
     } else {
         $productMediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($currentFlavorAsset->getId());
     }
     $targetFlavor = assetParamsOutputPeer::retrieveByAssetId($currentFlavorAsset->getId());
     //Retrieve convert job executing engien
     $convertEngineType = null;
     if ($dbBatchJob->getParentJob()) {
         $dbParentBatchJob = $dbBatchJob->getParentJob();
         if ($dbParentBatchJob->getJobType() == BatchJobType::CONVERT) {
             $convertEngineType = $dbParentBatchJob->getJobSubType();
         }
     }
     $postConvertData = $dbBatchJob->getData();
     $postConvertAssetType = BatchJob::POSTCONVERT_ASSET_TYPE_FLAVOR;
     if ($postConvertData instanceof kPostConvertJobData) {
         $postConvertAssetType = $postConvertData->getPostConvertAssetType();
     }
     // don't validate in case of bypass, in case target flavor or media info are null
     // or ISM/ISMC manifest assets
     if ($postConvertAssetType != BatchJob::POSTCONVERT_ASSET_TYPE_BYPASS && $targetFlavor && $productMediaInfo && !$targetFlavor->hasTag(assetParams::TAG_ISM_MANIFEST)) {
         try {
             $productFlavor = KDLWrap::CDLValidateProduct($sourceMediaInfo, $targetFlavor, $productMediaInfo, $convertEngineType);
         } 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->setStatusLocalReady();
     $currentFlavorAsset->save();
     $waitingFlavorAssets = assetPeer::retrieveByEntryIdAndStatus($currentFlavorAsset->getEntryId(), flavorAsset::FLAVOR_ASSET_STATUS_WAIT_FOR_CONVERT);
     $originalFlavorAsset = assetPeer::retrieveOriginalByEntryId($currentFlavorAsset->getEntryId());
     foreach ($waitingFlavorAssets as $waitingFlavorAsset) {
         $flavor = assetParamsOutputPeer::retrieveByAsset($waitingFlavorAsset);
         KalturaLog::debug('Check waiting flavor asset [' . $waitingFlavorAsset->getId() . ']');
         if ($dbBatchJob->getParentJob()) {
             $parentJob = $dbBatchJob->getParentJob();
         } else {
             $parentJob = $dbBatchJob;
         }
         kBusinessPreConvertDL::decideFlavorConvert($waitingFlavorAsset, $flavor, $originalFlavorAsset, null, null, $parentJob);
     }
     kFlowHelper::generateThumbnailsFromFlavor($dbBatchJob->getEntryId(), $dbBatchJob, $currentFlavorAsset->getFlavorParamsId());
     if ($currentFlavorAsset->getIsOriginal()) {
         $entry = $currentFlavorAsset->getentry();
         if ($entry) {
             kBusinessConvertDL::checkForPendingLiveClips($entry);
         }
     }
     return $currentFlavorAsset;
 }
Esempio n. 25
0
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this asset is new, it will return
  * an empty collection; or if this asset has previously
  * been saved, it will retrieve related assetParamsOutputs from storage.
  *
  * This method is protected by default in order to keep the public
  * api reasonable.  You can provide public methods for those you
  * actually need in asset.
  */
 public function getassetParamsOutputsJoinentry($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     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(assetParamsOutputPeer::FLAVOR_ASSET_ID, $this->id);
             $this->collassetParamsOutputs = assetParamsOutputPeer::doSelectJoinentry($criteria, $con, $join_behavior);
         }
     } else {
         // 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(assetParamsOutputPeer::FLAVOR_ASSET_ID, $this->id);
         if (!isset($this->lastassetParamsOutputCriteria) || !$this->lastassetParamsOutputCriteria->equals($criteria)) {
             $this->collassetParamsOutputs = assetParamsOutputPeer::doSelectJoinentry($criteria, $con, $join_behavior);
         }
     }
     $this->lastassetParamsOutputCriteria = $criteria;
     return $this->collassetParamsOutputs;
 }
 /**
  * @return the ready behavior
  */
 public function getReadyBehavior()
 {
     $flavorParamsOutput = assetParamsOutputPeer::retrieveByPK($this->flavorParamsOutputId);
     if ($flavorParamsOutput) {
         return $flavorParamsOutput->getReadyBehavior();
     }
     return null;
 }