Live Ingest — mobile WebRTC "Go Live"
Listeners can take the whole channel live from a phone browser. The chain is:
The WHIP/WHEP server (whip_server.py)
Python (aiohttp + aiortc) service, venv whip-venv/, port 8089, launched by
start_whip.sh and kept alive by watch_whip.sh (cron */5).
| Route | Method | Purpose |
|---|---|---|
/whip-info | GET | STUN/TURN servers + live flag (used by LiveManager to probe) |
/whip/ | POST | Create an ingest (browser posts an audio SDP offer) |
/whip/{id} | PATCH | DTLS renegotiation / ICE restart |
/whip/{id} | DELETE | Tear down an ingest |
/whep/ | GET | Minimal WHEP echo (subscribe back to the ingest) |
/go-live | GET | Serves the mobile "Go Live" page |
Key details:
- TURN credentials are minted client-side with HMAC-SHA1 using the coturn
static-auth-secretpattern (turn.mediahubnetwork.net:3478, +5349TLS, +tcp). The secret is read fromTURN_SECRETenv. - Audio only: video tracks are ignored. Audio frames are decoded and written to the FIFO as raw PCM (16-bit LE, 48 kHz, mono).
- The FIFO writer opens in a background task so the server starts even before ffmpeg (the reader) is attached.
- Engine registration: when the first audio track arrives, the server
re-registers the source with the Windows engine
(
POST http://10.40.3.174:5000/api/station/live/register) withurl="pipe:/home/sms/radio/whep_live.wav", ingest="webrtc". Re-registering every time is safe because LiveManager dedupes pipe/WebRTC sources on url+title+ingest — it survives engine restarts too. - When the last track ends, it stops the engine live state and kills the harbor reader.
The go-live.html page
whip_server.py serves /go-live from /home/sms/radio/go-live.html. On mobile:
- Fetches
/whip-infofor STUN/TURN. getUserMedia({ audio })(echo cancellation + noise suppression on).- Creates a WebRTC peer with
max-bundle, actrldata channel, and a live level meter. - POSTs the audio offer SDP (plain text) to
/whip/, applies the answer. - Stop broadcasting closes the peer and tears everything down.
Where this meets LiveManager
The WHIP ingest is just another entry in the LiveManager ranking (votes +
listeners + freshness). When the engine is asked to go live, _probeHarbor
checks http://10.10.8.230:8089/whip-info (live: true) to confirm the remote
feed is actually flowing before declaring the channel live. See
Live Manager.
See also
- Liquidsoap — the
channel_liveharbor + switch. - Live Manager — ranking + restream + monitor.
- Station control —
/api/station/live/*endpoints.