<?xml version="1.0" encoding="UTF-8"?>

<Server version="8">
	<Name>OvenMediaEngine</Name>
	<!-- Host type (origin/edge) -->
	<Type>edge</Type>
	<!-- Specify IP address to bind (* means all IPs) -->
	<IP>*</IP>
	<PrivacyProtection>false</PrivacyProtection>

	<!-- 
	To get the public IP address(mapped address of stun) of the local server. 
	This is useful when OME cannot obtain a public IP from an interface, such as AWS or docker environment. 
	If this is successful, you can use ${PublicIP} in your settings.
	-->
	<StunServer>stun.ovenmediaengine.com:13478</StunServer>

	<Modules>
		<!-- 
		Currently OME only supports h2 like all browsers do. Therefore, HTTP/2 only works on TLS ports.			
		-->
		<HTTP2>
			<Enable>true</Enable>
		</HTTP2>
		<LLHLS>
			<Enable>true</Enable>
		</LLHLS>
		<DynamicAppRemoval>
			<Enable>false</Enable>
		</DynamicAppRemoval>
		<!-- P2P works only in WebRTC and is experiment feature -->
		<P2P>
			<!-- disabled by default -->
			<Enable>false</Enable>
			<MaxClientPeersPerHostPeer>2</MaxClientPeersPerHostPeer>
		</P2P>
	</Modules>

	<!-- Settings for the ports to bind -->
	<Bind>
		<!-- Enable this configuration if you want to use API Server -->
		<!--
		<Managers>
			<API>
				<Port>${env:OME_API_PORT:8081}</Port>
				<WorkerCount>1</WorkerCount>
			</API>
		</Managers>
		-->
		<Providers>
			<!-- Pull providers -->
			<OVT>
				<WorkerCount>1</WorkerCount>
			</OVT>
		</Providers>

		<Publishers>
			<LLHLS>
				<!-- 
				OME only supports h2, so LLHLS works over HTTP/1.1 on non-TLS port. 
				Note that LLHLS runs higher performance over HTTP/2.
				Therefore, it is recommended to use TLS Port.
				-->
				<Port>${env:OME_LLHLS_STREAM_PORT:3333}</Port>
				<TLSPort>${env:OME_LLHLS_STREAM_TLS_PORT:3334}</TLSPort>
				<WorkerCount>1</WorkerCount>
			</LLHLS>
			<WebRTC>
				<Signalling>
					<Port>${env:OME_SIGNALLING_PORT:3333}</Port>
					<TLSPort>${env:OME_SIGNALLING_TLS_PORT:3334}</TLSPort>
					<WorkerCount>1</WorkerCount>
				</Signalling>
				<IceCandidates>
					<IceCandidate>${env:OME_HOST_IP:*}:${env:OME_WEBRTC_CANDIDATE_PORT:10005-10009/udp}</IceCandidate>
					<TcpRelay>${env:OME_HOST_IP:*}:${env:OME_WEBRTC_TCP_RELAY_PORT:3478}</TcpRelay>
					<TcpForce>true</TcpForce>
					<TcpRelayWorkerCount>1</TcpRelayWorkerCount>
				</IceCandidates>
			</WebRTC>
		</Publishers>
	</Bind>

	<!-- P2P works only in WebRTC -->
	<!--
	<P2P>
		<MaxClientPeersPerHostPeer>2</MaxClientPeersPerHostPeer>
	</P2P>
	-->

	<VirtualHosts>
		<!-- You can use wildcard like this to include multiple XMLs -->
		<VirtualHost include="VHost*.xml" />
		<VirtualHost>
			<Name>default</Name>
			<!--Distribution is a value that can be used when grouping the same vhost distributed across multiple servers. This value is output to the events log, so you can use it to aggregate statistics. -->
			<Distribution>ovenmediaengine.com</Distribution>

			<!-- Settings for multi ip/domain and TLS -->
			<Host>
				<Names>
					<!-- Host names
						<Name>stream1.airensoft.com</Name>
						<Name>stream2.airensoft.com</Name>
						<Name>*.sub.airensoft.com</Name>
						<Name>192.168.0.1</Name>
					-->
					<Name>*</Name>
				</Names>
				<TLS>
					<CertPath>./cert.crt</CertPath>
					<KeyPath>./cert.key</KeyPath>
					<ChainCertPath>./cert.ca-bundle</ChainCertPath>
				</TLS>
			</Host>

			<!-- Refer https://airensoft.gitbook.io/ovenmediaengine/signedpolicy

			<SignedPolicy>
				<PolicyQueryKeyName>${env:SIGNED_POLICY_POLICY_QUERY_KEY:policy}</PolicyQueryKeyName>
				<SignatureQueryKeyName>${env:SIGNED_POLICY_SIGNATURE_QUERY_KEY:signature}</SignatureQueryKeyName>
				<SecretKey>${env:SIGNED_URL_CRYPTO_KEY:aKq#1kj}</SecretKey>

				<Enables>
					<Providers>rtmp,webrtc,srt</Providers>
					<Publishers>webrtc,llhls</Publishers>
				</Enables>
			</SignedPolicy>
			-->

			<!-- Settings for ProxyPass (It can specify origin for each path) -->
			<Origins>
				<Properties>
					<NoInputFailoverTimeout>3000</NoInputFailoverTimeout>
					<UnusedStreamDeletionTimeout>60000</UnusedStreamDeletionTimeout>
				</Properties>
				<!--
				<Origin>
					<Location>/app/stream</Location>
					<Pass>
						<Scheme>ovt</Scheme>
						<Urls>
							<Url>origin.com:9000/app/stream_720p</Url>
						</Urls>
					</Pass>
				</Origin>
				<Origin>
					<Location>/app/</Location>
					<Pass>
						<Scheme>ovt</Scheme>
						<Urls>
							<Url>origin.com:9000/app/</Url>
						</Urls>
					</Pass>
				</Origin>
				-->
				<Origin>
					<Location>/</Location>
					<Pass>
						<Scheme>ovt</Scheme>
						<Urls>
							<Url>${env:DEFAULT_ORIGIN_SERVER:}:${env:DEFAULT_ORIGIN_PORT:9000}/</Url>
						</Urls>
						<!-- 
							Whether to pass the query string to the origin server in the URL the user requested to play (used by some RTSP servers) 
							default : true
						-->
						<ForwardQueryParams>true</ForwardQueryParams>
					</Pass>
				</Origin>
			</Origins>

			<!--
			When Edge tries to pull a stream, it looks first in <Origins> in local, and in OriginMapStore. 
			Therefore, it is recommended to disable Origins when using OriginMapStore.
			<OriginMapStore>
				In order to use OriginMap, you must enable OVT Publisher in Origin and OVT Provider in Edge.
				<RedisServer>
					<Host>192.168.0.160:6379</Host>
					<Auth>!@#ovenmediaengine</Auth>
				</RedisServer>
			</OriginMapStore>
			-->

			<!-- Default CORS Settings -->
			<CrossDomains>
				<Url>*</Url>
			</CrossDomains>

			<Applications>
				<Application>
					<!-- 
					Origins and OriginMapStore can dynamically create an application if no application exists 
					when creating a stream. They create a new application by copying the Application configuration 
					where <Name> is *. 
					In other words, an application with <Name> as * serves as a dynamic application template.
					-->
					<Name>*</Name>
					<Type>live</Type>
					<OutputProfiles>
						<OutputProfile>
							<Name>passthrough</Name>
							<OutputStreamName>${OriginStreamName}</OutputStreamName>
							<Encodes>
								<Video>
									<Bypass>true</Bypass>
								</Video>
								<Audio>
									<Bypass>true</Bypass>
								</Audio>
							</Encodes>
						</OutputProfile>
					</OutputProfiles>
					<Providers>
						<OVT />
					</Providers>
					<Publishers>
						<AppWorkerCount>1</AppWorkerCount>
						<StreamWorkerCount>8</StreamWorkerCount>
						<WebRTC>
							<Timeout>30000</Timeout>
							<Rtx>false</Rtx>
							<Ulpfec>false</Ulpfec>
							<JitterBuffer>false</JitterBuffer>
							<CreateDefaultPlaylist>true</CreateDefaultPlaylist>
						</WebRTC>
						<LLHLS>
							<ChunkDuration>0.5</ChunkDuration>
							<SegmentDuration>6</SegmentDuration>
							<SegmentCount>10</SegmentCount>
							<CrossDomains>
								<Url>*</Url>
							</CrossDomains>
							<CreateDefaultPlaylist>true</CreateDefaultPlaylist> <!-- llhls.m3u8 -->
						</LLHLS>
						<HLS>
							<SegmentCount>4</SegmentCount>
							<SegmentDuration>4</SegmentDuration>
							<CrossDomains>
								<Url>*</Url>
							</CrossDomains>
							<CreateDefaultPlaylist>true</CreateDefaultPlaylist> <!-- ts:playlist.m3u8 -->
						</HLS>
					</Publishers>
				</Application>
			</Applications>
		</VirtualHost>
	</VirtualHosts>
</Server>