--- type: decision tags: [parking, camera, ui, booth, video, hikvision] sources: [] updated: 2026-11-23 status: settled --- # Camera Live View — Booth Camera Tiles The booth operator can open a small tile per camera from the [[device-status-monitoring|device footer]] and watch that camera live while a vehicle is in front of it. **BUILT 2026-11-17**; verified end to end against the two park-lab cameras through the real server and in a browser (not yet in the [[desktop-shell-tauri|desktop shell]] — see *Not yet verified*). > **2026-11-23:** the user decided that the server holds no video or image work > ([[event-driven-refactor]]). The live picture is to come from the vision side; how the booth > screen gets it is not decided. This page describes what is built and running. ## What the user asked for (2026-11-17) - The camera chips in the footer are clickable; a click opens that camera's tile in the bottom right, about 15 % of the screen wide. A second camera's tile stacks to the **left** of the first. - A tile closes with ✕; which tiles are open is a **user preference** (restored on login). - A tile rests on the **latest entry/exit snapshot** of that camera; when the camera's vehicle events reach the booth, it shows **live video**. - (2026-11-17, second round) Live shows a **pulsing green LIVE badge**. A click on the picture opens a **large view** with a **Live / Snapshot switch** whose Live streams **on demand** — car or no car — so a camera-started stream can be stopped to look at the last snapshot and a snapshot can be switched to live. Closing the large view returns the tile to automatic: a stream the user started stops; a stream the camera started carries on in the tile. - (2026-11-17, third round) The large view **opens in the tile's state**: on Live when the camera is active (the same stream carries on, no reconnect), else on the Snapshot. The choice then holds while the view is open — a car leaving does not drop it to the snapshot, a car arriving does not switch it to live. - (2026-11-17, fourth round) On the Snapshot side the large view has **‹ ›** (and ← →) to step through that camera's older / newer snapshots; a chevron is muted at either end. The caption carries the date ("Dje 17:22:47"). The tile itself stays on the newest; closing the large view drops the browse position, so it reopens on the newest. On Live there are no chevrons. Server: `GET /api/cameras/:deviceId/snapshots/:snapshotId/neighbors` → `{ older, newer }` (`session:read`; 404 for another camera's snapshot), ordered by (capturedAt, id) like `latest-snapshot`, so equal timestamps neither skip nor loop. The caption always names the picture on screen: while a stepped-to still loads, the previous picture and its date stay; if its bytes are gone (retention), the view says *Snapshot unavailable* rather than show another still. ### When the stream stops A tile streams while its camera is active — **30 s after the camera's last vehicle push** (`LANE_BUSY_TTL_MS`, shared with the lane lights; the camera re-pushes every 1–3 s while a car moves and every 15–25 s while it stands, so a waiting car keeps it live) — or while the large view is open on Live. It also stops on ✕, logout, or a dropped booth feed (resumes on reconnect). The camera session closes 5 s after the last viewer anywhere stops (RTSP TEARDOWN). No upper bound. The large live view is the 1280×720 sub-stream (the same stream as the tile); the Snapshot side shows the stored evidence still (full resolution when the camera's snapshot stream is Main). ## Decision | Question | Choice | Why | |---|---|---| | Video source | The camera's **sub-stream (x02) set to MJPEG**, pulled over **RTSP** | The G2 firmware answers the HTTP MJPEG preview (`/ISAPI/Streaming/channels/102/httpPreview`) with `notSupport`; RTSP offers MJPEG as RTP/JPEG (RFC 2435). Every MJPEG frame is a whole picture, so a view is live ~150 ms after connect — H.264 would wait for a keyframe (every 2.5–4 s on these cameras) and need a decoder. | | Where it runs | **In the server process**, as a driver capability (`LiveStreamDevice`) in `packages/devices` | No sidecar container (camera config + `localAddress` already live in the DB; the [[device-adapter-pattern]] keeps the protocol in the driver). The server reassembles JPEG frames from RTP packets — about 450 small packets/s for two cameras; it never decodes or re-encodes. | | Fan-out | **One RTSP session per camera**, shared by every viewer, torn down 5 s after the last leaves | A camera has few stream slots and the [[lane-presence-and-anpr-entry|ANPR loop]] pulls stills from the same unit. | | Delivery to the page | A **WebSocket per open tile** (`/api/cameras/:id/live`), one JPEG per binary message, **latest frame only**, at the camera's own rate (no cap; `CAMERA_LIVE_MAX_FPS` can set one) | Works in the desktop shell, whose webview cannot carry the session cookie on an ``/`