Exemplo n.º 1
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);
     }
 }