/** * Will forward to the regular swf player according to the widget_id */ public function execute() { $ui_conf_id = $this->getRequestParameter("ui_conf_id"); $uiConf = uiConfPeer::retrieveByPK($ui_conf_id); if (!$uiConf) { die; } $partner_id = $uiConf->getPartnerId(); $subp_id = $uiConf->getSubpId(); $host = myPartnerUtils::getHost($partner_id); $ui_conf_swf_url = $uiConf->getSwfUrl(); if (!$ui_conf_swf_url) { $ui_conf_swf_url = "/swf/simpleeditor.swf"; } if (kString::beginsWith($ui_conf_swf_url, "http")) { $swf_url = $ui_conf_swf_url; // absolute URL } else { $use_cdn = $uiConf->getUseCdn(); $cdn_host = $use_cdn ? myPartnerUtils::getCdnHost($partner_id) : myPartnerUtils::getHost($partner_id); $swf_url = $cdn_host . myPartnerUtils::getUrlForPartner($partner_id, $subp_id) . $ui_conf_swf_url; // relative to the current host } // handle buggy case for backward compatiblity $partner_host = $host; if ($partner_host == "http://www.kaltura.com") { $partner_host = 1; } // otherwise the kse will build a flawed url with [[IMPORT]] $params = "contentUrl=" . urlencode($swf_url) . "&host=" . str_replace("http://", "", str_replace("https://", "", $partner_host)) . "&cdnHost=" . str_replace("http://", "", str_replace("https://", "", myPartnerUtils::getCdnHost($partner_id))) . "&uiConfId=" . $ui_conf_id . "&disableurlhashing=" . kConf::get('disable_url_hashing'); $wrapper_swf = myContentStorage::getFSFlashRootPath() . "/flexwrapper/" . kConf::get('editors_flex_wrapper_version') . "/FlexWrapper.swf"; $this->redirect($host . myPartnerUtils::getUrlForPartner($partner_id, $subp_id) . "{$wrapper_swf}?{$params}"); }
/** * Will forward to the uploader swf according to the ui_conf_id */ public function execute() { $ui_conf_id = $this->getRequestParameter("ui_conf_id"); $uiConf = uiConfPeer::retrieveByPK($ui_conf_id); if (!$uiConf) { die; } $partner_id = $uiConf->getPartnerId(); $subp_id = $uiConf->getSubpId(); $host = requestUtils::getRequestHost(); $ui_conf_swf_url = $uiConf->getSwfUrl(); if (!$ui_conf_swf_url) { die; } if (kString::beginsWith($ui_conf_swf_url, "http")) { $swf_url = $ui_conf_swf_url; // absolute URL } else { $use_cdn = $uiConf->getUseCdn(); $cdn_host = $use_cdn ? myPartnerUtils::getCdnHost($partner_id) : myPartnerUtils::getHost($partner_id); $swf_url = $cdn_host . myPartnerUtils::getUrlForPartner($partner_id, $subp_id) . $ui_conf_swf_url; // relative to the current host } $conf_vars = $uiConf->getConfVars(); if ($conf_vars) { $conf_vars = "&" . $conf_vars; } $params = "host=" . $host . "&uiConfId=" . $ui_conf_id . $conf_vars; $this->redirect("{$swf_url}?{$params}"); }
/** * @param flavorAsset $flavorAsset * @return string */ protected function doGetFlavorAssetUrl(flavorAsset $flavorAsset) { $entry = $flavorAsset->getentry(); $partnerId = $entry->getPartnerId(); $subpId = $entry->getSubpId(); $flavorAssetId = $flavorAsset->getId(); $partnerPath = myPartnerUtils::getUrlForPartner($partnerId, $subpId); $this->setFileExtension($flavorAsset->getFileExt()); $versionString = $this->getFlavorVersionString($flavorAsset); $url = "/s{$partnerPath}/serveFlavor/entryId/" . $flavorAsset->getEntryId() . "{$versionString}/flavorId/{$flavorAssetId}"; if ($this->clipTo) { $url .= "/clipTo/{$this->clipTo}"; } if ($this->extention) { $url .= "/name/a.{$this->extention}"; } $url = str_replace('\\', '/', $url); if ($this->protocol != StorageProfile::PLAY_FORMAT_RTMP) { $url .= '?novar=0'; $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $seekFromBytes = $this->getSeekFromBytes(kFileSyncUtils::getLocalFilePathForKey($syncKey)); if ($seekFromBytes) { $url .= '&fs=' . $seekFromBytes; } } else { if ($this->extention && strtolower($this->extention) != 'flv' || $this->containerFormat && strtolower($this->containerFormat) != 'flash video') { $url = "mp4:{$url}"; } } return $url; }
private static function purgeAssetFromEdgeCast(asset $asset) { // get partner $partnerId = $asset->getPartnerId(); $partner = PartnerPeer::retrieveByPK($partnerId); if (!$partner) { KalturaLog::err('Cannot find partner with id [' . $partnerId . ']'); return false; } $mediaType = $asset instanceof thumbAsset ? self::EDGE_SERVICE_HTTP_SMALL_OBJECT_MEDIA_TYPE : self::EDGE_SERVICE_HTTP_LARGE_OBJECT_MEDIA_TYPE; $mediaTypePathList = array(); try { $mediaTypePathList[] = array('MediaType' => $mediaType, 'MediaPath' => $asset->getDownloadUrl()); // asset download url } catch (Exception $e) { KalturaLog::err('Cannot get asset URL for asset id [' . $asset->getId() . '] - ' . $e->getMessage()); } if ($asset instanceof flavorAsset) { // get a list of all URLs leading to the asset for purging $subPartnerId = $asset->getentry()->getSubpId(); $partnerPath = myPartnerUtils::getUrlForPartner($partnerId, $subPartnerId); $assetId = $asset->getId(); $serveFlavorUrl = "{$partnerPath}/serveFlavor/entryId/" . $asset->getEntryId() . "/flavorId/{$assetId}" . '*'; // * wildcard should delete all serveFlavor urls $hosts = array($partner->getCdnHost(), $partner->getRtmpUrl(), $partner->getIisHost()); foreach ($hosts as $host) { if (!empty($host)) { $mediaTypePathList[] = array('MediaType' => $mediaType, 'MediaPath' => $host . $serveFlavorUrl); } } } return self::purgeFromEdgeCast($mediaTypePathList, $partner); }
/** * @param flavorAsset $flavorAsset * @return string */ public function getFlavorAssetUrl(flavorAsset $flavorAsset) { $entry = $flavorAsset->getentry(); $partnerId = $entry->getPartnerId(); $subpId = $entry->getSubpId(); $flavorAssetId = $flavorAsset->getId(); $partnerPath = myPartnerUtils::getUrlForPartner($partnerId, $subpId); $this->setFileExtension($flavorAsset->getFileExt()); $url = "/s{$partnerPath}/serveFlavor/flavorId/{$flavorAssetId}"; if ($this->clipTo) { $url .= "/clipTo/{$this->clipTo}"; } if ($this->extention) { $url .= "/name/{$flavorAssetId}.{$this->extention}"; } $url = str_replace('\\', '/', $url); if ($this->protocol != StorageProfile::PLAY_FORMAT_RTMP) { $url .= '?novar=0'; $url .= '&e=' . (time() + 120); $secret = $this->getMediaVault(); $fullUrl = $this->protocol . '://' . $this->domain . $url; $url .= '&h=' . md5($secret . $fullUrl); $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $seekFromBytes = $this->getSeekFromBytes(kFileSyncUtils::getLocalFilePathForKey($syncKey)); if ($seekFromBytes) { $url .= '&fs=' . $seekFromBytes; } } else { $url .= '/forceproxy/true'; } return $url; }
/** * Will forward to the regular swf player according to the widget_id */ public function execute() { $ui_conf_id = $this->getRequestParameter("ui_conf_id"); $uiConf = uiConfPeer::retrieveByPK($ui_conf_id); if (!$uiConf) { die; } $partner_id = $uiConf->getPartnerId(); $subp_id = $uiConf->getSubpId(); if (!$subp_id) { $subp_id = 0; } $host = myPartnerUtils::getHost($partner_id); $ui_conf_swf_url = $uiConf->getSwfUrl(); if (!$ui_conf_swf_url) { $ui_conf_swf_url = "/swf/ContributionWizard.swf"; } if (kString::beginsWith($ui_conf_swf_url, "http")) { $swf_url = $ui_conf_swf_url; // absolute URL } else { $use_cdn = $uiConf->getUseCdn(); $cdn_host = $use_cdn ? myPartnerUtils::getCdnHost($partner_id) : myPartnerUtils::getHost($partner_id); $swf_url = $cdn_host . myPartnerUtils::getUrlForPartner($partner_id, $subp_id) . $ui_conf_swf_url; // relative to the current host } $params = "contentUrl=" . urlencode($swf_url) . "&host=" . str_replace("http://", "", str_replace("https://", "", $host)) . "&cdnHost=" . str_replace("http://", "", str_replace("https://", "", myPartnerUtils::getCdnHost($partner_id))) . "&uiConfId=" . $ui_conf_id; $wrapper_swf = myContentStorage::getFSFlashRootPath() . "/flexwrapper/" . kConf::get('kcw_flex_wrapper_version') . "/FlexWrapper.swf"; $this->redirect($host . myPartnerUtils::getUrlForPartner($partner_id, $subp_id) . "{$wrapper_swf}?{$params}"); }
/** * Will forward to the uploader swf according to the ui_conf_id */ public function execute() { $ui_conf_id = $this->getRequestParameter("ui_conf_id"); $uiConf = uiConfPeer::retrieveByPK($ui_conf_id); if (!$uiConf) { KExternalErrors::dieError(KExternalErrors::UI_CONF_NOT_FOUND, "UI conf not found"); } $partner_id = $uiConf->getPartnerId(); $subp_id = $uiConf->getSubpId(); $host = requestUtils::getRequestHost(); $ui_conf_swf_url = $uiConf->getSwfUrl(); if (!$ui_conf_swf_url) { KExternalErrors::dieError(KExternalErrors::ILLEGAL_UI_CONF, "SWF URL not found in UI conf"); } if (kString::beginsWith($ui_conf_swf_url, "http")) { $swf_url = $ui_conf_swf_url; // absolute URL } else { $use_cdn = $uiConf->getUseCdn(); $cdn_host = $use_cdn ? myPartnerUtils::getCdnHost($partner_id) : myPartnerUtils::getHost($partner_id); $swf_url = $cdn_host . myPartnerUtils::getUrlForPartner($partner_id, $subp_id) . $ui_conf_swf_url; // relative to the current host } $conf_vars = $uiConf->getConfVars(); if ($conf_vars) { $conf_vars = "&" . $conf_vars; } $params = "host=" . $host . "&uiConfId=" . $ui_conf_id . $conf_vars; KExternalErrors::terminateDispatch(); $this->redirect("{$swf_url}?{$params}"); }
/** * @param flavorAsset $flavorAsset * @return string representing the basic url. */ protected function getBaseUrl(flavorAsset $flavorAsset) { $partnerId = $flavorAsset->getPartnerId(); $subpId = $flavorAsset->getentry()->getSubpId(); $partnerPath = myPartnerUtils::getUrlForPartner($partnerId, $subpId); $flavorAssetId = $flavorAsset->getId(); $versionString = $this->getFlavorVersionString($flavorAsset); $urlParams = $this->params->getUrlParams(); $url = "{$partnerPath}/serveFlavor/entryId/" . $flavorAsset->getEntryId() . "{$versionString}/flavorId/{$flavorAssetId}" . $urlParams; return $url; }
private function createArgumentsForXSLT() { $partnerPath = myPartnerUtils::getUrlForPartner($this->entry->getPartnerId(), $this->entry->getSubpId()); $prefix = myPartnerUtils::getCdnHost($this->entry->getPartnerId(), null, 'api') . $partnerPath . "/playManifest" . "/entryId/"; $arguments = array("distributionProfileId" => $this->distributionProfile->id, "playManifestPrefix" => $prefix); if ($this->distributionProfile->ipadnewPpvModule) { $arguments["ipadnewPpvModule"] = $this->distributionProfile->ipadnewPpvModule; } if ($this->distributionProfile->ipadnewFileName) { $arguments["ipadnewTypeName"] = $this->distributionProfile->ipadnewFileName; } if ($this->distributionProfile->ismPpvModule) { $arguments["ismPpvModule"] = $this->distributionProfile->ismPpvModule; } if ($this->distributionProfile->ismFileName) { $arguments["ismTypeName"] = $this->distributionProfile->ismFileName; } if ($this->distributionProfile->iphonenewPpvModule) { $arguments["iphonenewPpvModule"] = $this->distributionProfile->iphonenewPpvModule; } if ($this->distributionProfile->iphonenewFileName) { $arguments["iphonenewTypeName"] = $this->distributionProfile->iphonenewFileName; } if ($this->distributionProfile->mbrPpvModule) { $arguments["mbrPpvModule"] = $this->distributionProfile->mbrPpvModule; } if ($this->distributionProfile->mbrFileName) { $arguments["mbrTypeName"] = $this->distributionProfile->mbrFileName; } if ($this->distributionProfile->dashPpvModule) { $arguments["dashPpvModule"] = $this->distributionProfile->dashPpvModule; } if ($this->distributionProfile->dashFileName) { $arguments["dashTypeName"] = $this->distributionProfile->dashFileName; } if ($this->distributionProfile->widevinePpvModule) { $arguments["widevinePpvModule"] = $this->distributionProfile->widevinePpvModule; } if ($this->distributionProfile->widevineFileName) { $arguments["widevineTypeName"] = $this->distributionProfile->widevineFileName; } if ($this->distributionProfile->widevineMbrPpvModule) { $arguments["widevineMbrPpvModule"] = $this->distributionProfile->widevineMbrPpvModule; } if ($this->distributionProfile->widevineMbrFileName) { $arguments["widevineMbrTypeName"] = $this->distributionProfile->widevineMbrFileName; } return $arguments; }
private static function purgeAssetFromEdgeCast(asset $asset) { // get partner $partnerId = $asset->getPartnerId(); $partner = PartnerPeer::retrieveByPK($partnerId); if (!$partner) { KalturaLog::err('Cannot find partner with id [' . $partnerId . ']'); return false; } $mediaType = $asset instanceof thumbAsset ? self::EDGE_SERVICE_HTTP_SMALL_OBJECT_MEDIA_TYPE : self::EDGE_SERVICE_HTTP_LARGE_OBJECT_MEDIA_TYPE; $mediaTypePathList = array(); try { $mediaTypePathList[] = array('MediaType' => $mediaType, 'MediaPath' => $asset->getDownloadUrl()); // asset download url } catch (Exception $e) { KalturaLog::err('Cannot get asset URL for asset id [' . $asset->getId() . '] - ' . $e->getMessage()); } if ($asset instanceof flavorAsset) { // get a list of all URLs leading to the asset for purging $subPartnerId = $asset->getentry()->getSubpId(); $partnerPath = myPartnerUtils::getUrlForPartner($partnerId, $subPartnerId); $assetId = $asset->getId(); $serveFlavorUrl = "{$partnerPath}/serveFlavor/entryId/" . $asset->getEntryId() . "/flavorId/{$assetId}" . '*'; // * wildcard should delete all serveFlavor urls $types = array(kPluginableEnumsManager::apiToCore(EdgeCastDeliveryProfileType::EDGE_CAST_HTTP), kPluginableEnumsManager::apiToCore(EdgeCastDeliveryProfileType::EDGE_CAST_RTMP)); $deliveryProfile = $partner->getDeliveryProfileIds(); $deliveryProfileIds = array(); foreach ($deliveryProfile as $key => $value) { $deliveryProfileIds = array_merge($deliveryProfileIds, $value); } $c = new Criteria(); $c->add(DeliveryProfilePeer::PARTNER_ID, $partnerId); $c->add(DeliveryProfilePeer::ID, $deliveryProfileIds, Criteria::IN); $c->addSelectColumn(DeliveryProfilePeer::HOST_NAME); $stmt = PermissionPeer::doSelectStmt($c); $hosts = $stmt->fetchAll(PDO::FETCH_COLUMN); foreach ($hosts as $host) { if (!empty($host)) { $mediaTypePathList[] = array('MediaType' => $mediaType, 'MediaPath' => $host . $serveFlavorUrl); } } } return self::purgeFromEdgeCast($mediaTypePathList, $partner); }
/** * @param flavorAsset $flavorAsset * @return string representing the basic url. */ protected function getBaseUrl(flavorAsset $flavorAsset) { $entry = entryPeer::retrieveByPK($this->params->getEntryId()); $partnerId = $flavorAsset->getPartnerId(); $subpId = $entry->getSubpId(); $partnerPath = myPartnerUtils::getUrlForPartner($partnerId, $subpId); $url = "{$partnerPath}/serveFlavor/entryId/" . $entry->getId(); if ($entry->getType() == entryType::PLAYLIST) { $partner = $entry->getPartner(); $entryVersion = $entry->getVersion(); $partnerFlavorVersion = $partner->getCacheFlavorVersion(); $url .= ($entryVersion ? "/v/{$entryVersion}" : '') . ($partnerFlavorVersion ? "/pv/{$partnerFlavorVersion}" : ''); $url .= '/flavorParamIds/' . $flavorAsset->getFlavorParamsId(); } else { $url .= $this->getFlavorVersionString($flavorAsset); $url .= '/flavorId/' . $flavorAsset->getId(); } $url .= $this->params->getUrlParams(); return $url; }
protected function doGetFileSyncUrl(FileSync $fileSync) { $storage = StorageProfilePeer::retrieveByPK($fileSync->getDc()); if (!$storage) { return parent::doGetFileSyncUrl($fileSync); } $partnerPath = myPartnerUtils::getUrlForPartner($fileSync->getPartnerId(), $fileSync->getPartnerId() * 100); $objectSubType = $fileSync->getObjectSubType(); if ($fileSync->getObjectType() == FileSyncObjectType::ENTRY && $objectSubType == entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM) { return $this->doGetServeIsmUrl($fileSync, $partnerPath, $storage); } //To Remove - Until the migration process from asset sub type 3 to asset sub type 1 will be completed we need to support both formats if ($fileSync->getObjectType() == FileSyncObjectType::FLAVOR_ASSET && $objectSubType == flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ISM) { return $this->doGetServeIsmUrl($fileSync, $partnerPath, $storage); } if ($fileSync->getObjectType() == FileSyncObjectType::FLAVOR_ASSET && $objectSubType == flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET) { $asset = assetPeer::retrieveById($fileSync->getObjectId()); if ($asset->hasTag(assetParams::TAG_ISM_MANIFEST)) { return $this->doGetServeIsmUrl($fileSync, $partnerPath, $storage); } } return parent::doGetFileSyncUrl($fileSync); }
/** * @return kManifestRenderer */ public function serve() { if ($this->params->getManifestFileSync()) { /** @var FileSync $manifestFileSync */ $manifestFileSync = $this->params->getManifestFileSync(); $this->initDeliveryDynamicAttributes($this->params->getManifestFileSync()); if ($manifestFileSync->getFileType() == FileSync::FILE_SYNC_FILE_TYPE_FILE) { // return kaltura urls with serveSmil / serveManifest $partnerPath = myPartnerUtils::getUrlForPartner($manifestFileSync->getPartnerId(), $manifestFileSync->getPartnerId() * 100); $manifestObjectId = $manifestFileSync->getObjectId() . '_' . $manifestFileSync->getObjectSubType() . '_' . $manifestFileSync->getVersion(); $extension = pathinfo($manifestFileSync->getFilePath(), PATHINFO_EXTENSION); $url = $partnerPath . '/serveManifest/objectId/' . $manifestObjectId . '.' . $extension; $url = kDeliveryUtils::formatGenericUrl($url, $this->getPattern(), $this->params); } else { $url = $this->getFileSyncUrl($manifestFileSync, false); } $manifestInfo = $this->getFlavorAssetInfo($url); return $this->getRenderer(array($manifestInfo)); } else { KalturaLog::debug("No manifest file was found"); return null; } }
/** * @param flavorAsset $flavorAsset * @return string */ public function getFlavorAssetUrl(flavorAsset $flavorAsset) { $entry = $flavorAsset->getentry(); $partnerId = $entry->getPartnerId(); $subpId = $entry->getSubpId(); $flavorAssetId = $flavorAsset->getId(); $partnerPath = myPartnerUtils::getUrlForPartner($partnerId, $subpId); $this->setFileExtension($flavorAsset->getFileExt()); $url = "{$partnerPath}/serveFlavor/flavorId/{$flavorAssetId}"; if ($this->clipTo) { $url .= "/clipTo/{$this->clipTo}"; } if ($this->extention) { $url .= "/name/{$flavorAssetId}.{$this->extention}"; } if ($this->protocol != StorageProfile::PLAY_FORMAT_RTMP) { $url .= '?novar=0'; if ($entry->getSecurityPolicy()) { $url = "/s{$url}"; // set expire time in GMT hence the date("Z") offset $url .= "&nva=" . strftime("%Y%m%d%H%M%S", time() - date("Z") + 30); $secret = kConf::get("level3_authentication_key"); $hash = "0" . substr(self::hmac('sha1', $secret, $url), 0, 20); $url .= "&h={$hash}"; } $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $seekFromBytes = $this->getSeekFromBytes(kFileSyncUtils::getLocalFilePathForKey($syncKey)); if ($seekFromBytes) { $url .= '&start=' . $seekFromBytes; } } else { $url .= '/forceproxy/true'; } $url = str_replace('\\', '/', $url); return $url; }
private function getPlayManifestUrl($entry, $playbackProtocol, $tag, $fileExt) { $partnerPath = myPartnerUtils::getUrlForPartner($entry->getPartnerId(), $entry->getSubpId()); $downloadUrl = myPartnerUtils::getCdnHost($entry->getPartnerId()) . $partnerPath . "/playManifest" . "/entryId/{$entry->getId()}" . "/format/{$playbackProtocol}" . "/tags/{$tag}" . "/protocol/http" . "/f/a.{$fileExt}"; return $downloadUrl; }
private function serveRtmp() { switch ($this->entry->getType()) { case entryType::MEDIA_CLIP: $duration = $this->entry->getDurationInt(); $flavorAssets = array(); if ($this->flavorId) { $flavorAsset = flavorAssetPeer::retrieveById($this->flavorId); if (!$flavorAsset->hasTag(flavorParams::TAG_WEB)) { KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND); } if (!$flavorAsset->getStatus() == flavorAsset::FLAVOR_ASSET_STATUS_READY) { KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND); } $flavorAssets[] = $flavorAsset; } else { $flavorAssets = flavorAssetPeer::retreiveReadyByEntryIdAndTag($this->entryId, flavorParams::TAG_MBR); if (!count($flavorAssets)) { $flavorAssets = flavorAssetPeer::retreiveReadyByEntryIdAndTag($this->entryId, flavorParams::TAG_WEB); } } $flavorAssets = $this->removeMaxBitrateFlavors($flavorAssets); if (!$this->storageId) { $partner = $this->entry->getPartner(); $finalFlavors = array(); if ($partner->getStorageServePriority() == StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_FIRST) { foreach ($flavorAssets as $flavorAsset) { $key = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $fileSync = kFileSyncUtils::getReadyInternalFileSyncForKey($key); if ($fileSync) { $finalFlavors[] = $flavorAsset; } } } if (!count($finalFlavors) && $partner->getStorageServePriority() && $partner->getStorageServePriority() != StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_ONLY) { $storages = StorageProfilePeer::retrieveExternalByPartnerId($partner->getId()); if (count($storages) == 1) { $this->storageId = $storages[0]->getId(); } elseif (count($storages)) { $storagesFlavors = array(); foreach ($storages as $storage) { $storagesFlavors[$storage->getId()] = array(); foreach ($flavorAssets as $flavorAsset) { $key = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($key, $storage->getId()); if ($fileSync) { $storagesFlavors[$storage->getId()][] = $flavorAsset; } } } $maxCount = 0; foreach ($storagesFlavors as $storageId => $storageFlavors) { $count = count($storageFlavors); if ($count > $maxCount) { $maxCount = $count; $this->storageId = $storageId; $finalFlavors = $storageFlavors; } } $flavorAssets = $finalFlavors; } else { foreach ($flavorAssets as $flavorAsset) { $key = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $fileSync = kFileSyncUtils::getReadyInternalFileSyncForKey($key); if ($fileSync) { $finalFlavors[] = $flavorAsset; } } } } } foreach ($flavorAssets as $flavorAsset) { $mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($flavorAsset->getId()); if ($mediaInfo && ($mediaInfo->getVideoDuration() || $mediaInfo->getAudioDuration() || $mediaInfo->getContainerDuration())) { $duration = $mediaInfo->getVideoDuration() ? $mediaInfo->getVideoDuration() : ($mediaInfo->getAudioDuration() ? $mediaInfo->getAudioDuration() : $mediaInfo->getContainerDuration()); $duration /= 1000; break; } } $baseUrl = null; $flavors = array(); if ($this->storageId) { $storage = StorageProfilePeer::retrieveByPK($this->storageId); if (!$storage) { die; } $baseUrl = $storage->getDeliveryRmpBaseUrl(); // get all flavors with external urls foreach ($flavorAssets as $flavorAsset) { $key = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($key, $this->storageId); if (!$fileSync) { continue; } $urlManager = kUrlManager::getUrlManagerByStorageProfile($fileSync->getDc()); $urlManager->setClipTo($this->clipTo); $urlManager->setFileExtension($flavorAsset->getFileExt()); $urlManager->setProtocol(StorageProfile::PLAY_FORMAT_RTMP); $url = $urlManager->getFileSyncUrl($fileSync); $url = preg_replace('/^\\//', '', $url); $flavors[] = array('url' => $url, 'bitrate' => $flavorAsset->getBitrate(), 'width' => $flavorAsset->getWidth(), 'height' => $flavorAsset->getHeight()); } } else { $partnerId = $this->entry->getPartnerId(); $subpId = $this->entry->getSubpId(); $partnerPath = myPartnerUtils::getUrlForPartner($partnerId, $subpId); $baseUrl = myPartnerUtils::getRtmpUrl($partnerId); $urlManager = kUrlManager::getUrlManagerByCdn($this->cdnHost); // get all flavors with kaltura urls foreach ($flavorAssets as $flavorAsset) { $urlManager->setClipTo($this->clipTo); $urlManager->setFileExtension($flavorAsset->getFileExt()); $urlManager->setProtocol(StorageProfile::PLAY_FORMAT_RTMP); $url = $urlManager->getFlavorAssetUrl($flavorAsset); $url = preg_replace('/^\\//', '', $url); $flavors[] = array('url' => $url, 'bitrate' => $flavorAsset->getBitrate(), 'width' => $flavorAsset->getWidth(), 'height' => $flavorAsset->getHeight()); } } if (!count($flavors)) { KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND); } if (strpos($this->protocol, "rtmp") === 0) { $baseUrl = $this->protocol . '://' . preg_replace('/^rtmp.*?:\\/\\//', '', $baseUrl); } return $this->buildXml(self::PLAY_STREAM_TYPE_RECORDED, $flavors, 'video/x-flv', $duration, $baseUrl); case entryType::LIVE_STREAM: $streamId = $this->entry->getStreamRemoteId(); $streamUsername = $this->entry->getStreamUsername(); $baseUrl = $this->entry->getStreamUrl(); $baseUrl = rtrim($baseUrl, '/'); $flavors = $this->entry->getStreamBitrates(); if (count($flavors)) { foreach ($flavors as $index => $flavor) { $brIndex = $index + 1; $flavors[$index]['url'] = str_replace('%i', $brIndex, $this->entry->getStreamName()); } } else { $flavors[0]['url'] = str_replace('%i', '1', $this->entry->getStreamName()); } if (strpos($this->protocol, "rtmp") === 0) { $baseUrl = $this->protocol . '://' . preg_replace('/^rtmp.*?:\\/\\//', '', $baseUrl); } return $this->buildXml(self::PLAY_STREAM_TYPE_LIVE, $flavors, 'video/x-flv', null, $baseUrl); } KExternalErrors::dieError(KExternalErrors::INVALID_ENTRY_TYPE); }
public function getDownloadUrlWithExpiry($expiry, $useCdn = false) { $ksStr = ""; $partnerId = $this->getPartnerId(); $partner = PartnerPeer::retrieveByPK($partnerId); $secret = $partner->getSecret(); $privilege = ks::PRIVILEGE_DOWNLOAD . ":" . $this->getEntryId(); $result = kSessionUtils::startKSession($partnerId, $secret, null, $ksStr, $expiry, false, "", $privilege); if ($result < 0) { throw new Exception("Failed to generate session for flavor asset [" . $this->getId() . "]"); } $finalPath = myPartnerUtils::getUrlForPartner($this->getPartnerId(), $this->getPartnerId() * 100) . "/download" . "/entry_id/" . $this->getEntryId() . "/flavor/" . $this->getId() . "/ks/" . $ksStr; // Gonen May 12 2010 - removing CDN URLs. see ticket 5135 in internal mantis // in order to avoid conflicts with access_control (geo-location restriction), we always return the requestHost (www_host from kConf) // and not the CDN host relevant for the partner. // Tan-Tan January 27 2011 - in some places we do need the cdn, I added a paramter useCdn to force it. if ($useCdn) { $downloadUrl = myPartnerUtils::getCdnHost($partnerId) . $finalPath; } else { $downloadUrl = requestUtils::getRequestHost() . $finalPath; } return $downloadUrl; }
/** * @param flavorAsset $flavorAsset * @return string */ protected function doGetFlavorAssetUrl(flavorAsset $flavorAsset) { $partnerId = $flavorAsset->getPartnerId(); $subpId = $flavorAsset->getentry()->getSubpId(); $partnerPath = myPartnerUtils::getUrlForPartner($partnerId, $subpId); $flavorAssetId = $flavorAsset->getId(); $this->setFileExtension($flavorAsset->getFileExt()); $this->setContainerFormat($flavorAsset->getContainerFormat()); $versionString = $this->getFlavorVersionString($flavorAsset); $url = "{$partnerPath}/serveFlavor/entryId/" . $flavorAsset->getEntryId() . "{$versionString}/flavorId/{$flavorAssetId}"; if ($this->seekFromTime > 0) { $url .= "/seekFrom/{$this->seekFromTime}"; } if ($this->clipTo) { $url .= "/clipTo/{$this->clipTo}"; } switch ($this->protocol) { case StorageProfile::PLAY_FORMAT_RTMP: $url .= '/forceproxy/true'; if ($this->extention && strtolower($this->extention) != 'flv' || $this->containerFormat && strtolower($this->containerFormat) != 'flash video') { $url = "mp4:{$url}/name/a.mp4"; } else { $url .= "/name/a.flv"; } break; case StorageProfile::PLAY_FORMAT_APPLE_HTTP: $url .= "/file/playlist.m3u8"; break; } $url = str_replace('\\', '/', $url); return $url; }
public function getFinalDownloadUrlPathWithoutKs() { $finalPath = myPartnerUtils::getUrlForPartner($this->getPartnerId(), $this->getPartnerId() * 100) . "/download" . "/entry_id/" . $this->getEntryId() . "/flavor/" . $this->getId(); return $finalPath; }
/** * @param FileSync $fileSync * @return string */ protected function doGetFileSyncUrl(FileSync $fileSync) { $fileSync = kFileSyncUtils::resolve($fileSync); $storage = StorageProfilePeer::retrieveByPK($fileSync->getDc()); if (!$storage) { return parent::doGetFileSyncUrl($fileSync); } $serverUrl = $storage->getDeliveryIisBaseUrl(); $partnerPath = myPartnerUtils::getUrlForPartner($fileSync->getPartnerId(), $fileSync->getPartnerId() * 100); if ($this->protocol == StorageProfile::PLAY_FORMAT_APPLE_HTTP && isset($this->params["hd_ios"])) { $path = $fileSync->getFilePath(); $urlSuffix = str_replace('\\', '/', $path) . "/index_0_av.m3u8"; $urlPrefix = "http://" . $this->params["hd_ios"] . '/i/'; return $urlPrefix . ltrim($urlSuffix, '/'); } if ($this->protocol == "hdnetworksmil" && isset($this->params["hd_flash"])) { $path = $fileSync->getFilePath(); $urlSuffix = str_replace('\\', '/', $path); $urlPrefix = "http://" . $this->params["hd_flash"]; return $urlPrefix . '/' . ltrim($urlSuffix, '/'); } if ($fileSync->getObjectSubType() != entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM) { return parent::doGetFileSyncUrl($fileSync); } $serverUrl = myPartnerUtils::getIisHost($fileSync->getPartnerId(), "http"); $path = $partnerPath . '/serveIsm/objectId/' . $fileSync->getObjectId() . '_' . $fileSync->getObjectSubType() . '_' . $fileSync->getVersion() . '.' . pathinfo(kFileSyncUtils::resolve($fileSync)->getFilePath(), PATHINFO_EXTENSION) . '/manifest'; $matches = null; if (preg_match('/(https?:\\/\\/[^\\/]+)(.*)/', $serverUrl, $matches)) { $path = $matches[2] . $path; } $path = str_replace('//', '/', $path); return $path; }
public function getPlayManifestUrl($clientTag, $storageProfileId = null, $mediaProtocol = PlaybackProtocol::HTTP, $addKtToken = false) { $entryId = $this->getEntryId(); $partnerId = $this->getPartnerId(); $subpId = $this->getentry()->getSubpId(); $partnerPath = myPartnerUtils::getUrlForPartner($partnerId, $subpId); $flavorAssetId = $this->getId(); $url = "{$partnerPath}/playManifest/entryId/{$entryId}/flavorId/{$flavorAssetId}/protocol/{$mediaProtocol}/format/url"; if ($storageProfileId) { $url .= "/storageId/" . $storageProfileId; } if ($addKtToken) { $url .= self::KALTURA_TOKEN_PARAM_NAME . self::KALTURA_TOKEN_MARKER; } if ($this->getFileExt()) { $url .= "/a." . $this->getFileExt(); } $url .= "?clientTag={$clientTag}"; if ($addKtToken) { $url = self::calculateKalturaToken($url); } return $url; }
/** * @param int $duration * @param string $baseUrl * @return array */ private function buildRtmpFlavorsArray(&$duration, &$baseUrl) { $flavorAssets = $this->buildRtmpFlavorAssetArray(); $duration = $this->entry->getDurationInt(); $flavorDuration = $this->getDurationFromFlavorAssets($flavorAssets); if ($flavorDuration) { $duration = $flavorDuration; } $flavors = array(); if ($this->storageId) { $storage = StorageProfilePeer::retrieveByPK($this->storageId); if (!$storage) { die; } $baseUrl = $storage->getDeliveryRmpBaseUrl(); $urlManager = $this->getUrlManagerByStorageProfile($this->storageId); // get all flavors with external urls foreach ($flavorAssets as $flavorAsset) { $key = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($key, $this->storageId); if (!$fileSync) { continue; } $this->setupUrlManager($urlManager, $fileSync, $flavorAsset); $url = $urlManager->getFileSyncUrl($fileSync, false); $url = ltrim($url, "/"); $flavors[] = $this->getFlavorAssetInfo($url, '', $flavorAsset); } } $partner = $this->entry->getPartner(); if (!$this->storageId || !count($flavors) && $partner->getStorageServePriority() != StorageProfile::STORAGE_SERVE_PRIORITY_EXTERNAL_ONLY) { $partnerId = $this->entry->getPartnerId(); $subpId = $this->entry->getSubpId(); $partnerPath = myPartnerUtils::getUrlForPartner($partnerId, $subpId); $baseUrl = myPartnerUtils::getRtmpUrl($partnerId); // allow to replace {deliveryCode} place holder with the deliveryCode parameter passed to the action // a publisher with a rtmpUrl set to {deliveryCode}.example.com/ondemand will be able to use different // cdn configuration for different sub publishers by passing a different deliveryCode to the KDP if ($this->deliveryCode) { $baseUrl = str_replace("{deliveryCode}", $this->deliveryCode, $baseUrl); } $rtmpHost = parse_url($baseUrl, PHP_URL_HOST); $urlManager = $this->getUrlManagerByCdn($rtmpHost); // get all flavors with kaltura urls foreach ($flavorAssets as $flavorAsset) { /* @var $flavorAsset flavorAsset */ $this->setupUrlManager($urlManager, null, $flavorAsset); $url = $urlManager->getAssetUrl($flavorAsset, false); $url = ltrim($url, "/"); $flavors[] = $this->getFlavorAssetInfo($url, '', $flavorAsset); } } if (strpos($this->protocol, "rtmp") === 0) { $baseUrl = $this->protocol . '://' . preg_replace('/^rtmp.*?:\\/\\//', '', $baseUrl); } $urlManager->finalizeUrls($baseUrl, $flavors); $this->tokenizer = $urlManager->getTokenizer(); return $flavors; }
/** * Will forward to the regular swf player according to the widget_id */ public function execute() { $uv_cookie = @$_COOKIE['uv']; if (strlen($uv_cookie) != 35) { $uv_cookie = "uv_" . md5(uniqid(rand(), true)); } setrawcookie('uv', $uv_cookie, time() + 3600 * 24 * 365, '/'); // check if this is a request for the kdp without a wrapper // in case of an application loading the kdp (e.g. kmc) $nowrapper = $this->getRequestParameter("nowrapper", false); // allow caching if either the cache start time (cache_st) parameter // wasn't specified or if it is past the specified time $cache_st = $this->getRequestParameter("cache_st"); $allowCache = !$cache_st || $cache_st < time(); $referer = @$_SERVER['HTTP_REFERER']; $externalInterfaceDisabled = strstr($referer, "bebo.com") === false && strstr($referer, "myspace.com") === false && strstr($referer, "current.com") === false && strstr($referer, "myyearbook.com") === false && strstr($referer, "facebook.com") === false && strstr($referer, "friendster.com") === false ? "" : "&externalInterfaceDisabled=1"; // if there is no wrapper the loader is responsible for setting extra params to the kdp $noncached_params = ""; if (!$nowrapper) { $noncached_params = $externalInterfaceDisabled . "&referer=" . urlencode($referer); } $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? "https" : "http"; $requestKey = $protocol . $_SERVER["REQUEST_URI"]; // check if we cached the redirect url $cache = new myCache("kwidget", 10 * 60); // 10 minutes $cachedResponse = $cache->get($requestKey); if ($allowCache && $cachedResponse) { header("X-Kaltura:cached-action"); header("Expires: Sun, 19 Nov 2000 08:52:00 GMT"); header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0"); header("Pragma: no-cache"); header("Location:{$cachedResponse}" . $noncached_params); die; } // check if we cached the patched swf with flashvars $cache_swfdata = new myCache("kwidgetswf", 10 * 60); // 10 minutes $cachedResponse = $cache_swfdata->get($requestKey); if ($allowCache && $cachedResponse) { header("X-Kaltura:cached-action"); requestUtils::sendCdnHeaders("swf", strlen($cachedResponse), 60 * 10); echo $cachedResponse; die; } $widget_id = $this->getRequestParameter("wid"); $show_version = $this->getRequestParameter("v"); $debug_kdp = $this->getRequestParameter("debug_kdp", false); $widget = widgetPeer::retrieveByPK($widget_id); if (!$widget) { die; } // because of the routing rule - the entry_id & kmedia_type WILL exist. be sure to ignore them if smaller than 0 $kshow_id = $widget->getKshowId(); $entry_id = $widget->getEntryId(); $gallery_widget = !$kshow_id && !$entry_id; if (!$entry_id) { $entry_id = -1; } if ($widget->getSecurityType() != widget::WIDGET_SECURITY_TYPE_TIMEHASH) { // try eid - if failed entry_id $eid = $this->getRequestParameter("eid", $this->getRequestParameter("entry_id")); // try kid - if failed kshow_id $kid = $this->getRequestParameter("kid", $this->getRequestParameter("kshow_id")); if ($eid != null) { $entry_id = $eid; } elseif ($kid != null) { $kshow_id = $kid; } } if ($widget->getSecurityType() == widget::WIDGET_SECURITY_TYPE_MATCH_IP) { $allowCache = false; // here we'll attemp to match the ip of the request with that from the customData of the widget $custom_data = $widget->getCustomData(); $valid_country = false; if ($custom_data) { // in this case the custom_data should be of format: // valid_county_1,valid_country_2,...,valid_country_n;falback_entry_id $arr = explode(";", $custom_data); $countries_str = $arr[0]; $fallback_entry_id = isset($arr[1]) ? $arr[1] : null; $fallback_kshow_id = isset($arr[2]) ? $arr[2] : null; $current_country = ""; $valid_country = requestUtils::matchIpCountry($countries_str, $current_country); if (!$valid_country) { KalturaLog::log("kwidgetAction: Attempting to access widget [{$widget_id}] and entry [{$entry_id}] from country [{$current_country}]. Retrning entry_id: [{$fallback_entry_id}] kshow_id [{$fallback_kshow_id}]"); $entry_id = $fallback_entry_id; $kshow_id = $fallback_kshow_id; } } } elseif ($widget->getSecurityType() == widget::WIDGET_SECURITY_TYPE_FORCE_KS) { } $kmedia_type = -1; // support either uiconf_id or ui_conf_id $uiconf_id = $this->getRequestParameter("uiconf_id"); if (!$uiconf_id) { $uiconf_id = $this->getRequestParameter("ui_conf_id"); } if ($uiconf_id) { $widget_type = $uiconf_id; $uiconf_id_str = "&uiconf_id={$uiconf_id}"; } else { $widget_type = $widget->getUiConfId(); $uiconf_id_str = ""; } if (empty($widget_type)) { $widget_type = 3; } $kdata = $widget->getCustomData(); $partner_host = myPartnerUtils::getHost($widget->getPartnerId()); $partner_cdnHost = myPartnerUtils::getCdnHost($widget->getPartnerId()); $host = $partner_host; if ($widget_type == 10) { $swf_url = $host . "/swf/weplay.swf"; } else { $swf_url = $host . "/swf/kplayer.swf"; } $partner_id = $widget->getPartnerId(); $subp_id = $widget->getSubpId(); if (!$subp_id) { $subp_id = 0; } $uiConf = uiConfPeer::retrieveByPK($widget_type); // new ui_confs which are deleted should stop the script // the check for >100000 is for supporting very old mediawiki and such players if (!$uiConf && $widget_type > 100000) { die; } if ($uiConf) { $ui_conf_swf_url = $uiConf->getSwfUrl(); if (kString::beginsWith($ui_conf_swf_url, "http")) { $swf_url = $ui_conf_swf_url; // absolute URL } else { $use_cdn = $uiConf->getUseCdn(); $host = $use_cdn ? $partner_cdnHost : $partner_host; $swf_url = $host . myPartnerUtils::getUrlForPartner($partner_id, $subp_id) . $ui_conf_swf_url; } if ($debug_kdp) { $swf_url = str_replace("/kdp/", "/kdp_debug/", $swf_url); } } if ($show_version < 0) { $show_version = null; } $ip = requestUtils::getRemoteAddress(); // to convert back, use long2ip // the widget log should change to reflect the new data, but for now - i used $widget_id instead of the widgget_type // WidgetLog::createWidgetLog( $referer , $ip , $kshow_id , $entry_id , $kmedia_type , $widget_id ); if ($entry_id == -1) { $entry_id = null; } $kdp3 = false; $base_wrapper_swf = myContentStorage::getFSFlashRootPath() . "/kdpwrapper/" . kConf::get('kdp_wrapper_version') . "/kdpwrapper.swf"; $widgetIdStr = "widget_id={$widget_id}"; $partnerIdStr = "partner_id={$partner_id}&subp_id={$subp_id}"; if ($uiConf) { $ks_flashvars = ""; $conf_vars = $uiConf->getConfVars(); if ($conf_vars) { $conf_vars = "&" . $conf_vars; } $wrapper_swf = $base_wrapper_swf; $partner = PartnerPeer::retrieveByPK($partner_id); if ($partner) { $partner_type = $partner->getType(); } if (version_compare($uiConf->getSwfUrlVersion(), "3.0", ">=")) { $kdp3 = true; // further in the code, $wrapper_swf is being used and not $base_wrapper_swf $wrapper_swf = $base_wrapper_swf = myContentStorage::getFSFlashRootPath() . '/kdp3wrapper/' . kConf::get('kdp3_wrapper_version') . '/kdp3wrapper.swf'; $widgetIdStr = "widgetId={$widget_id}"; $uiconf_id_str = "&uiConfId={$uiconf_id}"; $partnerIdStr = "partnerId={$partner_id}&subpId={$subp_id}"; } // if we are loaded without a wrapper (directly in flex) // 1. dont create the ks - keep url the same for caching // 2. dont patch the uiconf - patching is done only to wrapper anyway if ($nowrapper) { $dynamic_date = $widgetIdStr . "&host=" . str_replace("http://", "", str_replace("https://", "", $partner_host)) . "&cdnHost=" . str_replace("http://", "", str_replace("https://", "", $partner_cdnHost)) . $uiconf_id_str . $conf_vars; $url = "{$swf_url}?{$dynamic_date}"; } else { // if kdp version >= 2.5 if (version_compare($uiConf->getSwfUrlVersion(), "2.5", ">=")) { // create an anonymous session $ks = ""; $result = kSessionUtils::createKSessionNoValidations($partner_id, 0, $ks, 86400, false, "", "view:*"); $ks_flashvars = "&{$partnerIdStr}&uid=0&ts=" . microtime(true); if ($widget->getSecurityType() != widget::WIDGET_SECURITY_TYPE_FORCE_KS) { $ks_flashvars = "&ks={$ks}" . $ks_flashvars; } // patch kdpwrapper with getwidget and getuiconf $root = myContentStorage::getFSContentRootPath(); $confFile_mtime = $uiConf->getUpdatedAt(null); $new_swf_path = "widget_{$widget_id}_{$widget_type}_{$confFile_mtime}_" . md5($base_wrapper_swf . $swf_url) . ".swf"; $md5 = md5($new_swf_path); $new_swf_path = "content/cacheswf/" . substr($md5, 0, 2) . "/" . substr($md5, 2, 2) . "/" . $new_swf_path; $cached_swf = "{$root}/{$new_swf_path}"; if (!file_exists($cached_swf) || filemtime($cached_swf) < $confFile_mtime) { kFile::fullMkdir($cached_swf); require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "api_v3" . DIRECTORY_SEPARATOR . "bootstrap.php"; $dispatcher = KalturaDispatcher::getInstance(); try { $widget_result = $dispatcher->dispatch("widget", "get", array("ks" => $ks, "id" => $widget_id)); $ui_conf_result = $dispatcher->dispatch("uiConf", "get", array("ks" => $ks, "id" => $widget_type)); } catch (Exception $ex) { die; } $serializer = new KalturaXmlSerializer(false); $serializer->serialize($widget_result); $widget_xml = $serializer->getSerializedData(); $serializer = new KalturaXmlSerializer(false); $serializer->serialize($ui_conf_result); $ui_conf_xml = $serializer->getSerializedData(); $patcher = new kPatchSwf($root . $base_wrapper_swf); $result = "<xml><result>{$widget_xml}</result><result>{$ui_conf_xml}</result></xml>"; $patcher->patch($result, $cached_swf); } if (file_exists($cached_swf)) { $wrapper_swf = $new_swf_path; } } $kdp_version_2 = strpos($swf_url, "kdp/v2.") > 0; if ($partner_host == "http://www.kaltura.com" && !$kdp_version_2 && !$kdp3) { $partner_host = 1; // otherwise the kdp will try going to cdnwww.kaltura.com } $track_wrapper = ''; if (kConf::get('track_kdpwrapper') && kConf::get('kdpwrapper_track_url')) { $track_wrapper = "&wrapper_tracker_url=" . urlencode(kConf::get('kdpwrapper_track_url') . "?activation_key=" . kConf::get('kaltura_activation_key') . "&package_version=" . kConf::get('kaltura_version')); } $dynamic_date = $widgetIdStr . $track_wrapper . "&kdpUrl=" . urlencode($swf_url) . "&host=" . str_replace("http://", "", str_replace("https://", "", $partner_host)) . "&cdnHost=" . str_replace("http://", "", str_replace("https://", "", $partner_cdnHost)) . ($show_version ? "&entryVersion={$show_version}" : "") . ($kshow_id ? "&kshowId={$kshow_id}" : "") . ($entry_id ? "&entryId={$entry_id}" : "") . $uiconf_id_str . $ks_flashvars . ($cache_st ? "&clientTag=cache_st:{$cache_st}" : "") . $conf_vars; // for now changed back to $host since kdp version prior to 1.0.15 didnt support loading by external domain kdpwrapper $url = $host . myPartnerUtils::getUrlForPartner($partner_id, $subp_id) . "/{$wrapper_swf}?{$dynamic_date}"; // patch wrapper with flashvars and dump to browser if (version_compare($uiConf->getSwfUrlVersion(), "2.6.6", ">=")) { $patcher = new kPatchSwf($root . $wrapper_swf, "KALTURA_FLASHVARS_DATA"); ob_start(); $patcher->patch($dynamic_date . "&referer=" . urlencode($referer)); $wrapper_data = ob_get_contents(); ob_end_clean(); requestUtils::sendCdnHeaders("swf", strlen($wrapper_data), $allowCache ? 60 * 10 : 0); echo $wrapper_data; if ($allowCache) { $cache_swfdata->put($requestKey, $wrapper_data); } die; } } } else { $dynamic_date = "kshowId={$kshow_id}" . "&host=" . requestUtils::getRequestHostId() . ($show_version ? "&entryVersion={$show_version}" : "") . ($entry_id ? "&entryId={$entry_id}" : "") . ($entry_id ? "&KmediaType={$kmedia_type}" : ""); $dynamic_date .= "&isWidget={$widget_type}&referer=" . urlencode($referer); $dynamic_date .= "&kdata={$kdata}"; $url = "{$swf_url}?{$dynamic_date}"; } // if referer has a query string an IE bug will prevent out flashvars to propagate // when nowrapper is true we cant use /swfparams either as there isnt a kdpwrapper if (!$nowrapper && $uiConf && version_compare($uiConf->getSwfUrlVersion(), "2.6.6", ">=")) { // apart from the /swfparam/ format, add .swf suffix to the end of the stream in case // a corporate firewall looks at the file suffix $pos = strpos($url, "?"); $url = substr($url, 0, $pos) . "/swfparams/" . urlencode(substr($url, $pos + 1)) . ".swf"; } if ($allowCache) { $cache->put($requestKey, $url); } if (strpos($url, "/swfparams/") > 0) { $url = substr($url, 0, -4) . urlencode($noncached_params) . ".swf"; } else { $url .= $noncached_params; } $this->redirect($url); }
/** * @param FileSync $fileSync * @return string */ public function getFileSyncUrl(FileSync $fileSync) { $fileSync = kFileSyncUtils::resolve($fileSync); $storage = StorageProfilePeer::retrieveByPK($fileSync->getDc()); if (!$storage) { return parent::getFileSyncUrl($fileSync); } $serverUrl = $storage->getDeliveryIisBaseUrl(); $partnerPath = myPartnerUtils::getUrlForPartner($fileSync->getPartnerId(), $fileSync->getPartnerId() * 100); if ($this->protocol == StorageProfile::PLAY_FORMAT_APPLE_HTTP) { return $partnerPath . $fileSync->getFilePath() . "/playlist.m3u8"; } if ($fileSync->getObjectSubType() != entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM) { return parent::getFileSyncUrl($fileSync); } $path = $partnerPath . '/serveIsm/objectId/' . $fileSync->getObjectId() . '_' . $fileSync->getObjectSubType() . '_' . $fileSync->getVersion() . '.' . pathinfo(kFileSyncUtils::resolve($fileSync)->getFilePath(), PATHINFO_EXTENSION) . '/manifest'; // $path = $partnerPath.'/serveIsm/objectId/'.pathinfo(kFileSyncUtils::resolve($fileSync)->getFilePath(), PATHINFO_BASENAME).'/manifest'; $matches = null; if (preg_match('/(https?:\\/\\/[^\\/]+)(.*)/', $serverUrl, $matches)) { $serverUrl = $matches[1]; $path = $matches[2] . $path; } $path = str_replace('//', '/', $path); $window = $this->params['smooth_auth_seconds']; $param = $this->params['smooth_auth_param']; $salt = $this->params['smooth_auth_salt']; $authPath = $this->urlauth_gen_url($path, $param, $window, $salt, null, null); return $serverUrl . '/' . $authPath; }
public function getRawDownloadUrl() { $finalPath = "/downloadUrl?url=" . myPartnerUtils::getUrlForPartner($this->getPartnerId(), $this->getSubpId()) . "/raw/entry_id/" . $this->getId(); $downloadUrl = myPartnerUtils::getCdnHost($this->getPartnerId()) . $finalPath; return $downloadUrl; }
public function getPlayManifestUrl($clientTag, $storageProfileId = null, $mediaProtocol = PlaybackProtocol::HTTP) { $entryId = $this->getEntryId(); $partnerId = $this->getPartnerId(); $subpId = $this->getentry()->getSubpId(); $partnerPath = myPartnerUtils::getUrlForPartner($partnerId, $subpId); $flavorAssetId = $this->getId(); $url = "{$partnerPath}/playManifest/entryId/{$entryId}/flavorId/{$flavorAssetId}/protocol/{$mediaProtocol}/format/url"; if ($storageProfileId) { $url .= "/storageId/" . $storageProfileId; } if ($this->getFileExt()) { $url .= "/a." . $this->getFileExt(); } $url .= "?clientTag={$clientTag}"; return $url; }