Пример #1
0
 /**
  * @return array
  */
 protected function getSecureHdUrl()
 {
     $params = array();
     if ($this->getSupportClipping()) {
         $seekStart = $this->params->getSeekFromTime();
         $seekEnd = $this->params->getClipTo();
         if ($seekStart != -1) {
             $params['start'] = floor($this->params->getSeekFromTime() / 1000);
             $this->params->setSeekFromTime(-1);
         } else {
             if ($seekEnd) {
                 $params['start'] = 0;
             }
         }
         if ($seekEnd) {
             $params['end'] = ceil($this->params->getClipTo() / 1000);
             $this->params->setClipTo(null);
         }
     }
     $flavors = $this->buildHttpFlavorsArray();
     $flavor = AkamaiDeliveryUtils::getHDN2ManifestUrl($flavors, $this->params->getMediaProtocol(), $this->getUrl(), '/manifest.f4m', '/z', $params);
     if (!$flavor) {
         KalturaLog::info(get_class() . ' failed to find flavor');
         return null;
     }
     if ($this->getExtraParams()) {
         $flavor['url'] = kDeliveryUtils::addQueryParameter($flavor['url'], $this->getExtraParams());
     }
     return $flavor;
 }
Пример #2
0
 /**
  * @param string $url
  * @param string $baseUrl
  * @param string $fileExtension
  * @return string
  */
 public function tokenizeUrl($url, $baseUrl = null, $fileExtension = null)
 {
     $url = preg_replace('/([^:])\\/\\//', '$1/', $url);
     $fullUrl = trim(str_replace('mp4:', '', $url), '/');
     if (!is_null($baseUrl)) {
         $fullUrl = rtrim($baseUrl, '/') . '/' . $fullUrl;
     }
     if ($this->includeExtension && $fileExtension == 'flv') {
         $fullUrl .= ".{$fileExtension}";
     }
     if ($this->window) {
         $expiry = "{$this->expiryName}=" . strftime("%Y%m%d%H%M%S", time() - date("Z") + $this->window);
         $url = kDeliveryUtils::addQueryParameter($url, $expiry);
         $fullUrl = kDeliveryUtils::addQueryParameter($fullUrl, $expiry);
     }
     $parsedUrl = parse_url($fullUrl);
     $pathString = '/' . ltrim($parsedUrl['path'], '/');
     if (isset($parsedUrl['query']) && strlen($parsedUrl['query']) > 0) {
         $pathString .= '?' . $parsedUrl['query'];
     }
     $token = substr(self::hmac('sha1', $this->key, $pathString), 0, 20);
     $url = $url = kDeliveryUtils::addQueryParameter($url, "{$this->name}={$this->gen}" . $token);
     return $url;
 }
 public function finalizeUrls(&$baseUrl, &$flavorsUrls)
 {
     if ($this->getDisableExtraAttributes()) {
         $baseUrl = kDeliveryUtils::addQueryParameter($baseUrl, "attributes=off");
     }
 }
 public function checkIsLive($url)
 {
     $url = kDeliveryUtils::addQueryParameter($url, "hdcore=" . kConf::get('hd_core_version'));
     return parent::checkIsLive($url);
 }
 /**
  * Fetch the manifest and build all flavors array
  * @param string $url
  */
 private function buildM3u8Flavors($url, array &$flavors)
 {
     if ($this->getDisableExtraAttributes()) {
         $url = kDeliveryUtils::addQueryParameter($url, "attributes=off");
     }
     $manifest = KCurlWrapper::getContent($url);
     if (!$manifest) {
         return;
     }
     $this->finalizeUrls($url, $flavors);
     $manifestLines = explode("\n", $manifest);
     $manifestLine = reset($manifestLines);
     while ($manifestLine) {
         $lineParts = explode(':', $manifestLine, 2);
         if ($lineParts[0] === '#EXT-X-STREAM-INF') {
             // passing the url as urlPrefix so that only the path will be tokenized
             $flavor = array('url' => '', 'urlPrefix' => requestUtils::resolve(next($manifestLines), $url), 'ext' => 'm3u8');
             $attributes = explode(',', $lineParts[1]);
             foreach ($attributes as $attribute) {
                 $attributeParts = explode('=', $attribute, 2);
                 switch ($attributeParts[0]) {
                     case 'BANDWIDTH':
                         $flavor['bitrate'] = $attributeParts[1] / 1024;
                         break;
                     case 'RESOLUTION':
                         list($flavor['width'], $flavor['height']) = explode('x', $attributeParts[1], 2);
                         break;
                 }
             }
             $flavors[] = $flavor;
         }
         $manifestLine = next($manifestLines);
     }
 }