feat(cameras): booth camera tiles — latest snapshot at rest, live video while a vehicle is in view

Footer camera chips open/close a tile per camera (bottom right, ~15% wide, stacking
leftwards); the open set is a per-user preference (users.open_cameras). A tile shows the
camera's newest entry/exit snapshot and switches to live video while that camera pushes
vehicle events (per-camera activity, same 30 s TTL as lane status).

- devices: RTSP MJPEG client + RFC 2435 RTP/JPEG reassembly; Hikvision openLiveStream()
  on the sub-stream (x02, must be MJPEG — H.264 is refused with that reason)
- server: CameraLiveHub (one shared upstream per camera, latest-frame delivery, fps cap,
  linger, backoff), CameraActivity, /api/cameras/:id/latest-snapshot, WS
  /api/cameras/:id/live (shared handshake auth with /api/ws + device:read),
  PUT /api/auth/open-cameras, migration 0033 (open_cameras + snapshot device/time index)
- web: CameraDock, footer toggles, binary frames in the platform socket (Tauri too)
- .gitattributes: *.jpg / *.bin binary (byte-exact test fixtures)

Verified on park-lab cameras end to end and in headless Firefox.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 12:48:50 +01:00
parent b6f7ea65a4
commit 39fb5fb7c2
36 changed files with 2067 additions and 45 deletions
@@ -0,0 +1,9 @@
-- Booth camera tiles (wiki/decisions/camera-live-view.md). Two additive changes:
-- * users.open_cameras: the camera tiles a user left open (JSON array of device ids),
-- restored on the next login from any booth, like language/theme/font_scale.
-- * an index for "the latest snapshot this camera took" — the tile's default picture.
-- Without it the lookup scans every stored image row (the bounded-request-cost rule,
-- park-2 2026-10-24). The previous image ignores both on rollback.
ALTER TABLE `users` ADD `open_cameras` text DEFAULT '[]' NOT NULL;
--> statement-breakpoint
CREATE INDEX IF NOT EXISTS `snapshots_device_time_idx` ON `snapshots` (`device_id`,`captured_at`);
+7
View File
@@ -232,6 +232,13 @@
"when": 1788720000000,
"tag": "0032_hot_path_indexes",
"breakpoints": true
},
{
"idx": 33,
"version": "6",
"when": 1788730000000,
"tag": "0033_camera_live_view",
"breakpoints": true
}
]
}
+4
View File
@@ -96,6 +96,10 @@ export const users = sqliteTable("users", {
// avoids float drift; the client clamps to 80–160 in steps of 10. Printed tickets are
// unaffected (server-rendered).
fontScale: integer("font_scale").notNull().default(100),
// Camera tiles this user left open on the booth screen (JSON array of camera device
// ids, in the order opened). Persisted like `theme`; restored on login from any booth.
// See wiki/decisions/camera-live-view.md.
openCameras: text("open_cameras").notNull().default("[]"),
// Optional operator profile metadata — display name + contact details. All
// nullable; only username/password/role are required to create a user. fullName
// (when set) is the human label for audit/Z-report display.