Add example OME Server.xml

This commit is contained in:
Trysdyn Black 2024-12-20 15:47:54 -08:00
parent 170b74cd3e
commit 80dea5fd69
2 changed files with 238 additions and 1 deletions

View file

@ -21,7 +21,7 @@ This project tries to be pretty lean. Requirements should be roughly...
3. Some number of applications
4. Applications configured with a producer webhook of `http://localhost:8080`
2. Extract or clone this repository somewhere
3. Configure your HTTP daemon/proxy/etc to proxy HTTPS to `http://localhost:8080`
3. Configure your HTTP daemon/proxy/etc to proxy HTTPS to `http://localhost:8080/admission`
4. Set up environment variables to your liking. The OvenMediaEngine API key and password are mandatory; see Configuration below
5. Start the management engine with either `python3 main.py` or a systemd unit as noted in `examples/`

237
example/ome_server.xml Normal file
View file

@ -0,0 +1,237 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Server version="8">
<Name>OvenMediaEngine</Name>
<!-- Don't change this. The only other valid option is "edge" which is not what we want. -->
<Type>origin</Type>
<!-- `*` means use STUN to figure out your IP. -->
<IP>*</IP>
<!-- This flag strips IPs from logs -->
<PrivacyProtection>false</PrivacyProtection>
<!--
You don't need STUN at all if you replace every instance of `*` in IP and port settings
throughout this entire config file with a publicly reachable IP address. I leave it for
simplicity sake. You may want to remove it for privacy/security purposes.
-->
<StunServer>stun.ovenmediaengine.com:13478</StunServer>
<Modules>
<HTTP2>
<Enable>true</Enable>
</HTTP2>
<LLHLS>
<Enable>false</Enable>
</LLHLS>
<P2P>
<Enable>false</Enable>
<MaxClientPeersPerHostPeer>2</MaxClientPeersPerHostPeer>
</P2P>
</Modules>
<Bind>
<Managers>
<!-- This port needs to be 8081 unless you go changing the Python code -->
<API>
<Port>8081</Port>
</API>
</Managers>
<Providers>
<!-- Enable RTMP ingest on port 1935 -->
<RTMP>
<Port>1935</Port>
<WorkerCount>4</WorkerCount>
</RTMP>
<!--
Enable WebRTC ingest. We assume you proxy HTTPS :3334 to localhost:3333 for WHIP.
UDP ports 10000 thru 10004 will be used for actual video transit.
The TCP Relay is actually a TURN server built into OvenMediaEngine, listening on :3478.
I personally want TCP/TURN but OBS Studio 31.0 won't work with it so it needs to be off.
-->
<WebRTC>
<Signalling>
<Port>3333</Port>
<WorkerCount>4</WorkerCount>
</Signalling>
<IceCandidates>
<IceCandidate>${env:OME_HOST_IP:*}:${env:OME_WEBRTC_CANDIDATE_PORT:10000-10004/udp}</IceCandidate>
<TcpRelay>${env:OME_HOST_IP:*}:${env:OME_WEBRTC_TCP_RELAY_PORT:3478}</TcpRelay>
<!-- It may be better to turn this on BUT OBS ignores it as of 31.0 and will use UDP -->
<TcpForce>false</TcpForce>
<TcpRelayWorkerCount>4</TcpRelayWorkerCount>
</IceCandidates>
</WebRTC>
</Providers>
<Publishers>
<!--
Enable WebRTC playback. This is the only playback method we use here.
This is the same proxied flow as ingest/providing
-->
<WebRTC>
<Signalling>
<Port>3333</Port>
<WorkerCount>4</WorkerCount>
</Signalling>
<IceCandidates>
<IceCandidate>${env:OME_WEBRTC_CANDIDATE_IP:*}:${env:OME_WEBRTC_CANDIDATE_PORT:10000-10004/udp}</IceCandidate>
<!-- We *can* use TCP here and I find it improves reliability for noisy connections. -->
<TcpRelay>${env:OME_WEBRTC_CANDIDATE_IP:*}:${env:OME_WEBRTC_TCP_RELAY_PORT:3478}</TcpRelay>
<TcpForce>true</TcpForce>
<TcpRelayWorkerCount>4</TcpRelayWorkerCount>
</IceCandidates>
</WebRTC>
</Publishers>
</Bind>
<Managers>
<Host>
<Names>
<Name>localhost</Name>
</Names>
</Host>
<API>
<!--
This is the API access login, in user:pass format.
This *must* match what is configured in your environment variables as
OVENMONITOR_API_USER and OVENMONITOR_API_PASSWORD.
If you're particularly clever you can use ${env:} injection here
-->
<AccessToken>EXAMPLE_USER:EXAMPLE_PASSWORD</AccessToken>
</API>
</Managers>
<!--
Multiple virtual hosts is untested. There's probably bugs if you do that.
Keep to one virtual host and name it "default" as a catchall.
-->
<VirtualHosts>
<VirtualHost>
<Name>default</Name>
<Distribution>ovenmediaengine.com</Distribution>
<Host>
<!-- Define this as a catchall host. You can do name or IP based hosting -->
<Names>
<Name>*</Name>
</Names>
</Host>
<!-- For OvenEmprex to work you must configure its admission webhook -->
<AdmissionWebhooks>
<ControlServerUrl>http://127.0.0.1:8080/admission</ControlServerUrl>
<SecretKey>aaa</SecretKey>
<Timeout>3000</Timeout>
<!--
We only want to process admissions on incoming streams.
At present we do not auth or care about viewers.
-->
<Enables>
<Providers>rtmp,webrtc,srt</Providers>
<Publishers></Publishers>
</Enables>
</AdmissionWebhooks>
<CrossDomains>
<Url>*</Url>
</CrossDomains>
<!--
Your application list defines what is acceptable for the first half of stream keys.
When looking at a stream URL like example.com/foo/bar, foo is the application.
Applications are also a container for settings like re-encoding, and are also the
container we keep multiple streams in for viewing the "webcall" interface.
The below example will establish an app named `example_app_1` which puts live the
following URLs:
- rtmp://example.com/example_app_1/STREAM_KEY for RTMP ingest
- https://example.com:3334/example_app_1/STREAM_KEY?direction=WHIP for WebRTC ingest
- https://example.com/example_app_1/ for the "webcall" interface to view all streams
- https://example.com/example_app_1/STREAM_KEY for HTTP viewing of STREAM_KEY
You can have multiple applications.
-->
<Applications>
<Application>
<Name>example_app_1</Name>
<Type>live</Type>
<OutputProfiles>
<!--
This output profile pipes video straight through to the viewer without
re-encoding it.
It will also re-encapsulate audio to the proper format for WebRTC if it is
not correct. This is a tiny CPU hit and should be fine.
If you wish to re-encode video you will need to research encoding settings
in the OvenMediaEngine docs and understand your CPU/GPU requirements.
-->
<OutputProfile>
<Name>bypass_stream</Name>
<OutputStreamName>${OriginStreamName}</OutputStreamName>
<Encodes>
<Video>
<Name>bypass_video</Name>
<Bypass>true</Bypass>
</Video>
<Audio>
<Name>force_opus</Name>
<Codec>opus</Codec>
<Bitrate>128000</Bitrate>
<Samplerate>48000</Samplerate>
<Channel>2</Channel>
<BypassIfMatch>
<Codec>eq</Codec>
</BypassIfMatch>
</Audio>
</Encodes>
</OutputProfile>
</OutputProfiles>
<!-- Allow WebRTC and RTMP ingest for this app -->
<Providers>
<WebRTC>
<Timeout>5000</Timeout>
<CrossDomains>
<Url>*</Url>
</CrossDomains>
</WebRTC>
<RTMP>
<!--
This flag decides what to do if a stream starts on an already used
key. By default the new connection is refused. Setting this to false
instead boots off the old connection. This is preferable in a trusted
environment as someone who disconnects can immediately restart the
stream without waiting for timeout.
It is *not* preferable in an untrusted environment where you're giving
untrusted streamers keys to use temporarily.
-->
<BlockDuplicateStreamName>false</BlockDuplicateStreamName>
</RTMP>
</Providers>
<Publishers>
<AppWorkerCount>4</AppWorkerCount>
<StreamWorkerCount>2</StreamWorkerCount>
<WebRTC>
<!--
These settings are various WebRTC smoothing flags. Unless noted, they don't
hurt anything to have on. OvenMediaEngine's docs explain them better.
-->
<Timeout>5000</Timeout>
<Rtx>true</Rtx>
<!--
ulpfec attempts to smooth noisy network connections.
It is not very helpful in our use-case and sometimes BREAKS some browsers.
-->
<Ulpfec>false</Ulpfec>
<JitterBuffer>true</JitterBuffer>
</WebRTC>
</Publishers>
</Application>
</Applications>
</VirtualHost>
</VirtualHosts>
</Server>