public function getDataUrl($version = NULL) { if ($this->getType() == entryType::PLAYLIST) { return myPlaylistUtils::getExecutionUrl($this); } $current_version = $this->getVersion(); $entryId = $this->getId(); $media_type = $this->getMediaType(); if ($media_type == self::ENTRY_MEDIA_TYPE_VIDEO || $media_type == self::ENTRY_MEDIA_TYPE_AUDIO) { $protocolStr = infraRequestUtils::getProtocol(); $url = requestUtils::getApiCdnHost(); $url .= myPartnerUtils::getUrlForPartner($this->getPartnerId(), $this->getSubpId()); $url .= "/playManifest/entryId/{$entryId}/format/url/protocol/{$protocolStr}"; } else { if ($media_type == self::ENTRY_MEDIA_TYPE_IMAGE) { $width = self::DEFAULT_IMAGE_WIDTH; $height = self::DEFAULT_IMAGE_HEIGHT; $url = myPartnerUtils::getCdnHost($this->getPartnerId()); $url .= myPartnerUtils::getUrlForPartner($this->getPartnerId(), $this->getSubpId()); if (!$version) { $version = $current_version; } $url .= "/thumbnail/entry_id/{$entryId}/def_height/{$height}/def_width/{$width}/version/{$version}/type/1"; } else { return null; } } 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()) { $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 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; }
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; }