snapshot
A single device snapshot returned as base64 JPEG/PNG.
A single device snapshot returned as base64 JPEG/PNG.
The SnapshotAddon wrapper returns this shape whether the frame came from the device-native provider (onboard capture) or from the stream-broker prebuffer fallback.
At a glance
| Capability | snapshot |
| Provided by | The device's own driver can provide it, and an addon can also wrap the device to provide it through the device bindings. |
| Active providers per device | one |
| Device types | camera |
| Source | packages/types/src/capabilities/snapshot.cap.ts |
Methods
| Method | Kind | Required of a provider | Access |
|---|---|---|---|
getSnapshot | query | yes | default |
invalidateCache | mutation | yes | admin |
getSnapshotOverview | query | yes | default |
getDebugState | query | yes | default |
getSnapshotLinks | query | yes | default |
getSnapshot
query
Input
| Field | Type | Required | Description |
|---|---|---|---|
deviceId | number | yes | |
streamId | string | no | |
force | boolean | no | Bypass the cache freshness check and fetch directly from the native (or stream-broker fallback). Triggered by the UI's "refresh" button so an operator can force a fresh frame even when the cache is well within the device's snapshotMaxAgeS window. force is a demand with a named principal, not a freshness preference — an operator button, the scheduled refresh, or a notification rule that left the camera's wake allowed. On a battery camera it is the one thing that walks past the wrapper's sleep gate and wakes the camera, so a poller, a thumbnail or a prestream must NEVER set it. Every such caller gets the cached frame, which on a sleeping battery camera is the correct answer: stale but honest beats woken. |
Output
| Field | Type | Required | Description |
|---|---|---|---|
base64 | string | yes | |
contentType | string | yes |
invalidateCache
mutation
Input
| Field | Type | Required | Description |
|---|---|---|---|
deviceId | number | yes |
Output
Nothing.
getSnapshotOverview
query
Cache-only batch overview — answers from the wrapper's in-memory cache in O(n) and NEVER triggers a capture. Lets a grid skip requesting images for devices that never produced a frame, and gives it an ETag per device for conditional (304-able) image fetches. lastCapturedAt/cacheAgeMs/etag are null for a device with no cached frame.
Input
| Field | Type | Required | Description |
|---|---|---|---|
deviceIds | number[] | yes |
Output
({ deviceId: number; lastCapturedAt: number | null; cacheAgeMs: number | null; etag: string | null })[]
getDebugState
query
The full decision chain for ONE device, for the viewer's debug readout — the answer to "why does this tile show what it shows" in a single poll: the battery slice the state was derived from, the resolved state + its reason, the cached frame's identity/age, whether a wake window is open, and whether a fresh capture is in flight. Cache-only and capture-free: a debug read must never wake a battery camera.
Input
| Field | Type | Required | Description |
|---|---|---|---|
deviceId | number | yes |
Output
| Field | Type | Required | Description |
|---|---|---|---|
battery | { sleeping: boolean; lastUpdated: number; lastContactAt?: number } | null | yes | The battery slice as read, or null when the device has none. |
state | { isBattery: boolean; reason: "disabled" | "offline" | "sleeping" | "unreachable" | "waking" | null } | yes | The resolved snapshot state (what the overlay decision used). |
frame | { capturedAt: number | null; ageMs: number | null } | yes | The cached frame behind the next paint. |
waking | boolean | yes | A wake window is currently open (the Waking overlay's source). |
getSnapshotLinks
query
Signed, expiring links to a CLIENT-SIZED frame — and the demand signal that makes those frames current.
Input
| Field | Type | Required | Description |
|---|---|---|---|
targets | ({ deviceId: number; width?: number })[] | yes | The tiles a surface is actually rendering. One entry per (device, width) the caller will paint — the width is snapped to the server's ladder and becomes part of the link's SIGNED identity. |
Output
({ deviceId: number; url: string | null; capturedAt: number | null; ageMs: number | null; expiresAt: number | null; width: number | null; neverCaptured: boolean; sleeping: boolean; stateReason: "disabled" | "offline" | "…
Status
| Field | Type | Required | Description |
|---|---|---|---|
lastCapturedAt | number | null | yes | Ms epoch of the last successful capture. Null if none yet. |
cacheAgeMs | number | null | yes | Age of the cached image in ms. Null if no cache. |
lastBytes | number | null | yes | Size in bytes of the last captured image. Null if no capture. |
lastStreamId | string | null | yes | Stream id used for the last capture ('high'|'mid'|'low' or custom). Null if via HTTP endpoint. |