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:
@@ -1,5 +1,7 @@
|
||||
import type {
|
||||
CameraDevice,
|
||||
LiveStreamDevice,
|
||||
LiveVideoSource,
|
||||
ClockSyncResult,
|
||||
DeviceHealth,
|
||||
Snapshot,
|
||||
@@ -14,6 +16,7 @@ import {
|
||||
stubLog,
|
||||
} from "./common.js";
|
||||
import { digestGet, digestRequest } from "./http-digest.js";
|
||||
import { RtspMjpegStream } from "./rtsp-mjpeg.js";
|
||||
|
||||
// Camera drivers — entry/exit snapshot-on-event. The host pulls a still over
|
||||
// HTTP when an event fires; the bytes are stored and referenced from the signed
|
||||
@@ -74,6 +77,8 @@ class HttpCamera implements CameraDevice {
|
||||
// Source outbound from the device-facing NIC on a multi-homed host (the
|
||||
// multi-subnet source-address trap — see wiki/concepts/wsl-dev-networking.md).
|
||||
readonly #localAddress: string | undefined;
|
||||
/** RTSP port for the live view (not a Setup field: 554 everywhere so far). */
|
||||
readonly #rtspPort: number;
|
||||
|
||||
constructor(
|
||||
readonly driverId: string,
|
||||
@@ -92,6 +97,7 @@ class HttpCamera implements CameraDevice {
|
||||
this.#localAddress = config.localAddress
|
||||
? String(config.localAddress)
|
||||
: undefined;
|
||||
this.#rtspPort = Number(config.rtspPort ?? 554);
|
||||
}
|
||||
|
||||
async connect(): Promise<void> {}
|
||||
@@ -165,6 +171,23 @@ class HttpCamera implements CameraDevice {
|
||||
});
|
||||
}
|
||||
|
||||
/** An RTSP MJPEG session on `path` with this camera's address + credentials. */
|
||||
protected rtspStream(path: string): LiveVideoSource {
|
||||
return new RtspMjpegStream({
|
||||
host: this.#host,
|
||||
port: this.#rtspPort,
|
||||
path,
|
||||
user: this.#user,
|
||||
password: this.#password,
|
||||
timeoutMs: this.#timeout,
|
||||
...(this.#localAddress ? { localAddress: this.#localAddress } : {}),
|
||||
});
|
||||
}
|
||||
|
||||
protected get channel(): number {
|
||||
return this.#channel;
|
||||
}
|
||||
|
||||
/** Digest request against an arbitrary device path (ISAPI / CGI config reads+writes). */
|
||||
protected deviceRequest(method: "GET" | "PUT", path: string, body?: string) {
|
||||
return digestRequest({
|
||||
@@ -216,7 +239,18 @@ export function hikvisionFixedZone(localIso: string): string {
|
||||
return `CST${sign}${hours}:${minutes}:00`;
|
||||
}
|
||||
|
||||
class HikvisionCamera extends HttpCamera {
|
||||
class HikvisionCamera extends HttpCamera implements LiveStreamDevice {
|
||||
/**
|
||||
* Live view for the booth's camera tiles: the channel's SUB-stream (x02) over RTSP,
|
||||
* which must be set to MJPEG on the camera (H.264 is refused with that reason).
|
||||
* The ANPR/evidence stills keep coming from /picture on the configured stream —
|
||||
* the codec of the sub-stream does not change them (measured on park-lab
|
||||
* 2026-11-17: no extra 503s with a stream open). See wiki/decisions/camera-live-view.md.
|
||||
*/
|
||||
openLiveStream(): LiveVideoSource {
|
||||
return this.rtspStream(`/Streaming/Channels/${this.channel}02`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the camera clock + zone. Rewrite the zone when it is not the site's current
|
||||
* fixed offset (see above); otherwise set the clock only when it drifts more than
|
||||
|
||||
Reference in New Issue
Block a user