private function serveLiveEntry() { if (in_array($this->entry->getSource(), LiveEntry::$kalturaLiveSourceTypes)) { if (!$this->entry->hasMediaServer()) { KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_LIVE, "Entry [{$this->entryId}] is not broadcasting"); } kApiCache::setExpiry(120); } list($baseUrl, $backupUrl) = $this->getLiveEntryBaseUrls(); $cdnHost = parse_url($baseUrl, PHP_URL_HOST); if ($this->deliveryAttributes->getFormat() == PlaybackProtocol::MULTICAST_SL) { $this->deliveryAttributes->setFormat(PlaybackProtocol::HDS); } $this->deliveryProfile = DeliveryProfilePeer::getLiveDeliveryProfileByHostName($cdnHost, $this->deliveryAttributes); if (!$this->deliveryProfile) { return null; } $this->deliveryProfile->setDynamicAttributes($this->deliveryAttributes); return $this->deliveryProfile->serve($baseUrl, $backupUrl); }
private function serveLiveEntry() { if (in_array($this->entry->getSource(), LiveEntry::$kalturaLiveSourceTypes)) { if (!$this->entry->hasMediaServer()) { KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_LIVE, "Entry [{$this->entryId}] is not broadcasting"); } kApiCache::setExpiry(120); } $liveStreamConfig = $this->getLiveEntryStreamConfig(); if (!$liveStreamConfig) { KExternalErrors::dieError(KExternalErrors::LIVE_STREAM_CONFIG_NOT_FOUND, "Live stream playbck configuration not found for entry [{$this->entryId}]"); } $cdnHost = parse_url($liveStreamConfig->getUrl(), PHP_URL_HOST); if ($this->deliveryAttributes->getFormat() == PlaybackProtocol::MULTICAST_SL) { $this->deliveryAttributes->setFormat(PlaybackProtocol::HDS); } $this->deliveryProfile = DeliveryProfilePeer::getLiveDeliveryProfileByHostName($cdnHost, $this->deliveryAttributes); if (!$this->deliveryProfile) { return null; } $this->deliveryProfile->setDynamicAttributes($this->deliveryAttributes); return $this->deliveryProfile->serve($liveStreamConfig); }
public static function addProvisionProvideJob(BatchJob $parentJob = null, entry $entry, kProvisionJobData $jobData) { $entry->setStatus(entryStatus::IMPORT); $entry->save(); $batchJob = null; if ($parentJob) { $batchJob = $parentJob->createChild(BatchJobType::PROVISION_PROVIDE, $entry->getSource()); } else { $batchJob = new BatchJob(); $batchJob->setEntryId($entry->getId()); $batchJob->setPartnerId($entry->getPartnerId()); } $batchJob->setObjectId($entry->getId()); $batchJob->setObjectType(BatchJobObjectType::ENTRY); return self::addJob($batchJob, $jobData, BatchJobType::PROVISION_PROVIDE, $entry->getSource()); }
public static function checkForPendingLiveClips(entry $entry) { if ($entry->getSource() != EntrySourceType::RECORDED_LIVE) { KalturaLog::notice("Entry [" . $entry->getId() . "] is not a recorded live"); return; } $liveEntry = entryPeer::retrieveByPKNoFilter($entry->getRootEntryId()); if (!$liveEntry || $liveEntry->getStatus() == entryStatus::DELETED || !$liveEntry instanceof LiveEntry) { KalturaLog::notice("Entry root [" . $entry->getRootEntryId() . "] is not a valid live entry"); return; } /* @var $liveEntry LiveEntry */ $pendingMediaEntries = $liveEntry->getAttachedPendingMediaEntries(); foreach ($pendingMediaEntries as $pendingMediaEntry) { /* @var $pendingMediaEntry kPendingMediaEntry */ if ($pendingMediaEntry->getRequiredDuration() && $pendingMediaEntry->getRequiredDuration() > $entry->getLengthInMsecs()) { KalturaLog::info("Pending entry [" . $pendingMediaEntry->getEntryId() . "] required duration [" . $pendingMediaEntry->getRequiredDuration() . "] while entry duration [" . $entry->getLengthInMsecs() . "] is too short"); continue; } $liveEntry->dettachPendingMediaEntry($pendingMediaEntry->getEntryId()); $pendingEntry = entryPeer::retrieveByPK($pendingMediaEntry->getEntryId()); if (!$pendingEntry) { KalturaLog::info("Pending entry [" . $pendingMediaEntry->getEntryId() . "] not found"); continue; } $sourceAsset = assetPeer::retrieveOriginalByEntryId($entry->getId()); if (!$sourceAsset) { $sourceAssets = assetPeer::retrieveReadyFlavorsByEntryId($entry->getId()); $sourceAsset = array_pop($sourceAssets); } if (!$sourceAsset) { KalturaLog::info("Pending entry [" . $pendingMediaEntry->getEntryId() . "] source asset not found"); continue; } /* @var $sourceAsset flavorAsset */ $operationAttributes = new kClipAttributes(); $operationAttributes->setOffset($pendingMediaEntry->getOffset()); $operationAttributes->setDuration($pendingMediaEntry->getDuration()); $targetAsset = assetPeer::retrieveOriginalByEntryId($pendingMediaEntry->getEntryId()); if (!$targetAsset) { $targetAsset = kFlowHelper::createOriginalFlavorAsset($entry->getPartnerId(), $pendingMediaEntry->getEntryId()); } $targetAsset->setFileExt($sourceAsset->getFileExt()); $targetAsset->save(); $sourceSyncKey = $sourceAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET); $targetSyncKey = $targetAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET); kFileSyncUtils::createSyncFileLinkForKey($targetSyncKey, $sourceSyncKey); $errDescription = ''; kBusinessPreConvertDL::decideAddEntryFlavor(null, $pendingMediaEntry->getEntryId(), $operationAttributes->getAssetParamsId(), $errDescription, $targetAsset->getId(), array($operationAttributes)); } $liveEntry->save(); }
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; } } 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); } }
public static function addProvisionProvideJob(BatchJob $parentJob = null, entry $entry) { $subType = $entry->getSource(); if ($subType == entry::ENTRY_MEDIA_SOURCE_AKAMAI_LIVE) { $partner = $entry->getPartner(); if (!is_null($partner)) { $jobData = new kAkamaiProvisionJobData(); $akamaiLiveParams = $partner->getAkamaiLiveParams(); if ($akamaiLiveParams) { $jobData->setWsdlUsername($akamaiLiveParams->getAkamaiLiveWsdlUsername()); $jobData->setWsdlPassword($akamaiLiveParams->getAkamaiLiveWsdlPassword()); $jobData->setCpcode($akamaiLiveParams->getAkamaiLiveCpcode()); $jobData->setEmailId($akamaiLiveParams->getAkamaiLiveEmailId()); $jobData->setPrimaryContact($akamaiLiveParams->getAkamaiLivePrimaryContact()); $jobData->setSecondaryContact($akamaiLiveParams->getAkamaiLiveSecondaryContact()); } } } else { $jobData = new kProvisionJobData(); } $jobData->setEncoderIP($entry->getEncodingIP1()); $jobData->setBackupEncoderIP($entry->getEncodingIP2()); $jobData->setEncoderPassword($entry->getStreamPassword()); $jobData->setEncoderUsername($entry->getStreamUsername()); $jobData->setEndDate($entry->getEndDate(null)); $jobData->setMediaType($entry->getMediaType()); $batchJob = null; if ($parentJob) { $batchJob = $parentJob->createChild(); } else { $batchJob = new BatchJob(); $batchJob->setEntryId($entry->getId()); $batchJob->setPartnerId($entry->getPartnerId()); } return self::addJob($batchJob, $jobData, BatchJobType::PROVISION_PROVIDE, $subType); }
public static function addProvisionProvideJob(BatchJob $parentJob = null, entry $entry) { $jobData = new kProvisionJobData(); $jobData->setEncoderIP($entry->getEncodingIP1()); $jobData->setBackupEncoderIP($entry->getEncodingIP2()); $jobData->setEncoderPassword($entry->getStreamPassword()); $jobData->setEncoderUsername($entry->getStreamUsername()); $jobData->setEndDate($entry->getEndDate(null)); $jobData->setMediaType($entry->getMediaType()); $batchJob = null; if ($parentJob) { $batchJob = $parentJob->createChild(); } else { $batchJob = new BatchJob(); $batchJob->setEntryId($entry->getId()); $batchJob->setPartnerId($entry->getPartnerId()); } $subType = $entry->getSource(); return self::addJob($batchJob, $jobData, BatchJobType::PROVISION_PROVIDE, $subType); }