WebRTC Peer
The WebRTC Peer service - connects SBN Video clients to a camera or call, and sets up peer-to-peer connections for applications such as Foresight and Safe and Secure.
WebRTC Peer
The WebRTC Peer sets up live media connections using WebRTC. It connects a browser-based SBN Video client to a camera or a call, and it also sets up direct peer-to-peer connections between two parties.
Overview
When an SBN Video client opens a live stream, the WebRTC Peer establishes the connection: it negotiates the audio and video, works out the network path to use, and links the client to the device stream. It works together with the API Proxy, which the client connects through, and the TURN server, which relays the media when a direct path is not possible.
The same service also sets up peer-to-peer connections that link two parties directly to each other rather than to a camera. Applications such as Foresight and Safe and Secure use this to connect people together.
In every case it uses the best path available - a direct connection where the network allows it, and a relay through the TURN server on more restrictive networks - and hands each side the STUN and TURN details it needs to connect.
- Runs: When configured. A deployment can run more than one to carry more concurrent video sessions.
- Required: Required to serve live video to browser clients.
- Depends on: NATS, the API Proxy (the client's entry point), and the TURN server (or an external TURN server) for firewall traversal.
Configuration
The WebRTC Peer is configured under the webrtcpeer namespace. View the defaults with ./sbn-media config eject and set host-specific overrides in sbn-media.local.yaml.
Setting | Default | Description |
|---|---|---|
| a public STUN server | The STUN servers used to discover the public network path. |
| false | Turn off the built-in TURN server and use an external one instead. |
| empty | The address of an external TURN server, used when the built-in one is turned off. |
| empty | The username for the external TURN server. |
| empty | The credential for the external TURN server. |
| empty | The host's public address, needed when it differs from the address the host binds to, so clients are offered an address they can reach. |
|
| The video codec offered to clients. |
|
| The audio codec offered to clients. |
| 5 | How long, in seconds, to wait when connecting to a device before giving up. |
| 20 | How long, in seconds, to wait for a control message to a device. |
Example:
After changing these settings in sbn-media.local.yaml, reload the configuration for them to take effect.
FAQ
Video does not connect for remote clients. What should I check?
This is almost always firewall traversal. Confirm the TURN server is reachable from clients (see the TURN Server page), and set webrtcpeer.nat1to1IPs to the host's public address when it differs from the address the host binds to. If the service will not start, run it in the foreground with sbn-media service exec webrtcpeer -ld to see the error.
Can I use an external STUN or TURN server?
Yes. List external STUN servers in webrtcpeer.stunServers. To use an external TURN server, set webrtcpeer.disableInternalTurnServer to true and provide its address and credentials in webrtcpeer.turnServer.
How many WebRTC Peer services do I need?
One is enough to start. Run more to carry more concurrent video sessions; the load is shared across them.
Which audio and video formats are used?
H.264 video and Opus audio by default, chosen for broad browser support. These are set by webrtcpeer.codec.video and webrtcpeer.codec.audio.
Related pages
- SBN Media Overview (
SBN-Media/overview) - Installing and Configuring SBN Media (
SBN-Media/installation) - API Proxy (
SBN-Media/Platform/api-proxy) - TURN Server (
SBN-Media/Telephony/turn-server)