本文整理匯總了PHP中myEntryUtils::resizeEntryImage方法的典型用法代碼示例。如果您正苦於以下問題:PHP myEntryUtils::resizeEntryImage方法的具體用法?PHP myEntryUtils::resizeEntryImage怎麽用?PHP myEntryUtils::resizeEntryImage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類myEntryUtils
的用法示例。
在下文中一共展示了myEntryUtils::resizeEntryImage方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getLocalThumbFilePath
public function getLocalThumbFilePath($version, $width, $height, $type, $bgcolor = "ffffff", $crop_provider = null, $quality = 0, $src_x = 0, $src_y = 0, $src_w = 0, $src_h = 0, $vid_sec = -1, $vid_slice = 0, $vid_slices = -1, $density = 0, $stripProfiles = false, $flavorId = null, $fileName = null)
{
if ($this->getStatus() == entryStatus::DELETED || $this->getModerationStatus() == moderation::MODERATION_STATUS_BLOCK) {
KalturaLog::log("rejected live stream entry - not serving thumbnail");
KExternalErrors::dieError(KExternalErrors::ENTRY_DELETED_MODERATED);
}
$contentPath = myContentStorage::getFSContentRootPath();
$liveEntryExist = false;
$liveThumbEntry = null;
$liveThumbEntryId = null;
$partner = $this->getPartner();
if ($partner) {
$liveThumbEntryId = $partner->getLiveThumbEntryId();
}
if ($liveThumbEntryId) {
$liveThumbEntry = entryPeer::retrieveByPK($liveThumbEntryId);
}
if ($liveThumbEntry && $liveThumbEntry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) {
$fileSyncVersion = $partner->getLiveThumbEntryVersion();
$liveEntryKey = $liveThumbEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA, $fileSyncVersion);
$contentPath = kFileSyncUtils::getLocalFilePathForKey($liveEntryKey);
if ($contentPath) {
$msgPath = $contentPath;
$liveEntryExist = true;
} else {
KalturaLog::err('no local file sync for audio entry id');
}
}
if (!$liveEntryExist) {
$msgPath = $contentPath . "content/templates/entry/thumbnail/live_thumb.jpg";
}
return myEntryUtils::resizeEntryImage($this, $version, $width, $height, $type, $bgcolor, $crop_provider, $quality, $src_x, $src_y, $src_w, $src_h, $vid_sec, $vid_slice, $vid_slices, $msgPath, $density, $stripProfiles);
}
示例2: getLocalThumbFilePath
/**
* will create thumbnail according to the entry type
* @return the thumbnail path.
*/
public function getLocalThumbFilePath($version, $width, $height, $type, $bgcolor = "ffffff", $crop_provider = null, $quality = 0, $src_x = 0, $src_y = 0, $src_w = 0, $src_h = 0, $vid_sec = -1, $vid_slice = 0, $vid_slices = -1, $density = 0, $stripProfiles = false, $flavorId = null, $fileName = null)
{
$contentPath = myContentStorage::getFSContentRootPath();
// if entry type is audio - serve generic thumb:
if ($this->getMediaType() == entry::ENTRY_MEDIA_TYPE_AUDIO) {
if ($this->getStatus() == entryStatus::DELETED || $this->getModerationStatus() == moderation::MODERATION_STATUS_BLOCK) {
KalturaLog::log("rejected audio entry - not serving thumbnail");
KExternalErrors::dieError(KExternalErrors::ENTRY_DELETED_MODERATED);
}
$audioEntryExist = false;
$audioThumbEntry = null;
$audioThumbEntryId = null;
$partner = $this->getPartner();
if ($partner) {
$audioThumbEntryId = $partner->getAudioThumbEntryId();
}
if ($audioThumbEntryId) {
$audioThumbEntry = entryPeer::retrieveByPK($audioThumbEntryId);
}
if ($audioThumbEntry && $audioThumbEntry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) {
$fileSyncVersion = $partner->getAudioThumbEntryVersion();
$audioEntryKey = $audioThumbEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA, $fileSyncVersion);
$contentPath = kFileSyncUtils::getLocalFilePathForKey($audioEntryKey);
if ($contentPath) {
$msgPath = $contentPath;
$audioEntryExist = true;
} else {
KalturaLog::err('no local file sync for entry id');
}
}
if (!$audioEntryExist) {
$msgPath = $contentPath . "content/templates/entry/thumbnail/audio_thumb.jpg";
}
return myEntryUtils::resizeEntryImage($this, $version, $width, $height, $type, $bgcolor, $crop_provider, $quality, $src_x, $src_y, $src_w, $src_h, $vid_sec, $vid_slice, $vid_slices, $msgPath, $density, $stripProfiles);
} elseif ($this->getMediaType() == entry::ENTRY_MEDIA_TYPE_SHOW) {
// roughcut without any thumbnail, probably just created
$msgPath = $contentPath . "content/templates/entry/thumbnail/auto_edit.jpg";
return myEntryUtils::resizeEntryImage($this, $version, $width, $height, $type, $bgcolor, $crop_provider, $quality, $src_x, $src_y, $src_w, $src_h, $vid_sec, $vid_slice, $vid_slices, $msgPath, $density, $stripProfiles);
} elseif ($this->getType() == entryType::MEDIA_CLIP) {
try {
return myEntryUtils::resizeEntryImage($this, $version, $width, $height, $type, $bgcolor, $crop_provider, $quality, $src_x, $src_y, $src_w, $src_h, $vid_sec, $vid_slice, $vid_slices);
} catch (Exception $ex) {
if ($ex->getCode() == kFileSyncException::FILE_DOES_NOT_EXIST_ON_CURRENT_DC) {
// get original flavor asset
$origFlavorAsset = assetPeer::retrieveOriginalByEntryId($this->getId());
if ($origFlavorAsset) {
$syncKey = $origFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
list($readyFileSync, $isLocal) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, TRUE, FALSE);
if ($readyFileSync) {
if ($isLocal) {
KalturaLog::err('Trying to redirect to myself - stop here.');
KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC);
}
//Ready fileSync is on the other DC - dumping
kFileUtils::dumpApiRequest(kDataCenterMgr::getRemoteDcExternalUrlByDcId(1 - kDataCenterMgr::getCurrentDcId()));
}
KalturaLog::err('No ready fileSync found on any DC.');
KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC);
}
}
}
}
}
示例3: 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)
}
示例4: execute
public function execute()
{
requestUtils::handleConditionalGet();
$entry_id = $this->getRequestParameter("entry_id");
$ks_str = $this->getRequestParameter("ks");
$base64_referrer = $this->getRequestParameter("referrer");
$referrer = base64_decode($base64_referrer);
if (!is_string($referrer)) {
// base64_decode can return binary data
$referrer = "";
}
$clip_from = $this->getRequestParameter("clip_from", 0);
// milliseconds
$clip_to = $this->getRequestParameter("clip_to", 2147483647);
// milliseconds
if ($clip_to == 0) {
$clip_to = 2147483647;
}
$request = $_SERVER["REQUEST_URI"];
// remove dynamic fields from the url so we'll request a single url from the cdn
$request = str_replace("/referrer/{$base64_referrer}", "", $request);
$request = str_replace("/ks/{$ks_str}", "", $request);
// workaround the filter which hides all the deleted entries -
// now that deleted entries are part of xmls (they simply point to the 'deleted' templates), we should allow them here
$entry = entryPeer::retrieveByPKNoFilter($entry_id);
if (!$entry) {
KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
}
myPartnerUtils::blockInactivePartner($entry->getPartnerId());
// set the memory size to be able to serve big files in a single chunk
ini_set("memory_limit", "64M");
// set the execution time to be able to serve big files in a single chunk
ini_set("max_execution_time", 240);
if ($entry->getType() == entryType::MIX && $entry->getStatus() == entryStatus::DELETED) {
// because the fiter was turned off - a manual check for deleted entries must be done.
die;
} else {
if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) {
$version = $this->getRequestParameter("version", null);
$width = $this->getRequestParameter("width", -1);
$height = $this->getRequestParameter("height", -1);
$crop_provider = $this->getRequestParameter("crop_provider", null);
$bgcolor = $this->getRequestParameter("bgcolor", "ffffff");
$type = $this->getRequestParameter("type", 1);
$quality = $this->getRequestParameter("quality", 0);
$src_x = $this->getRequestParameter("src_x", 0);
$src_y = $this->getRequestParameter("src_y", 0);
$src_w = $this->getRequestParameter("src_w", 0);
$src_h = $this->getRequestParameter("src_h", 0);
$vid_sec = $this->getRequestParameter("vid_sec", -1);
$vid_slice = $this->getRequestParameter("vid_slice", -1);
$vid_slices = $this->getRequestParameter("vid_slices", -1);
if ($width == -1 && $height == -1) {
$width = 640;
$height = 480;
} else {
if ($width == -1) {
// if only either width or height is missing reset them to zero, and convertImage will handle them
$width = 0;
} else {
if ($height == -1) {
$height = 0;
}
}
}
$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);
kFile::dumpFile($tempThumbPath, null, strpos($tempThumbPath, "_NOCACHE_") === false ? null : 0);
}
}
$audio_only = $this->getRequestParameter("audio_only");
// milliseconds
$flavor = $this->getRequestParameter("flavor", 1);
//
$flavor_param_id = $this->getRequestParameter("flavor_param_id", null);
//
$streamer = $this->getRequestParameter("streamer");
//
if (substr($streamer, 0, 4) == "rtmp") {
// the fms may add .mp4 to the end of the url
$streamer = "rtmp";
}
// grab seek_from_bytes parameter and normalize url
$seek_from_bytes = $this->getRequestParameter("seek_from_bytes", -1);
$request = str_replace("/seek_from_bytes/{$seek_from_bytes}", "", $request);
if ($seek_from_bytes <= 0) {
$seek_from_bytes = -1;
}
// grab seek_from parameter and normalize url
$seek_from = $this->getRequestParameter("seek_from", -1);
$request = str_replace("/seek_from/{$seek_from}", "", $request);
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";
//.........這裏部分代碼省略.........
示例5: execute
//.........這裏部分代碼省略.........
// 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";
}
kFileUtils::dumpFile($msgPath, null, 0);
}
if (!$file_sync) {
$tempThumbPath = $entry->getLocalThumbFilePath($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}");
KExternalErrors::dieGracefully();
}
$remoteUrl = kDataCenterMgr::getRedirectExternalUrl($file_sync, $_SERVER['REQUEST_URI']);
kFileUtils::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, $imageFilePath, $density, $stripProfiles, $thumbParams, $format);
} catch (Exception $ex) {
if ($ex->getCode() != kFileSyncException::FILE_DOES_NOT_EXIST_ON_CURRENT_DC) {
KalturaLog::err("Resize image failed");
KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC);
}
// get original flavor asset
$origFlavorAsset = assetPeer::retrieveOriginalByEntryId($entry_id);
if (!$origFlavorAsset) {
KalturaLog::err("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::err("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);
kFileUtils::dumpUrl($remoteUrl);
}
}
$nocache = false;
if ($securyEntryHelper->shouldDisableCache() || kApiCache::hasExtraFields() || !$securyEntryHelper->isKsWidget() && $securyEntryHelper->hasRules(ContextType::THUMBNAIL)) {
$nocache = true;
示例6: execute
//.........這裏部分代碼省略.........
}
$subType = entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB;
if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) {
$subType = entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA;
}
$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) {
// if entry type is audio - serve generic thumb:
if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_AUDIO) {
if ($entry->getStatus() == entryStatus::DELETED && $entry->getModerationStatus() == moderation::MODERATION_STATUS_BLOCK) {
KalturaLog::log("rejected audio entry - not serving thumbnail");
KExternalErrors::dieError(KExternalErrors::ENTRY_DELETED_MODERATED);
}
$contentPath = myContentStorage::getFSContentRootPath();
$msgPath = $contentPath . "content/templates/entry/thumbnail/audio_thumb.jpg";
$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, $msgPath);
//kFile::dumpFile($tempThumbPath, null, 0);
} elseif ($entry->getType() == entryType::LIVE_STREAM) {
if ($entry->getStatus() == entryStatus::DELETED && $entry->getModerationStatus() == moderation::MODERATION_STATUS_BLOCK) {
KalturaLog::log("rejected live stream entry - not serving thumbnail");
KExternalErrors::dieError(KExternalErrors::ENTRY_DELETED_MODERATED);
}
$contentPath = myContentStorage::getFSContentRootPath();
$msgPath = $contentPath . "content/templates/entry/thumbnail/live_thumb.jpg";
$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, $msgPath);
} elseif ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_SHOW) {
$contentPath = myContentStorage::getFSContentRootPath();
$msgPath = $contentPath . "content/templates/entry/thumbnail/auto_edit.jpg";
$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, $msgPath);
//kFile::dumpFile($tempThumbPath, null, 0);
} elseif ($entry->getType() == entryType::MEDIA_CLIP) {
// commenting out the new behavior, in this case the thumbnail will be created in resizeEntryImage
//$contentPath = myContentStorage::getFSContentRootPath();
//$msgPath = $contentPath."content/templates/entry/thumbnail/broken_thumb.jpg";
//header("Xkaltura-app: entry [$entry_id] in conversion, returning template broken thumb");
//KalturaLog::log( "Entry in conversion, no thumbnail yet [$entry_id], created dynamic 1x1 jpg");
//kFile::dumpFile($msgPath, null, 0);
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);
} catch (Exception $ex) {
if ($ex->getCode() == kFileSyncException::FILE_DOES_NOT_EXIST_ON_CURRENT_DC) {
// get original flavor asset
$origFlavorAsset = flavorAssetPeer::retrieveOriginalByEntryId($entry_id);
if ($origFlavorAsset) {
$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
示例7: serveAction
/**
* Serves thumbnail by its id
*
* @action serve
* @param string $thumbAssetId
* @param int $version
* @param KalturaThumbParams $thumbParams
* @param KalturaThumbnailServeOptions $options
* @return file
*
* @throws KalturaErrors::THUMB_ASSET_IS_NOT_READY
* @throws KalturaErrors::THUMB_ASSET_ID_NOT_FOUND
*/
public function serveAction($thumbAssetId, $version = null, KalturaThumbParams $thumbParams = null, KalturaThumbnailServeOptions $options = null)
{
if (!kCurrentContext::$ks) {
$thumbAsset = kCurrentContext::initPartnerByAssetId($thumbAssetId);
if (!$thumbAsset || $thumbAsset->getStatus() == asset::ASSET_STATUS_DELETED) {
throw new KalturaAPIException(KalturaErrors::THUMB_ASSET_ID_NOT_FOUND, $thumbAssetId);
}
// enforce entitlement
$this->setPartnerFilters(kCurrentContext::getCurrentPartnerId());
kEntitlementUtils::initEntitlementEnforcement();
} else {
$thumbAsset = assetPeer::retrieveById($thumbAssetId);
}
if (!$thumbAsset || !$thumbAsset instanceof thumbAsset) {
throw new KalturaAPIException(KalturaErrors::THUMB_ASSET_ID_NOT_FOUND, $thumbAssetId);
}
$entry = entryPeer::retrieveByPK($thumbAsset->getEntryId());
if (!$entry) {
//we will throw thumb asset not found, as the user is not entitled, and should not know that the entry exists.
throw new KalturaAPIException(KalturaErrors::THUMB_ASSET_ID_NOT_FOUND, $thumbAssetId);
}
$securyEntryHelper = new KSecureEntryHelper($entry, kCurrentContext::$ks, null, ContextType::THUMBNAIL);
$securyEntryHelper->validateAccessControl();
$ext = $thumbAsset->getFileExt();
if (is_null($ext)) {
$ext = 'jpg';
}
$fileName = $thumbAsset->getEntryId() . "_" . $thumbAsset->getId() . ".{$ext}";
if (!$thumbParams) {
if ($options && $options->download) {
header("Content-Disposition: attachment; filename=\"{$fileName}\"");
}
return $this->serveAsset($thumbAsset, $fileName, $version);
}
$thumbParams->validate();
$syncKey = $thumbAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET, $version);
if (!kFileSyncUtils::fileSync_exists($syncKey)) {
throw new KalturaAPIException(KalturaErrors::FILE_DOESNT_EXIST);
}
list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
/* @var $fileSync FileSync */
if (!$local) {
if (!in_array($fileSync->getDc(), kDataCenterMgr::getDcIds())) {
throw new KalturaAPIException(KalturaErrors::FILE_DOESNT_EXIST);
}
$remoteUrl = kDataCenterMgr::getRedirectExternalUrl($fileSync);
KalturaLog::info("Redirecting to [{$remoteUrl}]");
header("Location: {$remoteUrl}");
die;
}
$filePath = $fileSync->getFullPath();
$thumbVersion = $thumbAsset->getId() . '_' . $version;
$tempThumbPath = myEntryUtils::resizeEntryImage($entry, $thumbVersion, $thumbParams->width, $thumbParams->height, $thumbParams->cropType, $thumbParams->backgroundColor, null, $thumbParams->quality, $thumbParams->cropX, $thumbParams->cropY, $thumbParams->cropWidth, $thumbParams->cropHeight, -1, 0, -1, $filePath, $thumbParams->density, $thumbParams->stripProfiles, null);
if ($options && $options->download) {
header("Content-Disposition: attachment; filename=\"{$fileName}\"");
}
$mimeType = kFile::mimeType($tempThumbPath);
return $this->dumpFile($tempThumbPath, $mimeType);
}
示例8: getLocalThumbFilePath
public function getLocalThumbFilePath($version, $width, $height, $type, $bgcolor = "ffffff", $crop_provider = null, $quality = 0, $src_x = 0, $src_y = 0, $src_w = 0, $src_h = 0, $vid_sec = -1, $vid_slice = 0, $vid_slices = -1, $density = 0, $stripProfiles = false, $flavorId = null, $fileName = null)
{
KalturaLog::log("flavor_id [{$flavorId}] file_name [{$fileName}]");
if (is_null($flavorId)) {
KExternalErrors::dieError(KExternalErrors::MISSING_PARAMETER, 'flavor_id');
}
$flavor = assetPeer::retrieveById($flavorId);
if (is_null($flavor)) {
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND, $flavorId);
}
$flavorSyncKey = $flavor->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET);
$file_path = kFileSyncUtils::getReadyLocalFilePathForKey($flavorSyncKey);
$orig_image_path = null;
if (is_dir($file_path)) {
if (is_null($fileName)) {
KExternalErrors::dieError(KExternalErrors::MISSING_PARAMETER, 'file name');
}
$orig_image_path = $file_path . DIRECTORY_SEPARATOR . $fileName;
}
try {
return myEntryUtils::resizeEntryImage($this, $version, $width, $height, $type, $bgcolor, $crop_provider, $quality, $src_x, $src_y, $src_w, $src_h, $vid_sec, $vid_slice, $vid_slices, $orig_image_path, $density);
} catch (Exception $ex) {
if ($ex->getCode() == kFileSyncException::FILE_DOES_NOT_EXIST_ON_CURRENT_DC) {
$remoteFileSync = kFileSyncUtils::getOriginFileSyncForKey($flavorSyncKey, false);
if (!$remoteFileSync) {
// file does not exist on any DC - die
KalturaLog::err("No FileSync for flavor [{$flavorId}]");
KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND);
}
if ($remoteFileSync->getDc() == kDataCenterMgr::getCurrentDcId()) {
KalturaLog::err("Trying to redirect to myself - stop here.");
KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND);
}
if (!in_array($remoteFileSync->getDc(), kDataCenterMgr::getDcIds())) {
KalturaLog::err("Origin file sync is on remote storage.");
KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND);
}
$remoteUrl = kDataCenterMgr::getRedirectExternalUrl($remoteFileSync);
kFileUtils::dumpUrl($remoteUrl);
}
}
}