Пример #1
0
 /**
  * Derives the delivery profile dynamic attributes from the file sync and the flavor asset.
  * @param FileSync $fileSync
  * @param flavorAsset $flavorAsset
  */
 public function initDeliveryDynamicAttributes(FileSync $fileSync = null, flavorAsset $flavorAsset = null)
 {
     if ($flavorAsset) {
         $this->params->setContainerFormat($flavorAsset->getContainerFormat());
     }
     if ($flavorAsset && $flavorAsset->getFileExt() !== null) {
         // if the extension is missing use the one from the actual path
         $this->params->setFileExtension($flavorAsset->getFileExt());
     } else {
         if ($fileSync) {
             $this->params->setFileExtension(pathinfo($fileSync->getFilePath(), PATHINFO_EXTENSION));
         }
     }
 }
Пример #2
0
 private static function getExternalStorageUrl(Partner $partner, asset $asset, FileSyncKey $key, $servePlayManifest = false, $playManifestClientTag = null, $storageId = null)
 {
     if (!$partner->getStorageServePriority() || $partner->getStorageServePriority() == StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_ONLY) {
         return null;
     }
     if (is_null($storageId) && $partner->getStorageServePriority() == StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_FIRST) {
         if (kFileSyncUtils::getReadyInternalFileSyncForKey($key)) {
             // check if having file sync on kaltura dcs
             return null;
         }
     }
     $fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($key, $storageId);
     if (!$fileSync) {
         return null;
     }
     $storage = StorageProfilePeer::retrieveByPK($fileSync->getDc());
     if (!$storage) {
         return null;
     }
     if ($servePlayManifest) {
         // in case of an https request, if a delivery profile which supports https doesn't exist use an http cdn api host
         if (infraRequestUtils::getProtocol() == infraRequestUtils::PROTOCOL_HTTPS && DeliveryProfilePeer::getRemoteDeliveryByStorageId(DeliveryProfileDynamicAttributes::init($fileSync->getDc(), $asset->getEntryId(), PlaybackProtocol::HTTP, "https"))) {
             $url = requestUtils::getApiCdnHost();
         } else {
             $url = infraRequestUtils::PROTOCOL_HTTP . "://" . kConf::get("cdn_api_host");
         }
         $url .= $asset->getPlayManifestUrl($playManifestClientTag, $storageId);
     } else {
         $urlManager = DeliveryProfilePeer::getRemoteDeliveryByStorageId(DeliveryProfileDynamicAttributes::init($fileSync->getDc(), $asset->getEntryId()));
         if ($urlManager) {
             $dynamicAttrs = new DeliveryProfileDynamicAttributes();
             $dynamicAttrs->setFileExtension($asset->getFileExt());
             $dynamicAttrs->setStorageId($fileSync->getDc());
             $urlManager->setDynamicAttributes($dynamicAttrs);
             $url = ltrim($urlManager->getFileSyncUrl($fileSync), '/');
             if (strpos($url, "://") === false) {
                 $url = rtrim($urlManager->getUrl(), "/") . "/" . $url;
             }
         } else {
             KalturaLog::debug("Couldn't determine delivery profile for storage id");
             $url = null;
         }
     }
     return $url;
 }