本文整理汇总了PHP中assetPeer::retrieveOriginalByEntryId方法的典型用法代码示例。如果您正苦于以下问题:PHP assetPeer::retrieveOriginalByEntryId方法的具体用法?PHP assetPeer::retrieveOriginalByEntryId怎么用?PHP assetPeer::retrieveOriginalByEntryId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类assetPeer
的用法示例。
在下文中一共展示了assetPeer::retrieveOriginalByEntryId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: entryHandled
public function entryHandled(entry $dbEntry)
{
parent::entryHandled($dbEntry);
$originalFlavorAsset = assetPeer::retrieveOriginalByEntryId($dbEntry->getId());
$syncKey = $originalFlavorAsset->getSyncKey(asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$sourceFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey);
// call mediaInfo for file
$dbMediaInfo = new mediaInfo();
try {
$mediaInfoParser = new KMediaInfoMediaParser($sourceFilePath, kConf::get('bin_path_mediainfo'));
$mediaInfo = $mediaInfoParser->getMediaInfo();
$dbMediaInfo = $mediaInfo->toInsertableObject($dbMediaInfo);
$dbMediaInfo->setFlavorAssetId($originalFlavorAsset->getId());
$dbMediaInfo->save();
} catch (Exception $e) {
KalturaLog::err("Getting media info: " . $e->getMessage());
$dbMediaInfo = null;
}
// fix flavor asset according to mediainfo
if ($dbMediaInfo) {
KDLWrap::ConvertMediainfoCdl2FlavorAsset($dbMediaInfo, $originalFlavorAsset);
$flavorTags = KDLWrap::CDLMediaInfo2Tags($dbMediaInfo, array(flavorParams::TAG_WEB, flavorParams::TAG_MBR));
$originalFlavorAsset->setTags(implode(',', array_unique($flavorTags)));
}
$originalFlavorAsset->setStatusLocalReady();
$originalFlavorAsset->save();
$dbEntry->setStatus(entryStatus::READY);
$dbEntry->save();
}
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:29,代码来源:KalturaWebcamTokenResource.php
示例2: retrieveOriginalByEntryId
/**
* @param string $entryId
* @return mediaInfo
*/
public static function retrieveOriginalByEntryId($entryId)
{
$sourceFlavorAsset = assetPeer::retrieveOriginalByEntryId($entryId);
if (!$sourceFlavorAsset) {
return null;
}
$criteria = new Criteria();
$criteria->add(mediaInfoPeer::FLAVOR_ASSET_ID, $sourceFlavorAsset->getId());
$criteria->addDescendingOrderByColumn(mediaInfoPeer::CREATED_AT);
return mediaInfoPeer::doSelectOne($criteria);
}
示例3: reconvertEntry
private function reconvertEntry($entry_id, $conversion_profile_id, $job_priority)
{
$entry = entryPeer::retrieveByPK($entry_id);
$this->error = "";
if (!$entry) {
$error = "Cannot reconvert entry [{$entry_id}]. Might be a deleted entry";
return array($entry_id, null, null, $error);
}
$flavorAsset = assetPeer::retrieveOriginalByEntryId($entry_id);
if (!$flavorAsset) {
$flavorAsset = assetPeer::retrieveReadyWebByEntryId($entry_id);
if (!$flavorAsset) {
$flavorAssets = assetPeer::retrieveFlavorsByEntryId($entry_id);
if (!$flavorAssets) {
$error = "Cannot find good enough flavor asset to re-convert from";
return array($entry_id, $entry, null, $error);
}
$flavorAsset = $flavorAssets[0];
// choose the first one
}
}
$syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$filePath = kFileSyncUtils::getReadyLocalFilePathForKey($syncKey);
if (!$filePath) {
$error = "Cannot find a fileSync for the flavorAsset [" . $flavorAsset->getId() . "]";
return array($entry_id, $entry, null, $error);
}
$dbBatchJob = new BatchJob();
$dbBatchJob->setEntryId($entry_id);
$dbBatchJob->setPartnerId($entry->getPartnerId());
$dbBatchJob->setStatus(BatchJob::BATCHJOB_STATUS_PENDING);
$dbBatchJob->setDc(kDataCenterMgr::getCurrentDcId());
//$dbBatchJob->setPriority ( $job_priority ); Not supported anymore
$dbBatchJob->setObjectId($entry_id);
$dbBatchJob->setObjectType(BatchJobObjectType::ENTRY);
$dbBatchJob->setJobType(BatchJobType::CONVERT_PROFILE);
$dbBatchJob->save();
// creates a convert profile job
$convertProfileData = new kConvertProfileJobData();
$convertProfileData->setFlavorAssetId($flavorAsset->getId());
$convertProfileData->setInputFileSyncLocalPath($filePath);
kJobsManager::addJob($dbBatchJob, $convertProfileData, BatchJobType::CONVERT_PROFILE);
// save again afget the addJob
$dbBatchJob->save();
return array($entry_id, $entry, $dbBatchJob, $error);
}
示例4: resizeEntryImage
//.........这里部分代码省略.........
$capturedThumbPath = $contentPath . myContentStorage::getGeneralEntityPath("entry/tempthumb", $entry->getIntId(), $capturedThumbName, $entry->getThumbnail(), $version);
$orig_image_path = $capturedThumbPath . "temp_1.jpg";
// if we already captured the frame at that second, dont recapture, just use the existing file
if (!file_exists($orig_image_path)) {
// limit creation of more than XX ffmpeg image extraction processes
if (kConf::hasParam("resize_thumb_max_processes_ffmpeg") && trim(exec("ps -e -ocmd|awk '{print \$1}'|grep -c " . kConf::get("bin_path_ffmpeg"))) > kConf::get("resize_thumb_max_processes_ffmpeg")) {
KExternalErrors::dieError(KExternalErrors::TOO_MANY_PROCESSES);
}
// creating the thumbnail is a very heavy operation
// prevent calling it in parallel for the same thubmnail for 5 minutes
$cache = new myCache("thumb-processing", 5 * 60);
// 5 minutes
$processing = $cache->get($orig_image_path);
if ($processing) {
KExternalErrors::dieError(KExternalErrors::PROCESSING_CAPTURE_THUMBNAIL);
}
$cache->put($orig_image_path, true);
$flavorAsset = assetPeer::retrieveHighestBitrateByEntryId($entry->getId(), flavorParams::TAG_THUMBSOURCE);
if (is_null($flavorAsset)) {
$flavorAsset = assetPeer::retrieveOriginalReadyByEntryId($entry->getId());
if ($flavorAsset) {
$flavorSyncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($flavorSyncKey, false, false);
if (!$fileSync) {
$flavorAsset = null;
}
}
if (is_null($flavorAsset) || !($flavorAsset->hasTag(flavorParams::TAG_MBR) || $flavorAsset->hasTag(flavorParams::TAG_WEB))) {
// try the best playable
$flavorAsset = assetPeer::retrieveHighestBitrateByEntryId($entry->getId(), null, flavorParams::TAG_SAVE_SOURCE);
}
if (is_null($flavorAsset)) {
// if no READY ORIGINAL entry is available, try to retrieve a non-READY ORIGINAL entry
$flavorAsset = assetPeer::retrieveOriginalByEntryId($entry->getId());
}
}
if (is_null($flavorAsset)) {
// if no READY ORIGINAL entry is available, try to retrieve a non-READY ORIGINAL entry
$flavorAsset = assetPeer::retrieveOriginalByEntryId($entry->getId());
}
if (is_null($flavorAsset)) {
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
}
$flavorSyncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$entry_data_path = kFileSyncUtils::getReadyLocalFilePathForKey($flavorSyncKey);
if (!$entry_data_path) {
// since this is not really being processed on this server, and will probably cause redirect in thumbnailAction
// remove from cache so later requests will still get redirected and will not fail on PROCESSING_CAPTURE_THUMBNAIL
$cache->remove($orig_image_path);
throw new kFileSyncException('no ready filesync on current DC', kFileSyncException::FILE_DOES_NOT_EXIST_ON_CURRENT_DC);
}
// close db connections as we won't be requiring the database anymore and capturing a thumbnail may take a long time
kFile::closeDbConnections();
myFileConverter::autoCaptureFrame($entry_data_path, $capturedThumbPath . "temp_", $calc_vid_sec, -1, -1);
$cache->remove($orig_image_path);
}
}
// close db connections as we won't be requiring the database anymore and image manipulation may take a long time
kFile::closeDbConnections();
// limit creation of more than XX Imagemagick processes
if (kConf::hasParam("resize_thumb_max_processes_imagemagick") && trim(exec("ps -e -ocmd|awk '{print \$1}'|grep -c " . kConf::get("bin_path_imagemagick"))) > kConf::get("resize_thumb_max_processes_imagemagick")) {
KExternalErrors::dieError(KExternalErrors::TOO_MANY_PROCESSES);
}
// resizing (and editing)) an image file that failes results in a long server waiting time
// prevent this waiting time (of future requests) in case the resizeing failes
$cache = new myCache("thumb-processing-resize", 5 * 60);
示例5: execute
//.........这里部分代码省略.........
if ($seek_from <= 0) {
$seek_from = -1;
}
$this->dump_from_byte = 0;
// reset accurate seek from timestamp
$seek_from_timestamp = -1;
// backward compatibility
if ($flavor === "0") {
// for edit version
$flavor = "edit";
}
if ($flavor === "1" || $flavor === 1) {
// for play version
$flavor = null;
}
// when flavor is null, we will get a default flavor
if ($flavor == "edit") {
$flavorAsset = assetPeer::retrieveBestEditByEntryId($entry->getId());
} elseif (!is_null($flavor)) {
$flavorAsset = assetPeer::retrieveById($flavor);
// when specific asset was request, we don't validate its tags
if ($flavorAsset && ($flavorAsset->getEntryId() != $entry->getId() || $flavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_READY)) {
$flavorAsset = null;
}
// we will throw an error later
} elseif (is_null($flavor) && !is_null($flavor_param_id)) {
$flavorAsset = assetPeer::retrieveByEntryIdAndParams($entry->getId(), $flavor_param_id);
if ($flavorAsset && $flavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_READY) {
$flavorAsset = null;
}
// we will throw an error later
} else {
if ($entry->getSource() == entry::ENTRY_MEDIA_SOURCE_WEBCAM) {
$flavorAsset = assetPeer::retrieveOriginalByEntryId($entry->getId());
} else {
$flavorAsset = assetPeer::retrieveBestPlayByEntryId($entry->getId());
}
if (!$flavorAsset) {
$flavorAssets = assetPeer::retrieveReadyFlavorsByEntryIdAndTag($entry->getId(), flavorParams::TAG_WEB);
if (count($flavorAssets) > 0) {
$flavorAsset = $flavorAssets[0];
}
}
}
if (is_null($flavorAsset)) {
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
}
$syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
if (kFileSyncUtils::file_exists($syncKey, false)) {
$path = kFileSyncUtils::getReadyLocalFilePathForKey($syncKey);
} else {
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
if (is_null($fileSync)) {
KalturaLog::log("Error - no FileSync for flavor [" . $flavorAsset->getId() . "]");
KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND);
}
if ($fileSync->getFileType() == FileSync::FILE_SYNC_FILE_TYPE_URL) {
$urlManager = DeliveryProfilePeer::getRemoteDeliveryByStorageId(DeliveryProfileDynamicAttributes::init($fileSync->getDc(), $flavorAsset->getEntryId()), null, $flavorAsset);
if (!$urlManager) {
KalturaLog::log("Error - failed to find an HTTP delivery for storage profile [" . $fileSync->getDc() . "]");
KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND);
}
$url = rtrim($urlManager->getUrl(), '/') . '/' . ltrim($urlManager->getFileSyncUrl($fileSync), '/');
header('location: ' . $url);
die;
}
示例6: handleConvertProfileFinished
public static function handleConvertProfileFinished(BatchJob $dbBatchJob, kConvertProfileJobData $data, BatchJob $twinJob = null)
{
KalturaLog::debug("Convert Profile finished");
$originalflavorAsset = assetPeer::retrieveOriginalByEntryId($dbBatchJob->getEntryId());
if ($originalflavorAsset && $originalflavorAsset->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_TEMP) {
$originalflavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_DELETED);
$originalflavorAsset->setDeletedAt(time());
$originalflavorAsset->save();
}
kFlowHelper::generateThumbnailsFromFlavor($dbBatchJob->getEntryId(), $dbBatchJob);
return $dbBatchJob;
}
示例7: execute
//.........这里部分代码省略.........
}
if ($rel_height != -1) {
$heightRatio = $entry->getHeight() / $rel_height;
$src_y = $src_y * $heightRatio;
$src_h = $src_h * $heightRatio;
}
$subType = entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB;
if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) {
$subType = entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA;
}
KalturaLog::debug("get thumbnail filesyncs");
$dataKey = $entry->getSyncKey($subType);
list($file_sync, $local) = kFileSyncUtils::getReadyFileSyncForKey($dataKey, true, false);
$tempThumbPath = null;
$entry_status = $entry->getStatus();
// both 640x480 and 0x0 requests are probably coming from the kdp
// 640x480 - old kdp version requesting thumbnail
// 0x0 - new kdp version requesting the thumbnail of an unready entry
// we need to distinguish between calls from the kdp and calls from a browser: <img src=...>
// that can't handle swf input
if (($width == 640 && $height == 480 || $width == 0 && $height == 0) && ($entry_status == entryStatus::PRECONVERT || $entry_status == entryStatus::IMPORT || $entry_status == entryStatus::ERROR_CONVERTING || $entry_status == entryStatus::DELETED)) {
$contentPath = myContentStorage::getFSContentRootPath();
$msgPath = $contentPath . "content/templates/entry/bigthumbnail/";
if ($entry_status == entryStatus::DELETED) {
$msgPath .= $entry->getModerationStatus() == moderation::MODERATION_STATUS_BLOCK ? "entry_blocked.swf" : "entry_deleted.swf";
} else {
$msgPath .= $entry_status == entryStatus::ERROR_CONVERTING ? "entry_error.swf" : "entry_converting.swf";
}
kFile::dumpFile($msgPath, null, 0);
}
if (!$file_sync) {
$tempThumbPath = $entry->getLocalThumbFilePath($entry, $version, $width, $height, $type, $bgcolor, $crop_provider, $quality, $src_x, $src_y, $src_w, $src_h, $vid_sec, $vid_slice, $vid_slices, $density, $stripProfiles, $flavor_id, $file_name);
if (!$tempThumbPath) {
KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC);
}
}
if (!$local && !$tempThumbPath && $file_sync) {
if (!in_array($file_sync->getDc(), kDataCenterMgr::getDcIds())) {
$remoteUrl = $file_sync->getExternalUrl($entry->getId());
header("Location: {$remoteUrl}");
die;
}
$remoteUrl = kDataCenterMgr::getRedirectExternalUrl($file_sync, $_SERVER['REQUEST_URI']);
kFile::dumpUrl($remoteUrl);
}
// if we didnt return a template for the player die and dont return the original deleted thumb
if ($entry_status == entryStatus::DELETED) {
KExternalErrors::dieError(KExternalErrors::ENTRY_DELETED_MODERATED);
}
if (!$tempThumbPath) {
try {
$tempThumbPath = myEntryUtils::resizeEntryImage($entry, $version, $width, $height, $type, $bgcolor, $crop_provider, $quality, $src_x, $src_y, $src_w, $src_h, $vid_sec, $vid_slice, $vid_slices, null, $density, $stripProfiles, $thumbParams);
} catch (Exception $ex) {
if ($ex->getCode() != kFileSyncException::FILE_DOES_NOT_EXIST_ON_CURRENT_DC) {
KalturaLog::log("Error - resize image failed");
KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC);
}
// get original flavor asset
$origFlavorAsset = assetPeer::retrieveOriginalByEntryId($entry_id);
if (!$origFlavorAsset) {
KalturaLog::log("Error - no original flavor for entry [{$entry_id}]");
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
}
$syncKey = $origFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$remoteFileSync = kFileSyncUtils::getOriginFileSyncForKey($syncKey, false);
if (!$remoteFileSync) {
// file does not exist on any DC - die
KalturaLog::log("Error - no FileSync for entry [{$entry_id}]");
KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC);
}
if ($remoteFileSync->getDc() == kDataCenterMgr::getCurrentDcId()) {
KalturaLog::log("ERROR - Trying to redirect to myself - stop here.");
KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC);
}
if (!in_array($remoteFileSync->getDc(), kDataCenterMgr::getDcIds())) {
KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC);
}
$remoteUrl = kDataCenterMgr::getRedirectExternalUrl($remoteFileSync);
kFile::dumpUrl($remoteUrl);
}
}
$nocache = strpos($tempThumbPath, "_NOCACHE_") !== false;
if ($securyEntryHelper->shouldDisableCache() || kApiCache::hasExtraFields() || !$securyEntryHelper->isKsWidget() && $securyEntryHelper->hasRules()) {
$nocache = true;
}
// notify external proxy, so it'll cache this url
if (!$nocache && requestUtils::getHost() == kConf::get("apphome_url") && file_exists($tempThumbPath)) {
self::notifyProxy($_SERVER["REQUEST_URI"]);
}
// cache result
if (!$nocache) {
$requestKey = $_SERVER["REQUEST_URI"];
$cache = new myCache("thumb", 86400 * 30);
// 30 days
$cache->put($requestKey, $tempThumbPath);
}
kFile::dumpFile($tempThumbPath, null, $nocache ? 0 : null);
// TODO - can delete from disk assuming we caneasily recreate it and it will anyway be cached in the CDN
// however dumpfile dies at the end so we cant just write it here (maybe register a shutdown callback)
}
示例8: convert
/**
* Convert entry
*
* @param string $entryId Media entry id
* @param int $conversionProfileId
* @param KalturaConversionAttributeArray $dynamicConversionAttributes
* @return bigint job id
* @throws KalturaErrors::ENTRY_ID_NOT_FOUND
* @throws KalturaErrors::CONVERSION_PROFILE_ID_NOT_FOUND
* @throws KalturaErrors::FLAVOR_PARAMS_NOT_FOUND
*/
protected function convert($entryId, $conversionProfileId = null, KalturaConversionAttributeArray $dynamicConversionAttributes = null)
{
$entry = entryPeer::retrieveByPK($entryId);
if (!$entry) {
throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
}
$srcFlavorAsset = assetPeer::retrieveOriginalByEntryId($entryId);
if (!$srcFlavorAsset) {
throw new KalturaAPIException(KalturaErrors::ORIGINAL_FLAVOR_ASSET_IS_MISSING);
}
if (is_null($conversionProfileId) || $conversionProfileId <= 0) {
$conversionProfile = myPartnerUtils::getConversionProfile2ForEntry($entryId);
if (!$conversionProfile) {
throw new KalturaAPIException(KalturaErrors::CONVERSION_PROFILE_ID_NOT_FOUND, $conversionProfileId);
}
$conversionProfileId = $conversionProfile->getId();
} else {
//The search is with the entry's partnerId. so if conversion profile wasn't found it means that the
//conversionId is not exist or the conversion profileId does'nt belong to this partner.
$conversionProfile = conversionProfile2Peer::retrieveByPK($conversionProfileId);
if (is_null($conversionProfile)) {
throw new KalturaAPIException(KalturaErrors::CONVERSION_PROFILE_ID_NOT_FOUND, $conversionProfileId);
}
}
$srcSyncKey = $srcFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
// if the file sync isn't local (wasn't synced yet) proxy request to other datacenter
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($srcSyncKey, true, false);
if (!$fileSync) {
throw new KalturaAPIException(KalturaErrors::FILE_DOESNT_EXIST);
} else {
if (!$local) {
kFileUtils::dumpApiRequest(kDataCenterMgr::getRemoteDcExternalUrl($fileSync));
}
}
// even if it null
$entry->setConversionQuality($conversionProfileId);
$entry->save();
if ($dynamicConversionAttributes) {
$flavors = assetParamsPeer::retrieveByProfile($conversionProfileId);
if (!count($flavors)) {
throw new KalturaAPIException(KalturaErrors::FLAVOR_PARAMS_NOT_FOUND);
}
$srcFlavorParamsId = null;
$flavorParams = $entry->getDynamicFlavorAttributes();
foreach ($flavors as $flavor) {
if ($flavor->hasTag(flavorParams::TAG_SOURCE)) {
$srcFlavorParamsId = $flavor->getId();
}
$flavorParams[$flavor->getId()] = $flavor;
}
$dynamicAttributes = array();
foreach ($dynamicConversionAttributes as $dynamicConversionAttribute) {
if (is_null($dynamicConversionAttribute->flavorParamsId)) {
$dynamicConversionAttribute->flavorParamsId = $srcFlavorParamsId;
}
if (is_null($dynamicConversionAttribute->flavorParamsId)) {
continue;
}
$dynamicAttributes[$dynamicConversionAttribute->flavorParamsId][trim($dynamicConversionAttribute->name)] = trim($dynamicConversionAttribute->value);
}
if (count($dynamicAttributes)) {
$entry->setDynamicFlavorAttributes($dynamicAttributes);
$entry->save();
}
}
$srcFilePath = kFileSyncUtils::getLocalFilePathForKey($srcSyncKey);
$job = kJobsManager::addConvertProfileJob(null, $entry, $srcFlavorAsset->getId(), $srcFilePath);
if (!$job) {
return null;
}
return $job->getId();
}
示例9: exportSourceAssetFromJob
public static function exportSourceAssetFromJob(BatchJob $dbBatchJob)
{
// convert profile finished - export source flavor
if ($dbBatchJob->getJobType() == BatchJobType::CONVERT_PROFILE) {
$externalStorages = StorageProfilePeer::retrieveAutomaticByPartnerId($dbBatchJob->getPartnerId());
$sourceFlavor = assetPeer::retrieveOriginalByEntryId($dbBatchJob->getEntryId());
if (!$sourceFlavor) {
KalturaLog::debug('Cannot find source flavor for entry id [' . $dbBatchJob->getEntryId() . ']');
} else {
if (!$sourceFlavor->isLocalReadyStatus()) {
KalturaLog::debug('Source flavor id [' . $sourceFlavor->getId() . '] has status [' . $sourceFlavor->getStatus() . '] - not ready for export');
} else {
foreach ($externalStorages as $externalStorage) {
if ($externalStorage->triggerFitsReadyAsset($dbBatchJob->getEntryId())) {
self::exportFlavorAsset($sourceFlavor, $externalStorage);
}
}
}
}
}
// convert collection finished - export ism and ismc files
if ($dbBatchJob->getJobType() == BatchJobType::CONVERT_COLLECTION && $dbBatchJob->getJobSubType() == conversionEngineType::EXPRESSION_ENCODER3) {
$entry = $dbBatchJob->getEntry();
$externalStorages = StorageProfilePeer::retrieveAutomaticByPartnerId($dbBatchJob->getPartnerId());
foreach ($externalStorages as $externalStorage) {
if ($externalStorage->triggerFitsReadyAsset($entry->getId())) {
$ismKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM);
if (kFileSyncUtils::fileSync_exists($ismKey)) {
self::export($entry, $externalStorage, $ismKey);
}
$ismcKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISMC);
if (kFileSyncUtils::fileSync_exists($ismcKey)) {
self::export($entry, $externalStorage, $ismcKey);
}
}
}
}
return true;
}
示例10: requestConversionAction
/**
* request conversion for all entries that doesnt have the required flavor param
* returns a comma-separated ids of conversion jobs
*
* @action requestConversion
* @param string $feedId
* @return string
* @throws KalturaErrors::INVALID_FEED_ID
*/
public function requestConversionAction($feedId)
{
$syndicationFeedDB = syndicationFeedPeer::retrieveByPK($feedId);
if (!$syndicationFeedDB) {
throw new KalturaAPIException(KalturaErrors::INVALID_FEED_ID, $feedId);
}
// find entry ids that already converted to the flavor
$feedRendererWithTheFlavor = new KalturaSyndicationFeedRenderer($feedId);
$feedRendererWithTheFlavor->addFlavorParamsAttachedFilter();
$entriesWithTheFlavor = $feedRendererWithTheFlavor->getEntriesIds();
// create filter of the entries that not converted
$entryFilter = new entryFilter();
$entryFilter->setIdNotIn($entriesWithTheFlavor);
// create feed with the new filter
$feedRendererToConvert = new KalturaSyndicationFeedRenderer($feedId);
$feedRendererToConvert->addFilter($entryFilter);
$createdJobsIds = array();
$flavorParamsId = $feedRendererToConvert->syndicationFeed->flavorParamId;
while ($entry = $feedRendererToConvert->getNextEntry()) {
$originalFlavorAsset = assetPeer::retrieveOriginalByEntryId($entry->getId());
if (!is_null($originalFlavorAsset)) {
$err = "";
$job = kBusinessPreConvertDL::decideAddEntryFlavor(null, $entry->getId(), $flavorParamsId, $err);
if ($job && is_object($job)) {
$createdJobsIds[] = $job->getId();
}
}
}
return implode(',', $createdJobsIds);
}
示例11: serveByFlavorParamsIdAction
/**
* Serves the file content
*
* @action serveByFlavorParamsId
* @serverOnly
* @param string $entryId Document entry id
* @param string $flavorParamsId Flavor params id
* @param bool $forceProxy force to get the content without redirect
*
* @throws KalturaErrors::ENTRY_ID_NOT_FOUND
* @throws KalturaErrors::FLAVOR_ASSET_IS_NOT_READY
* @throws KalturaErrors::FLAVOR_ASSET_ID_NOT_FOUND
*/
public function serveByFlavorParamsIdAction($entryId, $flavorParamsId = null, $forceProxy = false)
{
KalturaResponseCacher::disableCache();
entryPeer::setDefaultCriteriaFilter();
$dbEntry = entryPeer::retrieveByPK($entryId);
if (!$dbEntry || $dbEntry->getType() != entryType::DOCUMENT) {
throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
}
$ksObj = $this->getKs();
$ks = $ksObj ? $ksObj->getOriginalString() : null;
$securyEntryHelper = new KSecureEntryHelper($dbEntry, $ks, null);
$securyEntryHelper->validateForDownload();
$flavorAsset = null;
assetPeer::resetInstanceCriteriaFilter();
if ($flavorParamsId) {
$flavorAsset = assetPeer::retrieveByEntryIdAndParams($entryId, $flavorParamsId);
if (!$flavorAsset) {
throw new KalturaAPIException(KalturaErrors::FLAVOR_ASSET_IS_NOT_READY, $flavorParamsId);
}
} else {
$flavorAsset = assetPeer::retrieveOriginalByEntryId($entryId);
if (!$flavorAsset) {
throw new KalturaAPIException(KalturaErrors::FLAVOR_ASSET_ID_NOT_FOUND, $flavorParamsId);
}
}
$fileName = $dbEntry->getName() . '.' . $flavorAsset->getFileExt();
return $this->serveFlavorAsset($flavorAsset, $fileName, $forceProxy);
}
示例12: addFlavorConvertJob
/**
* addFlavorConvertJob adds a single flavor conversion
*
* @param FileSyncKey $srcSyncKey
* @param flavorParamsOutput $flavor
* @param int $flavorAssetId
* @param int $mediaInfoId
* @param BatchJob $parentJob
* @param int $lastEngineType
* @param BatchJob $dbConvertFlavorJob
* @return BatchJob
*/
public static function addFlavorConvertJob(FileSyncKey $srcSyncKey, flavorParamsOutput $flavor, $flavorAssetId, $mediaInfoId = null, BatchJob $parentJob = null, $lastEngineType = null, BatchJob $dbConvertFlavorJob = null)
{
$localPath = null;
$remoteUrl = null;
$flavorAsset = assetPeer::retrieveById($flavorAssetId);
if (!$flavorAsset) {
KalturaLog::err("No flavor asset found for id [{$flavorAssetId}]");
return null;
}
if ($flavor->getSourceRemoteStorageProfileId() == StorageProfile::STORAGE_KALTURA_DC) {
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($srcSyncKey, true, false);
$partner = PartnerPeer::retrieveByPK($flavorAsset->getPartnerId());
if (!$fileSync) {
kBatchManager::updateEntry($flavorAsset->getEntryId(), entryStatus::ERROR_CONVERTING);
$flavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_ERROR);
$flavorAsset->setDescription("Source file sync not found: {$srcSyncKey}");
$flavorAsset->save();
KalturaLog::err("Source file sync not found: {$srcSyncKey}");
return null;
}
if (!$local) {
if ($fileSync->getFileType() == FileSync::FILE_SYNC_FILE_TYPE_URL && $partner && $partner->getImportRemoteSourceForConvert()) {
KalturaLog::debug("Creates import job for remote file sync");
$flavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_WAIT_FOR_CONVERT);
$flavorAsset->setDescription("Source file sync is importing: {$srcSyncKey}");
$flavorAsset->save();
$originalFlavorAsset = assetPeer::retrieveOriginalByEntryId($flavorAsset->getEntryId());
$url = $fileSync->getExternalUrl($flavorAsset->getEntryId());
return kJobsManager::addImportJob($parentJob, $flavorAsset->getEntryId(), $partner->getId(), $url, $originalFlavorAsset, null, null, true);
}
throw new kCoreException("Source file not found for flavor conversion [{$flavorAssetId}]", kCoreException::SOURCE_FILE_NOT_FOUND);
}
if ($fileSync->getFileType() != FileSync::FILE_SYNC_FILE_TYPE_URL) {
$localPath = $fileSync->getFullPath();
}
$remoteUrl = $fileSync->getExternalUrl($flavorAsset->getEntryId());
} else {
$fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($srcSyncKey, $flavor->getSourceRemoteStorageProfileId());
if (!$fileSync) {
kBatchManager::updateEntry($flavorAsset->getEntryId(), entryStatus::ERROR_CONVERTING);
$description = "Remote source file sync not found {$srcSyncKey}, storage profile id [" . $flavor->getSourceRemoteStorageProfileId() . "]";
KalturaLog::err($description);
$flavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_ERROR);
$flavorAsset->setDescription($description);
$flavorAsset->save();
return null;
}
$localPath = $fileSync->getFilePath();
$remoteUrl = $fileSync->getExternalUrl($flavorAsset->getEntryId());
}
$wamsAssetId = $fileSync->getWamsAssetId();
// creates convert data
$convertData = new kConvertJobData();
$convertData->setSrcFileSyncLocalPath($localPath);
$convertData->setSrcFileSyncRemoteUrl($remoteUrl);
$convertData->setMediaInfoId($mediaInfoId);
$convertData->setFlavorParamsOutputId($flavor->getId());
$convertData->setFlavorAssetId($flavorAssetId);
$convertData->setSrcFileSyncWamsAssetId($wamsAssetId);
KalturaLog::log("Conversion engines string: '" . $flavor->getConversionEngines() . "'");
$currentConversionEngine = null;
// TODO remove after all old version flavors migrated
// parse supported engine types
$conversionEngines = array();
if (!$flavor->getEngineVersion()) {
$conversionEngines = explode(',', $flavor->getConversionEngines());
KalturaLog::log(count($conversionEngines) . " conversion engines found for the flavor");
$currentConversionEngine = reset($conversionEngines);
// gets the first engine type
}
// remove until here
if (is_null($lastEngineType)) {
KalturaLog::log("Last Engine Type is null, engine version [" . $flavor->getEngineVersion() . "]");
if ($flavor->getEngineVersion()) {
$operatorSet = new kOperatorSets();
$operatorSet->setSerialized($flavor->getOperators());
$nextOperator = $operatorSet->getOperator();
if (!$nextOperator) {
KalturaLog::err("First operator is invalid");
return null;
}
KalturaLog::log("Set first operator in first set");
$currentConversionEngine = $nextOperator->id;
}
} else {
if ($parentJob && $flavor->getEngineVersion() && ($parentJob->getJobType() == BatchJobType::CONVERT || $parentJob->getJobType() == BatchJobType::POSTCONVERT)) {
// using next oprator
KalturaLog::log("Adding next conversion operator");
//.........这里部分代码省略.........
示例13: setAsSourceAction
/**
* Set a given flavor as the original flavor
*
* @action setAsSource
* @param string $assetId
* @validateUser entry entryId edit
* @throws KalturaErrors::ASSET_ID_NOT_FOUND
*/
public function setAsSourceAction($assetId)
{
// Retrieve required
$asset = assetPeer::retrieveById($assetId);
if (is_null($asset)) {
throw new KalturaAPIException(KalturaErrors::ASSET_ID_NOT_FOUND, $assetId);
}
if ($asset->getIsOriginal()) {
return;
}
// Retrieve original
$originalAsset = assetPeer::retrieveOriginalByEntryId($asset->getEntryId());
if (!is_null($originalAsset)) {
// Set original to non-original
$originalAsset->setIsOriginal(false);
$originalAsset->save();
}
// Set required as original
$asset->setIsOriginal(true);
$asset->save();
}
示例14: execute
//.........这里部分代码省略.........
// if we have a good file extension (from the first time) - use it in the content-disposition
// in some browsers it will be stronger than the URL's extension
$file_ext = pathinfo($relocate, PATHINFO_EXTENSION);
$name .= ".{$file_ext}";
}
if (!$direct_serve) {
header("Content-Disposition: attachment; filename=\"{$name}\"");
}
}
} else {
$ret_file_name = $entry_id;
}
$format = $this->getRequestParameter("format");
if ($type == "download" && $format && $entry->getType() != entryType::DOCUMENT) {
// this is a video for a specifc extension - use the proper flavorAsset
$flavor_asset = assetPeer::retrieveByEntryIdAndExtension($entry_id, $format);
if ($flavor_asset && $flavor_asset->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_READY) {
$file_sync = $this->redirectIfRemote($flavor_asset, flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET, null, true);
} else {
header('KalturaRaw: no flavor asset for extension');
header("HTTP/1.0 404 Not Found");
die;
}
$archive_file = $file_sync->getFullPath();
$mime_type = kFile::mimeType($archive_file);
kFile::dumpFile($archive_file, $mime_type);
}
// TODO - move to a different action - document should be plugin
if ($entry->getType() == entryType::DOCUMENT) {
// use the fileSync from the entry
if ($type == "download" && $format) {
$flavor_asset = assetPeer::retrieveByEntryIdAndExtension($entry_id, $format);
} else {
$flavor_asset = assetPeer::retrieveOriginalByEntryId($entry_id);
}
if ($flavor_asset && $flavor_asset->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_READY) {
$file_sync = $this->redirectIfRemote($flavor_asset, flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET, null, true);
} else {
header('KalturaRaw: no flavor asset for extension');
header("HTTP/1.0 404 Not Found");
die;
}
// Gonen 2010-08-05 workaround to make sure file name includes correct extension
// make sure a file extension is added to the downloaded file so browser will identify and
// allow opening with default program
// for direct serve we do not want to send content-disposition header
if (!$direct_serve) {
$ext = pathinfo($file_sync->getFullPath(), PATHINFO_EXTENSION);
if ($relocate) {
// remove relocate file extension
$reloc_ext = pathinfo($relocate, PATHINFO_EXTENSION);
$name = str_replace(".{$reloc_ext}", '', $name);
}
header("Content-Disposition: attachment; filename=\"{$name}.{$ext}\"");
}
kFile::dumpFile($file_sync->getFullPath());
} elseif ($entry->getType() == entryType::DATA) {
$version = $this->getRequestParameter("version");
$syncKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA, $version);
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
if ($local) {
$path = $fileSync->getFullPath();
} else {
$path = kDataCenterMgr::getRedirectExternalUrl($fileSync);
KalturaLog::info("Redirecting to [{$path}]");
}
示例15: execute
/**
* Will forward to the regular swf player according to the widget_id
*/
public function execute()
{
$entryId = $this->getRequestParameter("entry_id");
$flavorId = $this->getRequestParameter("flavor");
$fileName = $this->getRequestParameter("file_name");
$fileName = basename($fileName);
$ksStr = $this->getRequestParameter("ks");
$referrer = $this->getRequestParameter("referrer");
$referrer = base64_decode($referrer);
if (!is_string($referrer)) {
// base64_decode can return binary data
$referrer = "";
}
$entry = null;
if ($ksStr) {
try {
kCurrentContext::initKsPartnerUser($ksStr);
} catch (Exception $ex) {
KExternalErrors::dieError(KExternalErrors::INVALID_KS);
}
} else {
$entry = kCurrentContext::initPartnerByEntryId($entryId);
if (!$entry) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
}
kEntitlementUtils::initEntitlementEnforcement();
if (!$entry) {
$entry = entryPeer::retrieveByPK($entryId);
if (!$entry) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
} else {
if (!kEntitlementUtils::isEntryEntitled($entry)) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
}
KalturaMonitorClient::initApiMonitor(false, 'extwidget.download', $entry->getPartnerId());
myPartnerUtils::blockInactivePartner($entry->getPartnerId());
$shouldPreview = false;
$securyEntryHelper = new KSecureEntryHelper($entry, $ksStr, $referrer, ContextType::DOWNLOAD);
if ($securyEntryHelper->shouldPreview()) {
$shouldPreview = true;
} else {
$securyEntryHelper->validateForDownload();
}
$flavorAsset = null;
if ($flavorId) {
// get flavor asset
$flavorAsset = assetPeer::retrieveById($flavorId);
if (is_null($flavorAsset) || !$flavorAsset->isLocalReadyStatus()) {
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
}
// the request flavor should belong to the requested entry
if ($flavorAsset->getEntryId() != $entryId) {
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
}
if (!$securyEntryHelper->isAssetAllowed($flavorAsset)) {
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
}
} else {
$flavorAssets = assetPeer::retrieveReadyWebByEntryId($entry->getId());
foreach ($flavorAssets as $curFlavorAsset) {
if ($securyEntryHelper->isAssetAllowed($curFlavorAsset)) {
$flavorAsset = $curFlavorAsset;
break;
}
}
}
// Gonen 26-04-2010: in case entry has no flavor with 'mbr' tag - we return the source
if (!$flavorAsset && ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_VIDEO || $entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_AUDIO)) {
$flavorAsset = assetPeer::retrieveOriginalByEntryId($entryId);
if (!$securyEntryHelper->isAssetAllowed($flavorAsset)) {
$flavorAsset = null;
}
}
if ($flavorAsset) {
$syncKey = $this->getSyncKeyAndForFlavorAsset($entry, $flavorAsset);
} else {
$syncKey = $this->getBestSyncKeyForEntry($entry);
}
if (is_null($syncKey)) {
KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND);
}
$this->handleFileSyncRedirection($syncKey);
$filePath = kFileSyncUtils::getReadyLocalFilePathForKey($syncKey);
list($fileBaseName, $fileExt) = kAssetUtils::getFileName($entry, $flavorAsset);
if (!$fileName) {
$fileName = $fileBaseName;
}
if ($fileExt && !is_dir($filePath)) {
$fileName = $fileName . '.' . $fileExt;
}
$preview = 0;
if ($shouldPreview && $flavorAsset) {
$preview = $flavorAsset->estimateFileSize($entry, $securyEntryHelper->getPreviewLength());
} else {
//.........这里部分代码省略.........