Пример #1
0
 public static function getAssetUrl(asset $asset, $servePlayManifest = false, $playManifestClientTag = null, $storageId = null, $urlParameters = '')
 {
     $partner = PartnerPeer::retrieveByPK($asset->getPartnerId());
     if (!$partner) {
         return null;
     }
     $syncKey = $asset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     $externalStorageUrl = self::getExternalStorageUrl($partner, $asset, $syncKey, $servePlayManifest, $playManifestClientTag, $storageId);
     if ($externalStorageUrl) {
         return $externalStorageUrl;
     }
     if ($partner->getStorageServePriority() == StorageProfile::STORAGE_SERVE_PRIORITY_EXTERNAL_ONLY) {
         return null;
     }
     if ($asset instanceof flavorAsset && $servePlayManifest) {
         $url = requestUtils::getApiCdnHost() . $asset->getPlayManifestUrl($playManifestClientTag, $storageId);
     } else {
         $urlManager = DeliveryProfilePeer::getDeliveryProfile($asset->getEntryId());
         if ($asset instanceof flavorAsset) {
             $urlManager->initDeliveryDynamicAttributes(null, $asset);
         }
         $profileAttributes = $urlManager->getDynamicAttributes();
         $profileAttributes->setUrlParams($urlParameters);
         $url = $urlManager->getFullAssetUrl($asset);
         $url = preg_replace('/^https?:\\/\\//', '', $url);
         $protocol = infraRequestUtils::getProtocol();
         $deliveryProfileProtocols = $urlManager->getMediaProtocols();
         if (!is_null($deliveryProfileProtocols) && !in_array($protocol, explode(',', $deliveryProfileProtocols))) {
             $protocol = infraRequestUtils::PROTOCOL_HTTP;
         }
         $url = $protocol . "://" . $url;
     }
     return $url;
 }
 protected static function getAssetUrl(asset $asset)
 {
     $urlManager = DeliveryProfilePeer::getDeliveryProfile($asset->getEntryId());
     if ($asset instanceof flavorAsset) {
         $urlManager->initDeliveryDynamicAttributes(null, $asset);
     }
     $url = $urlManager->getFullAssetUrl($asset);
     $url = preg_replace('/^https?:\\/\\//', '', $url);
     $url = 'http://' . $url . '/ext/' . $asset->getId() . '.' . $asset->getFileExt();
     return $url;
 }
Пример #3
0
 private static function addIsmLink(entry $entry, SimpleXMLElement $mrss)
 {
     if (self::$addedIsmUrl) {
         return;
     }
     self::$addedIsmUrl = true;
     $syncKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM);
     $kalturaFileSync = kFileSyncUtils::getReadyInternalFileSyncForKey($syncKey);
     $urlManager = DeliveryProfilePeer::getDeliveryProfile($entry->getId(), PlaybackProtocol::SILVER_LIGHT);
     if (!$urlManager) {
         return;
     }
     $urlManager->initDeliveryDynamicAttributes($kalturaFileSync);
     $partner = $entry->getPartner();
     if (!$partner->getStorageServePriority() || $partner->getStorageServePriority() == StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_ONLY || $partner->getStorageServePriority() == StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_FIRST) {
         if ($kalturaFileSync) {
             $urlPrefix = $urlManager->getUrl();
             $url = $urlManager->getFileSyncUrl($kalturaFileSync, false);
             $mrss->addChild('ismUrl', $urlPrefix . $url);
             return;
         }
     }
     if (!$partner->getStorageServePriority() || $partner->getStorageServePriority() == StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_ONLY) {
         return null;
     }
     $externalFileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($syncKey);
     if ($externalFileSync) {
         $urlManager = DeliveryProfilePeer::getRemoteDeliveryByStorageId(DeliveryProfileDynamicAttributes::init($externalFileSync->getDc(), $entry->getId(), PlaybackProtocol::SILVER_LIGHT));
         if (is_null($urlManager)) {
             return;
         }
         $url = $urlManager->getFileSyncUrl($externalFileSync, false);
         $urlPrefix = $urlManager->getUrl();
         $mrss->addChild('ismUrl', $urlPrefix . $url);
         return;
     }
     if ($partner->getStorageServePriority() != StorageProfile::STORAGE_SERVE_PRIORITY_EXTERNAL_ONLY) {
         if ($kalturaFileSync) {
             $url = $urlManager->getFileSyncUrl($kalturaFileSync, false);
             $mrss->addChild('ismUrl', $urlPrefix . $url);
             return;
         }
     }
 }
 private function getFlavorAssetUrl($kalturaEntry)
 {
     $partner = PartnerPeer::retrieveByPK($this->syndicationFeed->partnerId);
     if (!$partner) {
         return null;
     }
     $flavorAsset = assetPeer::retrieveByEntryIdAndParams($kalturaEntry->id, $this->syndicationFeed->flavorParamId);
     if (!$flavorAsset) {
         return null;
     }
     $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     $externalStorageUrl = $this->getExternalStorageUrl($partner, $flavorAsset, $syncKey);
     if ($externalStorageUrl) {
         return $externalStorageUrl;
     }
     if ($partner->getStorageServePriority() == StorageProfile::STORAGE_SERVE_PRIORITY_EXTERNAL_ONLY) {
         return null;
     }
     if ($this->syndicationFeedDb->getServePlayManifest()) {
         $cdnHost = requestUtils::getApiCdnHost();
         $clientTag = 'feed:' . $this->syndicationFeedDb->getId();
         $url = $cdnHost . $flavorAsset->getPlayManifestUrl($clientTag);
     } else {
         $urlManager = DeliveryProfilePeer::getDeliveryProfile($flavorAsset->getEntryId());
         $urlManager->initDeliveryDynamicAttributes(null, $flavorAsset);
         $url = "http://" . $urlManager->getFullAssetUrl($flavorAsset);
     }
     return $url;
 }
 private function getFlavorAssetUrl($kalturaEntry)
 {
     $partner = PartnerPeer::retrieveByPK($this->syndicationFeed->partnerId);
     if (!$partner) {
         return null;
     }
     $flavorAsset = assetPeer::retrieveByEntryIdAndParams($kalturaEntry->id, $this->syndicationFeed->flavorParamId);
     if (!$flavorAsset) {
         return null;
     }
     $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     $externalStorageUrl = $this->getExternalStorageUrl($partner, $flavorAsset, $syncKey);
     if ($externalStorageUrl) {
         return $externalStorageUrl;
     }
     if ($partner->getStorageServePriority() == StorageProfile::STORAGE_SERVE_PRIORITY_EXTERNAL_ONLY) {
         return null;
     }
     if ($this->syndicationFeedDb->getServePlayManifest()) {
         $shouldAddKtToken = false;
         if ($this->syndicationFeed->type == KalturaSyndicationFeedType::ITUNES) {
             $entry = $flavorAsset->getentry();
             $accessControl = $entry->getaccessControl();
             if ($accessControl && $accessControl->hasRules()) {
                 $shouldAddKtToken = true;
             }
         }
         $cdnHost = requestUtils::getApiCdnHost();
         $clientTag = 'feed:' . $this->syndicationFeedDb->getId();
         $url = $cdnHost . $flavorAsset->getPlayManifestUrl($clientTag, null, PlaybackProtocol::HTTP, $shouldAddKtToken);
     } else {
         $urlManager = DeliveryProfilePeer::getDeliveryProfile($flavorAsset->getEntryId());
         $urlManager->initDeliveryDynamicAttributes(null, $flavorAsset);
         $protocol = requestUtils::getProtocol();
         if (!$urlManager->isProtocolSupported($protocol)) {
             $protocol = $protocol == 'http' ? 'https' : 'http';
             if (!$urlManager->isProtocolSupported($protocol)) {
                 $protocol = 'http';
             }
         }
         $url = $protocol . '://' . $urlManager->getFullAssetUrl($flavorAsset);
     }
     return $url;
 }