videoclips
videoclips — the unified, navigable-clip surface for a camera.
videoclips — the unified, navigable-clip surface for a camera.
A device-scoped wrapper COLLECTION: every provider a camera has is a SOURCE, and they are listed beside each other — never one substituted for another, and none of them privileged by name. A camera that exposes NATIVE onboard clips (Reolink SD card, a hub's storage, HKSV) adds its own catalog ALONGSIDE that one. (defaultActive above is the CAP's auto-bind to cameras, not a ranking among these sources — there is none.)
The mount stays per-device (resolveCapMount → device-scoped), and a device's SOURCES are its BINDINGS: deviceManager.getBindings(deviceId) is what says a provider serves this camera, never the set of addons that happen to have registered the capability somewhere in the cluster. That is what stopped one addon appearing three times on 107 — as the device's native provider, as the hub-local registration and as an <addonId>@<nodeId> one.
listClips is asked of ONE provider at a time, and NAMING it is REQUIRED ({ a union over everything a camera has: "l'utilizzatore è uno solo" [there is only one user]. The pick is a SURFACE's to make, from the { already holds, and it says which one it made. { — one row per source, by construction. { source namespace inside the clip id, which is why ids are self-contained.
A Clip is purely time-based (subtree-blind): playback resolves segments by temporal overlap, so the API never decides continuous vs events.
Ceiling on Clip.eventIds. A visit is annotated by its events; it is not a transport for them. At ~39 wire bytes per uuid this keeps a clip row inside the 1.5 KB budget (docs/design/2026-08-17-videoclips-implementation.md §7.2) while preserving eventIds[0] — the surface's thumbnail fallback.
At a glance
| Capability | videoclips |
| Provided by | An addon wraps the device and provides it. It is bound to a device through the device bindings and can be bound automatically to compatible devices. |
| Active providers per device | several (every registered provider stays active) |
| Device types | camera |
| Device settings | Yes: its settings section on the device page is built from this capability's methods. |
| Source | packages/types/src/capabilities/videoclips.cap.ts |
Methods
Every method takes the device id (deviceId) to address the device; the input tables below list the other fields.
| Method | Kind | Required of a provider | Access |
|---|---|---|---|
listClips | query | yes | protected |
listSources | query | yes | protected |
getClipPlayback | query | yes | protected |
readClipBytes | query | no | protected |
offerClipBytes | query | no | protected |
dialClipStream | query | no | protected |
getPlaybackOptions | query | no | protected |
listClips
query
Input
| Field | Type | Required | Description |
|---|---|---|---|
since | number | yes | |
until | number | yes | |
limit | number | no | |
provider | string | yes | WHICH provider to ask — the addonId a { carries, never a source id and never a list. Required. A provider the device is not bound to is refused by name rather than answered by another one. It was optional, documented as "absent means the device's BOUND provider, which is Dominevo on every camera". No code implemented that. Measured on the live hub 2026-09-20 — device 107, bound to recorder AND provider-reolink — a bare call with limit: 3 answered SIX rows, three from each source, merged newest-first: device-collection-dispatch.ts simply left the fan-out un-narrowed, so absence bought the union this method exists not to be, and limit meant limit × sources. There is nothing to restore the default to. getBindings answers a collection cap with a DERIVED, PLURAL set; setWrapperActive — the singleton authority that could name one — throws for a collection cap by design. Naming Dominevo here instead would privilege one addon by id inside a surface whose premise is that sources are peers, and would be wrong on the first camera with no recorder binding. So absence is REFUSED, in the schema, where the generated types make it unomittable rather than merely discouraged. The default belongs to the SURFACE, which has the listSources rows and can say which one it picked. It replaced sources?: string[], a VIEW filter over source ids that assumed the answer was a fan-out over everything a camera has. The operator settled otherwise on 2026-09-20 — "l'utilizzatore è uno solo" [there is only one user] — so the list is asked of one provider at a time and there is nothing to filter out of it. |
Output
({ id: string; source: string; kind: "motion" | "object" | "audio" | "native"; timeRange: { startMs: number; endMs: number }; labels?: string[]; thumbnail?: string; stillAtMs?: number; eventIds?: string[]; eventCount?: n…
listSources
query
The sources this camera has, WITH the reason any of them cannot answer.
Asked separately from listClips because an empty clip list is ambiguous and this is the only place the ambiguity is resolved: every bound provider contributes its own rows, and a provider that could not be reached at all still produces one row saying so. A surface that draws "no clips" without reading this is drawing a guess.
Input
No fields besides deviceId.
Output
({ source: string; label: string; addonId?: string; availability: { state: "ok" | "sleeping" | "unreachable" | "no-storage" | "index-empty"; reason?: string; catalogAsOf?: number } })[]
getClipPlayback
query
Input
| Field | Type | Required | Description |
|---|---|---|---|
clipId | string | yes | |
profile | "high" | "mid" | "low" | no | Which twin to serve, on the ONE quality scale the system already has (CamProfileSchema). low | mid → the sub file, high → the main twin; both ids are already on the row so this never re-searches the camera. Absent means the provider's own default (the sub file, which every source is measured to hold). auto is deliberately NOT accepted here: a stored file has no broker session, so the adaptive tier cannot be resolved for it. The viewer resolves auto to a profile the same way live does, before it calls. |
Output
| Field | Type | Required | Description |
|---|---|---|---|
playbackUrl | string | yes | A media URL through the hub data-plane. { says what kind — an HLS master playlist for a recording-derived clip, a progressive MP4 for a native file the vendor addon muxed and serves with Range. The URL is NOT a credential: both planes are registered access: 'authenticated' and the hub's /addon/<id>/<prefix> proxy takes the session cookie, so nothing is appended to it. |
format | "hls" | "mp4" | no | How to play { existing consumer already assumes. A player that branches on this is the one change a native clip needs; a player that ignores it will hand an MP4 to hls.js and fail parsing it as a manifest. |
served | "high" | "mid" | "low" | no | Which twin was actually served. A clip that holds only one stream answers with the one it has, and the surface SAYS so — a missing main twin is never served silently as if it were the asked-for quality. |
playbackEndpoints | string[] | no | Optional LAN/remote alternates for the same clip. |
token | string | no |
readClipBytes
query · optional for a provider
This clip's BYTES, base64, bounded — the by-handle read a clip EXPORT pulls once.
getClipPlayback is the right answer for a player: it hands back a URL on a plane the hub serves access:'authenticated', which a browser and a viewer session satisfy. It is the wrong answer for another ADDON: the hub's proxy in front of that plane takes only a user credential, which an addon does not hold, so a recorder that wants a camera's clip cannot fetch that URL. This method is the shape that answer forced — the same one (and the same bound) as recordingExport.readExportBytes.
This method remains for a consumer that genuinely wants the bytes in hand, and as the named fallback for a provider not yet redeployed.
Routing needs no provider pin: the id is source-prefixed and self-contained, so device-collection-dispatch.ts rule 3 hands the call to the source that claims it — and an id nobody claims is REFUSED rather than answered by another source.
The producer reuses the fetch path it already has, completion rules included: a clip is taken by cmd 5 and finished on a short idle window whose result is PROVED against the catalog row's own span, retried once when it comes up materially short, and served-and-named when it is still short.
Every refusal THROWS with its reason and none of them is silent — the sleep gate (decided before getApi(), liftable only by { bytes behind it, a mux that failed, and the size bound. The caller turns that reason into an operator-facing one; a truncated file is never an answer.
Input
| Field | Type | Required | Description |
|---|---|---|---|
clipId | string | yes | |
provider | string | yes | WHICH provider holds the bytes — the addonId a { listClips states one method above and for a second one this method learned the hard way. The caller is the stream broker, and the broker lives in addon-pipeline — the same addon that registers the RECORDER's videoclips provider. With no provider named, the in-process resolution handed it its own sibling, which implements this method solely to explain that an analytics visit has no file behind it. So every onboard clip answered with that sentence, a flash of video and nothing more, while the SAME call from outside the addon reached the right provider and returned the bytes (measured on 3628, 2026-09-21). |
profile | "high" | "mid" | "low" | no | auto is not accepted here for the same reason it is not accepted by getClipPlayback — a stored file has no broker session, so the adaptive tier cannot be resolved for it. |
maxBytes | number | no | The CALLER's byte bound, so an over-size clip is refused before it is read and encoded rather than after. Capped by { that ceiling. |
wake | "authorised" | no | The operator's authorisation to wake a sleeping camera for this read. Absent — the default — means a sleeping standalone battery camera is REFUSED by name, before any session is opened. |
Output
A clip's finished bytes, inline — the twin of recordingExport.readExportBytes.
bytes is the DECODED length, so nobody infers it from the base64 length, and served says which twin the caller actually got.
| Field | Type | Required | Description |
|---|---|---|---|
base64 | string | yes | |
contentType | string | yes | |
name | string | yes | Suggested filename, extension included. |
bytes | number | yes | |
served | "high" | "mid" | "low" | yes | Which twin was actually served — the same contract { export record persists it: a row read a week later must say the same thing the panel said at the moment of the tap. A missing main twin is never served silently as if it were the asked-for quality. |
durationMs | number | no | The DECODED duration of the delivered file, when the fetch measured one. A clip fetch verifies its own completion against the catalog row and retries a materially short pass; this is that measurement, carried so a consumer can say the same thing rather than re-deriving it. Absent when the producer did not measure — never zero, which would say the file is empty. |
offerClipBytes
query · optional for a provider
Where this clip's finished bytes can be TAKEN — the by-handle read a clip EXPORT pulls, over the addon→addon byte transport.
This is { same vocabulary, same completion rules, same served contract — the only difference is that the bytes travel over a one-shot loopback socket instead of inside a base64 field, so neither side holds the payload whole and the 50 MiB refusal on a long high twin stops existing. The bound that remains is { copy rather than the transport.
The ticket is loopback and same-host. A provider on an agent mints a URL that means nothing on the hub, and ctx.peerBytes.open refuses it cross-node by name rather than dialling whatever else holds that port here. A consumer that can be on the other side of a node boundary from its provider must be able to read that refusal and say so; it must not treat it as "no bytes".
A ticket is a one-shot bearer credential with a seconds-long life. Take it immediately, never persist it, never log its url. An untaken ticket costs the provider one map entry until its TTL, and outstanding tickets are bounded — which is also what makes a per-frame misuse of this method refuse by name rather than work slowly.
Optional on the provider for the same reason readClipBytes is: a source with no camera socket behind it has no bytes. A provider that predates this method answers NOT_IMPLEMENTED, and a consumer may fall back to readClipBytes — but it says so in the log, with the deploy hint, because that fallback re-imposes the 50 MiB refusal and an operator who sees too-large-to-transfer after this shipped is looking at a stale addon, not at a clip that cannot be exported.
Input
| Field | Type | Required | Description |
|---|---|---|---|
clipId | string | yes | |
provider | string | yes | WHICH provider holds the bytes — see readClipBytes.provider. |
profile | "high" | "mid" | "low" | no | Which twin — low | mid → the sub file, high → the main twin. |
maxBytes | number | no | The CALLER's byte bound, so an over-size clip is refused before the camera is touched rather than after. Capped by { that ceiling. |
wake | "authorised" | no | The operator's authorisation to wake a sleeping camera for this read. Absent — the default — means a sleeping standalone battery camera is REFUSED by name, before any session is opened. |
Output
Where a clip's finished bytes can be TAKEN — the answer to {
Everything { the one-shot ticket that leads to them. The metadata is answered BEFORE the transfer on purpose: a consumer learns which twin it got, what to call the file and how long the clip runs without having to read a byte, so a decision it would make on that metadata (a wrong twin, an implausible duration) costs no transfer at all.
| Field | Type | Required | Description |
|---|---|---|---|
ticket | { url: string; hostNodeId: string; expiresAtMs: number; declaredBytes: number | null } | yes | One shot, seconds-long, loopback, on the PROVIDER's own host. Open it with ctx.peerBytes.open(...), which refuses a ticket from another node by name rather than dialling a port that means something else here. |
contentType | string | yes | |
name | string | yes | Suggested filename, extension included. |
served | "high" | "mid" | "low" | yes | Which twin was actually served — see { |
durationMs | number | no | See { |
dialClipStream
query · optional for a provider
Where this clip's STREAM can be dialled — the forward-only fMP4 the provider writes from the first muxed byte, for the broker to play through the same WebRTC session as recorded footage, with the first frame at the first fragment instead of after the last byte.
Nothing is fetched here: the answer is a one-shot URL on the provider's own listener, and the camera is touched when it is dialled. The gates the file path runs (readClipBytes) run on the dial too — the id, the row, a clip still being written — and refuse in the same vocabulary, THROWN with clipExportFailure(<token>, <prose>). Every profile is served and the answer states which twin it carries; high is not refused. Optional on the provider for the same reason readClipBytes is: a source with no camera socket behind it (the recorder's analytics window, a HomeKit tee) has no stream.
Input
| Field | Type | Required | Description |
|---|---|---|---|
clipId | string | yes | |
provider | string | yes | WHICH provider holds the camera — see readClipBytes.provider. |
profile | "high" | "mid" | "low" | no | Which twin — high → the main file, everything else the sub. |
audio | "opus" | "pcmu" | "none" | no | Which audio codec the caller's session negotiated, so the provider can mux it. The ask travels on the DIAL because the mux is spawned once, before the first byte, and cannot gain a track later. ABSENT IS none, never a guess: a caller that does not state an ask is served the video-only stream that shipped first, so a broker older than this field keeps working unchanged. |
wake | "authorised" | no | The operator's authorisation to wake a sleeping camera for this dial — the same { — the default — means a sleeping standalone battery camera is REFUSED by name before any URL is minted. A caller sets it only when a viewer itself asked for the clip (the broker's playClip); a prefetch, a reconcile or a retry never does. With it, the provider wakes the camera and waits under a bound; a camera that does not come up is refused wake-timeout, naming the wait. |
Output
| Field | Type | Required | Description |
|---|---|---|---|
url | string | yes | |
expiresAtMs | number | yes | After this the token is gone and the URL answers 404 dial-expired. |
transport | "forward-only" | yes | What the stream IS — a consumer that cannot honour it must not dial. |
served | "high" | "mid" | "low" | yes | Which twin the stream ACTUALLY carries — not what was asked for. The stream serves every profile, and a recording whose main twin does not exist is streamed as its sub copy, which this field reports as low. Stated rather than assumed, the way { |
servedAudio | "opus" | "pcmu" | "none" | yes | Which audio the stream will ACTUALLY carry — served's companion for sound, and the same reasoning. The broker asks for the codec its WebRTC session negotiated, and the provider either muxes that codec or carries none. Stating it is what lets the broker wire the matching sink before the first byte, and what keeps a session from being handed a codec it cannot send — the audio shape of the substitution served exists to prevent. It is a promise about the CODEC, not about the content: a recording with no microphone track answers opus here and then arrives with no audio track at all. That second answer is in the stream, and the broker reads it from the moov. |
audioReason | "not-requested" | "unsupported-ask" | no | Why servedAudio is none although sound was asked for. |
getPlaybackOptions
query · optional for a provider
What a surface may DRAW for this provider's clips: the rates it can be played at, whether scrub is served, how far a position may be moved, and whether a backward frame-step means anything.
Asked per camera and per provider, so it must stay CHEAP — it is a statement about wiring, answered from a constant, never a call to the camera. A provider answers with one of { and never composes an envelope of its own.
Optional, and absence is load-bearing: a provider that has not answered has not restricted anything, and a viewer reads it as the freedom it always had.
Input
| Field | Type | Required | Description |
|---|---|---|---|
provider | string | yes | WHICH provider to ask — the addonId a { row carries. Required for the same reason listClips requires it: a collection cap has no "the bound one" to resolve to. |
Output
What a surface may DRAW for this provider's clips — the answer to {
The envelope is a PROVIDER fact, not a clip fact, and that is measured, not assumed: the broker's chooseClipPath reads exactly two inputs — whether dialClipStream and readClipBytes are wired — and both are constants of the broker's own closure over the provider's methods. The profile it is handed is explicitly not read. So every clip of a provider is served the same way, and a per-clip channel carried a value that could not vary. The per-clip clipTransport server message was removed for exactly that reason.
Queried per camera, before a clip is picked, so a control is rendered or DISABLED rather than offered and refused at play time.
| Field | Type | Required | Description |
|---|---|---|---|
transport | "stream" | "file" | yes | How this provider's clips reach the player. stream is the provider's forward-only fMP4; file is one bounded by-handle fetch of the whole clip, stbl indexed. |
seek | "forward" | "free" | yes | forward = only ahead of the playhead. free = anywhere. |
stepBack | boolean | yes | Frame-step BACKWARD is meaningful. Forward always is. |
scrub | boolean | yes | Whether the scrub gesture is served, as opposed to refused by name. |
rates | number[] | yes | The rates that can be delivered, ascending, always containing 1. The viewer draws its picker from this and from nothing else — a constant it keeps instead is the second authority that produced the defect: 8 and 16 were offered, the broker clamped them to 4, and no line anywhere said so. 0 is not a member: pause is the absence of a rate. |