Cameras on devices (openpanel C1): frames in memory, a binary uplink, demand

- Volatile frames are held in memory with a byte-bounded queue instead of
  the /dev/shm ring scanned on every put; workers keep writing to the
  directory, which is trimmed on a timer. A volatile upload no longer spools
  to disk. ARTIFACT_VOLATILE_BYTES=0 turns the ring off.
- A device sends camera frames as binary messages on its socket, held and
  published in one step and credited to its device node; refused frames are
  logged and dropped. Its snapshot carries demand and the uplink (binary, or
  http through the portal).
- One demand registry for every socket's wanted media, the tunnel's
  included, plus what running flows read, mapped onto on-demand ports and
  published as device_demand; at most 8 media names per socket.
- Per-message deflate off in serve and dev; a device may fetch the last 8
  digests of a message; published dashboards cached per store revision; a
  revoked device socket is closed with 1008.
- Media tiles want bytes only while on screen; the Devices tab previews a
  wired camera; the device node warns when a flow reads an on-demand port.
This commit is contained in:
Melvin Strobl
2026-10-16 20:43:14 +02:00
parent d79203a5f7
commit ecc4bee4bb
29 changed files with 1425 additions and 220 deletions
+12 -9
View File
@@ -207,16 +207,19 @@ class Settings(BaseSettings):
# Storing bytes and recording the reference are two steps; this is the
# window between them.
ARTIFACT_GC_GRACE_S: int = 3600
#: Where frames a flow only shows live are held: memory rather than the
#: data volume, so a camera at ten frames a second is not writing to an SD
#: card. Empty works it out — a directory under `/dev/shm` named for this
#: data directory, so two instances on one host do not trim each other —
#: and falls back to the temporary directory where there is no `/dev/shm`.
#: Where a worker in this container writes the frames a flow only shows
#: live: memory rather than the data volume, so a camera at ten frames a
#: second is not writing to an SD card. The engine holds its own frames in
#: its memory. Empty works it out — a directory under `/dev/shm` named for
#: this data directory, so two instances on one host do not trim each
#: other — and falls back to the temporary directory where there is no
#: `/dev/shm`.
ARTIFACT_VOLATILE_DIR: Path | None = None
#: How much the volatile ring holds before the oldest frames fall out of
#: it; 0 turns it off, and a volatile save then lands in the durable store
#: like any other. Under Docker's default 64 MB `/dev/shm`: raise
#: `shm_size` with it.
#: How many bytes of live frames the engine holds before the oldest fall
#: out, and the workers' directory too; 0 turns the ring off, and a
#: volatile save then lands in the durable store like any other. Under
#: Docker's default 64 MB `/dev/shm`: raise `shm_size` with it when
#: workers publish frames.
ARTIFACT_VOLATILE_BYTES: int = 48 * 1024 * 1024
# Without a Redis host the engine keeps its state in memory.
REDIS_HOST: str | None = None