本文整理汇总了PHP中kJobsManager::addPostConvertJob方法的典型用法代码示例。如果您正苦于以下问题:PHP kJobsManager::addPostConvertJob方法的具体用法?PHP kJobsManager::addPostConvertJob怎么用?PHP kJobsManager::addPostConvertJob使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kJobsManager
的用法示例。
在下文中一共展示了kJobsManager::addPostConvertJob方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bypassConversion
/**
* @param flavorAsset $originalFlavorAsset
* @param entry $entry
* @param BatchJob $convertProfileJob
* @return BatchJob
*/
public static function bypassConversion(flavorAsset $originalFlavorAsset, entry $entry, BatchJob $convertProfileJob)
{
if (!$originalFlavorAsset->hasTag(flavorParams::TAG_MBR)) {
$mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($originalFlavorAsset->getId());
if ($mediaInfo) {
$tagsArray = $originalFlavorAsset->getTagsArray();
$finalTagsArray = KDLWrap::CDLMediaInfo2Tags($mediaInfo, $tagsArray);
$originalFlavorAsset->setTagsArray($finalTagsArray);
}
}
$offset = $entry->getThumbOffset();
// entry getThumbOffset now takes the partner DefThumbOffset into consideration
$srcSyncKey = $originalFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$srcFileSyncLocalPath = kFileSyncUtils::getLocalFilePathForKey($srcSyncKey);
$jobSubType = BatchJob::BATCHJOB_SUB_TYPE_POSTCONVERT_BYPASS;
return kJobsManager::addPostConvertJob($convertProfileJob, $jobSubType, $srcFileSyncLocalPath, $originalFlavorAsset->getId(), null, true, $offset);
}
示例2: bypassConversion
/**
* @param flavorAsset $originalFlavorAsset
* @param entry $entry
* @param BatchJob $convertProfileJob
* @return BatchJob
*/
public static function bypassConversion(flavorAsset $originalFlavorAsset, entry $entry, BatchJob $convertProfileJob)
{
if (!$originalFlavorAsset->hasTag(flavorParams::TAG_MBR)) {
$mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($originalFlavorAsset->getId());
if ($mediaInfo) {
$tagsArray = $originalFlavorAsset->getTagsArray();
$finalTagsArray = KDLWrap::CDLMediaInfo2Tags($mediaInfo, $tagsArray);
$originalFlavorAsset->setTagsArray($finalTagsArray);
}
}
if (!$entry->getCreateThumb()) {
// mark the asset as ready
$originalFlavorAsset->setStatusLocalReady();
$originalFlavorAsset->save();
kFlowHelper::generateThumbnailsFromFlavor($entry->getId(), null, $originalFlavorAsset->getFlavorParamsId());
kBusinessPostConvertDL::handleConvertFinished(null, $originalFlavorAsset);
return null;
}
$offset = $entry->getThumbOffset();
// entry getThumbOffset now takes the partner DefThumbOffset into consideration
$srcSyncKey = $originalFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$srcFileSyncLocalPath = kFileSyncUtils::getLocalFilePathForKey($srcSyncKey);
$srcFileSyncWamsAssetId = kFileSyncUtils::getWamsAssetIdForKey($srcSyncKey);
$postConvertAssetType = BatchJob::POSTCONVERT_ASSET_TYPE_BYPASS;
return kJobsManager::addPostConvertJob($convertProfileJob, $postConvertAssetType, $srcFileSyncLocalPath, $originalFlavorAsset->getId(), null, true, $offset, null, $srcFileSyncWamsAssetId);
}
示例3: handleConvertCollectionFinished
/**
* @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());
//.........这里部分代码省略.........
示例4: objectChanged
public function objectChanged(BaseObject $object, array $modifiedColumns)
{
if ($object instanceof entry && in_array(entryPeer::STATUS, $modifiedColumns) && ($object->getStatus() == entryStatus::READY || $object->getStatus() == entryStatus::ERROR_CONVERTING) && $object->getReplacedEntryId()) {
kFlowHelper::handleEntryReplacement($object);
return true;
}
if ($object instanceof UploadToken && in_array(UploadTokenPeer::STATUS, $modifiedColumns) && $object->getStatus() == UploadToken::UPLOAD_TOKEN_FULL_UPLOAD) {
kFlowHelper::handleUploadFinished($object);
return true;
}
if ($object instanceof BatchJob && $object->getJobType() == BatchJobType::BULKUPLOAD && $object->getStatus() == BatchJob::BATCHJOB_STATUS_ABORTED && in_array(BatchJobPeer::STATUS, $modifiedColumns) && in_array($object->getColumnsOldValue(BatchJobPeer::STATUS), BatchJobPeer::getClosedStatusList())) {
$partner = $object->getPartner();
if ($partner->getEnableBulkUploadNotificationsEmails()) {
kFlowHelper::sendBulkUploadNotificationEmail($object, MailType::MAIL_TYPE_BULKUPLOAD_ABORTED, array($partner->getAdminName(), $object->getId(), kFlowHelper::createBulkUploadLogUrl($object)));
}
return true;
}
if ($object instanceof UserRole && in_array(UserRolePeer::PERMISSION_NAMES, $modifiedColumns)) {
$filter = new kuserFilter();
$filter->set('_eq_role_ids', $object->getId());
kJobsManager::addIndexJob($object->getPartnerId(), IndexObjectType::USER, $filter, false);
return true;
}
if ($object instanceof FileSync) {
$c = new Criteria();
$c->add(BatchJobLockPeer::OBJECT_ID, $object->getId());
$c->add(BatchJobLockPeer::OBJECT_TYPE, BatchJobObjectType::FILE_SYNC);
$c->add(BatchJobLockPeer::JOB_TYPE, BatchJobType::FILESYNC_IMPORT);
$c->add(BatchJobLockPeer::STATUS, array(BatchJob::BATCHJOB_STATUS_RETRY, BatchJob::BATCHJOB_STATUS_PENDING), Criteria::IN);
$fileSyncImportJobs = BatchJobLockPeer::doSelect($c);
foreach ($fileSyncImportJobs as $fileSyncImportJob) {
kJobsManager::abortDbBatchJob(BatchJobPeer::retrieveByPK($fileSyncImportJob->getId()));
}
return true;
}
if (!$object instanceof flavorAsset || !in_array(assetPeer::STATUS, $modifiedColumns)) {
return true;
}
$entry = entryPeer::retrieveByPKNoFilter($object->getEntryId());
KalturaLog::info("Asset id [" . $object->getId() . "] isOriginal [" . $object->getIsOriginal() . "] status [" . $object->getStatus() . "]");
if ($object->getIsOriginal()) {
return true;
}
if ($object->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_VALIDATING) {
$postConvertAssetType = BatchJob::POSTCONVERT_ASSET_TYPE_FLAVOR;
$offset = $entry->getThumbOffset();
// entry getThumbOffset now takes the partner DefThumbOffset into consideration
$syncKey = $object->getSyncKey(asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$fileSync = kFileSyncUtils::getLocalFileSyncForKey($syncKey, false);
if (!$fileSync) {
return true;
}
$srcFileSyncLocalPath = kFileSyncUtils::getLocalFilePathForKey($syncKey);
if ($srcFileSyncLocalPath) {
kJobsManager::addPostConvertJob(null, $postConvertAssetType, $srcFileSyncLocalPath, $object->getId(), null, $entry->getCreateThumb(), $offset);
}
} elseif ($object->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_READY) {
// If we get a ready flavor and the entry is in no content
if ($entry->getStatus() == entryStatus::NO_CONTENT) {
$entry->setStatus(entryStatus::PENDING);
// we change the entry to pending
$entry->save();
}
}
return true;
}