本文整理汇总了PHP中entry::setThumbnail方法的典型用法代码示例。如果您正苦于以下问题:PHP entry::setThumbnail方法的具体用法?PHP entry::setThumbnail怎么用?PHP entry::setThumbnail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类entry
的用法示例。
在下文中一共展示了entry::setThumbnail方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createEntry
/**
* This helps create special entries in a kshow - the show_entry & intro
* $type can be either entry::ENTRY_MEDIA_TYPE_SHOW (for the show_entry) or entry::ENTRY_MEDIA_TYPE_VIDEO (for the intro)
*/
public function createEntry($type, $kuser_id, $thumbnail = null, $entry_name = null)
{
// for invites we use the default invites from the kaltura gallery show
if ($type != entry::ENTRY_MEDIA_TYPE_SHOW) {
$kshow_type = $this->getType();
$intros = array(kshow::KSHOW_TYPE_MASHUP, kshow::KSHOW_TYPE_MUSIC_VIDEO, kshow::KSHOW_TYPE_HOWTO, kshow::KSHOW_TYPE_CALL_FOR_ACTION, kshow::KSHOW_TYPE_CONTEST, kshow::KSHOW_TYPE_GROUP_GREETING, kshow::KSHOW_TYPE_SPORTS, kshow::KSHOW_TYPE_DIGITAL_STORY, kshow::KSHOW_TYPE_GROUP_TRAVELOGUE);
$id = 0;
if (in_array($kshow_type, $intros)) {
$id = $kshow_type;
}
$id = 120 + $id;
$entry = entryPeer::retrieveByPK($id);
if ($entry) {
$this->setIntroId($entry->getId());
$this->m_intro = $entry;
}
return $entry;
}
$kshow = $this;
$entry = new entry();
$entry->setKshowId($kshow->getId());
$entry->setKuserId($kuser_id);
$entry->setCreatorKuserId($kuser_id);
if ($this->getPartnerId() !== null) {
$entry->setPartnerId($this->getPartnerId());
}
// inherit partner_id from kshow
if ($this->getSubpId() !== null) {
$entry->setSubpId($this->getSubpId());
}
// inherit subp_id from kshow
$entry->setStatus(entryStatus::READY);
if ($entry_name) {
$type_text = $entry_name;
} else {
$type_text = "Kaltura Video";
}
//$entry->setData ( "&kal_show.flv");
$entry->setThumbnail($thumbnail ? $thumbnail : "&kal_show.jpg");
$entry->setCreateThumb(false);
$entry->setType(entryType::MIX);
$entry->setMediaType(entry::ENTRY_MEDIA_TYPE_SHOW);
$entry->setEditorType(myMetadataUtils::METADATA_EDITOR_SIMPLE);
$entry->setName($type_text);
$entry->setTags($type_text . "," . $kshow->getTags());
$entry->save();
$this->setShowEntryId($entry->getId());
$this->m_show_entry = $entry;
return $entry;
}
示例2: decideThumbGenerate
//.........这里部分代码省略.........
$srcAsset = flavorAssetPeer::retrieveHighestBitrateByEntryId($entry->getId());
}
}
if (is_null($srcAsset)) {
throw new APIException(APIErrors::FLAVOR_ASSET_IS_NOT_READY);
}
$errDescription = null;
$mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($srcAsset->getId());
$destThumbParamsOutput = self::validateThumbAndMediaInfo($destThumbParams, $mediaInfo, $errDescription);
$thumbAsset = thumbAssetPeer::retrieveByEntryIdAndParams($entry->getId(), $destThumbParams->getId());
if ($thumbAsset) {
$description = $thumbAsset->getDescription() . "\n" . $errDescription;
$thumbAsset->setDescription($description);
} else {
$thumbAsset = new thumbAsset();
$thumbAsset->setPartnerId($entry->getPartnerId());
$thumbAsset->setEntryId($entry->getId());
$thumbAsset->setDescription($errDescription);
$thumbAsset->setFlavorParamsId($destThumbParams->getId());
}
$thumbAsset->incrementVersion();
$thumbAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_CONVERTING);
$thumbAsset->setTags($destThumbParamsOutput->getTags());
$thumbAsset->setFileExt($destThumbParamsOutput->getFileExt());
if (!$destThumbParamsOutput) {
$thumbAsset->setStatus(thumbAsset::FLAVOR_ASSET_STATUS_ERROR);
$thumbAsset->save();
return null;
}
$thumbAsset->save();
// save flavor params
$destThumbParamsOutput->setPartnerId($entry->getPartnerId());
$destThumbParamsOutput->setEntryId($entry->getId());
$destThumbParamsOutput->setFlavorAssetId($thumbAsset->getId());
$destThumbParamsOutput->setFlavorAssetVersion($thumbAsset->getVersion());
$destThumbParamsOutput->save();
$srcSyncKey = $srcAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$srcAssetType = $srcAsset->getType();
if (!$runSync) {
$job = kJobsManager::addCapturaThumbJob($parentJob, $entry->getPartnerId(), $entry->getId(), $thumbAsset->getId(), $srcSyncKey, $srcAssetType, $destThumbParamsOutput);
return $thumbAsset;
}
$errDescription = null;
$capturedPath = self::generateThumbnail($srcAsset, $destThumbParamsOutput, $errDescription);
// failed
if (!$capturedPath) {
$thumbAsset->incrementVersion();
$thumbAsset->setStatus(thumbAsset::FLAVOR_ASSET_STATUS_ERROR);
$thumbAsset->setDescription($thumbAsset->getDescription() . "\n{$errDescription}");
$thumbAsset->save();
return $thumbAsset;
}
$thumbAsset->incrementVersion();
$thumbAsset->setStatus(thumbAsset::FLAVOR_ASSET_STATUS_READY);
if (file_exists($capturedPath)) {
list($width, $height, $type, $attr) = getimagesize($capturedPath);
$thumbAsset->setWidth($width);
$thumbAsset->setHeight($height);
$thumbAsset->setSize(filesize($capturedPath));
}
$logPath = $capturedPath . '.log';
if (file_exists($logPath)) {
$thumbAsset->incLogFileVersion();
$thumbAsset->save();
// creats the file sync
$logSyncKey = $thumbAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_CONVERT_LOG);
kFileSyncUtils::moveFromFile($logPath, $logSyncKey);
KalturaLog::debug("Log archived file to: " . kFileSyncUtils::getLocalFilePathForKey($logSyncKey));
} else {
$thumbAsset->save();
}
$syncKey = $thumbAsset->getSyncKey(thumbAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
kFileSyncUtils::moveFromFile($capturedPath, $syncKey);
KalturaLog::debug("Thumbnail archived file to: " . kFileSyncUtils::getLocalFilePathForKey($syncKey));
if ($thumbAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB)) {
// increment thumbnail version
$entry->setThumbnail(".jpg");
$entry->save();
$entrySyncKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
$syncFile = kFileSyncUtils::createSyncFileLinkForKey($entrySyncKey, $syncKey, false);
if ($syncFile) {
// removes the DEFAULT_THUMB tag from all other thumb assets
$entryThumbAssets = thumbAssetPeer::retrieveByEntryId($thumbAsset->getEntryId());
foreach ($entryThumbAssets as $entryThumbAsset) {
if ($entryThumbAsset->getId() == $thumbAsset->getId()) {
continue;
}
if (!$entryThumbAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB)) {
continue;
}
$entryThumbAsset->removeTags(array(thumbParams::TAG_DEFAULT_THUMB));
$entryThumbAsset->save();
}
}
}
if (!is_null($thumbAsset->getFlavorParamsId())) {
kFlowHelper::generateThumbnailsFromFlavor($thumbAsset->getEntryId(), null, $thumbAsset->getFlavorParamsId());
}
return $thumbAsset;
}
示例3: handleEntry
//.........这里部分代码省略.........
$entry->setCreatorKuserId($kuser_id);
if ($this->partner_id != null) {
$entry->setPartnerId($this->partner_id);
$entry->setSubpId($this->subp_id);
}
$entry->setName($name ? $name : $this->getParam('entry_name'));
// $entry->setDescription('');//$this->getParam('entry_description'));
$entry->setType($type);
$entry->setMediaType($media_type);
$entry->setTags($tags ? $tags : $this->getParam('entry_tags'));
$entry->setSource($media_source);
$entry->setSourceId($this->getParam('entry_media_id'));
if ($media_date) {
$entry->setMediaDate($media_date);
}
// if source_link wasnt given use the entry_url HOWEVER, use it only if id doesnt contain @ which suggests the use of a password
$entry->setSourceLink($entry_source_link ? $entry_source_link : (strstr($entry_url, '@') ? "" : $entry_url));
if ($media_source == entry::ENTRY_MEDIA_SOURCE_FILE) {
$entry->setSourceLink("file:{$entry_fullPath}");
}
$entry->setLicenseType($this->getParam('entry_license'));
$entry->setCredit($this->getParam('entry_credit'));
$entry->setStatus($entry_status);
if ($duration !== null) {
$entry->setLengthInMsecs($duration);
}
if ($this->entry_id == 0) {
$entry->save();
$this->entry_id = $entry->getId();
}
// move thumb to final destination and set db entry
if ($media_type != entry::ENTRY_MEDIA_TYPE_AUDIO && $entry_thumbNum && $need_thumb) {
KalturaLog::debug("handleEntry: saving none audio thumb [{$thumbBigFullPath}]");
$entry->setThumbnail('.jpg');
if ($thumbBigFullPath) {
if ($media_type != entry::ENTRY_MEDIA_TYPE_IMAGE) {
myFileConverter::convertImage($thumbBigFullPath, $thumbFullPath);
}
/*$thumbBigFinalPath = $content.$entry->getBigThumbnailPath();
myContentStorage::moveFile($thumbBigFullPath, $thumbBigFinalPath, true , $should_copy );
*/
$entryThumbKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
try {
if (!$should_copy) {
kFileSyncUtils::moveFromFile($thumbBigFullPath, $entryThumbKey);
} else {
kFileSyncUtils::copyFromFile($thumbBigFullPath, $entryThumbKey);
}
} catch (Exception $e) {
$entry->setStatus(entryStatus::ERROR_CONVERTING);
$entry->save();
throw $e;
}
}
}
// after extracting the thumb we can move the entry to its next destination
KalturaLog::debug("handleEntry: current status [" . $entry->getStatus() . "]");
// if needed a job will be submitted for importing external media sources
if ($entry->getStatus() == entryStatus::IMPORT) {
KalturaLog::debug("handleEntry: creating import job");
// changed by Tan-Tan, Nov 09 to support the new batch mechanism
kJobsManager::addImportJob(null, $this->entry_id, $this->partner_id, $entry_url);
// remarked by Tan-Tan
// $entry_fullPath = $content.'/content/imports/data/'.$this->entry_id.".".$ext;
// myContentStorage::fullMkdir($entry_fullPath);
//
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:67,代码来源:myInsertEntryHelper.class.php
示例4: decideThumbGenerate
//.........这里部分代码省略.........
$destThumbParamsOutput->setDensity($partner->getDefThumbDensity());
}
}
$thumbAsset = assetPeer::retrieveByEntryIdAndParams($entry->getId(), $destThumbParams->getId());
if ($thumbAsset) {
$description = $thumbAsset->getDescription() . "\n" . $errDescription;
$thumbAsset->setDescription($description);
} else {
$thumbAsset = new thumbAsset();
$thumbAsset->setPartnerId($entry->getPartnerId());
$thumbAsset->setEntryId($entry->getId());
$thumbAsset->setDescription($errDescription);
$thumbAsset->setFlavorParamsId($destThumbParams->getId());
}
$thumbAsset->incrementVersion();
$thumbAsset->setTags($destThumbParamsOutput->getTags());
$thumbAsset->setFileExt($destThumbParamsOutput->getFileExt());
if ($thumbAsset->getStatus() != asset::ASSET_STATUS_READY) {
$thumbAsset->setStatus(asset::ASSET_STATUS_CONVERTING);
}
//Sets the default thumb if this the only default thumb
kBusinessPreConvertDL::setIsDefaultThumb($thumbAsset);
if (!$destThumbParamsOutput) {
$thumbAsset->setStatus(thumbAsset::FLAVOR_ASSET_STATUS_ERROR);
$thumbAsset->save();
return null;
}
$thumbAsset->save();
// save flavor params
$destThumbParamsOutput->setPartnerId($entry->getPartnerId());
$destThumbParamsOutput->setEntryId($entry->getId());
$destThumbParamsOutput->setFlavorAssetId($thumbAsset->getId());
$destThumbParamsOutput->setFlavorAssetVersion($thumbAsset->getVersion());
$destThumbParamsOutput->save();
$srcSyncKey = $srcAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$srcAssetType = $srcAsset->getType();
if (!$runSync) {
$job = kJobsManager::addCapturaThumbJob($parentJob, $entry->getPartnerId(), $entry->getId(), $thumbAsset->getId(), $srcSyncKey, $srcAsset->getId(), $srcAssetType, $destThumbParamsOutput);
return $thumbAsset;
}
$errDescription = null;
// Since this method is called when trying to crop an existing thumbnail, need to add this check - thumbAssets have no mediaInfo.
$capturedPath = self::generateThumbnail($srcAsset, $destThumbParamsOutput, $errDescription, $mediaInfo ? $mediaInfo->getVideoRotation() : null);
// failed
if (!$capturedPath) {
$thumbAsset->incrementVersion();
$thumbAsset->setStatus(thumbAsset::FLAVOR_ASSET_STATUS_ERROR);
$thumbAsset->setDescription($thumbAsset->getDescription() . "\n{$errDescription}");
$thumbAsset->save();
return $thumbAsset;
}
$thumbAsset->incrementVersion();
$thumbAsset->setStatus(thumbAsset::FLAVOR_ASSET_STATUS_READY);
if (file_exists($capturedPath)) {
list($width, $height, $type, $attr) = getimagesize($capturedPath);
$thumbAsset->setWidth($width);
$thumbAsset->setHeight($height);
$thumbAsset->setSize(filesize($capturedPath));
}
$logPath = $capturedPath . '.log';
if (file_exists($logPath)) {
$thumbAsset->incLogFileVersion();
$thumbAsset->save();
// creats the file sync
$logSyncKey = $thumbAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_CONVERT_LOG);
kFileSyncUtils::moveFromFile($logPath, $logSyncKey);
KalturaLog::debug("Log archived file to: " . kFileSyncUtils::getLocalFilePathForKey($logSyncKey));
} else {
$thumbAsset->save();
}
$syncKey = $thumbAsset->getSyncKey(thumbAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
kFileSyncUtils::moveFromFile($capturedPath, $syncKey);
KalturaLog::debug("Thumbnail archived file to: " . kFileSyncUtils::getLocalFilePathForKey($syncKey));
if ($thumbAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB)) {
// increment thumbnail version
$entry->setThumbnail(".jpg");
$entry->setCreateThumb(false);
$entry->save();
$entrySyncKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
$syncFile = kFileSyncUtils::createSyncFileLinkForKey($entrySyncKey, $syncKey);
if ($syncFile) {
// removes the DEFAULT_THUMB tag from all other thumb assets
$entryThumbAssets = assetPeer::retrieveThumbnailsByEntryId($thumbAsset->getEntryId());
foreach ($entryThumbAssets as $entryThumbAsset) {
if ($entryThumbAsset->getId() == $thumbAsset->getId()) {
continue;
}
if (!$entryThumbAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB)) {
continue;
}
$entryThumbAsset->removeTags(array(thumbParams::TAG_DEFAULT_THUMB));
$entryThumbAsset->save();
}
}
}
if (!is_null($thumbAsset->getFlavorParamsId())) {
kFlowHelper::generateThumbnailsFromFlavor($thumbAsset->getEntryId(), null, $thumbAsset->getFlavorParamsId());
}
return $thumbAsset;
}
示例5: createThumbnailFromEntry
public static function createThumbnailFromEntry(entry $entry, entry $source_entry, $time_offset, $flavorParamsId = null)
{
$media_type = $source_entry->getMediaType();
// should capture thumbnail from video
if ($media_type == entry::ENTRY_MEDIA_TYPE_VIDEO && $time_offset != -1) {
$flavorAsset = null;
if ($flavorParamsId) {
$flavorAsset = flavorAssetPeer::retrieveByEntryIdAndFlavorParams($source_entry->getId(), $flavorParamsId);
}
if (is_null($flavorAsset) || $flavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_READY) {
$flavorAsset = flavorAssetPeer::retrieveOriginalByEntryId($source_entry->getId());
}
if (is_null($flavorAsset)) {
$flavorAsset = flavorAssetPeer::retrieveHighestBitrateByEntryId($source_entry->getId());
}
if (is_null($flavorAsset)) {
throw new Exception("Flavor asset not found");
}
$flavorSyncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
if (!$flavorSyncKey) {
return false;
}
$dataPath = kFileSyncUtils::getReadyLocalFilePathForKey($flavorSyncKey);
$tempPath = myContentStorage::getFSUploadsPath();
$tempThumbPrefix = $tempPath . "temp_thumb" . microtime(true);
$thumbBigFullPath = $tempThumbPrefix . "big_1.jpg";
$thumbFullPath = $tempThumbPrefix . '1.jpg';
myFileConverter::autoCaptureFrame($dataPath, $tempThumbPrefix . "big_", $time_offset, -1, -1);
// removed creation of "small thumb" - not in use
myFileConverter::convertImage($thumbBigFullPath, $thumbFullPath);
$bigThumbExists = file_exists($thumbBigFullPath) && filesize($thumbBigFullPath);
if (!$bigThumbExists) {
return false;
}
$entry->setThumbnail(".jpg");
$entry->save();
// create new thumb file for entry
$newThumbKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
kFileSyncUtils::moveFromFile($thumbBigFullPath, $newThumbKey);
} else {
if ($media_type == entry::ENTRY_MEDIA_TYPE_VIDEO && $time_offset == -1 || $media_type == entry::ENTRY_MEDIA_TYPE_SHOW) {
$thumbBigFullKey = $source_entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
if (!kFileSyncUtils::fileSync_exists($thumbBigFullKey)) {
return false;
}
$entry->setThumbnail(".jpg");
$entry->save();
// copy existing thumb
$newThumbKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
kFileSyncUtils::softCopy($thumbBigFullKey, $newThumbKey);
} elseif ($media_type == entry::ENTRY_MEDIA_TYPE_IMAGE) {
$thumb_key = $source_entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
$thumb_path = kFileSyncUtils::getLocalFilePathForKey($thumb_key);
$entry->setThumbnail(".jpg");
$entry->save();
// copy existing thumb
$newThumbKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
kFileSyncUtils::copyFromFile($thumb_path, $newThumbKey);
} else {
return false;
}
}
self::disableAutoThumbnailCreation($entry->getId());
return true;
}
示例6: createFriendsMakeover
public static function createFriendsMakeover($subp_id, $puser_id, $puser_ids)
{
list($kshow_id, $roughcut_entry) = self::getFriendsMakover($subp_id, $puser_id);
if (!$kshow_id) {
return array(0, 0, 0);
}
$kshow = kshowPeer::retrieveByPK($kshow_id);
if (!$roughcut_entry) {
$roughcut_entry = new entry();
$roughcut_entry->setKshowId($kshow->getId());
$roughcut_entry->setKuserId($kshow->getProducerId());
$roughcut_entry->setCreatorKuserId($kshow->getProducerId());
$roughcut_entry->setPartnerId($kshow->getPartnerId());
$roughcut_entry->setSubpId($kshow->getSubpId());
$roughcut_entry->setStatus(entryStatus::READY);
$roughcut_entry->setThumbnail("&kal_show.jpg");
$roughcut_entry->setType(entryType::MIX);
$roughcut_entry->setMediaType(entry::ENTRY_MEDIA_TYPE_SHOW);
$roughcut_entry->setName("Kaltura Video");
$roughcut_entry->setTags("");
$roughcut_entry->save();
}
list($entry_ids, $entry_puser_ids) = self::getMakeoverEntries($subp_id, $puser_id, $puser_ids);
$custom_data = implode(",", $entry_puser_ids);
if ($roughcut_entry->getFromCustomData("facelift", $subp_id) == $custom_data) {
// if the users list didnt change use the current roughcut
return array($kshow_id, $roughcut_entry->getId(), 0);
}
$c = new Criteria();
$c->add(entryPeer::ID, $entry_ids, Criteria::IN);
$entries = entryPeer::doSelect($c);
self::createKEditorMetadata($kshow, $roughcut_entry, $entries);
$roughcut_entry->putInCustomData("facelift", $custom_data, $subp_id);
$roughcut_entry->save();
return array($kshow_id, $roughcut_entry->getId(), 1);
}
示例7: replaceEntry
/**
* @param entry $entry
* @param entry $tempEntry
*/
public static function replaceEntry(entry $entry, entry $tempEntry = null)
{
if (!$tempEntry) {
$tempEntry = entryPeer::retrieveByPK($entry->getReplacingEntryId());
}
if (!$tempEntry) {
KalturaLog::err("Temp entry id [" . $entry->getReplacingEntryId() . "] not found");
return;
}
//Extract all assets of the temp entry
$tempAssets = assetPeer::retrieveByEntryId($tempEntry->getId());
//Extract all assets of the existing entry
$oldAssets = assetPeer::retrieveByEntryId($entry->getId());
$newAssets = array();
//Loop which creates a mapping between the new assets' paramsId and their type to the asset itself
foreach ($tempAssets as $newAsset) {
if ($newAsset->getStatus() != asset::FLAVOR_ASSET_STATUS_READY) {
KalturaLog::info("Do not add new asset [" . $newAsset->getId() . "] to flavor [" . $newAsset->getFlavorParamsId() . "] status [" . $newAsset->getStatus() . "]");
continue;
}
//If doesn't exist - create a new array for the current asset's type.
if (!isset($newAssets[$newAsset->getType()])) {
$newAssets[$newAsset->getType()] = array();
}
if ($newAsset->getFlavorParamsId() || $newAsset instanceof flavorAsset) {
$newAssets[$newAsset->getType()][$newAsset->getFlavorParamsId()] = $newAsset;
KalturaLog::info("Added new asset [" . $newAsset->getId() . "] for asset params [" . $newAsset->getFlavorParamsId() . "]");
} else {
$newAssets[$newAsset->getType()]['asset_' . count($newAssets[$newAsset->getType()])] = $newAsset;
KalturaLog::info("Added new asset [" . $newAsset->getId() . "] with no asset params");
}
}
$defaultThumbAssetNew = null;
$defaultThumbAssetOld = null;
foreach ($oldAssets as $oldAsset) {
/* @var $oldAsset asset */
//If the newAssets map contains an asset of the same type and paramsId as the current old asset,
// re-link the old asset to the new asset.
if (isset($newAssets[$oldAsset->getType()]) && isset($newAssets[$oldAsset->getType()][$oldAsset->getFlavorParamsId()])) {
$newAsset = $newAssets[$oldAsset->getType()][$oldAsset->getFlavorParamsId()];
if ($oldAsset->hasTag(assetParams::TAG_RECORDING_ANCHOR)) {
$newAsset->addTags(array(assetParams::TAG_RECORDING_ANCHOR));
}
/* @var $newAsset asset */
KalturaLog::info("Create link from new asset [" . $newAsset->getId() . "] to old asset [" . $oldAsset->getId() . "] for flavor [" . $oldAsset->getFlavorParamsId() . "]");
$oldAsset->linkFromAsset($newAsset);
$oldAsset->save();
self::createFileSyncLinkFromReplacingAsset($oldAsset, $newAsset, asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
self::createFileSyncLinkFromReplacingAsset($oldAsset, $newAsset, asset::FILE_SYNC_ASSET_SUB_TYPE_ISM);
self::createFileSyncLinkFromReplacingAsset($oldAsset, $newAsset, asset::FILE_SYNC_ASSET_SUB_TYPE_ISMC);
self::createFileSyncLinkFromReplacingAsset($oldAsset, $newAsset, asset::FILE_SYNC_ASSET_SUB_TYPE_MPD);
$newFlavorMediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($newAsset->getId());
if ($newFlavorMediaInfo) {
$oldFlavorNewMediaInfo = $newFlavorMediaInfo->copy();
$oldFlavorNewMediaInfo->setFlavorAssetId($oldAsset->getId());
$oldFlavorNewMediaInfo->setFlavorAssetVersion($oldAsset->getVersion());
$oldFlavorNewMediaInfo->save();
}
unset($newAssets[$oldAsset->getType()][$oldAsset->getFlavorParamsId()]);
if ($oldAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB)) {
$defaultThumbAssetNew = $oldAsset;
KalturaLog::info("Nominating ThumbAsset [" . $oldAsset->getId() . "] as the default ThumbAsset after replacent");
}
} elseif ($oldAsset instanceof flavorAsset || $oldAsset instanceof thumbAsset) {
if ($oldAsset instanceof thumbAsset && $oldAsset->keepOnEntryReplacement()) {
KalturaLog::info("KeepManualThumbnails ind is set, manual thumbnail is not deleted [" . $oldAsset->getId() . "]");
if ($oldAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB)) {
$defaultThumbAssetOld = $oldAsset;
}
} else {
KalturaLog::info("Delete old asset [" . $oldAsset->getId() . "] for paramsId [" . $oldAsset->getFlavorParamsId() . "]");
$oldAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_DELETED);
$oldAsset->setDeletedAt(time());
$oldAsset->save();
}
}
}
foreach ($newAssets as $newAssetsByTypes) {
foreach ($newAssetsByTypes as $newAsset) {
$createdAsset = $newAsset->copyToEntry($entry->getId(), $entry->getPartnerId());
KalturaLog::info("Copied from new asset [" . $newAsset->getId() . "] to copied asset [" . $createdAsset->getId() . "] for flavor [" . $newAsset->getFlavorParamsId() . "]");
if ($createdAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB)) {
$defaultThumbAssetNew = $newAsset;
KalturaLog::info("Nominating ThumbAsset [" . $newAsset->getId() . "] as the default ThumbAsset after replacent");
}
}
}
if ($defaultThumbAssetOld) {
KalturaLog::info("Kepping ThumbAsset [" . $defaultThumbAssetOld->getId() . "] as the default ThumbAsset");
} elseif ($defaultThumbAssetNew) {
kBusinessConvertDL::setAsDefaultThumbAsset($defaultThumbAssetNew);
KalturaLog::info("Setting ThumbAsset [" . $defaultThumbAssetNew->getId() . "] as the default ThumbAsset");
} else {
KalturaLog::info("No default ThumbAsset found for replacing entry [" . $tempEntry->getId() . "]");
$entry->setThumbnail(".jpg");
// thumbnailversion++
//.........这里部分代码省略.........
示例8: executeImpl
protected function executeImpl(kshow $kshow, entry &$entry)
{
$this->res = "";
$likuser_id = $this->getLoggedInUserId();
// if we allow multiple rouchcuts - there is no reason for one suer to override someone else's thumbnail
if ($this->allowMultipleRoughcuts()) {
if ($likuser_id != $entry->getKuserId()) {
// ERROR - attempting to update an entry which doesnt belong to the user
return "<xml>!!</xml>";
//$this->securityViolation( $kshow->getId() );
}
}
$debug = @$_GET["debug"];
/*
$kshow_id = @$_GET["kshow_id"];
$debug = @$_GET["debug"];
$this->kshow_id = $kshow_id;
if ( $kshow_id == NULL || $kshow_id == 0 ) return;
$kshow = kshowPeer::retrieveByPK( $kshow_id );
if ( ! $kshow )
{
$this->res = "No kshow " . $kshow_id ;
return;
}
// is the logged-in-user is not an admin or the producer - check if show can be published
$likuser_id = $this->getLoggedInUserId();
$viewer_type = myKshowUtils::getViewerType($kshow, $likuser_id);
if ( $viewer_type != KshowKuser::KSHOWKUSER_VIEWER_PRODUCER && ( ! $kshow->getCanPublish() ) )
{
// ERROR - attempting to publish a non-publishable show
return "<xml>!</xml>";//$this->securityViolation( $kshow->getId() );
}
// ASSUME - the kshow & roughcut already exist
$show_entry_id = $kshow->getShowEntryId();
$roughcut = entryPeer::retrieveByPK( $show_entry_id );
$roughcut = entryPeer::retrieveByPK( $entry_id );
if ( ! $roughcut)
{
$this->res = "No roughcut for kshow " . $kshow->getId() ;
return;
}
*/
// echo "for entry: $show_entry_id current thumb path: " . $entry->getThumbnail() ;
$entry->setThumbnail(".jpg");
$entry->setCreateThumb(false);
$entry->save();
//$thumb_data = $_REQUEST["ThumbData"];
if (isset($HTTP_RAW_POST_DATA)) {
$thumb_data = $HTTP_RAW_POST_DATA;
} else {
$thumb_data = file_get_contents("php://input");
}
// $thumb_data = $GLOBALS["HTTP_RAW_POST_DATA"];
$thumb_data_size = strlen($thumb_data);
$bigThumbPath = myContentStorage::getFSContentRootPath() . $entry->getBigThumbnailPath();
kFile::fullMkdir($bigThumbPath);
kFile::setFileContent($bigThumbPath, $thumb_data);
$path = myContentStorage::getFSContentRootPath() . $entry->getThumbnailPath();
kFile::fullMkdir($path);
myFileConverter::createImageThumbnail($bigThumbPath, $path);
$roughcutPath = myContentStorage::getFSContentRootPath() . $entry->getDataPath();
$xml_doc = new KDOMDocument();
$xml_doc->load($roughcutPath);
if (myMetadataUtils::updateThumbUrl($xml_doc, $entry->getBigThumbnailUrl())) {
$xml_doc->save($roughcutPath);
}
$this->res = $entry->getBigThumbnailUrl();
}
示例9: replaceEntry
//.........这里部分代码省略.........
//If doesn't exist - create a new array for the current asset's type.
if (!isset($newAssets[$newAsset->getType()])) {
$newAssets[$newAsset->getType()] = array();
}
if ($newAsset->getFlavorParamsId() || $newAsset instanceof flavorAsset) {
$newAssets[$newAsset->getType()][$newAsset->getFlavorParamsId()] = $newAsset;
KalturaLog::debug("Added new asset [" . $newAsset->getId() . "] for asset params [" . $newAsset->getFlavorParamsId() . "]");
} else {
$newAssets[$newAsset->getType()]['asset_' . count($newAssets[$newAsset->getType()])] = $newAsset;
KalturaLog::debug("Added new asset [" . $newAsset->getId() . "] with no asset params");
}
}
$saveEntry = false;
$defaultThumbAssetNew = null;
foreach ($oldAssets as $oldAsset) {
/* @var $oldAsset asset */
kFileSyncUtils::clearWAMSDataForKey($oldAsset->getSyncKey(asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET));
//If the newAssets map contains an asset of the same type and paramsId as the current old asset,
// re-link the old asset to the new asset.
if (isset($newAssets[$oldAsset->getType()]) && isset($newAssets[$oldAsset->getType()][$oldAsset->getFlavorParamsId()])) {
$newAsset = $newAssets[$oldAsset->getType()][$oldAsset->getFlavorParamsId()];
/* @var $newAsset asset */
KalturaLog::debug("Create link from new asset [" . $newAsset->getId() . "] to old asset [" . $oldAsset->getId() . "] for flavor [" . $oldAsset->getFlavorParamsId() . "]");
if ($oldAsset instanceof flavorAsset) {
$oldAsset->setBitrate($newAsset->getBitrate());
$oldAsset->setFrameRate($newAsset->getFrameRate());
$oldAsset->setVideoCodecId($newAsset->getVideoCodecId());
}
$oldAsset->setWidth($newAsset->getWidth());
$oldAsset->setHeight($newAsset->getHeight());
$oldAsset->setContainerFormat($newAsset->getContainerFormat());
$oldAsset->setSize($newAsset->getSize());
$oldAsset->setFileExt($newAsset->getFileExt());
$oldAsset->setTags($newAsset->getTags());
$oldAsset->setDescription($newAsset->getDescription());
$oldAsset->incrementVersion();
$oldAsset->setStatusLocalReady();
$oldAsset->save();
$oldFileSync = $oldAsset->getSyncKey(asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$newFileSync = $newAsset->getSyncKey(asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
kFileSyncUtils::createSyncFileLinkForKey($oldFileSync, $newFileSync);
$newFlavorMediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($newAsset->getId());
if ($newFlavorMediaInfo) {
$oldFlavorNewMediaInfo = $newFlavorMediaInfo->copy();
$oldFlavorNewMediaInfo->setFlavorAssetId($oldAsset->getId());
$oldFlavorNewMediaInfo->setFlavorAssetVersion($oldAsset->getVersion());
$oldFlavorNewMediaInfo->save();
}
unset($newAssets[$oldAsset->getType()][$oldAsset->getFlavorParamsId()]);
if ($oldAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB)) {
$defaultThumbAssetNew = $oldAsset;
KalturaLog::debug("Nominating ThumbAsset [" . $oldAsset->getId() . "] as the default ThumbAsset after replacent");
}
} elseif ($oldAsset instanceof flavorAsset || $oldAsset instanceof thumbAsset) {
KalturaLog::debug("Delete old asset [" . $oldAsset->getId() . "] for paramsId [" . $oldAsset->getFlavorParamsId() . "]");
$oldAsset->setStatus(flavorAsset::ASSET_STATUS_DELETED);
$oldAsset->setDeletedAt(time());
$oldAsset->save();
$entry->removeFlavorParamsId($oldAsset->getFlavorParamsId());
$saveEntry = true;
}
}
foreach ($newAssets as $newAssetsByTypes) {
foreach ($newAssetsByTypes as $newAsset) {
$createdAsset = $newAsset->copyToEntry($entry->getId(), $entry->getPartnerId());
KalturaLog::debug("Copied from new asset [" . $newAsset->getId() . "] to copied asset [" . $createdAsset->getId() . "] for flavor [" . $newAsset->getFlavorParamsId() . "]");
if ($createdAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB)) {
$defaultThumbAssetNew = $newAsset;
KalturaLog::debug("Nominating ThumbAsset [" . $newAsset->getId() . "] as the default ThumbAsset after replacent");
}
}
}
if ($defaultThumbAssetNew) {
kBusinessConvertDL::setAsDefaultThumbAsset($defaultThumbAssetNew);
kalturalog::debug("Setting ThumbAsset [" . $defaultThumbAssetNew->getId() . "] as the default ThumbAsset");
} else {
kalturalog::debug("No default ThumbAsset found for replacing entry [" . $tempEntry->getId() . "]");
$entry->setThumbnail(".jpg");
// thumbnailversion++
$entry->save();
$tempEntrySyncKey = $tempEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
$realEntrySyncKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
kFileSyncUtils::createSyncFileLinkForKey($realEntrySyncKey, $tempEntrySyncKey);
}
$entry->setDimensions($tempEntry->getWidth(), $tempEntry->getHeight());
$entry->setLengthInMsecs($tempEntry->getLengthInMsecs());
$entry->setConversionProfileId($tempEntry->getConversionProfileId());
$entry->setConversionQuality($tempEntry->getConversionQuality());
$entry->setReplacingEntryId(null);
$entry->setReplacementStatus(entryReplacementStatus::NONE);
$entry->setStatus($tempEntry->getStatus());
$entry->save();
myEntryUtils::deleteEntry($tempEntry, null, true);
$te = new TrackEntry();
$te->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_REPLACED_ENTRY);
$te->setEntryId($entry->getId());
$te->setParam1Str($tempEntry->getId());
$te->setDescription(__METHOD__ . "[" . __LINE__ . "]");
TrackEntry::addTrackEntry($te);
}