-
Notifications
You must be signed in to change notification settings - Fork 5
WebRTC
English | 中文
LiveForge supports WebRTC for ultra-low-latency publish and subscribe using the WHIP and WHEP standards.
webrtc:
enabled: true
listen: ":8443"
ice_servers:
- urls: ["stun:stun.l.google.com:19302"]
udp_port_range: [20000, 30000]
candidates: []
# tls: true # Optional: override global TLS setting| Field | Type | Default | Description |
|---|---|---|---|
enabled |
bool | true |
Enable/disable the WebRTC module |
listen |
string | ":8443" |
HTTP signaling server listen address |
ice_servers |
list | Google STUN | STUN/TURN servers for ICE candidate gathering |
udp_port_range |
[int, int] | [20000, 30000] |
UDP port range for ICE media transport |
candidates |
list | [] |
External IP addresses to advertise as ICE host candidates (for NAT/Docker) |
tls |
*bool | nil |
Per-module TLS override (see Server & TLS) |
ice_servers:
- urls: ["stun:stun.l.google.com:19302"]
- urls: ["turn:turn.example.com:3478"]
username: "user"
credential: "pass"WHIP (WebRTC-HTTP Ingestion Protocol) allows publishing a stream via a single HTTP POST.
Endpoint: POST /webrtc/whip/{app}/{key}
The request body is an SDP offer with Content-Type: application/sdp. The response is an SDP answer with HTTP status 201 Created.
Open the web console at http://localhost:8090/console, click "+ WebRTC Publish", select camera and microphone, and start streaming. The console uses the WHIP endpoint internally.
curl -X POST http://localhost:8443/webrtc/whip/live/stream1 \
-H "Content-Type: application/sdp" \
-d @offer.sdpThe Location header in the response contains the session URL for management.
WHEP (WebRTC-HTTP Egress Protocol) allows subscribing to a stream via a single HTTP POST.
Endpoint: POST /webrtc/whep/{app}/{key}
Append a mode query parameter to control startup behavior:
| Mode | URL | Behavior |
|---|---|---|
realtime (default) |
/webrtc/whep/live/stream1 |
Skip GOP cache, wait for the next live keyframe. Lowest latency. |
live |
/webrtc/whep/live/stream1?mode=live |
Send GOP cache for immediate playback, then live frames. |
DELETE /webrtc/session/{session-id}
Tears down the peer connection and releases all resources.
PATCH /webrtc/session/{session-id}
Content-Type: application/trickle-ice-sdpfrag
Used for trickle ICE candidate delivery.
| Type | Codecs |
|---|---|
| Video | H.264, H.265, VP8, VP9, AV1 |
| Audio | Opus, G.711 (PCMU/PCMA) |
- Browser-to-browser streaming -- publish from a browser camera via WHIP, watch in another browser via WHEP
- Ultra-low-latency monitoring -- sub-second end-to-end latency
- Interactive live streaming -- real-time bidirectional communication
- Protocol bridging -- publish via WHIP, distribute via HLS/DASH/RTMP to large audiences