Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
 /**
  * Delivering the status of a live stream (on-air/offline) if it is possible
  * 
  * @action isLive
  * @param string $id ID of the live stream
  * @param KalturaPlaybackProtocol $protocol protocol of the stream to test.
  * @return bool
  * 
  * @throws KalturaErrors::LIVE_STREAM_STATUS_CANNOT_BE_DETERMINED
  * @throws KalturaErrors::INVALID_ENTRY_ID
  */
 public function isLiveAction($id, $protocol)
 {
     if (!kCurrentContext::$ks) {
         kEntitlementUtils::initEntitlementEnforcement(null, false);
         $liveStreamEntry = kCurrentContext::initPartnerByEntryId($id);
         if (!$liveStreamEntry || $liveStreamEntry->getStatus() == entryStatus::DELETED) {
             throw new KalturaAPIException(KalturaErrors::INVALID_ENTRY_ID, $id);
         }
         // enforce entitlement
         $this->setPartnerFilters(kCurrentContext::getCurrentPartnerId());
     } else {
         $liveStreamEntry = entryPeer::retrieveByPK($id);
     }
     if (!$liveStreamEntry || $liveStreamEntry->getType() != entryType::LIVE_STREAM) {
         throw new KalturaAPIException(KalturaErrors::INVALID_ENTRY_ID, $id);
     }
     if (!in_array($liveStreamEntry->getSource(), LiveEntry::$kalturaLiveSourceTypes)) {
         KalturaResponseCacher::setConditionalCacheExpiry(self::ISLIVE_ACTION_NON_KALTURA_LIVE_CONDITIONAL_CACHE_EXPIRY);
     }
     /* @var $liveStreamEntry LiveStreamEntry */
     if (in_array($liveStreamEntry->getSource(), array(KalturaSourceType::LIVE_STREAM, KalturaSourceType::LIVE_STREAM_ONTEXTDATA_CAPTIONS))) {
         return $this->responseHandlingIsLive($liveStreamEntry->hasMediaServer());
     }
     $dpda = new DeliveryProfileDynamicAttributes();
     $dpda->setEntryId($id);
     $dpda->setFormat($protocol);
     switch ($protocol) {
         case KalturaPlaybackProtocol::HLS:
         case KalturaPlaybackProtocol::APPLE_HTTP:
             $url = $liveStreamEntry->getHlsStreamUrl();
             foreach (array(KalturaPlaybackProtocol::HLS, KalturaPlaybackProtocol::APPLE_HTTP) as $hlsProtocol) {
                 $config = $liveStreamEntry->getLiveStreamConfigurationByProtocol($hlsProtocol, requestUtils::getProtocol());
                 if ($config) {
                     $url = $config->getUrl();
                     $protocol = $hlsProtocol;
                     break;
                 }
             }
             KalturaLog::info('Determining status of live stream URL [' . $url . ']');
             $urlManager = DeliveryProfilePeer::getLiveDeliveryProfileByHostName(parse_url($url, PHP_URL_HOST), $dpda);
             if ($urlManager) {
                 return $this->responseHandlingIsLive($urlManager->isLive($url));
             }
             break;
         case KalturaPlaybackProtocol::HDS:
         case KalturaPlaybackProtocol::AKAMAI_HDS:
             $config = $liveStreamEntry->getLiveStreamConfigurationByProtocol($protocol, requestUtils::getProtocol());
             if ($config) {
                 $url = $config->getUrl();
                 KalturaLog::info('Determining status of live stream URL [' . $url . ']');
                 $urlManager = DeliveryProfilePeer::getLiveDeliveryProfileByHostName(parse_url($url, PHP_URL_HOST), $dpda);
                 if ($urlManager) {
                     return $this->responseHandlingIsLive($urlManager->isLive($url));
                 }
             }
             break;
     }
     throw new KalturaAPIException(KalturaErrors::LIVE_STREAM_STATUS_CANNOT_BE_DETERMINED, $protocol);
 }
Ejemplo n.º 3
0
 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);
 }