<commit_before><?php

class WowzaMediaServerNode extends MediaServerNode {
	const DEFAULT_MANIFEST_PORT = 1935;
	const DEFAULT_WEB_SERVICES_PORT = 888;
	const DEFAULT_WEB_SERVICES_PROTOCOL = 'http';
	const DEFAULT_TRANSCODER = 'default';
	const DEFAULT_GPUID = -1;
	
	const CUSTOM_DATA_APP_PREFIX = 'app_prefix';
	const CUSTOM_DATA_TRANSCODER_CONFIG = 'transcoder';
	const CUSTOM_DATA_GPUID = 'gpuid';
	const CUSTOM_DATA_LIVE_SERVICE_PORT = 'live_service_port';
	const CUSTOM_DATA_LIVE_SERVICE_PROTOCOL = 'live_service_protocol';
	const CUSTOM_DATA_LIVE_SERVICE_INTERNAL_DOMAIN = 'live_service_internal_domain';
	
	const WEB_SERVICE_LIVE = 'live';
	
	static protected $webServices = array(
		self::WEB_SERVICE_LIVE => 'KalturaMediaServerLiveService',
	);
	
	/**
	 * Applies default values to this object.
	 * This method should be called from the object's constructor (or equivalent initialization method).
	 * @see __construct()
	 */
	public function applyDefaultValues()
	{
		parent::applyDefaultValues();
		
		$this->setType(WowzaPlugin::getWowzaMediaServerTypeCoreValue(WowzaMediaServerNodeType::WOWZA_MEDIA_SERVER));
	}
	
	public function getManifestUrl($protocol = 'http', $format = null)
	{		
		$playbackHost = $this->getPlaybackHost($protocol, $format);
		
		$hostname = $this->getHostname();
		if(!$this->getIsExternalMediaServer())
			$hostname = preg_replace('/\..*$/', '', $hostname);
		
		$url = "$protocol://$playbackHost";
		$url = str_replace("{hostName}", $hostname, $url);
		return $url;
		
	}
	
	public function getLiveWebServiceName()
	{
		return WowzaMediaServerNode::WEB_SERVICE_LIVE;
	}
	
	public function getPlaybackHost($protocol = 'http', $format = null)
	{
		$mediaServerGlobalConfig = array();
		
		if(kConf::hasMap('media_servers'))
			$mediaServerGlobalConfig = array_merge($mediaServerGlobalConfig, kConf::getMap('media_servers'));
		
		if($this->partner_media_server_config)
			$mediaServerGlobalConfig = array_merge($mediaServerGlobalConfig, $this->partner_media_server_config);
			
		$domain = $this->getDomainByProtocolAndFormat($mediaServerGlobalConfig, $protocol, $format);
		
		$port = $this->getPortByProtocolAndFormat($mediaServerGlobalConfig, $protocol, $format);
		
		$appPrefix = $this->getApplicationPrefix($mediaServerGlobalConfig);
		
		return "$domain:$port/$appPrefix";
	}
	
	/**
	 * @param string $serviceName
	 * @return KalturaMediaServerClient
	 */
	public function getWebService($serviceName)
	{	
		if(!isset(self::$webServices[$service]))
			return null;
			
		$serviceClass = self::$webServices[$service];
		
		$domain = $this->getLiveServiceInternalDomain() ? $this->getLiveServiceInternalDomain() : $this->getHostname();
		$port = $this->getLiveServicePort();
		$protocol = $this->getLiveServiceProtocol();
		
		$url = "$protocol://$domain:$port/$service?wsdl";
		KalturaLog::debug("Service URL: $url");
		return new $serviceClass($url);
	}
	
	public function getDomainByProtocolAndFormat($mediaServerConfig, $protocol = 'http', $format = null)
	{	
		$domain = $this->getPlaybackHostName();
		
		$domainField = "domain" . ($format ? "-$format" : "");
		
		$domain = $this->getValueByField($mediaServerConfig, $domainField, $domain);
		
		$mediaServerPlaybackDomainConfig = $this->getMediaServerPlaybackDomainConfig();
		if($mediaServerPlaybackDomainConfig)
		{
			$domainField = $protocol . ($format ? "-$format" : "");
			if(isset($mediaServerPlaybackDomainConfig[$domainField]))
				$domain = $mediaServerPlaybackDomainConfig[$domainField];
		}
		
		return $domain;
	}<commit_msg>Fix variable name<commit_after><?php

class WowzaMediaServerNode extends MediaServerNode {
	const DEFAULT_MANIFEST_PORT = 1935;
	const DEFAULT_WEB_SERVICES_PORT = 888;
	const DEFAULT_WEB_SERVICES_PROTOCOL = 'http';
	const DEFAULT_TRANSCODER = 'default';
	const DEFAULT_GPUID = -1;
	
	const CUSTOM_DATA_APP_PREFIX = 'app_prefix';
	const CUSTOM_DATA_TRANSCODER_CONFIG = 'transcoder';
	const CUSTOM_DATA_GPUID = 'gpuid';
	const CUSTOM_DATA_LIVE_SERVICE_PORT = 'live_service_port';
	const CUSTOM_DATA_LIVE_SERVICE_PROTOCOL = 'live_service_protocol';
	const CUSTOM_DATA_LIVE_SERVICE_INTERNAL_DOMAIN = 'live_service_internal_domain';
	
	const WEB_SERVICE_LIVE = 'live';
	
	static protected $webServices = array(
		self::WEB_SERVICE_LIVE => 'KalturaMediaServerLiveService',
	);
	
	/**
	 * Applies default values to this object.
	 * This method should be called from the object's constructor (or equivalent initialization method).
	 * @see __construct()
	 */
	public function applyDefaultValues()
	{
		parent::applyDefaultValues();
		
		$this->setType(WowzaPlugin::getWowzaMediaServerTypeCoreValue(WowzaMediaServerNodeType::WOWZA_MEDIA_SERVER));
	}
	
	public function getManifestUrl($protocol = 'http', $format = null)
	{		
		$playbackHost = $this->getPlaybackHost($protocol, $format);
		
		$hostname = $this->getHostname();
		if(!$this->getIsExternalMediaServer())
			$hostname = preg_replace('/\..*$/', '', $hostname);
		
		$url = "$protocol://$playbackHost";
		$url = str_replace("{hostName}", $hostname, $url);
		return $url;
		
	}
	
	public function getLiveWebServiceName()
	{
		return WowzaMediaServerNode::WEB_SERVICE_LIVE;
	}
	
	public function getPlaybackHost($protocol = 'http', $format = null)
	{
		$mediaServerGlobalConfig = array();
		
		if(kConf::hasMap('media_servers'))
			$mediaServerGlobalConfig = array_merge($mediaServerGlobalConfig, kConf::getMap('media_servers'));
		
		if($this->partner_media_server_config)
			$mediaServerGlobalConfig = array_merge($mediaServerGlobalConfig, $this->partner_media_server_config);
			
		$domain = $this->getDomainByProtocolAndFormat($mediaServerGlobalConfig, $protocol, $format);
		
		$port = $this->getPortByProtocolAndFormat($mediaServerGlobalConfig, $protocol, $format);
		
		$appPrefix = $this->getApplicationPrefix($mediaServerGlobalConfig);
		
		return "$domain:$port/$appPrefix";
	}
	
	/**
	 * @param string $serviceName
	 * @return KalturaMediaServerClient
	 */
	public function getWebService($serviceName)
	{	
		if(!isset(self::$webServices[$serviceName]))
			return null;
			
		$serviceClass = self::$webServices[$serviceName];
		
		$domain = $this->getLiveServiceInternalDomain() ? $this->getLiveServiceInternalDomain() : $this->getHostname();
		$port = $this->getLiveServicePort();
		$protocol = $this->getLiveServiceProtocol();
		
		$url = "$protocol://$domain:$port/$serviceName?wsdl";
		KalturaLog::debug("Service URL: $url");
		return new $serviceClass($url);
	}
	
	public function getDomainByProtocolAndFormat($mediaServerConfig, $protocol = 'http', $format = null)
	{	
		$domain = $this->getPlaybackHostName();
		
		$domainField = "domain" . ($format ? "-$format" : "");
		
		$domain = $this->getValueByField($mediaServerConfig, $domainField, $domain);
		
		$mediaServerPlaybackDomainConfig = $this->getMediaServerPlaybackDomainConfig();
		if($mediaServerPlaybackDomainConfig)
		{
			$domainField = $protocol . ($format ? "-$format" : "");
			if(isset($mediaServerPlaybackDomainConfig[$domainField]))
				$domain = $mediaServerPlaybackDomainConfig[$domainField];
		}
		
		return $domain;
	}
{'fraction_non_alphanumeric': 0.13532562729066816, 'fraction_numerical': 0.002255427121511136, 'mean_word_length': 5.868344627299129, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4039513', 'n_tokens_mistral': 2462, 'n_tokens_neox': 2220, 'n_words': 376}