本文整理汇总了PHP中entry::getType方法的典型用法代码示例。如果您正苦于以下问题:PHP entry::getType方法的具体用法?PHP entry::getType怎么用?PHP entry::getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类entry
的用法示例。
在下文中一共展示了entry::getType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: entryCreated
/**
* @param entry $object
* @return bool true if should continue to the next consumer
*/
public function entryCreated(entry $object)
{
$mediaType = null;
if ($object->getType() == entryType::AUTOMATIC) {
KalturaLog::debug("entry id [" . $object->getId() . "] type [" . $object->getType() . "] source link [" . $object->getSourceLink() . "]");
$mediaType = $object->getMediaType();
if (isset(self::$fileExtensions[$mediaType])) {
$object->setType(entryType::DOCUMENT);
} elseif (is_null($mediaType) || $mediaType == entry::ENTRY_MEDIA_TYPE_ANY || $mediaType == entry::ENTRY_MEDIA_TYPE_AUTOMATIC) {
$this->setDocumentType($object);
}
}
if ($object->getType() != entryType::DOCUMENT) {
KalturaLog::debug("entry id [" . $object->getId() . "] type [" . $object->getType() . "]");
return true;
}
if (is_null($mediaType) || $mediaType == entry::ENTRY_MEDIA_TYPE_ANY || $mediaType == entry::ENTRY_MEDIA_TYPE_AUTOMATIC) {
$this->setDocumentType($object);
}
if ($object instanceof DocumentEntry) {
KalturaLog::debug("entry id [" . $object->getId() . "] already handled");
return true;
}
KalturaLog::debug("Handling object [" . get_class($object) . "] type [" . $object->getType() . "] id [" . $object->getId() . "] status [" . $object->getStatus() . "]");
if ($object->getConversionProfileId()) {
$object->setStatus(entryStatus::PRECONVERT);
$object->save();
}
return true;
}
示例2: matches
/**
* This function checks if the entry type matches the filter, and return 'true' or 'false' accordingly.
* @param entry $entry
* @return boolean
*/
public function matches(entry $entry)
{
// check if type equals
if ($entry->getType() == $this->get('_eq_type')) {
return true;
}
// check if type in
if (in_array($entry->getType(), explode(',', $this->get('_in_type')))) {
return true;
}
return false;
}
示例3: serveRtmp
/**
* @return kManifestRenderer
*/
private function serveRtmp()
{
$baseUrl = null;
switch ($this->entry->getType()) {
case entryType::MEDIA_CLIP:
$flavors = $this->buildRtmpFlavorsArray($duration, $baseUrl);
if (!count($flavors)) {
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
}
$renderer = new kF4MManifestRenderer();
$renderer->entryId = $this->entryId;
$renderer->tokenizer = $this->tokenizer;
$renderer->flavors = $flavors;
$renderer->baseUrl = $baseUrl;
$renderer->duration = $duration;
$renderer->mimeType = $this->getMimeType($flavors);
return $renderer;
case entryType::LIVE_STREAM:
$flavors = $this->buildRtmpLiveStreamFlavorsArray($baseUrl);
$renderer = new kF4MManifestRenderer();
$renderer->entryId = $this->entryId;
$renderer->tokenizer = $this->tokenizer;
$renderer->flavors = $flavors;
$renderer->baseUrl = $baseUrl;
$renderer->streamType = kF4MManifestRenderer::PLAY_STREAM_TYPE_LIVE;
$renderer->mimeType = $this->getMimeType($flavors);
$renderer->deliveryCode = $this->deliveryCode;
return $renderer;
}
KExternalErrors::dieError(KExternalErrors::INVALID_ENTRY_TYPE);
}
示例4: generateMultiUrl
protected static function generateMultiUrl(array $flavors, entry $entry)
{
$urls = array();
foreach ($flavors as $flavor) {
$urls[] = $flavor['url'];
}
$urls = array_unique($urls);
if (count($urls) == 1) {
$baseUrl = reset($urls);
return '/' . ltrim($baseUrl, '/');
}
$prefix = kString::getCommonPrefix($urls);
$postfix = kString::getCommonPostfix($urls);
if ($entry->getType() == entryType::PLAYLIST) {
// in case of a playlist, need to merge the flavor params of the urls
// instead of using a urlset, since nginx-vod does not support urlsets of
// non-trivial mapping responses.
// so instead of building:
// /p/123/serveFlavor/entryId/0_abc/flavorParamIds/100,1,2,3,/forceproxy/true/name/a.mp4.urlset
// we build:
// /p/123/serveFlavor/entryId/0_abc/flavorParamIds/1001,1002,1003/forceproxy/true/name/a.mp4.urlset
$prefix = substr($prefix, 0, strrpos($prefix, '/') + 1);
$postfix = substr($postfix, strpos($postfix, '/'));
}
$prefixLen = strlen($prefix);
$postfixLen = strlen($postfix);
$middlePart = ',';
foreach ($urls as $url) {
$middlePart .= substr($url, $prefixLen, strlen($url) - $prefixLen - $postfixLen) . ',';
}
if ($entry->getType() == entryType::PLAYLIST && strpos($middlePart, '/') === false) {
$middlePart = rtrim(ltrim($middlePart, ','), ',');
$result = $prefix . $middlePart . $postfix;
} else {
$result = $prefix . $middlePart . $postfix . '.urlset';
}
return '/' . ltrim($result, '/');
}
示例5: entryHandled
public function entryHandled(entry $dbEntry)
{
$srcEntry = entryPeer::retrieveByPK($this->entryId);
if ($srcEntry->getType() == KalturaEntryType::MEDIA_CLIP && $dbEntry->getType() == KalturaEntryType::MEDIA_CLIP && $dbEntry->getMediaType() == KalturaMediaType::IMAGE) {
if ($dbEntry->getMediaType() == KalturaMediaType::IMAGE) {
$dbEntry->setDimensions($srcEntry->getWidth(), $srcEntry->getHeight());
$dbEntry->setMediaDate($srcEntry->getMediaDate(null));
$dbEntry->save();
} else {
$srcFlavorAsset = null;
if (is_null($this->flavorParamsId)) {
$srcFlavorAsset = assetPeer::retrieveOriginalByEntryId($this->entryId);
} else {
$srcFlavorAsset = assetPeer::retrieveByEntryIdAndParams($this->entryId, $this->flavorParamsId);
}
if ($srcFlavorAsset) {
$dbEntry->setDimensions($srcFlavorAsset->getWidth(), $srcFlavorAsset->getHeight());
$dbEntry->save();
}
}
}
return parent::entryHandled($dbEntry);
}
示例6: copyEntry
public static function copyEntry(entry $entry, Partner $toPartner = null, $dontCopyUsers = false)
{
KalturaLog::log("copyEntry - Copying entry [" . $entry->getId() . "] to partner [" . $toPartner->getId() . "]");
$newEntry = $entry->copy();
$newEntry->setIntId(null);
if ($toPartner instanceof Partner) {
$newEntry->setPartnerId($toPartner->getId());
$newEntry->setSubpId($toPartner->getId() * 100);
$newEntry->setAccessControlId($toPartner->getDefaultAccessControlId());
$flavorParamsStr = $entry->getFlavorParamsIds();
$flavorParams = explode(',', $flavorParamsStr);
$newFlavorParams = array();
foreach ($flavorParams as $flavorParamsId) {
$newFlavorParamsId = kObjectCopyHandler::getMappedId('flavorParams', $flavorParamsId);
if (is_null($newFlavorParamsId)) {
$newFlavorParamsId = $flavorParamsId;
}
$newFlavorParams[] = $newFlavorParamsId;
}
$newEntry->setFlavorParamsIds(implode(',', $newFlavorParams));
}
$newKuser = null;
if (!$dontCopyUsers) {
// copy the kuser (if the same puser id exists its kuser will be used)
kuserPeer::setUseCriteriaFilter(false);
$kuser = $entry->getKuser();
$newKuser = kuserPeer::createKuserForPartner($newEntry->getPartnerId(), $kuser->getPuserId());
$newEntry->setKuserId($newKuser->getId());
kuserPeer::setUseCriteriaFilter(true);
}
// copy the kshow
kshowPeer::setUseCriteriaFilter(false);
$kshow = $entry->getKshow();
if ($kshow) {
$newKshow = $kshow->copy();
$newKshow->setIntId(null);
$newKshow->setPartnerId($toPartner->getId());
$newKshow->setSubpId($toPartner->getId() * 100);
if ($newKuser) {
$newKshow->setProducerId($newKuser->getId());
}
$newKshow->save();
$newEntry->setKshowId($newKshow->getId());
}
kshowPeer::setUseCriteriaFilter(true);
// reset the statistics
myEntryUtils::resetEntryStatistics($newEntry);
// set the new partner id into the default category criteria filter
$defaultCategoryFilter = categoryPeer::getCriteriaFilter()->getFilter();
$oldPartnerId = $defaultCategoryFilter->get(categoryPeer::PARTNER_ID);
$defaultCategoryFilter->remove(categoryPeer::PARTNER_ID);
$defaultCategoryFilter->addAnd(categoryPeer::PARTNER_ID, $newEntry->getPartnerId());
// save the entry
$newEntry->save();
// restore the original partner id in the default category criteria filter
$defaultCategoryFilter->remove(categoryPeer::PARTNER_ID);
$defaultCategoryFilter->addAnd(categoryPeer::PARTNER_ID, $oldPartnerId);
KalturaLog::log("copyEntry - New entry [" . $newEntry->getId() . "] was created");
// for any type that does not require assets:
$shouldCopyDataForNonClip = $entry->getType() != entryType::MEDIA_CLIP;
$shouldCopyDataForClip = false;
// only images get their data copied
if ($entry->getType() == entryType::MEDIA_CLIP) {
if ($entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_VIDEO && $entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_AUDIO) {
$shouldCopyDataForClip = true;
}
}
if ($shouldCopyDataForNonClip || $shouldCopyDataForClip) {
// copy the data
$from = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
// replaced__getDataPath
$to = $newEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
// replaced__getDataPath
KalturaLog::log("copyEntriesByType - copying entry data [" . $from . "] to [" . $to . "]");
kFileSyncUtils::softCopy($from, $to);
}
$ismFrom = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM);
if (kFileSyncUtils::fileSync_exists($ismFrom)) {
$ismTo = $newEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM);
KalturaLog::log("copying entry ism [" . $ismFrom . "] to [" . $ismTo . "]");
kFileSyncUtils::softCopy($ismFrom, $ismTo);
}
$ismcFrom = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISMC);
if (kFileSyncUtils::fileSync_exists($ismcFrom)) {
$ismcTo = $newEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISMC);
KalturaLog::log("copying entry ism [" . $ismcFrom . "] to [" . $ismcTo . "]");
kFileSyncUtils::softCopy($ismcFrom, $ismcTo);
}
$from = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
// replaced__getThumbnailPath
$considerCopyThumb = true;
// if entry is image - data is thumbnail, and it was copied
if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) {
$considerCopyThumb = false;
}
// if entry is not clip, and there is no file in both DCs - nothing to copy
if ($entry->getType() != entryType::MEDIA_CLIP && !kFileSyncUtils::file_exists($from, true)) {
$considerCopyThumb = false;
}
if ($considerCopyThumb) {
//.........这里部分代码省略.........
示例7: attachResource
/**
* @param kResource $resource
* @param entry $dbEntry
* @param asset $asset
*/
protected function attachResource(kResource $resource, entry $dbEntry, asset $asset = null)
{
$service = null;
switch ($dbEntry->getType()) {
case entryType::MEDIA_CLIP:
$service = new MediaService();
$service->initService('media', 'media', $this->actionName);
break;
case entryType::MIX:
$service = new MixingService();
$service->initService('mixing', 'mixing', $this->actionName);
break;
case entryType::PLAYLIST:
$service = new PlaylistService();
$service->initService('playlist', 'playlist', $this->actionName);
break;
case entryType::DATA:
$service = new DataService();
$service->initService('data', 'data', $this->actionName);
break;
case entryType::LIVE_STREAM:
$service = new LiveStreamService();
$service->initService('liveStream', 'liveStream', $this->actionName);
break;
default:
throw new KalturaAPIException(KalturaErrors::ENTRY_TYPE_NOT_SUPPORTED, $dbEntry->getType());
}
$service->attachResource($resource, $dbEntry, $asset);
}
示例8: execute
public function execute()
{
KExternalErrors::setResponseErrorCode(KExternalErrors::HTTP_STATUS_NOT_FOUND);
$this->deliveryAttributes = new DeliveryProfileDynamicAttributes();
// Parse input parameters
$this->deliveryAttributes->setSeekFromTime($this->getRequestParameter("seekFrom", -1));
if ($this->deliveryAttributes->getSeekFromTime() <= 0) {
$this->deliveryAttributes->setSeekFromTime(-1);
}
$this->deliveryAttributes->setClipTo($this->getRequestParameter("clipTo", 0));
$this->deliveryAttributes->setPlaybackRate($this->getRequestParameter("playbackRate", 0));
$deliveryCode = $this->getRequestParameter("deliveryCode", null);
$playbackContext = $this->getRequestParameter("playbackContext", null);
$this->deliveryAttributes->setMediaProtocol($this->getRequestParameter("protocol", null));
if (!$this->deliveryAttributes->getMediaProtocol() || $this->deliveryAttributes->getMediaProtocol() === "null") {
$this->deliveryAttributes->setMediaProtocol(PlaybackProtocol::HTTP);
}
$this->deliveryAttributes->setFormat($this->getRequestParameter("format"));
if (!$this->deliveryAttributes->getFormat()) {
$this->deliveryAttributes->setFormat(PlaybackProtocol::HTTP);
}
if ($this->deliveryAttributes->getFormat() == self::HDNETWORKSMIL) {
$this->deliveryAttributes->setMediaProtocol(PlaybackProtocol::HTTP);
}
// Akamai HD doesn't support any other protocol
if ($this->deliveryAttributes->getFormat() == PlaybackProtocol::AKAMAI_HDS) {
if (strpos($this->deliveryAttributes->getMediaProtocol(), "http") !== 0) {
$this->deliveryAttributes->setMediaProtocol(PlaybackProtocol::HTTP);
}
}
$tags = $this->getRequestParameter("tags", null);
if (!$tags) {
$this->deliveryAttributes->setTags(self::getDefaultTagsByFormat($this->deliveryAttributes->getFormat()));
} else {
$tagsArray = explode(',', $tags);
$tags = array();
foreach ($tagsArray as $tag) {
$tags[] = array(trim($tag));
}
$this->deliveryAttributes->setTags($tags);
}
$this->deliveryAttributes->setpreferredBitrate($this->getRequestParameter("preferredBitrate", null));
$this->maxBitrate = $this->getRequestParameter("maxBitrate", null);
if ($this->maxBitrate && (!is_numeric($this->maxBitrate) || $this->maxBitrate <= 0)) {
KExternalErrors::dieError(KExternalErrors::INVALID_MAX_BITRATE);
}
$this->deliveryAttributes->setStorageId($this->getRequestParameter("storageId", null));
$this->cdnHost = $this->getRequestParameter("cdnHost", null);
$this->deliveryAttributes->setResponseFormat($this->getRequestParameter("responseFormat", null));
// Initialize
$this->initEntry();
$this->deliveryAttributes->setEntryId($this->entryId);
$this->deliveryAttributes->setUsePlayServer((bool) $this->getRequestParameter("usePlayServer") && PermissionPeer::isValidForPartner(PermissionName::FEATURE_PLAY_SERVER, $this->entry->getPartnerId()));
if ($this->deliveryAttributes->getUsePlayServer()) {
$this->deliveryAttributes->setPlayerConfig($this->getRequestParameter("playerConfig"));
//In case request needs to be redirected to play-server we need to add the ui conf id to the manifest url as well
$this->deliveryAttributes->setUiConfId($this->getRequestParameter("uiConfId"));
}
$this->secureEntryHelper->updateDeliveryAttributes($this->deliveryAttributes);
$this->enforceEncryption();
$renderer = null;
switch ($this->entry->getType()) {
case entryType::MEDIA_CLIP:
// VOD
$renderer = $this->serveVodEntry();
break;
case entryType::LIVE_STREAM:
case entryType::LIVE_CHANNEL:
// Live stream
$renderer = $this->serveLiveEntry();
break;
default:
KExternalErrors::dieError(KExternalErrors::INVALID_ENTRY_TYPE);
}
if (!$renderer) {
KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'This format is unsupported');
}
$renderer->contributors = array();
$config = new kManifestContributorConfig();
$config->format = $this->deliveryAttributes->getFormat();
$config->deliveryCode = $deliveryCode;
$config->storageId = $this->deliveryAttributes->getStorageId();
$config->entryId = $this->entryId;
$contributors = KalturaPluginManager::getPluginInstances('IKalturaPlayManifestContributor');
foreach ($contributors as $contributor) {
/* @var $contributor IKalturaPlayManifestContributor */
$renderer->contributors = array_merge($renderer->contributors, $contributor->getManifestEditors($config));
}
$renderer->entryId = $this->entryId;
$renderer->duration = $this->duration;
if ($this->deliveryProfile) {
$renderer->tokenizer = $this->deliveryProfile->getTokenizer();
}
$renderer->defaultDeliveryCode = $this->entry->getPartner()->getDefaultDeliveryCode();
$renderer->lastModified = time();
// Handle caching
$canCacheAccessControl = false;
if (kConf::hasParam("force_caching_headers") && in_array($this->entry->getPartnerId(), kConf::get("force_caching_headers"))) {
$renderer->cachingHeadersAge = 60;
$renderer->forceCachingHeaders = true;
//.........这里部分代码省略.........
示例9: serveRtmp
private function serveRtmp()
{
switch ($this->entry->getType()) {
case entryType::MEDIA_CLIP:
$duration = $this->entry->getDurationInt();
$flavorAssets = array();
if ($this->flavorId) {
$flavorAsset = flavorAssetPeer::retrieveById($this->flavorId);
if (!$flavorAsset->hasTag(flavorParams::TAG_WEB)) {
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
}
if (!$flavorAsset->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_READY) {
KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
}
$flavorAssets[] = $flavorAsset;
} else {
$flavorAssets = flavorAssetPeer::retreiveReadyByEntryIdAndTag($this->entryId, flavorParams::TAG_MBR);
if (!count($flavorAssets)) {
$flavorAssets = flavorAssetPeer::retreiveReadyByEntryIdAndTag($this->entryId, flavorParams::TAG_WEB);
}
}
$flavorAssets = $this->removeMaxBitrateFlavors($flavorAssets);
if (!$this->storageId) {
$partner = $this->entry->getPartner();
$finalFlavors = array();
if ($partner->getStorageServePriority() == StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_FIRST) {
foreach ($flavorAssets as $flavorAsset) {
$key = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$fileSync = kFileSyncUtils::getReadyInternalFileSyncForKey($key);
if ($fileSync) {
$finalFlavors[] = $flavorAsset;
}
}
}
if (!count($finalFlavors) && $partner->getStorageServePriority() && $partner->getStorageServePriority() != StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_ONLY) {
$storages = StorageProfilePeer::retrieveExternalByPartnerId($partner->getId());
if (count($storages) == 1) {
$this->storageId = $storages[0]->getId();
} elseif (count($storages)) {
$storagesFlavors = array();
foreach ($storages as $storage) {
$storagesFlavors[$storage->getId()] = array();
foreach ($flavorAssets as $flavorAsset) {
$key = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($key, $storage->getId());
if ($fileSync) {
$storagesFlavors[$storage->getId()][] = $flavorAsset;
}
}
}
$maxCount = 0;
foreach ($storagesFlavors as $storageId => $storageFlavors) {
$count = count($storageFlavors);
if ($count > $maxCount) {
$maxCount = $count;
$this->storageId = $storageId;
$finalFlavors = $storageFlavors;
}
}
$flavorAssets = $finalFlavors;
} else {
foreach ($flavorAssets as $flavorAsset) {
$key = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$fileSync = kFileSyncUtils::getReadyInternalFileSyncForKey($key);
if ($fileSync) {
$finalFlavors[] = $flavorAsset;
}
}
}
}
}
foreach ($flavorAssets as $flavorAsset) {
$mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($flavorAsset->getId());
if ($mediaInfo && ($mediaInfo->getVideoDuration() || $mediaInfo->getAudioDuration() || $mediaInfo->getContainerDuration())) {
$duration = $mediaInfo->getVideoDuration() ? $mediaInfo->getVideoDuration() : ($mediaInfo->getAudioDuration() ? $mediaInfo->getAudioDuration() : $mediaInfo->getContainerDuration());
$duration /= 1000;
break;
}
}
$baseUrl = null;
$flavors = array();
if ($this->storageId) {
$storage = StorageProfilePeer::retrieveByPK($this->storageId);
if (!$storage) {
die;
}
$baseUrl = $storage->getDeliveryRmpBaseUrl();
// get all flavors with external urls
foreach ($flavorAssets as $flavorAsset) {
$key = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($key, $this->storageId);
if (!$fileSync) {
continue;
}
$urlManager = kUrlManager::getUrlManagerByStorageProfile($fileSync->getDc());
$urlManager->setClipTo($this->clipTo);
$urlManager->setFileExtension($flavorAsset->getFileExt());
$urlManager->setProtocol(StorageProfile::PLAY_FORMAT_RTMP);
$url = $urlManager->getFileSyncUrl($fileSync);
$url = preg_replace('/^\\//', '', $url);
//.........这里部分代码省略.........
示例10: setMimeType
/**
* @param array $flavors
* @return string
*/
protected function setMimeType(entry $entry)
{
if ($entry->getType() == entryType::MEDIA_CLIP && count($this->flavors)) {
$isMp3 = true;
foreach ($this->flavors as $flavor) {
if (!isset($flavor['ext']) || strtolower($flavor['ext']) != 'mp3') {
$isMp3 = false;
}
}
if ($isMp3) {
$this->mimeType = 'audio/mpeg';
return;
}
}
$this->mimeType = 'video/x-flv';
}
示例11: setContextDataStreamerTypeAndMediaProtocol
private function setContextDataStreamerTypeAndMediaProtocol(accessControlScope $scope, $flavorTags)
{
if ($this->streamerType && $this->streamerType != PlaybackProtocol::AUTO) {
$this->mediaProtocol = $this->mediaProtocol ? $this->mediaProtocol : $this->streamerType;
} elseif ($this->entry instanceof LiveEntry) {
$protocols = array();
if (!in_array($this->entry->getSource(), LiveEntry::$kalturaLiveSourceTypes)) {
$protocols[] = PlaybackProtocol::AKAMAI_HDS;
}
$protocols[] = PlaybackProtocol::HDS;
if ($this->entry->getStreamName()) {
$this->streamerType = PlaybackProtocol::RTMP;
}
foreach ($protocols as $protocol) {
$config = $this->entry->getLiveStreamConfigurationByProtocol($protocol, requestUtils::getProtocol());
if ($config) {
$this->streamerType = $protocol;
break;
}
}
if (in_array($this->entry->getSource(), array(EntrySourceType::LIVE_STREAM, EntrySourceType::LIVE_STREAM_ONTEXTDATA_CAPTIONS))) {
$this->streamerType = PlaybackProtocol::HDS;
}
if ($this->entry->getSource() == EntrySourceType::AKAMAI_LIVE) {
$this->streamerType = PlaybackProtocol::RTMP;
}
if ($this->entry->getSource() == EntrySourceType::AKAMAI_UNIVERSAL_LIVE) {
$this->streamerType = PlaybackProtocol::AKAMAI_HDS;
}
} elseif ($this->entry->getType() == entryType::PLAYLIST) {
$this->streamerType = PlaybackProtocol::AKAMAI_HDS;
$this->mediaProtocol = infraRequestUtils::getProtocol();
} else {
$this->isSecured = $this->isSecured || PermissionPeer::isValidForPartner(PermissionName::FEATURE_ENTITLEMENT_USED, $this->entry->getPartnerId());
$forcedDeliveryTypeKey = kDeliveryUtils::getForcedDeliveryTypeKey($this->selectedTag);
if ($forcedDeliveryTypeKey) {
$defaultDeliveryTypeKey = $forcedDeliveryTypeKey;
} else {
$defaultDeliveryTypeKey = $this->partner->getDefaultDeliveryType();
}
if (!$defaultDeliveryTypeKey || $defaultDeliveryTypeKey == PlaybackProtocol::AUTO) {
$deliveryType = $this->selectDeliveryTypeForAuto();
} else {
$deliveryType = kDeliveryUtils::getDeliveryTypeFromConfig($defaultDeliveryTypeKey);
}
if (!$deliveryType) {
$deliveryType = array();
}
$this->streamerType = kDeliveryUtils::getStreamerType($deliveryType);
$this->mediaProtocol = kDeliveryUtils::getMediaProtocol($deliveryType);
}
$httpStreamerTypes = array(PlaybackProtocol::HTTP, PlaybackProtocol::HDS, PlaybackProtocol::HLS, PlaybackProtocol::SILVER_LIGHT, PlaybackProtocol::MPEG_DASH);
if (in_array($this->streamerType, $httpStreamerTypes)) {
$this->mediaProtocol = infraRequestUtils::getProtocol();
}
if ($this->streamerType == PlaybackProtocol::AKAMAI_HD || $this->streamerType == PlaybackProtocol::AKAMAI_HDS) {
$this->mediaProtocol = PlaybackProtocol::HTTP;
}
//If a plugin can determine the streamerType and mediaProtocol, prefer plugin result
$pluginInstances = KalturaPluginManager::getPluginInstances('IKalturaContextDataHelper');
foreach ($pluginInstances as $pluginInstance) {
/* @var $pluginInstance IKalturaContextDataHelper */
$this->streamerType = $pluginInstance->getContextDataStreamerType($scope, $flavorTags, $this->streamerType);
$this->mediaProtocol = $pluginInstance->getContextDataMediaProtocol($scope, $flavorTags, $this->streamerType, $this->mediaProtocol);
}
}
示例12: copyEntry
public static function copyEntry(entry $entry, Partner $toPartner = null, $dontCopyUsers = false)
{
KalturaLog::log("copyEntry - Copying entry [" . $entry->getId() . "] to partner [" . $toPartner->getId() . "]");
$newEntry = $entry->copy();
$newEntry->setIntId(null);
$newEntry->setCategories(null);
$newEntry->setCategoriesIds(null);
if ($toPartner instanceof Partner) {
$newEntry->setPartnerId($toPartner->getId());
$newEntry->setSubpId($toPartner->getId() * 100);
$newEntry->setAccessControlId($toPartner->getDefaultAccessControlId());
}
$newKuser = null;
if (!$dontCopyUsers) {
// copy the kuser (if the same puser id exists its kuser will be used)
kuserPeer::setUseCriteriaFilter(false);
$kuser = $entry->getKuser();
$newKuser = kuserPeer::createKuserForPartner($newEntry->getPartnerId(), $kuser->getPuserId());
$newEntry->setKuserId($newKuser->getId());
$newEntry->setCreatorKuserId($newKuser->getId());
kuserPeer::setUseCriteriaFilter(true);
}
// copy the kshow
kshowPeer::setUseCriteriaFilter(false);
$kshow = $entry->getKshow();
if ($kshow) {
$newKshow = $kshow->copy();
$newKshow->setIntId(null);
$newKshow->setPartnerId($toPartner->getId());
$newKshow->setSubpId($toPartner->getId() * 100);
if ($newKuser) {
$newKshow->setProducerId($newKuser->getId());
}
$newKshow->save();
$newEntry->setKshowId($newKshow->getId());
}
kshowPeer::setUseCriteriaFilter(true);
// reset the statistics
myEntryUtils::resetEntryStatistics($newEntry);
// set the new partner id into the default category criteria filter
$defaultCategoryFilter = categoryPeer::getCriteriaFilter()->getFilter();
$oldPartnerId = $defaultCategoryFilter->get(categoryPeer::PARTNER_ID);
$defaultCategoryFilter->remove(categoryPeer::PARTNER_ID);
$defaultCategoryFilter->addAnd(categoryPeer::PARTNER_ID, $newEntry->getPartnerId());
// save the entry
$newEntry->save();
// restore the original partner id in the default category criteria filter
$defaultCategoryFilter->remove(categoryPeer::PARTNER_ID);
$defaultCategoryFilter->addAnd(categoryPeer::PARTNER_ID, $oldPartnerId);
KalturaLog::log("copyEntry - New entry [" . $newEntry->getId() . "] was created");
// for any type that does not require assets:
$shouldCopyDataForNonClip = true;
if ($entry->getType() == entryType::MEDIA_CLIP) {
$shouldCopyDataForNonClip = false;
}
if ($entry->getType() == entryType::PLAYLIST) {
$shouldCopyDataForNonClip = false;
}
$shouldCopyDataForClip = false;
// only images get their data copied
if ($entry->getType() == entryType::MEDIA_CLIP) {
if ($entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_VIDEO && $entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_AUDIO) {
$shouldCopyDataForClip = true;
}
}
//if entry is a static playlist, link between it and its new child entries
if ($entry->getType() == entryType::PLAYLIST) {
switch ($entry->getMediaType()) {
case entry::ENTRY_MEDIA_TYPE_TEXT:
$from = $entry->getDataContent();
KalturaLog::debug("Entries to copy from source static playlist: [{$from}]");
$fromEntryIds = explode(",", $from);
$toEntryIds = array();
foreach ($fromEntryIds as $fromEntryId) {
$toEntryIds[] = kObjectCopyHandler::getMappedId(entryPeer::OM_CLASS, $fromEntryId);
}
$newEntry->setDataContent(implode(",", $toEntryIds));
break;
case entry::ENTRY_MEDIA_TYPE_XML:
list($totalResults, $fromFiltersList) = myPlaylistUtils::getPlaylistFilterListStruct($entry->getDataContent());
$toPlaylistXml = new SimpleXMLElement("<playlist/>");
$toPlaylistXml->addChild("total_results", $totalResults);
$toFiltersXml = $toPlaylistXml->addChild("filters");
foreach ($fromFiltersList as $filterXML) {
$entryFilter = new entryFilter();
$entryFilter->fillObjectFromXml($filterXML, "_");
if (isset($entryFilter->fields["_matchand_categories_ids"])) {
$categoriesIds = explode(",", $entryFilter->fields["_matchand_categories_ids"]);
$newCategoriesIds = array();
foreach ($categoriesIds as $categoryId) {
$newCategoriesIds[] = kObjectCopyHandler::getMappedId(categoryPeer::OM_CLASS, $categoryId);
}
$entryFilter->fields["_matchand_categories_ids"] = implode(",", $newCategoriesIds);
}
if (isset($entryFilter->fields["_matchor_categories_ids"])) {
$categoriesIds = explode(",", $entryFilter->fields["_matchor_categories_ids"]);
$newCategoriesIds = array();
foreach ($categoriesIds as $categoryId) {
$newCategoriesIds[] = kObjectCopyHandler::getMappedId(categoryPeer::OM_CLASS, $categoryId);
}
//.........这里部分代码省略.........
示例13: getEntryMrssXml
/**
* @param entry $entry
* @param SimpleXMLElement $mrss
* @param kMrssParameters $mrssParams
* @return SimpleXMLElement
*/
public static function getEntryMrssXml(entry $entry, SimpleXMLElement $mrss = null, kMrssParameters $mrssParams = null)
{
if ($mrss === null) {
$mrss = new SimpleXMLElement('<item/>');
}
$mrss->addChild('entryId', $entry->getId());
if ($entry->getReferenceID()) {
$mrss->addChild('referenceID', $entry->getReferenceID());
}
$mrss->addChild('createdAt', $entry->getCreatedAt(null));
$mrss->addChild('updatedAt', $entry->getUpdatedAt(null));
$mrss->addChild('title', self::stringToSafeXml($entry->getName()));
if ($mrssParams && !is_null($mrssParams->getLink())) {
$mrss->addChild('link', $mrssParams->getLink() . $entry->getId());
}
$mrss->addChild('type', $entry->getType());
$mrss->addChild('licenseType', $entry->getLicenseType());
$mrss->addChild('userId', $entry->getPuserId(true));
$mrss->addChild('name', self::stringToSafeXml($entry->getName()));
$mrss->addChild('status', self::stringToSafeXml($entry->getStatus()));
$mrss->addChild('description', self::stringToSafeXml($entry->getDescription()));
$thumbnailUrl = $mrss->addChild('thumbnailUrl');
$thumbnailUrl->addAttribute('url', $entry->getThumbnailUrl());
if (trim($entry->getTags(), " \r\n\t")) {
$tags = $mrss->addChild('tags');
foreach (explode(',', $entry->getTags()) as $tag) {
$tags->addChild('tag', self::stringToSafeXml($tag));
}
}
$categories = explode(',', $entry->getCategories());
foreach ($categories as $category) {
$category = trim($category);
if ($category) {
$categoryNode = $mrss->addChild('category', self::stringToSafeXml($category));
if (strrpos($category, '>') > 0) {
$categoryNode->addAttribute('name', self::stringToSafeXml(substr($category, strrpos($category, '>') + 1)));
} else {
$categoryNode->addAttribute('name', self::stringToSafeXml($category));
}
}
}
$mrss->addChild('partnerData', self::stringToSafeXml($entry->getPartnerData()));
if ($entry->getAccessControlId()) {
$mrss->addChild('accessControlId', $entry->getAccessControlId());
}
if ($entry->getConversionProfileId()) {
$mrss->addChild('conversionProfileId', $entry->getConversionProfileId());
}
if ($entry->getStartDate(null)) {
$mrss->addChild('startDate', $entry->getStartDate(null));
}
if ($entry->getEndDate(null)) {
$mrss->addChild('endDate', $entry->getEndDate(null));
}
switch ($entry->getType()) {
case entryType::MEDIA_CLIP:
self::appendMediaEntryMrss($entry, $mrss);
break;
case entryType::MIX:
self::appendMixEntryMrss($entry, $mrss);
break;
case entryType::PLAYLIST:
self::appendPlaylistEntryMrss($entry, $mrss);
break;
case entryType::DATA:
self::appendDataEntryMrss($entry, $mrss);
break;
case entryType::LIVE_STREAM:
self::appendLiveStreamEntryMrss($entry, $mrss);
break;
default:
break;
}
$assets = assetPeer::retrieveReadyByEntryId($entry->getId());
foreach ($assets as $asset) {
if ($mrssParams && !is_null($mrssParams->getFilterByFlavorParams()) && $asset->getFlavorParamsId() != $mrssParams->getFilterByFlavorParams()) {
continue;
}
if ($asset instanceof flavorAsset) {
self::appendFlavorAssetMrss($asset, $mrss, $mrssParams);
}
if ($asset instanceof thumbAsset) {
self::appendThumbAssetMrss($asset, $mrss);
}
}
$mrssContributors = self::getMrssContributors();
if (count($mrssContributors)) {
foreach ($mrssContributors as $mrssContributor) {
$mrssContributor->contribute($entry, $mrss, $mrssParams);
}
}
if ($mrssParams && $mrssParams->getIncludePlayerTag()) {
$uiconfId = !is_null($mrssParams->getPlayerUiconfId()) ? '/ui_conf_id/' . $mrssParams->getPlayerUiconfId() : '';
$playerUrl = 'http://' . kConf::get('www_host') . '/kwidget/wid/_' . $entry->getPartnerId() . '/entry_id/' . $entry->getId() . '/ui_conf' . ($uiconfId ? "/{$uiconfId}" : '');
//.........这里部分代码省略.........
示例14: getEntryMrssXml
/**
* @param entry $entry
* @param SimpleXMLElement $mrss
* @param string $link
* @param string $filterFlavors
* @return SimpleXMLElement
*/
public static function getEntryMrssXml(entry $entry, SimpleXMLElement $mrss = null, $link = null, $fitlerByFlovorParams = null)
{
if (!$mrss) {
$mrss = new SimpleXMLElement('<item/>');
}
$mrss->addChild('entryId', $entry->getId());
$mrss->addChild('createdAt', $entry->getCreatedAt(null));
$mrss->addChild('title', self::stringToSafeXml($entry->getName()));
$mrss->addChild('link', $link . $entry->getId());
$mrss->addChild('type', $entry->getType());
$mrss->addChild('licenseType', $entry->getLicenseType());
$mrss->addChild('userId', $entry->getPuserId(true));
$mrss->addChild('name', self::stringToSafeXml($entry->getName()));
$mrss->addChild('description', self::stringToSafeXml($entry->getDescription()));
$thumbnailUrl = $mrss->addChild('thumbnailUrl');
$thumbnailUrl->addAttribute('url', $entry->getThumbnailUrl());
$tags = $mrss->addChild('tags');
foreach (explode(',', $entry->getTags()) as $tag) {
$tags->addChild('tag', self::stringToSafeXml($tag));
}
$mrss->addChild('partnerData', self::stringToSafeXml($entry->getPartnerData()));
$mrss->addChild('accessControlId', $entry->getAccessControlId());
$categories = explode(',', $entry->getCategories());
foreach ($categories as $category) {
if ($category) {
$mrss->addChild('category', self::stringToSafeXml($category));
}
}
if ($entry->getStartDate(null)) {
$mrss->addChild('startDate', $entry->getStartDate(null));
}
if ($entry->getEndDate(null)) {
$mrss->addChild('endDate', $entry->getEndDate(null));
}
switch ($entry->getType()) {
case entryType::MEDIA_CLIP:
self::appendMediaEntryMrss($entry, $mrss);
break;
case entryType::MIX:
self::appendMixEntryMrss($entry, $mrss);
break;
case entryType::PLAYLIST:
self::appendPlaylistEntryMrss($entry, $mrss);
break;
case entryType::DATA:
self::appendDataEntryMrss($entry, $mrss);
break;
case entryType::LIVE_STREAM:
self::appendLiveStreamEntryMrss($entry, $mrss);
break;
default:
break;
}
$flavorAssets = flavorAssetPeer::retreiveReadyByEntryId($entry->getId());
foreach ($flavorAssets as $flavorAsset) {
if (!is_null($fitlerByFlovorParams) && $flavorAsset->getFlavorParamsId() != $fitlerByFlovorParams) {
continue;
}
$content = $mrss->addChild('content');
$content->addAttribute('url', self::getAssetUrl($flavorAsset));
$content->addAttribute('flavorAssetId', $flavorAsset->getId());
$content->addAttribute('isSource', $flavorAsset->getIsOriginal() ? 'true' : 'false');
$content->addAttribute('containerFormat', $flavorAsset->getContainerFormat());
$content->addAttribute('extension', $flavorAsset->getFileExt());
if (!is_null($flavorAsset->getFlavorParamsId())) {
$content->addAttribute('flavorParamsId', $flavorAsset->getFlavorParamsId());
$flavorParams = flavorParamsPeer::retrieveByPK($flavorAsset->getFlavorParamsId());
if ($flavorParams) {
$content->addAttribute('flavorParamsName', $flavorParams->getName());
$content->addAttribute('format', $flavorParams->getFormat());
$content->addAttribute('videoBitrate', $flavorParams->getVideoBitrate());
$content->addAttribute('videoCodec', $flavorParams->getVideoCodec());
$content->addAttribute('audioBitrate', $flavorParams->getAudioBitrate());
$content->addAttribute('audioCodec', $flavorParams->getAudioCodec());
$content->addAttribute('frameRate', $flavorParams->getFrameRate());
$content->addAttribute('height', $flavorParams->getHeight());
$content->addAttribute('width', $flavorParams->getWidth());
}
}
$tags = $content->addChild('tags');
foreach (explode(',', $flavorAsset->getTags()) as $tag) {
$tags->addChild('tag', self::stringToSafeXml($tag));
}
}
$thumbAssets = thumbAssetPeer::retreiveReadyByEntryId($entry->getId());
foreach ($thumbAssets as $thumbAsset) {
$thumbnail = $mrss->addChild('thumbnail');
$thumbnail->addAttribute('url', self::getAssetUrl($thumbAsset));
$thumbnail->addAttribute('thumbAssetId', $thumbAsset->getId());
$thumbnail->addAttribute('isDefault', $thumbAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB) ? 'true' : 'false');
$thumbnail->addAttribute('format', $thumbAsset->getContainerFormat());
if ($thumbAsset->getFlavorParamsId()) {
$thumbnail->addAttribute('thumbParamsId', $thumbAsset->getFlavorParamsId());
//.........这里部分代码省略.........
示例15: addConvertProfileJob
//.........这里部分代码省略.........
$conversionProfile = myPartnerUtils::getConversionProfile2ForEntry($entry->getId());
// load the asset params to the instance pool
$flavorIds = flavorParamsConversionProfilePeer::getFlavorIdsByProfileId($conversionProfile->getId());
assetParamsPeer::retrieveByPKs($flavorIds);
$conversionRequired = false;
$sourceFileRequiredStorages = array();
$sourceIncludedInProfile = false;
$flavorAsset = assetPeer::retrieveById($flavorAssetId);
$flavors = flavorParamsConversionProfilePeer::retrieveByConversionProfile($conversionProfile->getId());
KalturaLog::debug("Found flavors [" . count($flavors) . "] in conversion profile [" . $conversionProfile->getId() . "]");
foreach ($flavors as $flavor) {
/* @var $flavor flavorParamsConversionProfile */
if ($flavor->getFlavorParamsId() == $flavorAsset->getFlavorParamsId()) {
KalturaLog::debug("Flavor [" . $flavor->getFlavorParamsId() . "] is ingested source");
$sourceIncludedInProfile = true;
continue;
}
$flavorParams = assetParamsPeer::retrieveByPK($flavor->getFlavorParamsId());
if ($flavorParams instanceof liveParams || $flavor->getOrigin() == assetParamsOrigin::INGEST) {
KalturaLog::debug("Flavor [" . $flavor->getFlavorParamsId() . "] should be ingested");
continue;
}
if ($flavor->getOrigin() == assetParamsOrigin::CONVERT_WHEN_MISSING) {
$siblingFlavorAsset = assetPeer::retrieveByEntryIdAndParams($entry->getId(), $flavor->getFlavorParamsId());
if ($siblingFlavorAsset) {
KalturaLog::debug("Flavor [" . $flavor->getFlavorParamsId() . "] already ingested");
continue;
}
}
$sourceFileRequiredStorages[] = $flavorParams->getSourceRemoteStorageProfileId();
$conversionRequired = true;
break;
}
if ($conversionRequired) {
foreach ($sourceFileRequiredStorages as $storageId) {
if ($storageId == StorageProfile::STORAGE_KALTURA_DC) {
$key = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
list($syncFile, $local) = kFileSyncUtils::getReadyFileSyncForKey($key, true, false);
if ($syncFile && $syncFile->getFileType() == FileSync::FILE_SYNC_FILE_TYPE_URL && $partner && $partner->getImportRemoteSourceForConvert()) {
KalturaLog::debug("Creates import job for remote file sync");
$url = $syncFile->getExternalUrl($entry->getId());
kJobsManager::addImportJob($parentJob, $entry->getId(), $partner->getId(), $url, $flavorAsset, null, null, true);
$importingSources = true;
continue;
}
} elseif ($flavorAsset->getExternalUrl($storageId)) {
continue;
}
kBatchManager::updateEntry($entry->getId(), entryStatus::ERROR_CONVERTING);
$flavorAsset = assetPeer::retrieveById($flavorAssetId);
$flavorAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_ERROR);
$flavorAsset->setDescription('Entry of size 0 should not be converted');
$flavorAsset->save();
KalturaLog::err('Entry of size 0 should not be converted');
return null;
}
} else {
if ($flavorAsset->getStatus() == asset::FLAVOR_ASSET_STATUS_QUEUED) {
if ($sourceIncludedInProfile) {
$flavorAsset->setStatusLocalReady();
} else {
$flavorAsset->setStatus(asset::FLAVOR_ASSET_STATUS_DELETED);
$flavorAsset->setDeletedAt(time());
}
$flavorAsset->save();
if ($sourceIncludedInProfile) {
kBusinessPostConvertDL::handleConvertFinished(null, $flavorAsset);
}
}
return null;
}
}
if ($entry->getStatus() != entryStatus::READY) {
$entry->setStatus(entryStatus::PRECONVERT);
}
$jobData = new kConvertProfileJobData();
$jobData->setFlavorAssetId($flavorAssetId);
$jobData->setInputFileSyncLocalPath($inputFileSyncLocalPath);
$jobData->setExtractMedia(true);
if ($entry->getType() != entryType::MEDIA_CLIP) {
$jobData->setExtractMedia(false);
$entry->setCreateThumb(false);
}
$entry->save();
$batchJob = null;
if ($parentJob) {
$batchJob = $parentJob->createChild(BatchJobType::CONVERT_PROFILE);
} else {
$batchJob = new BatchJob();
$batchJob->setEntryId($entry->getId());
$batchJob->setPartnerId($entry->getPartnerId());
$batchJob->setUseNewRoot(true);
}
$batchJob->setObjectId($entry->getId());
$batchJob->setObjectType(BatchJobObjectType::ENTRY);
if ($importingSources) {
$batchJob->setStatus(BatchJob::BATCHJOB_STATUS_DONT_PROCESS);
}
return self::addJob($batchJob, $jobData, BatchJobType::CONVERT_PROFILE);
}