/** * @param flavorAsset $flavor * @param StorageProfile $externalStorage */ protected function exportFlavorAsset(flavorAsset $flavor, StorageProfile $externalStorage) { $flavorParamsIds = $externalStorage->getFlavorParamsIds(); KalturaLog::log(__METHOD__ . " flavorParamsIds [{$flavorParamsIds}]"); if (!is_null($flavorParamsIds) && strlen(trim($flavorParamsIds))) { $flavorParamsArr = explode(',', $flavorParamsIds); if (!in_array($flavor->getFlavorParamsId(), $flavorParamsArr)) { return; } } $key = $flavor->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $this->export($flavor->getentry(), $externalStorage, $key, !$flavor->getIsOriginal()); return true; }
/** * @param flavorAsset $object * @return bool true if should continue to the next consumer */ private function addedFlavorAsset(flavorAsset $object) { if ($object instanceof flavorAsset && $object->getIsOriginal()) { if ($this->saveIfShouldScan($object)) { $profile = self::$flavorAssetIdsToScan[$object->getId()]; // suitable virus scan profile found - create scan job $syncKey = $object->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $srcFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey); kVirusScanJobsManager::addVirusScanJob(null, $object->getPartnerId(), $object->getEntryId(), $object->getId(), $srcFilePath, $profile->getEngineType(), $profile->getActionIfInfected()); return false; // pause other event consumers until virus scan job is finished } } return true; // no scan jobs to do, object added event consumption may continue normally }
public static function getReadyBehavior(flavorAsset $flavorAsset) { if ($flavorAsset->getIsOriginal()) { try { $profile = myPartnerUtils::getConversionProfile2ForEntry($flavorAsset->getEntryId()); if ($profile) { $flavorParamsConversionProfile = flavorParamsConversionProfilePeer::retrieveByFlavorParamsAndConversionProfile($flavorAsset->getFlavorParamsId(), $profile->getId()); if ($flavorParamsConversionProfile) { return $flavorParamsConversionProfile->getReadyBehavior(); } } } catch (Exception $e) { KalturaLog::err('getConversionProfile2ForEntry Error: ' . $e->getMessage()); } } $targetFlavor = flavorParamsOutputPeer::retrieveByFlavorAssetId($flavorAsset->getId()); if ($targetFlavor) { return $targetFlavor->getReadyBehavior(); } return flavorParamsConversionProfile::READY_BEHAVIOR_INHERIT_FLAVOR_PARAMS; }
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); } } }
/** * @param flavorAsset $flavorAsset * @param IRemoteStorageResource $contentResource * @throws KalturaErrors::STORAGE_PROFILE_ID_NOT_FOUND */ protected function attachRemoteStorageResource(flavorAsset $flavorAsset, IRemoteStorageResource $contentResource) { $resources = $contentResource->getResources(); $flavorAsset->setFileExt($contentResource->getFileExt()); $flavorAsset->incrementVersion(); $flavorAsset->save(); $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); foreach ($resources as $currentResource) { $storageProfile = StorageProfilePeer::retrieveByPK($currentResource->getStorageProfileId()); $fileSync = kFileSyncUtils::createReadyExternalSyncFileForKey($syncKey, $currentResource->getUrl(), $storageProfile); } if ($flavorAsset->getIsOriginal()) { $flavorAsset->setStatus(asset::FLAVOR_ASSET_STATUS_QUEUED); } else { $flavorAsset->setStatusLocalReady(); } $flavorAsset->save(); kBusinessPostConvertDL::handleConvertFinished(null, $flavorAsset); }