Ejemplo n.º 1
0
 /**
  * @return array primary URL and backup URL
  */
 private function getLiveEntryBaseUrls()
 {
     $this->initFlavorParamsIds();
     $tag = null;
     $tags = $this->deliveryAttributes->getTags();
     if (count($tags) == 1) {
         $tag = reset($tags);
     }
     $protocol = $this->deliveryAttributes->getMediaProtocol();
     if (in_array($this->deliveryAttributes->getFormat(), self::$httpFormats) && !in_array($protocol, self::$httpProtocols)) {
         $protocol = requestUtils::getProtocol();
     }
     $liveStreamConfig = $this->entry->getLiveStreamConfigurationByProtocol($this->deliveryAttributes->getFormat(), $protocol, $tag, false, $this->flavorParamsIds);
     /* @var $liveStreamConfig kLiveStreamConfiguration */
     if ($liveStreamConfig) {
         return array($liveStreamConfig->getUrl(), $liveStreamConfig->getBackupUrl());
     }
     switch ($this->deliveryAttributes->getFormat()) {
         case PlaybackProtocol::RTMP:
             $baseUrl = $this->entry->getStreamUrl();
             $baseUrl = rtrim($baseUrl, '/');
             if (strpos($this->deliveryAttributes->getMediaProtocol(), "rtmp") === 0) {
                 $baseUrl = $this->deliveryAttributes->getMediaProtocol() . '://' . preg_replace('/^rtmp.*?:\\/\\//', '', $baseUrl);
             }
             return array($baseUrl, null);
         case PlaybackProtocol::APPLE_HTTP:
             return array($this->entry->getHlsStreamUrl(), null);
             // TODO pass single tag
     }
     return array(null, null);
 }
Ejemplo n.º 2
0
 /**
  * @return array primary URL and backup URL
  */
 private function getLiveEntryStreamConfig()
 {
     $this->initFlavorParamsIds();
     $tag = null;
     $tags = $this->deliveryAttributes->getTags();
     if (count($tags) == 1) {
         $tag = reset($tags);
     }
     $protocol = $this->deliveryAttributes->getMediaProtocol();
     if (in_array($this->deliveryAttributes->getFormat(), self::$httpFormats) && !in_array($protocol, self::$httpProtocols)) {
         $protocol = requestUtils::getProtocol();
     }
     // use only cloud transcode flavors if timeAlignedRenditions was set
     $partnerId = $this->entry->getPartnerId();
     $partner = PartnerPeer::retrieveByPK($partnerId);
     $partnerTimeAligned = $partner->getTimeAlignedRenditions();
     if ($partnerTimeAligned && $this->getRequestParameter("playerType") === 'flash') {
         // check entry's flavors
         $entryFlavorParams = assetParamsPeer::retrieveByPKs(explode(',', $this->entry->getFlavorParamsIds()));
         $hasTranscode = false;
         foreach ($entryFlavorParams as $flavor) {
             // check if we have any transcode flavor
             if (!$flavor->hasTag("ingest")) {
                 $hasTranscode = true;
             }
         }
         // if so, use only the transcode
         if ($hasTranscode) {
             $tag = 'mbr';
         }
     }
     $liveStreamConfig = $this->entry->getLiveStreamConfigurationByProtocol($this->deliveryAttributes->getFormat(), $protocol, $tag, false, $this->flavorParamsIds);
     /* @var $liveStreamConfig kLiveStreamConfiguration */
     if ($liveStreamConfig) {
         return $liveStreamConfig;
     }
     switch ($this->deliveryAttributes->getFormat()) {
         case PlaybackProtocol::RTMP:
             $baseUrl = $this->entry->getStreamUrl();
             $baseUrl = rtrim($baseUrl, '/');
             if (strpos($this->deliveryAttributes->getMediaProtocol(), "rtmp") === 0) {
                 $baseUrl = $this->deliveryAttributes->getMediaProtocol() . '://' . preg_replace('/^rtmp.*?:\\/\\//', '', $baseUrl);
             }
             $liveStreamConfig = new kLiveStreamConfiguration();
             $liveStreamConfig->setUrl($baseUrl);
             $liveStreamConfig->setProtocol(PlaybackProtocol::RTMP);
             return $liveStreamConfig;
         case PlaybackProtocol::APPLE_HTTP:
             // TODO pass single tag
             $liveStreamConfig = new kLiveStreamConfiguration();
             $liveStreamConfig->setUrl($this->entry->getHlsStreamUrl());
             $liveStreamConfig->setProtocol(PlaybackProtocol::APPLE_HTTP);
             return $liveStreamConfig;
     }
     return null;
 }
Ejemplo n.º 3
0
 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);
     }
 }