feat(web): add camera-scoped WebRTC live view

This commit is contained in:
arnaud.dartois committed 2026-11-04 22:46:28 +01:00
1 parent dee59ed0db
commit 495740292a
25 files changed
+954 -9

No files matched your search

+76 -1
View File
@@ -138,7 +138,7 @@ docker compose --env-file docker/.env -f docker/docker-compose.backup.yml up -d
Configure Ollama at `http://ollama:11434` in Central's AI settings when enabled.
Choose RustFS as the storage provider in Central and use `http://rustfs:9000` as
its endpoint. Configure the ntfy server URL in Central's notification settings.
TURN is not required until WebRTC is enabled.
Live view can connect directly when ICE succeeds. For clients behind restrictive NAT/firewalls, deploy and validate TURN, then configure its URLs and matching shared secret in Central; without a reachable relay, those clients may not connect.
Redis is provided as a standalone service but is not currently required by
Central. Backups are independent of the core startup and require the core
network and PostgreSQL service to be running.
@@ -146,3 +146,78 @@ network and PostgreSQL service to be running.
See [GPU Agent notes](gpu-runtime.md) and
[Agent update signing](agent-release-signing.md) for device access and
trusted-key setup.
## Optional live video with WebRTC
The live-view vertical uses the separately maintained MediaMTX image. It is not
started with the core stack. Configure Central with the public `HEIMDALL_WHEP_URL`
and `HEIMDALL_PUBLISH_RTSPS_URL` (including scheme, host and port only). Provide
`HEIMDALL_MEDIAMTX_AUTH_URL` to the MediaMTX container; when both services share
the default Docker network this can use the Central service name and internal
port. Configure `HEIMDALL_WEBRTC_PUBLIC_HOST`,
`HEIMDALL_WEBRTC_ALLOWED_ORIGIN`, and `HEIMDALL_LIVE_MEDIA_CERT_DIR` for the
public listener and its TLS certificate (`server.crt` and `server.key`). The
certificate must cover both public WHEP and RTSPS hostnames. Open the configured
RTSPS/WHEP TCP ports and WebRTC ICE UDP port in the firewall. Add STUN URLs under
`LiveMedia:IceServers`; for TURN REST credentials set
`LiveMedia:Turn:Urls` and `LiveMedia:Turn:SharedSecret`. Central returns
five-minute HMAC credentials to the browser; the shared secret is never sent.
When using `docker-compose.coturn.yml`, configure the Central secret from the same
protected secret source as `docker/secrets/coturn_secret`; protect the Central
`.env` with owner-only permissions.
Start the core project first so its external `heimdall-net` network exists, then
start MediaMTX with a separate project name:
```sh
docker compose --env-file docker/.env -f docker/docker-compose.webrtc.yml -p heimdall-live up -d
```
Stop only this optional project with `docker compose ... -p heimdall-live down`.
Live publishing requires an assigned Agent and an online, enabled camera. Agent
relays are video-only H.264 passthrough, limited to two simultaneous cameras per
Agent. Central reserves eight viewers per camera and two per user in its process;
use one Central instance until shared reservation storage is configured. A stream
with a browser-incompatible codec is not transcoded. The WHEP read session
expires after ten minutes; the browser deletes the WHEP resource on
stop/navigation. Physical camera and external TURN validation remain deployment
acceptance work.
### Disposable live-view acceptance
For an isolated local playback test, use the local-only override and synthetic
source Compose files. Generate a unique `.env` outside the repository with new
PostgreSQL/JWT secrets, loopback ports, `HEIMDALL_NETWORK_NAME`,
`HEIMDALL_WEBRTC_ALLOWED_ORIGIN`, and
`HEIMDALL_MEDIAMTX_AUTH_URL=http://heimdall:8080/api/live-media/auth`.
Configure `HEIMDALL_WHEP_URL=http://127.0.0.1:<whep-port>`,
`HEIMDALL_PUBLISH_RTSPS_URL=rtsp://127.0.0.1:<publish-port>`,
`HEIMDALL_ALLOW_INSECURE_HTTP=true`,
`HEIMDALL_ALLOW_INSECURE_RTSP=true`, and
`HEIMDALL_WEBRTC_ALLOWED_ORIGIN=http://localhost:<web-port>`. Set
`HEIMDALL_NETWORK_NAME` to a unique network name and select unused values for
`WEB_PORT`, `HEIMDALL_TEST_PUBLISH_PORT`, `HEIMDALL_TEST_WHEP_PORT`,
`HEIMDALL_TEST_ICE_PORT`, `HEIMDALL_SYNTHETIC_RTSP_PORT`, and
`HEIMDALL_TEST_AGENT_PORT`. Insecure protocols are allowed only because all media
ports bind to loopback in this recipe. Then start Central, the local MediaMTX,
and synthetic source from changed source, excluding the Agent until a site token
is available:
```sh
docker compose -p "$project" --env-file "$env_file" \
-f docker/docker-compose.yml \
-f docker/docker-compose.webrtc-local-test.yml \
-f docker/docker-compose.webrtc-test.yml \
up -d --build postgresql heimdall mediamtx synthetic-camera synthetic-camera-publisher
```
Complete first-admin setup, create a site, put its generated test site token in
the disposable `.env`, and start `heimdall-agent` from the same Compose files.
Create and assign an online camera with the synthetic source RTSP URL, then open
its detail page and start live video. Verify an ungranted user is denied, stop
and disable the camera, and check the Agent process and WHEP session are closed.
Use unique ports and the unique network value for each run. Tear down only this
project with `down --volumes --remove-orphans`, confirm its containers, named
volumes and network are gone, and delete its temporary environment/secret files.
This recipe is HTTP/RTSP loopback-only; production configuration remains RTSPS
and HTTPS with a trusted certificate.