mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 09:31:20 -04:00
1.9 KiB
1.9 KiB
mediaMTX Integration
Each rover runs mediaMTX locally to capture the Pi camera, and the control server hosts a central mediaMTX instance that fans video out to drivers and spectators. When a rover connects, the Node server asks the central mediaMTX to pull the rover’s local WHEP stream and expose it under the rover’s name.
Pi (publisher)
- mediaMTX samples the Pi camera (
paths.rovercam.source: rpiCamera) and exposes the HTTP API onhttp://127.0.0.1:9997. roverdautomatically detects the Pi’s own WHEP endpoint (e.g.http://roomba-alpha.local:8889/whep/rovercam) and reports abridgeWhepUrl(converted towhep://.../whep) to the server. No manual per-rover video URL configuration is required.- The
media.manageflag keeps the local service alive viasystemctland hits the API for health checks (media.healthUrl, defaults tohttp://127.0.0.1:9997/v3/paths/list).
Control server (viewer)
- The central mediaMTX instance serves WHEP playback at
/whep/<roverId>and exposes its control API onhttp://127.0.0.1:9997. - When a rover connects, the Node server calls
POST /v3/config/paths/replace/<roverId>and setssource: whep://<pi-ip>:8889/rovercam/whep. When the rover disconnects, the path is removed. - Viewers still use
video:requestto obtain a session token. They POST their SDP offer to/whep/<roverId>withAuthorization: Basic base64(token:token). mediaMTX forwards thetokento/mediamtx/auth(in theuserfield) before allowing the stream to start, and the Node server enforces lockdown/role rules there.
Driver / spectator UIs
- When a user requests video the browser asks the Node server for a session token, and if the current mode/role allows it, the server returns the WHEP URL plus the session id.
- Spectator mode and lockdown are enforced purely on the Node server: no direct Pi URLs are ever exposed, and once a user has a session it remains valid until they disconnect or lockdown revokes it.