Live view over WebRTC (openpanel L1, server and browser)

A device reporting a `live` port streams its camera to the browser's own
RTCPeerConnection. The flows socket carries the signalling as text, so it
crosses the portal: `live` messages on a person's socket, `signal` on a
device's (start, sdp, candidate, bye, busy). The server routes by session,
holds a device to two viewers, ends a session when either socket closes or
no answer comes within 10 s, and gives each socket an outbox of its own
that ends a session rather than drop a message. TURN credentials are
minted per session in coturn's REST scheme (STUN_URLS, TURN_URLS,
TURN_SECRET), the viewer's with the device's offer; GET /devices/{id}/ice
hands them out too. The tunnel keeps a stream's early frames instead of
dropping them past eight and forgets them when the stream or link goes.

A media tile on a device's camera, and the Devices tab's preview, play
live when tapped, pause frames meanwhile, and fall back to frames with a
short note on busy, failure or no picture within 10 s. coturn is an
optional compose service behind the `turn` profile.
This commit is contained in:
Melvin Strobl
2026-10-17 08:37:39 +02:00
parent efd883d092
commit 6a98dcd23f
20 changed files with 1535 additions and 24 deletions
+12
View File
@@ -229,6 +229,18 @@ class Settings(BaseSettings):
list[AnyUrl] | str, BeforeValidator(parse_cors)
] = []
#: Where a live view's two ends look for a way to each other, comma
#: separated. None by default: on one network the peers find each other
#: without, and a third-party server would learn who watches what. coturn
#: serves STUN as well, so its `stun:` address goes here.
STUN_URLS: Annotated[list[str] | str, BeforeValidator(parse_cors)] = []
#: The relay a live view falls back to when the two ends cannot reach each
#: other, as `turn:` and `turns:` URLs. Used only with `TURN_SECRET`, the
#: secret the TURN server shares (coturn's `static-auth-secret`), from
#: which each viewer and device gets credentials of its own.
TURN_URLS: Annotated[list[str] | str, BeforeValidator(parse_cors)] = []
TURN_SECRET: str = ""
@model_validator(mode="before")
@classmethod
def _derive_data_paths(cls, data: Any) -> Any: