@camstack/addon-provider-hikvision 1.2.126 → 1.2.131
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/addon.js +2258 -1706
- package/dist/addon.mjs +2258 -1706
- package/package.json +1 -1
package/dist/addon.js
CHANGED
|
@@ -5372,7 +5372,7 @@ var ZodIssueCode = {
|
|
|
5372
5372
|
var ZodFirstPartyTypeKind;
|
|
5373
5373
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5374
5374
|
//#endregion
|
|
5375
|
-
//#region ../types/dist/sleep-
|
|
5375
|
+
//#region ../types/dist/sleep-PEo0-Fz9.mjs
|
|
5376
5376
|
/**
|
|
5377
5377
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5378
5378
|
* window to float samples (D455).
|
|
@@ -6508,6 +6508,24 @@ function normalizeAddonInitResult(result) {
|
|
|
6508
6508
|
if (Array.isArray(result)) return { providers: result };
|
|
6509
6509
|
return result;
|
|
6510
6510
|
}
|
|
6511
|
+
/** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
|
|
6512
|
+
var PeerBytesTicketSchema = object({
|
|
6513
|
+
/** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
|
|
6514
|
+
url: string().min(1),
|
|
6515
|
+
/**
|
|
6516
|
+
* The HOST node this URL means something on — the hub or a named agent,
|
|
6517
|
+
* never a runner. {@link AddonPeerBytes.open} compares it to its own and
|
|
6518
|
+
* refuses `cross-node` by name when they differ, without dialling.
|
|
6519
|
+
*/
|
|
6520
|
+
hostNodeId: string().min(1),
|
|
6521
|
+
expiresAtMs: number().int().nonnegative(),
|
|
6522
|
+
/**
|
|
6523
|
+
* What the producer DECLARED the body to be, when it knows — `null` when it
|
|
6524
|
+
* does not. Never `0` for unknown (D393): a consumer sizing a bound off this
|
|
6525
|
+
* must be able to tell "the producer did not say" from "the body is empty".
|
|
6526
|
+
*/
|
|
6527
|
+
declaredBytes: number().int().nonnegative().nullable()
|
|
6528
|
+
});
|
|
6511
6529
|
/** Shared Zod schemas used across streaming capabilities. */
|
|
6512
6530
|
var CamProfileSchema = _enum([
|
|
6513
6531
|
"high",
|
|
@@ -7542,24 +7560,6 @@ object({
|
|
|
7542
7560
|
unreachable: number()
|
|
7543
7561
|
})
|
|
7544
7562
|
});
|
|
7545
|
-
/** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
|
|
7546
|
-
var PeerBytesTicketSchema = object({
|
|
7547
|
-
/** `http://127.0.0.1:<port>/<token>`. One `GET` takes it. */
|
|
7548
|
-
url: string().min(1),
|
|
7549
|
-
/**
|
|
7550
|
-
* The HOST node this URL means something on — the hub or a named agent,
|
|
7551
|
-
* never a runner. {@link AddonPeerBytes.open} compares it to its own and
|
|
7552
|
-
* refuses `cross-node` by name when they differ, without dialling.
|
|
7553
|
-
*/
|
|
7554
|
-
hostNodeId: string().min(1),
|
|
7555
|
-
expiresAtMs: number().int().nonnegative(),
|
|
7556
|
-
/**
|
|
7557
|
-
* What the producer DECLARED the body to be, when it knows — `null` when it
|
|
7558
|
-
* does not. Never `0` for unknown (D393): a consumer sizing a bound off this
|
|
7559
|
-
* must be able to tell "the producer did not say" from "the body is empty".
|
|
7560
|
-
*/
|
|
7561
|
-
declaredBytes: number().int().nonnegative().nullable()
|
|
7562
|
-
});
|
|
7563
7563
|
/**
|
|
7564
7564
|
* Adoption job — the background form of `device-adoption.adopt`.
|
|
7565
7565
|
*
|
|
@@ -7671,7 +7671,7 @@ var AdoptionJobSchema = object({
|
|
|
7671
7671
|
* component's original options — detection to the detection-pipeline wrapper
|
|
7672
7672
|
* binding, audio analysis to its own, recording to `RecordingConfig.enabled`
|
|
7673
7673
|
* (which was always first-class; the switch was a veneer over
|
|
7674
|
-
* `
|
|
7674
|
+
* `recordingArchive.setDeviceConfig`), notifications to a notification-center
|
|
7675
7675
|
* per-device setting, the two camera planes to their own components.
|
|
7676
7676
|
*
|
|
7677
7677
|
* What survives is {@link composeSwitchedOff}: `CameraStatus.switchedOff`, the
|
|
@@ -7697,7 +7697,7 @@ var AdoptionJobSchema = object({
|
|
|
7697
7697
|
* | `stream-broker` | `deviceManager.setDisabled` | `StreamBrokerManager.reconcileAllCatalogs` releases the brokers; `ensureBroker` refuses re-creation |
|
|
7698
7698
|
* | `object-detection` | `deviceManager.setWrapperActive('detection-pipeline')` | `PipelineSettingsStore.resolvePipelineForDevice` returns `{ steps: [], audio: null }` |
|
|
7699
7699
|
* | `audio-analysis` | `deviceManager.setWrapperActive('audio-analysis')` | `AudioSubscriptionController.subscribeAudioStream` returns `null` before opening the stream |
|
|
7700
|
-
* | `recording` | `
|
|
7700
|
+
* | `recording` | `recordingArchive.setDeviceConfig` → `RecordingConfig.enabled` | `band-decision.shouldRecord` returns false; the controller detaches the device |
|
|
7701
7701
|
* | `notifications` | `notificationRules.setDeviceMuted` | `NotificationCenter.evaluateAndEnqueue` returns before any rule is evaluated |
|
|
7702
7702
|
* | `privacy-mask` | `privacyMask.setMask({ enabled })` → the CAMERA | the camera blanks the masked regions itself; every stream and recording carries the black boxes |
|
|
7703
7703
|
* | `device-audio` | `privacyMask.setAudioEnabled` → the CAMERA | the camera stops encoding an audio track at all; every consumer sees silent video |
|
|
@@ -11876,87 +11876,6 @@ method(ListInputSchema, array(BrokerInfoSchema$1)), method(GetInputSchema, Broke
|
|
|
11876
11876
|
auth: "admin"
|
|
11877
11877
|
}), method(GetStateInputSchema, unknown().nullable()), method(_void(), RegistryStatusSchema);
|
|
11878
11878
|
DeviceType.Camera;
|
|
11879
|
-
/**
|
|
11880
|
-
* The signals a device can emit to WAKE its own stream.
|
|
11881
|
-
*
|
|
11882
|
-
* A camera whose stream is built on demand sleeps until something asks for it,
|
|
11883
|
-
* and "something" cannot be a consumer that is merely attached — a Frigate-style
|
|
11884
|
-
* puller holds a session open for ever, and treating that as demand would keep
|
|
11885
|
-
* a battery camera awake for ever, which is the whole thing the battery is for
|
|
11886
|
-
* (D173). So the wake has to come from the CAMERA: an event it noticed by
|
|
11887
|
-
* itself, with no stream running.
|
|
11888
|
-
*
|
|
11889
|
-
* ## The vocabulary is the PROVIDER'S, not ours
|
|
11890
|
-
*
|
|
11891
|
-
* Like `consumables`, this cap declares no vocabulary of its own. A provider
|
|
11892
|
-
* names each signal with a `code` it chooses and a `label` an operator reads.
|
|
11893
|
-
* Reolink offers motion and camera-native detection; another provider may offer
|
|
11894
|
-
* a tamper, a doorbell press, a PIR, or something no camera in this fleet has
|
|
11895
|
-
* yet. A fixed enum here would mean every new signal is a framework release.
|
|
11896
|
-
*
|
|
11897
|
-
* It is deliberately NOT derived from the caps a device already binds. Whether
|
|
11898
|
-
* a camera CAN push firmware motion is expressed by `motionSources` containing
|
|
11899
|
-
* `'onboard'`, and whether it does AI on-camera by the `native-object-detection`
|
|
11900
|
-
* binding — but both answer "what drives the detection pipeline", which is a
|
|
11901
|
-
* different question from "what may wake a sleeping stream". A camera can do
|
|
11902
|
-
* the first and not be trusted with the second, and the operator picks per
|
|
11903
|
-
* camera. Two questions, two authorities.
|
|
11904
|
-
*
|
|
11905
|
-
* ## Availability is not permission
|
|
11906
|
-
*
|
|
11907
|
-
* `listSignals` says what the device CAN emit. Whether a given signal actually
|
|
11908
|
-
* wakes the stream is the operator's per-camera choice, held by the broker
|
|
11909
|
-
* alongside the cooldown — see the stream-broker cap's wake settings. A
|
|
11910
|
-
* provider declaring a signal is not a provider enabling it.
|
|
11911
|
-
*/
|
|
11912
|
-
/** One signal a device can emit. */
|
|
11913
|
-
var StreamSignalSchema = object({
|
|
11914
|
-
/** Stable id chosen by the provider, e.g. `'motion'`, `'person'`, `'tamper'`. */
|
|
11915
|
-
code: string().min(1),
|
|
11916
|
-
/** What an operator reads in the picker. The provider's own wording. */
|
|
11917
|
-
label: string().min(1),
|
|
11918
|
-
/**
|
|
11919
|
-
* Whether the provider recommends this signal ON when a camera is first set
|
|
11920
|
-
* up. A provider knows which of its signals are cheap and reliable; an
|
|
11921
|
-
* operator should not have to discover that by trial. Reolink recommends
|
|
11922
|
-
* both of its own.
|
|
11923
|
-
*/
|
|
11924
|
-
recommended: boolean()
|
|
11925
|
-
});
|
|
11926
|
-
var StreamSignalsStatusSchema = object({
|
|
11927
|
-
signals: array(StreamSignalSchema),
|
|
11928
|
-
lastFetchedAt: number()
|
|
11929
|
-
});
|
|
11930
|
-
var streamSignalsCapability = {
|
|
11931
|
-
name: "stream-signals",
|
|
11932
|
-
scope: "device",
|
|
11933
|
-
deviceNative: true,
|
|
11934
|
-
mode: "singleton",
|
|
11935
|
-
deviceTypes: Object.values(DeviceType),
|
|
11936
|
-
runtimeState: StreamSignalsStatusSchema,
|
|
11937
|
-
/**
|
|
11938
|
-
* Runtime-state durability: **session** — mirrored in RAM, never written.
|
|
11939
|
-
*
|
|
11940
|
-
* The slice holds what the DEVICE says it can emit. That is a probed fact,
|
|
11941
|
-
* not an operator choice: the provider re-declares it on every registration,
|
|
11942
|
-
* so losing it loses nothing and persisting it would freeze an answer the
|
|
11943
|
-
* camera is entitled to change. Measured the same day on the sibling case —
|
|
11944
|
-
* `native-object-detection.supportedClasses` was persisted, and a firmware
|
|
11945
|
-
* class the camera really detected stayed missing for the life of the row
|
|
11946
|
-
* because the fix could not reach it.
|
|
11947
|
-
*
|
|
11948
|
-
* See `RuntimeStateDurability`. Enforced by
|
|
11949
|
-
* `scripts/check-runtime-state-durability.ts`.
|
|
11950
|
-
*/
|
|
11951
|
-
durability: "session",
|
|
11952
|
-
methods: {
|
|
11953
|
-
/**
|
|
11954
|
-
* What this device can emit. Empty is a valid and common answer — most
|
|
11955
|
-
* cameras have nothing to offer here, and an empty list is what makes the
|
|
11956
|
-
* broker's picker show nothing rather than a false choice.
|
|
11957
|
-
*/
|
|
11958
|
-
listSignals: method(_void(), array(StreamSignalSchema).readonly()) }
|
|
11959
|
-
};
|
|
11960
11879
|
/** Stream delivery format. (Relocated from the retired `streaming-engine` cap.) */
|
|
11961
11880
|
var StreamFormatSchema = _enum([
|
|
11962
11881
|
"webrtc",
|
|
@@ -13422,6 +13341,210 @@ method(object({ codec: string() }), boolean()), method(_void(), object({
|
|
|
13422
13341
|
});
|
|
13423
13342
|
DeviceType.Camera;
|
|
13424
13343
|
/**
|
|
13344
|
+
* device-admin-link — "this device has a management page of its own, and here
|
|
13345
|
+
* is its address".
|
|
13346
|
+
*
|
|
13347
|
+
* ## Why this is not a `deviceConfig` cap
|
|
13348
|
+
*
|
|
13349
|
+
* There is nothing to edit. A `deviceConfig` cap (D14) exists so the framework
|
|
13350
|
+
* can DERIVE a settings form from `getOptions` + `getStatus` and route a flat
|
|
13351
|
+
* patch back through a setter; it costs a `builderId` reducer in
|
|
13352
|
+
* `device-config-contribution.ts` and a `*-config-schema.ts` beside it, and it
|
|
13353
|
+
* renders a form section. This cap answers ONE question with ONE read and
|
|
13354
|
+
* renders a button. Nothing about it is a form, so it carries no `deviceConfig`
|
|
13355
|
+
* block, no `settings`, no `runtimeState` and no reducer — exactly like
|
|
13356
|
+
* `reboot`, the other pure-RPC device-native cap.
|
|
13357
|
+
*
|
|
13358
|
+
* ## Absent, and the difference between "no page" and "we cannot say"
|
|
13359
|
+
*
|
|
13360
|
+
* The two are answered at DIFFERENT layers, on purpose:
|
|
13361
|
+
*
|
|
13362
|
+
* - **"We cannot say"** → the provider never registers the cap for that
|
|
13363
|
+
* device. A VeSync humidifier, a Petkit feeder, a Dreame vacuum and a Dreo
|
|
13364
|
+
* fan are reached only through a vendor cloud; there is no address to hand
|
|
13365
|
+
* out and no page to open. A Tuya plug, a Wyze camera and a Gree air
|
|
13366
|
+
* conditioner DO have a LAN IP, and still have no HTTP management page
|
|
13367
|
+
* behind it. None of them register, so `deviceManager.getBindings` never
|
|
13368
|
+
* lists the cap and no surface asks.
|
|
13369
|
+
* - **"This device has no page, and I know that"** → the provider registers
|
|
13370
|
+
* and `getAdminLink` returns `null`. This is the answer for a device whose
|
|
13371
|
+
* sibling DOES have a page: a Reolink battery camera reached over UDP by
|
|
13372
|
+
* `uid` with a blank `host`, an Ecowitt gateway configured in `listener`
|
|
13373
|
+
* transport, a Home Assistant broker authenticated by supervisor token
|
|
13374
|
+
* (which carries no `baseUrl` at all).
|
|
13375
|
+
*
|
|
13376
|
+
* Both draw NOTHING. A button that opens a browser error is worse than no
|
|
13377
|
+
* button, and D62 is the same rule from the other side: an off switch is
|
|
13378
|
+
* reported off, never made to look broken. There is no third state where the
|
|
13379
|
+
* UI renders a disabled button "because the device might have a page".
|
|
13380
|
+
*
|
|
13381
|
+
* ## The URL never carries credentials
|
|
13382
|
+
*
|
|
13383
|
+
* Not in userinfo, not in a query string. Every provider builds through
|
|
13384
|
+
* `buildDeviceAdminUrl` (`device-admin-link-url.ts`), which takes host, port,
|
|
13385
|
+
* scheme and path as separate arguments — there is no parameter a secret could
|
|
13386
|
+
* arrive in — and re-checks its own output for the `scheme://user:pass@` shape
|
|
13387
|
+
* that `scripts/check-no-credential-urls-in-fixtures.ts` bans from recorded
|
|
13388
|
+
* output. `scripts/check-admin-link-builder-is-the-only-url-source.ts` is what
|
|
13389
|
+
* keeps providers from hand-rolling one anyway.
|
|
13390
|
+
*
|
|
13391
|
+
* This matters here more than anywhere else in the repo, because every provider
|
|
13392
|
+
* that knows a device's host knows its PASSWORD too: `{ host, port, username,
|
|
13393
|
+
* password }` sit in one object on Hikvision, Amcrest, Reolink and ONVIF alike,
|
|
13394
|
+
* and `http://admin:hunter2@192.168.50.139/` is a URL a browser accepts. The
|
|
13395
|
+
* camera's own page will ask for its own login. That is correct, and pre-
|
|
13396
|
+
* filling it is the operator's business, not ours.
|
|
13397
|
+
*
|
|
13398
|
+
* ## It is a LAN fact
|
|
13399
|
+
*
|
|
13400
|
+
* The URL addresses the device where the NODE can see it. It is not proxied,
|
|
13401
|
+
* not made reachable from outside, and not sent anywhere. A surface renders it
|
|
13402
|
+
* as a link the operator's own browser follows, on the operator's own network,
|
|
13403
|
+
* or renders nothing.
|
|
13404
|
+
*/
|
|
13405
|
+
/**
|
|
13406
|
+
* Whose page is it. The distinction is for the OPERATOR, who needs to know
|
|
13407
|
+
* before clicking whether he is about to land on a camera's own web server or
|
|
13408
|
+
* inside Home Assistant.
|
|
13409
|
+
*/
|
|
13410
|
+
var AdminLinkTargetEnum = _enum(["device", "integration"]);
|
|
13411
|
+
var DeviceAdminLinkSchema = object({
|
|
13412
|
+
/**
|
|
13413
|
+
* Absolute `http(s)://` URL. Built by `buildDeviceAdminUrl` and therefore
|
|
13414
|
+
* free of userinfo and of any credential-shaped query key.
|
|
13415
|
+
*/
|
|
13416
|
+
url: string(),
|
|
13417
|
+
/**
|
|
13418
|
+
* What the surface calls it — "Web UI", "Home Assistant", "UniFi controller".
|
|
13419
|
+
* The PROVIDER names it, because only the provider knows what the page is;
|
|
13420
|
+
* a UI that invented the label from the addon id would call the Home
|
|
13421
|
+
* Assistant device page "Provider Homeassistant".
|
|
13422
|
+
*/
|
|
13423
|
+
label: string(),
|
|
13424
|
+
target: AdminLinkTargetEnum,
|
|
13425
|
+
/**
|
|
13426
|
+
* Host the URL points at, without scheme, port or path — for the tooltip, so
|
|
13427
|
+
* an operator can see WHERE the button goes before he follows it. Redundant
|
|
13428
|
+
* with `url` by construction; carried separately so no surface has to parse
|
|
13429
|
+
* a URL to show it.
|
|
13430
|
+
*/
|
|
13431
|
+
host: string()
|
|
13432
|
+
});
|
|
13433
|
+
var deviceAdminLinkCapability = {
|
|
13434
|
+
name: "device-admin-link",
|
|
13435
|
+
scope: "device",
|
|
13436
|
+
deviceNative: true,
|
|
13437
|
+
mode: "singleton",
|
|
13438
|
+
methods: {
|
|
13439
|
+
/**
|
|
13440
|
+
* The device's management page, or `null` when this device has none.
|
|
13441
|
+
*
|
|
13442
|
+
* `auth: 'admin'` deliberately. This is administration, not actuation —
|
|
13443
|
+
* the same bucket as `reboot` and `camera-credentials`, and explicitly NOT
|
|
13444
|
+
* the actuation set `scripts/check-actuation-not-admin.ts` protects (D403).
|
|
13445
|
+
* The URL is also a statement about the LAN, which a household member with
|
|
13446
|
+
* a `view` grant on a light has no reason to be handed.
|
|
13447
|
+
*
|
|
13448
|
+
* The surfaces gate on the QUERY, never on a role they guessed: a caller
|
|
13449
|
+
* without the right loses the query and draws nothing, which is the same
|
|
13450
|
+
* thing a device with no page draws. There is no path on which a button
|
|
13451
|
+
* appears and then fails — the D403 failure mode, from the other end.
|
|
13452
|
+
*/
|
|
13453
|
+
getAdminLink: method(object({ deviceId: number().int().nonnegative() }), DeviceAdminLinkSchema.nullable(), { auth: "admin" }) }
|
|
13454
|
+
};
|
|
13455
|
+
/**
|
|
13456
|
+
* Query keys that may never appear on an admin link. A credential smuggled as
|
|
13457
|
+
* `?password=` is the same leak as userinfo, in a form the userinfo check
|
|
13458
|
+
* cannot see: it survives copy-paste, referrer headers and proxy logs
|
|
13459
|
+
* identically.
|
|
13460
|
+
*/
|
|
13461
|
+
var CREDENTIAL_QUERY_KEYS = [
|
|
13462
|
+
"password",
|
|
13463
|
+
"passwd",
|
|
13464
|
+
"pwd",
|
|
13465
|
+
"pass",
|
|
13466
|
+
"user",
|
|
13467
|
+
"username",
|
|
13468
|
+
"usr",
|
|
13469
|
+
"login",
|
|
13470
|
+
"token",
|
|
13471
|
+
"access_token",
|
|
13472
|
+
"auth",
|
|
13473
|
+
"authorization",
|
|
13474
|
+
"apikey",
|
|
13475
|
+
"api_key",
|
|
13476
|
+
"secret",
|
|
13477
|
+
"credential",
|
|
13478
|
+
"credentials",
|
|
13479
|
+
"session",
|
|
13480
|
+
"sessionid",
|
|
13481
|
+
"key"
|
|
13482
|
+
];
|
|
13483
|
+
/**
|
|
13484
|
+
* The same userinfo shape `scripts/check-no-credential-urls-in-fixtures.ts`
|
|
13485
|
+
* scans recorded fixtures for, applied to what we are about to EMIT. Kept
|
|
13486
|
+
* structurally identical on purpose: a URL this function returns is a URL that
|
|
13487
|
+
* guard would pass.
|
|
13488
|
+
*/
|
|
13489
|
+
var CREDENTIAL_URL = /[a-z][a-z0-9+.-]*:\/\/[^/\s:@'"]+:[^/\s:@'"]+@/i;
|
|
13490
|
+
/** A host that is safe to place in an authority component verbatim. */
|
|
13491
|
+
var PLAIN_HOST = /^[a-zA-Z0-9._-]+$/;
|
|
13492
|
+
/** A bracketed IPv6 literal, the only other authority form we emit. */
|
|
13493
|
+
var IPV6_HOST = /^\[[0-9a-fA-F:.]+\]$/;
|
|
13494
|
+
function defaultPortFor(scheme) {
|
|
13495
|
+
return scheme === "https" ? 443 : 80;
|
|
13496
|
+
}
|
|
13497
|
+
/**
|
|
13498
|
+
* Build the admin-page URL, or refuse by name.
|
|
13499
|
+
*
|
|
13500
|
+
* The refusal is never thrown: a provider answering "no page for this device"
|
|
13501
|
+
* is an ordinary answer (`getAdminLink` → `null`), and a throw here would turn
|
|
13502
|
+
* a missing host on one device into a failed query for the whole surface.
|
|
13503
|
+
*/
|
|
13504
|
+
function buildDeviceAdminUrl(parts) {
|
|
13505
|
+
const host = parts.host.trim();
|
|
13506
|
+
if (host.length === 0) return {
|
|
13507
|
+
ok: false,
|
|
13508
|
+
reason: "empty-host"
|
|
13509
|
+
};
|
|
13510
|
+
if (host.includes("@")) return {
|
|
13511
|
+
ok: false,
|
|
13512
|
+
reason: "host-carries-userinfo"
|
|
13513
|
+
};
|
|
13514
|
+
if (!PLAIN_HOST.test(host) && !IPV6_HOST.test(host)) return {
|
|
13515
|
+
ok: false,
|
|
13516
|
+
reason: "host-not-plain"
|
|
13517
|
+
};
|
|
13518
|
+
if (parts.port !== null) {
|
|
13519
|
+
if (!Number.isInteger(parts.port) || parts.port < 1 || parts.port > 65535) return {
|
|
13520
|
+
ok: false,
|
|
13521
|
+
reason: "port-out-of-range"
|
|
13522
|
+
};
|
|
13523
|
+
}
|
|
13524
|
+
if (!parts.path.startsWith("/")) return {
|
|
13525
|
+
ok: false,
|
|
13526
|
+
reason: "path-not-absolute"
|
|
13527
|
+
};
|
|
13528
|
+
const query = parts.query ?? {};
|
|
13529
|
+
for (const key of Object.keys(query)) if (CREDENTIAL_QUERY_KEYS.includes(key.toLowerCase())) return {
|
|
13530
|
+
ok: false,
|
|
13531
|
+
reason: "credential-query-key"
|
|
13532
|
+
};
|
|
13533
|
+
const authority = parts.port === null || parts.port === defaultPortFor(parts.scheme) ? host : `${host}:${String(parts.port)}`;
|
|
13534
|
+
const search = new URLSearchParams();
|
|
13535
|
+
for (const [key, value] of Object.entries(query)) search.append(key, value);
|
|
13536
|
+
const suffix = search.size > 0 ? `?${search.toString()}` : "";
|
|
13537
|
+
const url = `${parts.scheme}://${authority}${parts.path}${suffix}`;
|
|
13538
|
+
if (CREDENTIAL_URL.test(url)) return {
|
|
13539
|
+
ok: false,
|
|
13540
|
+
reason: "userinfo-in-result"
|
|
13541
|
+
};
|
|
13542
|
+
return {
|
|
13543
|
+
ok: true,
|
|
13544
|
+
url
|
|
13545
|
+
};
|
|
13546
|
+
}
|
|
13547
|
+
/**
|
|
13425
13548
|
* Identity envelope for a device's upstream-system metadata.
|
|
13426
13549
|
*
|
|
13427
13550
|
* Two jobs:
|
|
@@ -13856,210 +13979,6 @@ method(object({ integrationId: string() }), object({ filters: array(AdoptionFilt
|
|
|
13856
13979
|
auth: "admin"
|
|
13857
13980
|
});
|
|
13858
13981
|
/**
|
|
13859
|
-
* device-admin-link — "this device has a management page of its own, and here
|
|
13860
|
-
* is its address".
|
|
13861
|
-
*
|
|
13862
|
-
* ## Why this is not a `deviceConfig` cap
|
|
13863
|
-
*
|
|
13864
|
-
* There is nothing to edit. A `deviceConfig` cap (D14) exists so the framework
|
|
13865
|
-
* can DERIVE a settings form from `getOptions` + `getStatus` and route a flat
|
|
13866
|
-
* patch back through a setter; it costs a `builderId` reducer in
|
|
13867
|
-
* `device-config-contribution.ts` and a `*-config-schema.ts` beside it, and it
|
|
13868
|
-
* renders a form section. This cap answers ONE question with ONE read and
|
|
13869
|
-
* renders a button. Nothing about it is a form, so it carries no `deviceConfig`
|
|
13870
|
-
* block, no `settings`, no `runtimeState` and no reducer — exactly like
|
|
13871
|
-
* `reboot`, the other pure-RPC device-native cap.
|
|
13872
|
-
*
|
|
13873
|
-
* ## Absent, and the difference between "no page" and "we cannot say"
|
|
13874
|
-
*
|
|
13875
|
-
* The two are answered at DIFFERENT layers, on purpose:
|
|
13876
|
-
*
|
|
13877
|
-
* - **"We cannot say"** → the provider never registers the cap for that
|
|
13878
|
-
* device. A VeSync humidifier, a Petkit feeder, a Dreame vacuum and a Dreo
|
|
13879
|
-
* fan are reached only through a vendor cloud; there is no address to hand
|
|
13880
|
-
* out and no page to open. A Tuya plug, a Wyze camera and a Gree air
|
|
13881
|
-
* conditioner DO have a LAN IP, and still have no HTTP management page
|
|
13882
|
-
* behind it. None of them register, so `deviceManager.getBindings` never
|
|
13883
|
-
* lists the cap and no surface asks.
|
|
13884
|
-
* - **"This device has no page, and I know that"** → the provider registers
|
|
13885
|
-
* and `getAdminLink` returns `null`. This is the answer for a device whose
|
|
13886
|
-
* sibling DOES have a page: a Reolink battery camera reached over UDP by
|
|
13887
|
-
* `uid` with a blank `host`, an Ecowitt gateway configured in `listener`
|
|
13888
|
-
* transport, a Home Assistant broker authenticated by supervisor token
|
|
13889
|
-
* (which carries no `baseUrl` at all).
|
|
13890
|
-
*
|
|
13891
|
-
* Both draw NOTHING. A button that opens a browser error is worse than no
|
|
13892
|
-
* button, and D62 is the same rule from the other side: an off switch is
|
|
13893
|
-
* reported off, never made to look broken. There is no third state where the
|
|
13894
|
-
* UI renders a disabled button "because the device might have a page".
|
|
13895
|
-
*
|
|
13896
|
-
* ## The URL never carries credentials
|
|
13897
|
-
*
|
|
13898
|
-
* Not in userinfo, not in a query string. Every provider builds through
|
|
13899
|
-
* `buildDeviceAdminUrl` (`device-admin-link-url.ts`), which takes host, port,
|
|
13900
|
-
* scheme and path as separate arguments — there is no parameter a secret could
|
|
13901
|
-
* arrive in — and re-checks its own output for the `scheme://user:pass@` shape
|
|
13902
|
-
* that `scripts/check-no-credential-urls-in-fixtures.ts` bans from recorded
|
|
13903
|
-
* output. `scripts/check-admin-link-builder-is-the-only-url-source.ts` is what
|
|
13904
|
-
* keeps providers from hand-rolling one anyway.
|
|
13905
|
-
*
|
|
13906
|
-
* This matters here more than anywhere else in the repo, because every provider
|
|
13907
|
-
* that knows a device's host knows its PASSWORD too: `{ host, port, username,
|
|
13908
|
-
* password }` sit in one object on Hikvision, Amcrest, Reolink and ONVIF alike,
|
|
13909
|
-
* and `http://admin:hunter2@192.168.50.139/` is a URL a browser accepts. The
|
|
13910
|
-
* camera's own page will ask for its own login. That is correct, and pre-
|
|
13911
|
-
* filling it is the operator's business, not ours.
|
|
13912
|
-
*
|
|
13913
|
-
* ## It is a LAN fact
|
|
13914
|
-
*
|
|
13915
|
-
* The URL addresses the device where the NODE can see it. It is not proxied,
|
|
13916
|
-
* not made reachable from outside, and not sent anywhere. A surface renders it
|
|
13917
|
-
* as a link the operator's own browser follows, on the operator's own network,
|
|
13918
|
-
* or renders nothing.
|
|
13919
|
-
*/
|
|
13920
|
-
/**
|
|
13921
|
-
* Whose page is it. The distinction is for the OPERATOR, who needs to know
|
|
13922
|
-
* before clicking whether he is about to land on a camera's own web server or
|
|
13923
|
-
* inside Home Assistant.
|
|
13924
|
-
*/
|
|
13925
|
-
var AdminLinkTargetEnum = _enum(["device", "integration"]);
|
|
13926
|
-
var DeviceAdminLinkSchema = object({
|
|
13927
|
-
/**
|
|
13928
|
-
* Absolute `http(s)://` URL. Built by `buildDeviceAdminUrl` and therefore
|
|
13929
|
-
* free of userinfo and of any credential-shaped query key.
|
|
13930
|
-
*/
|
|
13931
|
-
url: string(),
|
|
13932
|
-
/**
|
|
13933
|
-
* What the surface calls it — "Web UI", "Home Assistant", "UniFi controller".
|
|
13934
|
-
* The PROVIDER names it, because only the provider knows what the page is;
|
|
13935
|
-
* a UI that invented the label from the addon id would call the Home
|
|
13936
|
-
* Assistant device page "Provider Homeassistant".
|
|
13937
|
-
*/
|
|
13938
|
-
label: string(),
|
|
13939
|
-
target: AdminLinkTargetEnum,
|
|
13940
|
-
/**
|
|
13941
|
-
* Host the URL points at, without scheme, port or path — for the tooltip, so
|
|
13942
|
-
* an operator can see WHERE the button goes before he follows it. Redundant
|
|
13943
|
-
* with `url` by construction; carried separately so no surface has to parse
|
|
13944
|
-
* a URL to show it.
|
|
13945
|
-
*/
|
|
13946
|
-
host: string()
|
|
13947
|
-
});
|
|
13948
|
-
var deviceAdminLinkCapability = {
|
|
13949
|
-
name: "device-admin-link",
|
|
13950
|
-
scope: "device",
|
|
13951
|
-
deviceNative: true,
|
|
13952
|
-
mode: "singleton",
|
|
13953
|
-
methods: {
|
|
13954
|
-
/**
|
|
13955
|
-
* The device's management page, or `null` when this device has none.
|
|
13956
|
-
*
|
|
13957
|
-
* `auth: 'admin'` deliberately. This is administration, not actuation —
|
|
13958
|
-
* the same bucket as `reboot` and `camera-credentials`, and explicitly NOT
|
|
13959
|
-
* the actuation set `scripts/check-actuation-not-admin.ts` protects (D403).
|
|
13960
|
-
* The URL is also a statement about the LAN, which a household member with
|
|
13961
|
-
* a `view` grant on a light has no reason to be handed.
|
|
13962
|
-
*
|
|
13963
|
-
* The surfaces gate on the QUERY, never on a role they guessed: a caller
|
|
13964
|
-
* without the right loses the query and draws nothing, which is the same
|
|
13965
|
-
* thing a device with no page draws. There is no path on which a button
|
|
13966
|
-
* appears and then fails — the D403 failure mode, from the other end.
|
|
13967
|
-
*/
|
|
13968
|
-
getAdminLink: method(object({ deviceId: number().int().nonnegative() }), DeviceAdminLinkSchema.nullable(), { auth: "admin" }) }
|
|
13969
|
-
};
|
|
13970
|
-
/**
|
|
13971
|
-
* Query keys that may never appear on an admin link. A credential smuggled as
|
|
13972
|
-
* `?password=` is the same leak as userinfo, in a form the userinfo check
|
|
13973
|
-
* cannot see: it survives copy-paste, referrer headers and proxy logs
|
|
13974
|
-
* identically.
|
|
13975
|
-
*/
|
|
13976
|
-
var CREDENTIAL_QUERY_KEYS = [
|
|
13977
|
-
"password",
|
|
13978
|
-
"passwd",
|
|
13979
|
-
"pwd",
|
|
13980
|
-
"pass",
|
|
13981
|
-
"user",
|
|
13982
|
-
"username",
|
|
13983
|
-
"usr",
|
|
13984
|
-
"login",
|
|
13985
|
-
"token",
|
|
13986
|
-
"access_token",
|
|
13987
|
-
"auth",
|
|
13988
|
-
"authorization",
|
|
13989
|
-
"apikey",
|
|
13990
|
-
"api_key",
|
|
13991
|
-
"secret",
|
|
13992
|
-
"credential",
|
|
13993
|
-
"credentials",
|
|
13994
|
-
"session",
|
|
13995
|
-
"sessionid",
|
|
13996
|
-
"key"
|
|
13997
|
-
];
|
|
13998
|
-
/**
|
|
13999
|
-
* The same userinfo shape `scripts/check-no-credential-urls-in-fixtures.ts`
|
|
14000
|
-
* scans recorded fixtures for, applied to what we are about to EMIT. Kept
|
|
14001
|
-
* structurally identical on purpose: a URL this function returns is a URL that
|
|
14002
|
-
* guard would pass.
|
|
14003
|
-
*/
|
|
14004
|
-
var CREDENTIAL_URL = /[a-z][a-z0-9+.-]*:\/\/[^/\s:@'"]+:[^/\s:@'"]+@/i;
|
|
14005
|
-
/** A host that is safe to place in an authority component verbatim. */
|
|
14006
|
-
var PLAIN_HOST = /^[a-zA-Z0-9._-]+$/;
|
|
14007
|
-
/** A bracketed IPv6 literal, the only other authority form we emit. */
|
|
14008
|
-
var IPV6_HOST = /^\[[0-9a-fA-F:.]+\]$/;
|
|
14009
|
-
function defaultPortFor(scheme) {
|
|
14010
|
-
return scheme === "https" ? 443 : 80;
|
|
14011
|
-
}
|
|
14012
|
-
/**
|
|
14013
|
-
* Build the admin-page URL, or refuse by name.
|
|
14014
|
-
*
|
|
14015
|
-
* The refusal is never thrown: a provider answering "no page for this device"
|
|
14016
|
-
* is an ordinary answer (`getAdminLink` → `null`), and a throw here would turn
|
|
14017
|
-
* a missing host on one device into a failed query for the whole surface.
|
|
14018
|
-
*/
|
|
14019
|
-
function buildDeviceAdminUrl(parts) {
|
|
14020
|
-
const host = parts.host.trim();
|
|
14021
|
-
if (host.length === 0) return {
|
|
14022
|
-
ok: false,
|
|
14023
|
-
reason: "empty-host"
|
|
14024
|
-
};
|
|
14025
|
-
if (host.includes("@")) return {
|
|
14026
|
-
ok: false,
|
|
14027
|
-
reason: "host-carries-userinfo"
|
|
14028
|
-
};
|
|
14029
|
-
if (!PLAIN_HOST.test(host) && !IPV6_HOST.test(host)) return {
|
|
14030
|
-
ok: false,
|
|
14031
|
-
reason: "host-not-plain"
|
|
14032
|
-
};
|
|
14033
|
-
if (parts.port !== null) {
|
|
14034
|
-
if (!Number.isInteger(parts.port) || parts.port < 1 || parts.port > 65535) return {
|
|
14035
|
-
ok: false,
|
|
14036
|
-
reason: "port-out-of-range"
|
|
14037
|
-
};
|
|
14038
|
-
}
|
|
14039
|
-
if (!parts.path.startsWith("/")) return {
|
|
14040
|
-
ok: false,
|
|
14041
|
-
reason: "path-not-absolute"
|
|
14042
|
-
};
|
|
14043
|
-
const query = parts.query ?? {};
|
|
14044
|
-
for (const key of Object.keys(query)) if (CREDENTIAL_QUERY_KEYS.includes(key.toLowerCase())) return {
|
|
14045
|
-
ok: false,
|
|
14046
|
-
reason: "credential-query-key"
|
|
14047
|
-
};
|
|
14048
|
-
const authority = parts.port === null || parts.port === defaultPortFor(parts.scheme) ? host : `${host}:${String(parts.port)}`;
|
|
14049
|
-
const search = new URLSearchParams();
|
|
14050
|
-
for (const [key, value] of Object.entries(query)) search.append(key, value);
|
|
14051
|
-
const suffix = search.size > 0 ? `?${search.toString()}` : "";
|
|
14052
|
-
const url = `${parts.scheme}://${authority}${parts.path}${suffix}`;
|
|
14053
|
-
if (CREDENTIAL_URL.test(url)) return {
|
|
14054
|
-
ok: false,
|
|
14055
|
-
reason: "userinfo-in-result"
|
|
14056
|
-
};
|
|
14057
|
-
return {
|
|
14058
|
-
ok: true,
|
|
14059
|
-
url
|
|
14060
|
-
};
|
|
14061
|
-
}
|
|
14062
|
-
/**
|
|
14063
13982
|
* `device-export` — collection cap for addons that export camstack
|
|
14064
13983
|
* devices to external ecosystems (HomeAssistant via MQTT discovery,
|
|
14065
13984
|
* HomeKit/HAP, Alexa Smart Home, …).
|
|
@@ -24461,6 +24380,87 @@ method(_void(), ProviderInfoSchema, { auth: "admin" }), method(object({ config:
|
|
|
24461
24380
|
kind: "mutation",
|
|
24462
24381
|
auth: "admin"
|
|
24463
24382
|
});
|
|
24383
|
+
/**
|
|
24384
|
+
* The signals a device can emit to WAKE its own stream.
|
|
24385
|
+
*
|
|
24386
|
+
* A camera whose stream is built on demand sleeps until something asks for it,
|
|
24387
|
+
* and "something" cannot be a consumer that is merely attached — a Frigate-style
|
|
24388
|
+
* puller holds a session open for ever, and treating that as demand would keep
|
|
24389
|
+
* a battery camera awake for ever, which is the whole thing the battery is for
|
|
24390
|
+
* (D173). So the wake has to come from the CAMERA: an event it noticed by
|
|
24391
|
+
* itself, with no stream running.
|
|
24392
|
+
*
|
|
24393
|
+
* ## The vocabulary is the PROVIDER'S, not ours
|
|
24394
|
+
*
|
|
24395
|
+
* Like `consumables`, this cap declares no vocabulary of its own. A provider
|
|
24396
|
+
* names each signal with a `code` it chooses and a `label` an operator reads.
|
|
24397
|
+
* Reolink offers motion and camera-native detection; another provider may offer
|
|
24398
|
+
* a tamper, a doorbell press, a PIR, or something no camera in this fleet has
|
|
24399
|
+
* yet. A fixed enum here would mean every new signal is a framework release.
|
|
24400
|
+
*
|
|
24401
|
+
* It is deliberately NOT derived from the caps a device already binds. Whether
|
|
24402
|
+
* a camera CAN push firmware motion is expressed by `motionSources` containing
|
|
24403
|
+
* `'onboard'`, and whether it does AI on-camera by the `native-object-detection`
|
|
24404
|
+
* binding — but both answer "what drives the detection pipeline", which is a
|
|
24405
|
+
* different question from "what may wake a sleeping stream". A camera can do
|
|
24406
|
+
* the first and not be trusted with the second, and the operator picks per
|
|
24407
|
+
* camera. Two questions, two authorities.
|
|
24408
|
+
*
|
|
24409
|
+
* ## Availability is not permission
|
|
24410
|
+
*
|
|
24411
|
+
* `listSignals` says what the device CAN emit. Whether a given signal actually
|
|
24412
|
+
* wakes the stream is the operator's per-camera choice, held by the broker
|
|
24413
|
+
* alongside the cooldown — see the stream-broker cap's wake settings. A
|
|
24414
|
+
* provider declaring a signal is not a provider enabling it.
|
|
24415
|
+
*/
|
|
24416
|
+
/** One signal a device can emit. */
|
|
24417
|
+
var StreamSignalSchema = object({
|
|
24418
|
+
/** Stable id chosen by the provider, e.g. `'motion'`, `'person'`, `'tamper'`. */
|
|
24419
|
+
code: string().min(1),
|
|
24420
|
+
/** What an operator reads in the picker. The provider's own wording. */
|
|
24421
|
+
label: string().min(1),
|
|
24422
|
+
/**
|
|
24423
|
+
* Whether the provider recommends this signal ON when a camera is first set
|
|
24424
|
+
* up. A provider knows which of its signals are cheap and reliable; an
|
|
24425
|
+
* operator should not have to discover that by trial. Reolink recommends
|
|
24426
|
+
* both of its own.
|
|
24427
|
+
*/
|
|
24428
|
+
recommended: boolean()
|
|
24429
|
+
});
|
|
24430
|
+
var StreamSignalsStatusSchema = object({
|
|
24431
|
+
signals: array(StreamSignalSchema),
|
|
24432
|
+
lastFetchedAt: number()
|
|
24433
|
+
});
|
|
24434
|
+
var streamSignalsCapability = {
|
|
24435
|
+
name: "stream-signals",
|
|
24436
|
+
scope: "device",
|
|
24437
|
+
deviceNative: true,
|
|
24438
|
+
mode: "singleton",
|
|
24439
|
+
deviceTypes: Object.values(DeviceType),
|
|
24440
|
+
runtimeState: StreamSignalsStatusSchema,
|
|
24441
|
+
/**
|
|
24442
|
+
* Runtime-state durability: **session** — mirrored in RAM, never written.
|
|
24443
|
+
*
|
|
24444
|
+
* The slice holds what the DEVICE says it can emit. That is a probed fact,
|
|
24445
|
+
* not an operator choice: the provider re-declares it on every registration,
|
|
24446
|
+
* so losing it loses nothing and persisting it would freeze an answer the
|
|
24447
|
+
* camera is entitled to change. Measured the same day on the sibling case —
|
|
24448
|
+
* `native-object-detection.supportedClasses` was persisted, and a firmware
|
|
24449
|
+
* class the camera really detected stayed missing for the life of the row
|
|
24450
|
+
* because the fix could not reach it.
|
|
24451
|
+
*
|
|
24452
|
+
* See `RuntimeStateDurability`. Enforced by
|
|
24453
|
+
* `scripts/check-runtime-state-durability.ts`.
|
|
24454
|
+
*/
|
|
24455
|
+
durability: "session",
|
|
24456
|
+
methods: {
|
|
24457
|
+
/**
|
|
24458
|
+
* What this device can emit. Empty is a valid and common answer — most
|
|
24459
|
+
* cameras have nothing to offer here, and an empty list is what makes the
|
|
24460
|
+
* broker's picker show nothing rather than a false choice.
|
|
24461
|
+
*/
|
|
24462
|
+
listSignals: method(_void(), array(StreamSignalSchema).readonly()) }
|
|
24463
|
+
};
|
|
24464
24464
|
/** Profile-exported FormBuilder schema. Shape is ConfigUISchema at the UI. */
|
|
24465
24465
|
var ProfileSettingsSchemaBridge = unknown().nullable();
|
|
24466
24466
|
var ProfileSettingsBagSchema = record(string(), unknown());
|
|
@@ -25501,27 +25501,74 @@ var ClipStreamDialSchema = object({
|
|
|
25501
25501
|
audioReason: ClipStreamAudioReasonSchema.optional()
|
|
25502
25502
|
});
|
|
25503
25503
|
/**
|
|
25504
|
-
* The playback rates
|
|
25504
|
+
* The playback rates the broker can pace over media it HOLDS, ascending,
|
|
25505
|
+
* always with `1` — and the WIDEST ladder there is. It is the domain the
|
|
25506
|
+
* broker's `clampPlaybackRate` is derived from, at both ends.
|
|
25505
25507
|
*
|
|
25506
25508
|
* These are the BROKER's: it re-paces frames it has already demuxed — the
|
|
25507
25509
|
* `MonotonicClock` divides source elapsed time by the factor and the pacer
|
|
25508
|
-
* pushes that much faster
|
|
25509
|
-
*
|
|
25510
|
-
*
|
|
25511
|
-
*
|
|
25512
|
-
*
|
|
25513
|
-
* `<playSpeed>`
|
|
25514
|
-
*
|
|
25515
|
-
*
|
|
25516
|
-
*
|
|
25517
|
-
*
|
|
25518
|
-
*
|
|
25519
|
-
*
|
|
25520
|
-
*
|
|
25521
|
-
*
|
|
25522
|
-
*
|
|
25510
|
+
* pushes that much faster. `1.5` is in it because a re-pacer has no reason to
|
|
25511
|
+
* refuse it.
|
|
25512
|
+
*
|
|
25513
|
+
* **`8` is here since D621, and it is the pacer's, not a camera's.** D620
|
|
25514
|
+
* measured the thing that was assumed for a year and was never true: a
|
|
25515
|
+
* Reolink `<playSpeed>` does not time-compress anything. At 1, 2, 4 and 8 the
|
|
25516
|
+
* transfer is byte-identical — same 947 472 bytes, same 594 access units,
|
|
25517
|
+
* same 39.855 s presentation span, same 624 AAC frames — and only the wall
|
|
25518
|
+
* clock moves. It buys SUPPLY, never speed. So there was never a second
|
|
25519
|
+
* mechanism to wire for 8×: there is one, this one, and what it needs is
|
|
25520
|
+
* media in hand and a clamp that does not move the number.
|
|
25521
|
+
*
|
|
25522
|
+
* **`16` is deliberately NOT here, and will not join by widening this array.**
|
|
25523
|
+
* The camera's `playSpeed 16` is not a rate at all but an I-frame-only MODE —
|
|
25524
|
+
* measured on 592: 10 access units for a whole 36.3 s sub clip, 20 for the
|
|
25525
|
+
* main twin at a 2 025 ms median spacing, and no audio track. That is
|
|
25526
|
+
* different CONTENT, a stream of its own, and the honest broker-side twin of
|
|
25527
|
+
* it would be a pacer that DROPS whole GOPs rather than one that pushes 16×
|
|
25528
|
+
* the bitrate at a live WebRTC track. Neither exists. A `16` in this array
|
|
25529
|
+
* today would be a rate accepted and delivered at 8 — D612's defect, which
|
|
25530
|
+
* this list exists to end, one number further along.
|
|
25531
|
+
*
|
|
25532
|
+
* Every entry must survive the broker's `clampPlaybackRate` unchanged. Since
|
|
25533
|
+
* D621 that is structural rather than a discipline: the clamp reads this
|
|
25534
|
+
* array's own ends. What still has to be proved behaviourally — and is, in
|
|
25535
|
+
* the broker's `clip-stream-feeder.spec` — is that the PACER really empties a
|
|
25536
|
+
* clip `rate` times faster, because a clamp agreeing with a ladder is a
|
|
25537
|
+
* constant compared against itself.
|
|
25538
|
+
*
|
|
25539
|
+
* Narrower ladders exist for transports whose SUPPLY is bounded; they are
|
|
25540
|
+
* subsets of this one ({@link CLIP_STREAM_SOURCE_RATES},
|
|
25541
|
+
* {@link CLIP_REALTIME_SOURCE_RATES}).
|
|
25523
25542
|
*/
|
|
25524
25543
|
var CLIP_BROKER_PACED_RATES = [
|
|
25544
|
+
.25,
|
|
25545
|
+
.5,
|
|
25546
|
+
1,
|
|
25547
|
+
1.5,
|
|
25548
|
+
2,
|
|
25549
|
+
4,
|
|
25550
|
+
8
|
|
25551
|
+
];
|
|
25552
|
+
/**
|
|
25553
|
+
* The rates a provider-STREAMED clip can be delivered at — a subset of
|
|
25554
|
+
* {@link CLIP_BROKER_PACED_RATES}, and frozen below it on purpose (D621).
|
|
25555
|
+
*
|
|
25556
|
+
* A `stream` clip's media does not exist yet: it arrives on a socket from the
|
|
25557
|
+
* camera while the pacer consumes it. The pacer takes `rate` seconds of media
|
|
25558
|
+
* per second of wall clock, so the ceiling is whatever the SOURCE supplies,
|
|
25559
|
+
* and that is a measurement per vendor rather than a preference.
|
|
25560
|
+
*
|
|
25561
|
+
* Reolink, the one provider on this envelope, was measured on 592
|
|
25562
|
+
* (2026-09-23, D620): with the `<ReplaySeek>` that 0.11.1 sends before every
|
|
25563
|
+
* replay, a sub clip arrives at **1.2×** and a main twin at **1.37×**. The
|
|
25564
|
+
* ladder below is therefore ALREADY beyond this transport above 1 — the D612
|
|
25565
|
+
* defect returned through a door nobody opened — and D620 fixed the repair
|
|
25566
|
+
* order: the supply first, the ladder after. So this array does not move with
|
|
25567
|
+
* the broker's, and it does not gain `8`; what it gains, when the library
|
|
25568
|
+
* forwards a `<playSpeed>` large enough to feed the rate being paced over it,
|
|
25569
|
+
* is the right to be widened on a measurement rather than shortened on one.
|
|
25570
|
+
*/
|
|
25571
|
+
var CLIP_STREAM_SOURCE_RATES = [
|
|
25525
25572
|
.25,
|
|
25526
25573
|
.5,
|
|
25527
25574
|
1,
|
|
@@ -26006,7 +26053,7 @@ var CLIP_PLAYBACK_OPTIONS = {
|
|
|
26006
26053
|
seek: "forward",
|
|
26007
26054
|
stepBack: false,
|
|
26008
26055
|
scrub: false,
|
|
26009
|
-
rates:
|
|
26056
|
+
rates: CLIP_STREAM_SOURCE_RATES
|
|
26010
26057
|
},
|
|
26011
26058
|
/**
|
|
26012
26059
|
* A `stream` whose SOURCE runs at realtime — a Hikvision RTSP replay.
|
|
@@ -27390,6 +27437,143 @@ DeviceType.Camera, method(object({ deviceId: number() }), CameraCredentialsSchem
|
|
|
27390
27437
|
auth: "admin"
|
|
27391
27438
|
});
|
|
27392
27439
|
/**
|
|
27440
|
+
* camera-grid-layout — the geometry of a COMPOSITE camera, on the camera's own
|
|
27441
|
+
* page.
|
|
27442
|
+
*
|
|
27443
|
+
* ## Why this is a capability and not an addon settings schema
|
|
27444
|
+
*
|
|
27445
|
+
* It was one, and it did not render. The addon declared the editor as a
|
|
27446
|
+
* `type: 'widget'` field inside its own `deviceSettingsSchema()`; the hub
|
|
27447
|
+
* returned that section correctly and `ConfigFormField` renders `type:'widget'`
|
|
27448
|
+
* perfectly well — and nothing ever asked camera-grid for it. The Cluster →
|
|
27449
|
+
* Pipeline → Device Overrides page interrogates a HAND-WRITTEN list of four
|
|
27450
|
+
* addons (`PIPELINE_CLUSTER_DEVICE_ADDONS`), whose own comment says an addon
|
|
27451
|
+
* not on it "falls off silently".
|
|
27452
|
+
*
|
|
27453
|
+
* Adding a fifth name to that list would have been the wrong fix twice over:
|
|
27454
|
+
* that page is per-camera DETECTION tuning, and a grid's geometry belongs
|
|
27455
|
+
* beside PTZ and motion zones on the camera itself. The device page is
|
|
27456
|
+
* BINDING-driven (D12), so the way in is a capability bound to the device —
|
|
27457
|
+
* and this cap carries its section the way `recording` does, by RETURNING it
|
|
27458
|
+
* from `getDeviceSettingsContribution`.
|
|
27459
|
+
*
|
|
27460
|
+
* Seven other widgets are still declared the other way, through a
|
|
27461
|
+
* `deviceConfig.ui` block the framework derives a section from. That route
|
|
27462
|
+
* gives the addon no say in where its own panel lands and no way to decline
|
|
27463
|
+
* for a device the panel does not suit, which is why this one does not use it.
|
|
27464
|
+
*
|
|
27465
|
+
* ## Why one addon may implement it
|
|
27466
|
+
*
|
|
27467
|
+
* It is a device-scoped NATIVE cap, registered by the grid camera device
|
|
27468
|
+
* itself. Nothing else declares a composite camera, so nothing else has a
|
|
27469
|
+
* layout — and the device-scoped route means the widget asks THE camera, not
|
|
27470
|
+
* "the camera-grid addon", which is what let the old custom-action pair be
|
|
27471
|
+
* reached only by a caller that already knew the addon id.
|
|
27472
|
+
*
|
|
27473
|
+
* ## The tab
|
|
27474
|
+
*
|
|
27475
|
+
* `streaming`, not a top-tab of its own. A grid's geometry IS what its stream
|
|
27476
|
+
* is, so the Streaming tab is where it belongs; a `grid` top-tab would need an
|
|
27477
|
+
* entry in `WELL_KNOWN_TAB_MAP` or the device page renders the raw id as the
|
|
27478
|
+
* label (measured on the robot camera, 2026-09-06 — a tab called "navigation"
|
|
27479
|
+
* next to "PTZ").
|
|
27480
|
+
*/
|
|
27481
|
+
/** A rectangle in normalized [0,1] coordinates of whatever contains it. */
|
|
27482
|
+
var GridNormalizedRectSchema = object({
|
|
27483
|
+
x: number().min(0).max(1),
|
|
27484
|
+
y: number().min(0).max(1),
|
|
27485
|
+
width: number().gt(0).max(1),
|
|
27486
|
+
height: number().gt(0).max(1)
|
|
27487
|
+
});
|
|
27488
|
+
/**
|
|
27489
|
+
* One source camera, the part of its picture taken, and where that part lands.
|
|
27490
|
+
*
|
|
27491
|
+
* Both rectangles are NORMALIZED (D519): a source camera can change resolution
|
|
27492
|
+
* — a profile switch, a firmware update, a substream that comes back different
|
|
27493
|
+
* — and a stored PIXEL rectangle would quietly start cutting the wrong region,
|
|
27494
|
+
* which is the class of bug nobody files.
|
|
27495
|
+
*/
|
|
27496
|
+
var GridLayoutCellSchema = object({
|
|
27497
|
+
deviceId: number().int().positive(),
|
|
27498
|
+
/** The part of the SOURCE taken, normalized against the source. */
|
|
27499
|
+
source: GridNormalizedRectSchema,
|
|
27500
|
+
/** Where it lands, normalized against the CANVAS. */
|
|
27501
|
+
cell: GridNormalizedRectSchema
|
|
27502
|
+
});
|
|
27503
|
+
/**
|
|
27504
|
+
* Which profiles this grid can actually compose, and why not.
|
|
27505
|
+
*
|
|
27506
|
+
* A grid's `high` composes its sources' `high` and its `low` their `low`, so a
|
|
27507
|
+
* profile is on offer only when EVERY source can serve it. The refusal NAMES
|
|
27508
|
+
* the sources, because "this grid has no low" is not a finding — "615 has no
|
|
27509
|
+
* low" is, and it is the one an operator can act on.
|
|
27510
|
+
*/
|
|
27511
|
+
var GridProfileOfferSchema = object({
|
|
27512
|
+
profile: _enum([
|
|
27513
|
+
"high",
|
|
27514
|
+
"mid",
|
|
27515
|
+
"low"
|
|
27516
|
+
]),
|
|
27517
|
+
offered: boolean(),
|
|
27518
|
+
/** Sources that cannot serve it. Empty when it is offered, or when there are no cells. */
|
|
27519
|
+
missingSources: array(number().int().positive()),
|
|
27520
|
+
/**
|
|
27521
|
+
* The canvas this profile composes onto, `WxH`, or empty when it is not
|
|
27522
|
+
* offered. DERIVED from the cells and the sources' own size at this profile —
|
|
27523
|
+
* it is reported because nothing else in the system would ever say what the
|
|
27524
|
+
* grid came out as, and because it is the number an operator would otherwise
|
|
27525
|
+
* expect to type.
|
|
27526
|
+
*/
|
|
27527
|
+
canvas: string(),
|
|
27528
|
+
/**
|
|
27529
|
+
* Whether this profile is PUBLISHED, of the ones the grid could serve.
|
|
27530
|
+
*
|
|
27531
|
+
* A grid's `high` is composed of its sources' `high`, so on a 4K fleet it is
|
|
27532
|
+
* a 4K canvas built from 4K decodes — something to opt into, not something a
|
|
27533
|
+
* viewer's adaptive should be handed by climbing to the top rung it can see.
|
|
27534
|
+
* Default is `mid` + `low`.
|
|
27535
|
+
*/
|
|
27536
|
+
published: boolean()
|
|
27537
|
+
});
|
|
27538
|
+
var GridLayoutViewSchema = object({
|
|
27539
|
+
/** The persisted grid row this camera was declared from. */
|
|
27540
|
+
instanceId: string(),
|
|
27541
|
+
deviceId: number().int().nonnegative(),
|
|
27542
|
+
name: string(),
|
|
27543
|
+
/**
|
|
27544
|
+
* NO canvas size. A grid's resolution is not authored: each profile derives
|
|
27545
|
+
* its own from the cells and its sources' dimensions. The two numbers that
|
|
27546
|
+
* used to be here were a text field that silently decided both how much the
|
|
27547
|
+
* composite cost and how sharp it was — see `profiles[].canvas` for what it
|
|
27548
|
+
* came out as.
|
|
27549
|
+
*/
|
|
27550
|
+
fps: number().int(),
|
|
27551
|
+
cells: array(GridLayoutCellSchema),
|
|
27552
|
+
/** What the catalog will publish, and what it refuses to. Read-only. */
|
|
27553
|
+
profiles: array(GridProfileOfferSchema)
|
|
27554
|
+
});
|
|
27555
|
+
var GridLayoutPatchSchema = object({
|
|
27556
|
+
deviceId: number().int().nonnegative(),
|
|
27557
|
+
name: string().min(1).max(160).optional(),
|
|
27558
|
+
fps: number().int().min(1).max(60).optional(),
|
|
27559
|
+
/** Which profiles to publish. See `GridProfileOffer.published`. */
|
|
27560
|
+
publishedProfiles: array(_enum([
|
|
27561
|
+
"high",
|
|
27562
|
+
"mid",
|
|
27563
|
+
"low"
|
|
27564
|
+
])).max(3).optional(),
|
|
27565
|
+
/**
|
|
27566
|
+
* The whole cell list at once. A per-cell patch would need an ordering the
|
|
27567
|
+
* editor does not have, and a half-applied layout is a picture nobody asked
|
|
27568
|
+
* for.
|
|
27569
|
+
*/
|
|
27570
|
+
cells: array(GridLayoutCellSchema).max(16)
|
|
27571
|
+
});
|
|
27572
|
+
DeviceType.Camera, method(object({ deviceId: number().int().nonnegative() }), GridLayoutViewSchema.nullable(), { auth: "admin" }), method(GridLayoutPatchSchema, GridLayoutViewSchema, {
|
|
27573
|
+
kind: "mutation",
|
|
27574
|
+
auth: "admin"
|
|
27575
|
+
});
|
|
27576
|
+
/**
|
|
27393
27577
|
* Carbon-monoxide alarm sensor. Drives Home Assistant `binary_sensor`
|
|
27394
27578
|
* entries with `device_class: carbon_monoxide`. Push-driven.
|
|
27395
27579
|
*/
|
|
@@ -28192,764 +28376,224 @@ var dayNightCapability = {
|
|
|
28192
28376
|
volatileStateFields: ["lastFetchedAt"]
|
|
28193
28377
|
};
|
|
28194
28378
|
/**
|
|
28195
|
-
*
|
|
28196
|
-
*
|
|
28197
|
-
*
|
|
28198
|
-
*
|
|
28199
|
-
*
|
|
28200
|
-
*
|
|
28201
|
-
* nothing of its own. Every value here is read from the camera and every
|
|
28202
|
-
* write goes back to the camera; there is no CamStack-side mirror that
|
|
28203
|
-
* could disagree with the device.
|
|
28204
|
-
*
|
|
28205
|
-
* ## One shape, two firmwares
|
|
28206
|
-
*
|
|
28207
|
-
* Measured 2026-09-22 against the live fleet:
|
|
28208
|
-
*
|
|
28209
|
-
* | fact | Hikvision (ISAPI) | Reolink (Baichuan) |
|
|
28210
|
-
* | --- | --- | --- |
|
|
28211
|
-
* | storage | `ContentMgmt/Storage` `<hdd>` rows: status, capacity, freeSpace (MB) | `getHddInfoList` (cmd 102): `mount`, `format`, `capacity` GB + `capacityM` MB remainder |
|
|
28212
|
-
* | tracks | several (101 **and** 103 on both 1436 and 3833), each with its own schedule | one per channel |
|
|
28213
|
-
* | schedule | per track, 7 `ScheduleAction` blocks: DayOfWeek + TimeOfDay range + ONE `ActionRecordingMode` | per trigger type, a 168-char weekly HOUR mask |
|
|
28214
|
-
* | triggers | `CMR`, `MOTION` | `Normal`, `MD`, `people`, `vehicle`, `dog_cat`, `crossline`, `intrude`, `loitering` |
|
|
28215
|
-
* | pre-record | `PreRecordTimeSeconds` | `preRecordTime` |
|
|
28216
|
-
* | post-record | `PostRecordTimeSeconds` | `recordDelayTime` |
|
|
28217
|
-
* | overwrite | per track `LoopEnable` | `cycle`, with `cycleList` enumerating the accepted values |
|
|
28218
|
-
* | segment length | not exposed on V5.7.1 | `packageTime` (minutes) |
|
|
28219
|
-
*
|
|
28220
|
-
* The two schedule models look different and are the same thing in
|
|
28221
|
-
* different coordinates: both answer "for this trigger, during which
|
|
28222
|
-
* weekly windows does the camera record". {@link RecordWindow} is that
|
|
28223
|
-
* question in one shape — Hikvision's ranges map straight onto it,
|
|
28224
|
-
* Reolink's mask expands into hour-aligned windows.
|
|
28225
|
-
*
|
|
28226
|
-
* ## Union, not intersection
|
|
28227
|
-
*
|
|
28228
|
-
* **The same fields exist on every camera.** What differs per device is
|
|
28229
|
-
* which VALUES that device accepts, and that is what {@link
|
|
28230
|
-
* RecordingOnboardOptions} reports — a `{ readable, writable, reason }`
|
|
28231
|
-
* per field plus the schedule's own limits. A control a camera cannot
|
|
28232
|
-
* honour is rendered DISABLED WITH ITS REASON, never missing and never
|
|
28233
|
-
* dead: disabled must not look like broken.
|
|
28234
|
-
*
|
|
28235
|
-
* ## Refusal by name
|
|
28236
|
-
*
|
|
28237
|
-
* A write a camera cannot honour is refused with a sentence the operator
|
|
28238
|
-
* can read — never accepted and dropped. Both providers refuse through
|
|
28239
|
-
* {@link describeOnboardRefusal}, so the vocabulary is one function and
|
|
28240
|
-
* one test, not two hand-written vendor opinions.
|
|
28379
|
+
* Generic device-level status snapshot. Auto-registered by `BaseDevice`
|
|
28380
|
+
* for every device, regardless of provider — the kernel needs a uniform
|
|
28381
|
+
* cap-keyed slice for the basic device flags every consumer expects to
|
|
28382
|
+
* read across processes (the `online` flag in particular). Driver-specific
|
|
28383
|
+
* caps (`battery`, `doorbell`, …) carry their domain-specific state on
|
|
28384
|
+
* their own slices.
|
|
28241
28385
|
*
|
|
28242
|
-
*
|
|
28243
|
-
* `
|
|
28244
|
-
*
|
|
28245
|
-
* `
|
|
28246
|
-
*
|
|
28386
|
+
* Pattern is identical to `battery`: schema-bearing `runtimeState`,
|
|
28387
|
+
* empty `methods`, single change event. Reads land at
|
|
28388
|
+
* `runtimeState.getCapState('device-status')`; writes at
|
|
28389
|
+
* `runtimeState.setCapState('device-status', …)`. Cross-process
|
|
28390
|
+
* consumers reach the same data via the `device-state` cap router
|
|
28391
|
+
* (`getCapSlice({deviceId, capName: 'device-status'})`).
|
|
28247
28392
|
*/
|
|
28393
|
+
var DeviceStatusSchema = object({
|
|
28394
|
+
/**
|
|
28395
|
+
* Device-level liveness. Drivers flip via `markOnline(boolean)` on
|
|
28396
|
+
* `BaseDevice`. Provider semantics vary — RTSP aggregates broker
|
|
28397
|
+
* stream-health, Reolink reads firmware push events, ONVIF tracks
|
|
28398
|
+
* ping responses. This cap intentionally does NOT prescribe which
|
|
28399
|
+
* signal drives the flag.
|
|
28400
|
+
*/
|
|
28401
|
+
online: boolean(),
|
|
28402
|
+
/** Ms epoch of the last `online` transition. Lets consumers tell
|
|
28403
|
+
* apart "just came online" from "still online". */
|
|
28404
|
+
lastChangedAt: number()
|
|
28405
|
+
});
|
|
28406
|
+
var deviceStatusCapability = {
|
|
28407
|
+
name: "device-status",
|
|
28408
|
+
scope: "device",
|
|
28409
|
+
deviceNative: true,
|
|
28410
|
+
mode: "singleton",
|
|
28411
|
+
methods: {},
|
|
28412
|
+
events: {
|
|
28413
|
+
/** Emitted when `online` transitions. Mirrors the semantics of
|
|
28414
|
+
* `battery.onStatusChanged`. */
|
|
28415
|
+
onStatusChanged: { data: object({
|
|
28416
|
+
deviceId: number(),
|
|
28417
|
+
status: DeviceStatusSchema
|
|
28418
|
+
}) } },
|
|
28419
|
+
status: {
|
|
28420
|
+
schema: DeviceStatusSchema,
|
|
28421
|
+
kind: "push"
|
|
28422
|
+
},
|
|
28423
|
+
runtimeState: DeviceStatusSchema,
|
|
28424
|
+
/**
|
|
28425
|
+
* Runtime-state durability: **restored** — the previous observation is what makes the first reading after a restart a COMPARISON instead of a phantom transition (D130). 32 real flips across 16 devices in 25 min — the busiest slice in the cold half.
|
|
28426
|
+
*
|
|
28427
|
+
* See `RuntimeStateDurability`. Enforced by
|
|
28428
|
+
* `scripts/check-runtime-state-durability.ts`.
|
|
28429
|
+
*/
|
|
28430
|
+
durability: "restored",
|
|
28431
|
+
/** Clock fields: written, but excluded from the compare that decides
|
|
28432
|
+
* whether persisting is worth a SQLite commit. */
|
|
28433
|
+
volatileStateFields: ["lastChangedAt"]
|
|
28434
|
+
};
|
|
28248
28435
|
/**
|
|
28249
|
-
*
|
|
28436
|
+
* Doorbell button cap. Two kinds of providers coexist behind this cap
|
|
28437
|
+
* name (same pattern as `snapshot`):
|
|
28250
28438
|
*
|
|
28251
|
-
*
|
|
28252
|
-
*
|
|
28253
|
-
*
|
|
28254
|
-
*
|
|
28255
|
-
*
|
|
28256
|
-
*
|
|
28257
|
-
*
|
|
28258
|
-
*/
|
|
28259
|
-
var RecordTriggerSchema = _enum([
|
|
28260
|
-
"continuous",
|
|
28261
|
-
"motion",
|
|
28262
|
-
"person",
|
|
28263
|
-
"vehicle",
|
|
28264
|
-
"animal",
|
|
28265
|
-
"lineCrossing",
|
|
28266
|
-
"intrusion",
|
|
28267
|
-
"loitering",
|
|
28268
|
-
"alarmInput"
|
|
28269
|
-
]);
|
|
28270
|
-
/**
|
|
28271
|
-
* One weekly recording window: "on `day`, from `startMinute` to
|
|
28272
|
-
* `endMinute`, record on `trigger`".
|
|
28439
|
+
* - **Native** providers: registered per-device by device-driver
|
|
28440
|
+
* addons via `ctx.registerNativeCap` — either on a
|
|
28441
|
+
* `DeviceType.Button` accessory with `role: DeviceRole.Doorbell`,
|
|
28442
|
+
* or directly on the camera (Reolink registers at camera level).
|
|
28443
|
+
* Emits an `onPressed` event every time the firmware pushes a
|
|
28444
|
+
* ring; status tracks the last press and a pressCount since start
|
|
28445
|
+
* (diagnostic).
|
|
28273
28446
|
*
|
|
28274
|
-
*
|
|
28275
|
-
*
|
|
28276
|
-
*
|
|
28277
|
-
*
|
|
28278
|
-
*
|
|
28447
|
+
* - **Wrapper** provider: the `virtual-doorbell` system builtin
|
|
28448
|
+
* (`@camstack/system/builtins/doorbell`). Turns ANY binary-ish
|
|
28449
|
+
* device (contact / switch / event-emitter …) into a doorbell for
|
|
28450
|
+
* a camera. `defaultActive: false` — the operator explicitly binds
|
|
28451
|
+
* it per camera in the device-bindings UI, then picks the source
|
|
28452
|
+
* device + trigger in the per-device settings.
|
|
28453
|
+
*
|
|
28454
|
+
* The DeviceEventPropagator re-emits `onPressed` on the camera parent
|
|
28455
|
+
* — subscribers listening at the camera level receive ring events
|
|
28456
|
+
* with `via[]` populated. No code on the parent needed.
|
|
28279
28457
|
*/
|
|
28280
|
-
var
|
|
28281
|
-
|
|
28282
|
-
|
|
28283
|
-
|
|
28284
|
-
|
|
28458
|
+
var DoorbellStatusSchema = object({
|
|
28459
|
+
/** Ms epoch of the last press. null = never observed since this provider started. */
|
|
28460
|
+
lastPressedAt: number().nullable(),
|
|
28461
|
+
/** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
|
|
28462
|
+
pressCountSinceStart: number()
|
|
28285
28463
|
});
|
|
28286
|
-
|
|
28287
|
-
|
|
28288
|
-
|
|
28289
|
-
|
|
28290
|
-
|
|
28291
|
-
|
|
28292
|
-
|
|
28293
|
-
|
|
28294
|
-
|
|
28295
|
-
|
|
28296
|
-
|
|
28297
|
-
|
|
28298
|
-
|
|
28464
|
+
var DoorbellPressEventSchema = object({
|
|
28465
|
+
deviceId: number(),
|
|
28466
|
+
timestamp: number()
|
|
28467
|
+
});
|
|
28468
|
+
var doorbellCapability = {
|
|
28469
|
+
name: "doorbell",
|
|
28470
|
+
scope: "device",
|
|
28471
|
+
deviceNative: true,
|
|
28472
|
+
mode: "singleton",
|
|
28473
|
+
kind: "wrapper",
|
|
28474
|
+
defaultActive: false,
|
|
28475
|
+
deviceTypes: [DeviceType.Button, DeviceType.Camera],
|
|
28476
|
+
exposesDeviceSettings: true,
|
|
28477
|
+
methods: {},
|
|
28478
|
+
events: {
|
|
28299
28479
|
/**
|
|
28300
|
-
*
|
|
28301
|
-
*
|
|
28302
|
-
*
|
|
28303
|
-
* measurement (D393), and a card whose size is unknown must not be
|
|
28304
|
-
* rendered as a card of size zero.
|
|
28480
|
+
* Fires once per physical press. Reolink delivers via Baichuan
|
|
28481
|
+
* push (`ReolinkSimpleEvent.type === 'doorbell'`). There is no
|
|
28482
|
+
* release/duration — it's a pulse.
|
|
28305
28483
|
*/
|
|
28306
|
-
|
|
28484
|
+
onPressed: { data: DoorbellPressEventSchema } },
|
|
28485
|
+
status: {
|
|
28486
|
+
schema: DoorbellStatusSchema,
|
|
28487
|
+
kind: "push"
|
|
28488
|
+
},
|
|
28307
28489
|
/**
|
|
28308
|
-
*
|
|
28490
|
+
* Runtime-state slice — last press timestamp + lifetime press count.
|
|
28491
|
+
* Mirrored by the kernel and readable via
|
|
28492
|
+
* `device.state.doorbell.value`. UIs can show "last ring 5m ago"
|
|
28493
|
+
* without subscribing.
|
|
28494
|
+
*/
|
|
28495
|
+
runtimeState: DoorbellStatusSchema,
|
|
28496
|
+
/**
|
|
28497
|
+
* Runtime-state durability: **restored** — a monotonic accumulator: the slice IS the record. `lastPressedAt` is content here, not a clock, so it is deliberately NOT volatile.
|
|
28309
28498
|
*
|
|
28310
|
-
*
|
|
28311
|
-
*
|
|
28312
|
-
* card converges on once it has wrapped. At loop steady state the
|
|
28313
|
-
* number is identical whether the camera recorded yesterday or stopped
|
|
28314
|
-
* a month ago.
|
|
28499
|
+
* See `RuntimeStateDurability`. Enforced by
|
|
28500
|
+
* `scripts/check-runtime-state-durability.ts`.
|
|
28315
28501
|
*/
|
|
28316
|
-
|
|
28317
|
-
|
|
28318
|
-
writable: boolean().optional()
|
|
28319
|
-
});
|
|
28502
|
+
durability: "restored"
|
|
28503
|
+
};
|
|
28320
28504
|
/**
|
|
28321
|
-
*
|
|
28322
|
-
*
|
|
28323
|
-
*
|
|
28324
|
-
*
|
|
28325
|
-
*
|
|
28505
|
+
* Enum-state sensor — a string value picked from a finite option set.
|
|
28506
|
+
* Drives HA `sensor` entries with `state_class: enum` (HVAC action
|
|
28507
|
+
* states, weather conditions, contact-source channels, mode strings).
|
|
28508
|
+
* The option set is stable across observations; it is persisted in the
|
|
28509
|
+
* device config blob (via the control slice at adoption) and is NOT
|
|
28510
|
+
* stored in `sourceInfo`.
|
|
28326
28511
|
*/
|
|
28327
|
-
|
|
28328
|
-
|
|
28329
|
-
|
|
28330
|
-
|
|
28331
|
-
|
|
28332
|
-
|
|
28333
|
-
|
|
28334
|
-
|
|
28335
|
-
|
|
28336
|
-
}),
|
|
28337
|
-
object({
|
|
28338
|
-
kind: literal("unknown"),
|
|
28339
|
-
reason: string()
|
|
28340
|
-
})
|
|
28341
|
-
]),
|
|
28342
|
-
tracks: array(object({
|
|
28343
|
-
id: string(),
|
|
28344
|
-
enabled: boolean(),
|
|
28345
|
-
isVideo: boolean(),
|
|
28346
|
-
/** From the camera's own track description. Null when it does not say. */
|
|
28347
|
-
codec: string().nullable(),
|
|
28348
|
-
resolution: string().nullable(),
|
|
28349
|
-
/** Per-track overwrite flag, where the firmware keeps it per track. */
|
|
28350
|
-
overwriteWhenFull: boolean().nullable()
|
|
28351
|
-
})),
|
|
28512
|
+
/** Locale-render shape for an ISO `value` carried by a `DateTimeSensor`-role
|
|
28513
|
+
* enum sensor: `date` (date-only), `time` (time-only), `datetime` (both). */
|
|
28514
|
+
var EnumSensorDateTimeFormatSchema = _enum([
|
|
28515
|
+
"date",
|
|
28516
|
+
"time",
|
|
28517
|
+
"datetime"
|
|
28518
|
+
]);
|
|
28519
|
+
var EnumSensorStatusSchema = object({
|
|
28520
|
+
value: string(),
|
|
28352
28521
|
/**
|
|
28353
|
-
*
|
|
28354
|
-
*
|
|
28522
|
+
* Set for `DateTimeSensor`-role sensors so the UI renders the ISO `value`
|
|
28523
|
+
* as a locale date/time/datetime; absent for plain enum sensors. HA
|
|
28524
|
+
* `device_class=timestamp` → `'datetime'`, `device_class=date` → `'date'`,
|
|
28525
|
+
* a time-only sensor → `'time'`.
|
|
28355
28526
|
*/
|
|
28356
|
-
|
|
28357
|
-
/**
|
|
28358
|
-
|
|
28359
|
-
|
|
28360
|
-
|
|
28361
|
-
|
|
28362
|
-
|
|
28363
|
-
|
|
28364
|
-
|
|
28365
|
-
|
|
28527
|
+
format: EnumSensorDateTimeFormatSchema.optional(),
|
|
28528
|
+
/** Ms epoch when the slice was last updated. */
|
|
28529
|
+
lastFetchedAt: number()
|
|
28530
|
+
});
|
|
28531
|
+
var enumSensorCapability = {
|
|
28532
|
+
name: "enum-sensor",
|
|
28533
|
+
scope: "device",
|
|
28534
|
+
deviceNative: true,
|
|
28535
|
+
mode: "singleton",
|
|
28536
|
+
deviceTypes: [DeviceType.Sensor],
|
|
28537
|
+
methods: {},
|
|
28538
|
+
status: {
|
|
28539
|
+
schema: EnumSensorStatusSchema,
|
|
28540
|
+
kind: "push"
|
|
28541
|
+
},
|
|
28542
|
+
runtimeState: EnumSensorStatusSchema,
|
|
28366
28543
|
/**
|
|
28367
|
-
*
|
|
28368
|
-
* an unrecognised trigger, an unparseable clock, a weekday it does not
|
|
28369
|
-
* name.
|
|
28544
|
+
* Runtime-state durability: **restored** — as `numeric-sensor`; 80 devices.
|
|
28370
28545
|
*
|
|
28371
|
-
*
|
|
28372
|
-
*
|
|
28373
|
-
* saves back a schedule shorter than the one they were looking at
|
|
28374
|
-
* (D391). Non-zero means the window list is INCOMPLETE and a write
|
|
28375
|
-
* that replaces it would delete what was not shown — which is why a
|
|
28376
|
-
* provider reporting a non-zero count also reports the schedule as not
|
|
28377
|
-
* writable.
|
|
28546
|
+
* See `RuntimeStateDurability`. Enforced by
|
|
28547
|
+
* `scripts/check-runtime-state-durability.ts`.
|
|
28378
28548
|
*/
|
|
28379
|
-
|
|
28549
|
+
durability: "restored",
|
|
28550
|
+
/** Clock fields: written, but excluded from the compare that decides
|
|
28551
|
+
* whether persisting is worth a SQLite commit. */
|
|
28552
|
+
volatileStateFields: ["lastFetchedAt"]
|
|
28553
|
+
};
|
|
28554
|
+
/**
|
|
28555
|
+
* Generic stateless event emitter. Installed on a `DeviceType.EventEmitter`
|
|
28556
|
+
* device. Carries the device's EXACT declared event vocabulary verbatim
|
|
28557
|
+
* (NO normalization). Two shapes:
|
|
28558
|
+
* - structured source (HA `event.*` entity) → `eventTypes` is the fixed
|
|
28559
|
+
* declared vocabulary (e.g. ['press_short','press_long',...]).
|
|
28560
|
+
* - generic/legacy source (HA bus events, e.g. zha_event) → `eventTypes`
|
|
28561
|
+
* is [] (open) and `lastEvent.data` carries the complex payload.
|
|
28562
|
+
* `seq` is monotonic so two identical events still produce distinct slice writes.
|
|
28563
|
+
*/
|
|
28564
|
+
var EventFireSchema = object({
|
|
28565
|
+
deviceId: number(),
|
|
28566
|
+
eventType: string(),
|
|
28567
|
+
data: record(string(), unknown()).nullable(),
|
|
28568
|
+
timestamp: number(),
|
|
28569
|
+
seq: number()
|
|
28570
|
+
});
|
|
28571
|
+
var EventEmitterStatusSchema = object({
|
|
28572
|
+
eventTypes: array(string()),
|
|
28573
|
+
lastEvent: EventFireSchema.nullable(),
|
|
28574
|
+
eventCountSinceStart: number()
|
|
28575
|
+
});
|
|
28576
|
+
var eventEmitterCapability = {
|
|
28577
|
+
name: "event-emitter",
|
|
28578
|
+
scope: "device",
|
|
28579
|
+
deviceNative: true,
|
|
28580
|
+
mode: "singleton",
|
|
28581
|
+
deviceTypes: [DeviceType.EventEmitter],
|
|
28582
|
+
methods: {},
|
|
28583
|
+
events: { onEvent: { data: EventFireSchema } },
|
|
28584
|
+
status: {
|
|
28585
|
+
schema: EventEmitterStatusSchema,
|
|
28586
|
+
kind: "push"
|
|
28587
|
+
},
|
|
28588
|
+
runtimeState: EventEmitterStatusSchema,
|
|
28380
28589
|
/**
|
|
28381
|
-
*
|
|
28590
|
+
* Runtime-state durability: **session** — `eventCountSinceStart` names its own scope.
|
|
28382
28591
|
*
|
|
28383
|
-
*
|
|
28384
|
-
*
|
|
28385
|
-
* to a card that is not there. Neither the schedule nor the storage
|
|
28386
|
-
* read says anything wrong on its own; only the pair does.
|
|
28387
|
-
*/
|
|
28388
|
-
recordingToNowhere: boolean(),
|
|
28389
|
-
lastFetchedAt: number()
|
|
28390
|
-
});
|
|
28391
|
-
/** Numeric range descriptor — `{ min, max, step }` per the getOptions convention. */
|
|
28392
|
-
var RangeSchema = object({
|
|
28393
|
-
min: number(),
|
|
28394
|
-
max: number(),
|
|
28395
|
-
step: number()
|
|
28396
|
-
});
|
|
28397
|
-
/**
|
|
28398
|
-
* The values a camera actually takes for a numeric field, when they are a SET
|
|
28399
|
-
* rather than a range.
|
|
28400
|
-
*
|
|
28401
|
-
* `{min,max,step}` cannot say what these two firmwares do. Measured on 1436
|
|
28402
|
-
* (I91DN) on 2026-09-22 by writing each value and reading it back:
|
|
28403
|
-
*
|
|
28404
|
-
* - pre-record: `0, 5, 10, 15, 20, 25, 30` and `2147483647` (INT32_MAX, the
|
|
28405
|
-
* camera's "no limit" — `-1` and `4294967295` both land on it);
|
|
28406
|
-
* - post-record: `5, 10, 30, 60, 120, 300, 600`.
|
|
28407
|
-
*
|
|
28408
|
-
* Neither is expressible as a step: the first has a sentinel two billion away
|
|
28409
|
-
* from its neighbours, the second doubles and then jumps. A range that tried
|
|
28410
|
-
* would forbid values the camera takes AND permit values it silently replaces
|
|
28411
|
-
* with 5 — wrong in both directions at once.
|
|
28412
|
-
*
|
|
28413
|
-
* `sentinel` names the member that is not a duration, so a surface can render
|
|
28414
|
-
* "no limit" instead of `2147483647` seconds.
|
|
28415
|
-
*/
|
|
28416
|
-
var AllowedValuesSchema = object({
|
|
28417
|
-
values: array(number()).min(1),
|
|
28418
|
-
sentinel: object({
|
|
28419
|
-
value: number(),
|
|
28420
|
-
meaning: _enum(["no-limit", "disabled"])
|
|
28421
|
-
}).optional()
|
|
28422
|
-
});
|
|
28423
|
-
/**
|
|
28424
|
-
* Per-field availability on ONE camera.
|
|
28425
|
-
*
|
|
28426
|
-
* The field exists on every camera — this says whether this one can be
|
|
28427
|
-
* read and whether it can be written, and `reason` says why not when
|
|
28428
|
-
* either is false. The UI renders the control DISABLED with the reason
|
|
28429
|
-
* rather than hiding it, so a limitation is legible instead of looking
|
|
28430
|
-
* like a missing feature.
|
|
28431
|
-
*/
|
|
28432
|
-
var OnboardFieldSupportSchema = object({
|
|
28433
|
-
readable: boolean(),
|
|
28434
|
-
writable: boolean(),
|
|
28435
|
-
/** Required whenever `readable` or `writable` is false. */
|
|
28436
|
-
reason: string().optional()
|
|
28437
|
-
});
|
|
28438
|
-
/** What this camera's schedule model can express. */
|
|
28439
|
-
var OnboardScheduleSupportSchema = object({
|
|
28440
|
-
support: OnboardFieldSupportSchema,
|
|
28441
|
-
/**
|
|
28442
|
-
* The smallest time step the camera can express, in minutes.
|
|
28443
|
-
*
|
|
28444
|
-
* Hikvision takes arbitrary minutes (`00:05:00`–`23:57:00` observed on
|
|
28445
|
-
* 1436's track 103). Reolink's schedule is a 7×24 HOUR mask, so 60. A
|
|
28446
|
-
* window whose edges are not a multiple of this is REFUSED rather than
|
|
28447
|
-
* quietly rounded — rounding is how an operator's 06:30 becomes 06:00
|
|
28448
|
-
* and nothing says so.
|
|
28449
|
-
*/
|
|
28450
|
-
granularityMinutes: number(),
|
|
28451
|
-
/** Triggers this camera can record on. A window naming another is refused. */
|
|
28452
|
-
triggers: array(RecordTriggerSchema),
|
|
28453
|
-
/**
|
|
28454
|
-
* False when the camera stores ONE trigger per time range, so two
|
|
28455
|
-
* windows overlapping on the same day cannot carry different triggers.
|
|
28456
|
-
* True on Reolink, whose mask is per-trigger and independent.
|
|
28457
|
-
*/
|
|
28458
|
-
supportsOverlappingTriggers: boolean()
|
|
28459
|
-
});
|
|
28460
|
-
var RecordingOnboardOptionsSchema = object({
|
|
28461
|
-
enabled: OnboardFieldSupportSchema,
|
|
28462
|
-
overwriteWhenFull: OnboardFieldSupportSchema,
|
|
28463
|
-
preRecordSec: OnboardFieldSupportSchema,
|
|
28464
|
-
preRecordSecRange: RangeSchema.optional(),
|
|
28465
|
-
/** Preferred over the range when the camera takes a SET, not a span. */
|
|
28466
|
-
preRecordSecAllowed: AllowedValuesSchema.optional(),
|
|
28467
|
-
postRecordSec: OnboardFieldSupportSchema,
|
|
28468
|
-
postRecordSecRange: RangeSchema.optional(),
|
|
28469
|
-
/** Preferred over the range when the camera takes a SET, not a span. */
|
|
28470
|
-
postRecordSecAllowed: AllowedValuesSchema.optional(),
|
|
28471
|
-
segmentMinutes: OnboardFieldSupportSchema,
|
|
28472
|
-
segmentMinutesRange: RangeSchema.optional(),
|
|
28473
|
-
/** Preferred over the range when the camera takes a SET, not a span. */
|
|
28474
|
-
segmentMinutesAllowed: AllowedValuesSchema.optional(),
|
|
28475
|
-
schedule: OnboardScheduleSupportSchema
|
|
28476
|
-
});
|
|
28477
|
-
/**
|
|
28478
|
-
* A partial change. Every field optional.
|
|
28479
|
-
*
|
|
28480
|
-
* Unlike the other `deviceConfig` caps, a provider here does **NOT**
|
|
28481
|
-
* silently ignore a field it cannot support — it refuses, by name,
|
|
28482
|
-
* through {@link describeOnboardRefusal}. Silence on a recording setting
|
|
28483
|
-
* is the failure D62 exists to prevent: the operator believes the camera
|
|
28484
|
-
* is recording the way the form says, and it is not.
|
|
28485
|
-
*/
|
|
28486
|
-
var RecordingOnboardPatchSchema = object({
|
|
28487
|
-
enabled: boolean().optional(),
|
|
28488
|
-
overwriteWhenFull: boolean().optional(),
|
|
28489
|
-
preRecordSec: number().optional(),
|
|
28490
|
-
postRecordSec: number().optional(),
|
|
28491
|
-
segmentMinutes: number().optional(),
|
|
28492
|
-
/** The complete new window set for the primary track — not a delta. */
|
|
28493
|
-
windows: array(RecordWindowSchema).optional()
|
|
28494
|
-
});
|
|
28495
|
-
var recordingOnboardCapability = {
|
|
28496
|
-
name: "recording-onboard",
|
|
28497
|
-
scope: "device",
|
|
28498
|
-
deviceNative: true,
|
|
28499
|
-
mode: "singleton",
|
|
28500
|
-
deviceTypes: [DeviceType.Camera],
|
|
28501
|
-
deviceConfig: { ui: {
|
|
28502
|
-
kind: "derived-form",
|
|
28503
|
-
builderId: "recording-onboard",
|
|
28504
|
-
tab: "recording"
|
|
28505
|
-
} },
|
|
28506
|
-
methods: {
|
|
28507
|
-
getOptions: method(object({ deviceId: number() }), RecordingOnboardOptionsSchema),
|
|
28508
|
-
setSettings: method(object({
|
|
28509
|
-
deviceId: number(),
|
|
28510
|
-
settings: RecordingOnboardPatchSchema
|
|
28511
|
-
}), _void(), {
|
|
28512
|
-
kind: "mutation",
|
|
28513
|
-
auth: "admin"
|
|
28514
|
-
})
|
|
28515
|
-
},
|
|
28516
|
-
status: {
|
|
28517
|
-
schema: RecordingOnboardStatusSchema,
|
|
28518
|
-
kind: "poll"
|
|
28519
|
-
},
|
|
28520
|
-
runtimeState: RecordingOnboardStatusSchema,
|
|
28521
|
-
/**
|
|
28522
|
-
* Runtime-state durability: **restored** — operator-set camera-side
|
|
28523
|
-
* recording config; mutation-driven, and the storage half is the last
|
|
28524
|
-
* thing the camera said about its own card.
|
|
28525
|
-
*
|
|
28526
|
-
* See `RuntimeStateDurability`. Enforced by
|
|
28527
|
-
* `scripts/check-runtime-state-durability.ts`.
|
|
28528
|
-
*/
|
|
28529
|
-
durability: "restored",
|
|
28530
|
-
/** Clock fields: written, but excluded from the compare that decides
|
|
28531
|
-
* whether persisting is worth a SQLite commit. */
|
|
28532
|
-
volatileStateFields: ["lastFetchedAt"]
|
|
28533
|
-
};
|
|
28534
|
-
/**
|
|
28535
|
-
* Day-of-week names in the cap's index order (0 = Monday), for messages
|
|
28536
|
-
* an operator reads and for Hikvision's `<DayOfWeek>` element.
|
|
28537
|
-
*/
|
|
28538
|
-
var DAY_NAMES = [
|
|
28539
|
-
"Monday",
|
|
28540
|
-
"Tuesday",
|
|
28541
|
-
"Wednesday",
|
|
28542
|
-
"Thursday",
|
|
28543
|
-
"Friday",
|
|
28544
|
-
"Saturday",
|
|
28545
|
-
"Sunday"
|
|
28546
|
-
];
|
|
28547
|
-
/**
|
|
28548
|
-
* Does `patch` ask this camera for something it cannot do?
|
|
28549
|
-
*
|
|
28550
|
-
* Returns the operator-readable reason, or `null` when every field in
|
|
28551
|
-
* the patch is within what `options` says this camera accepts. A
|
|
28552
|
-
* provider calls this BEFORE touching the camera and throws the string:
|
|
28553
|
-
* refusing is the point, and refusing identically on both vendors is why
|
|
28554
|
-
* this is one function.
|
|
28555
|
-
*
|
|
28556
|
-
* The order of checks is the order an operator would read them: the
|
|
28557
|
-
* scalar knobs first, then the schedule, because a schedule complaint is
|
|
28558
|
-
* longer and a scalar one is usually the real problem.
|
|
28559
|
-
*/
|
|
28560
|
-
function describeOnboardRefusal(options, patch) {
|
|
28561
|
-
if (patch.enabled !== void 0 && !options.enabled.writable) return unwritable("the master recording switch", options.enabled.reason);
|
|
28562
|
-
if (patch.overwriteWhenFull !== void 0 && !options.overwriteWhenFull.writable) return unwritable("overwrite-when-full", options.overwriteWhenFull.reason);
|
|
28563
|
-
const preRefusal = refuseNumeric("pre-record seconds", patch.preRecordSec, options.preRecordSec, options.preRecordSecRange, options.preRecordSecAllowed);
|
|
28564
|
-
if (preRefusal) return preRefusal;
|
|
28565
|
-
const postRefusal = refuseNumeric("post-record seconds", patch.postRecordSec, options.postRecordSec, options.postRecordSecRange, options.postRecordSecAllowed);
|
|
28566
|
-
if (postRefusal) return postRefusal;
|
|
28567
|
-
const segmentRefusal = refuseNumeric("segment length (minutes)", patch.segmentMinutes, options.segmentMinutes, options.segmentMinutesRange, options.segmentMinutesAllowed);
|
|
28568
|
-
if (segmentRefusal) return segmentRefusal;
|
|
28569
|
-
if (patch.windows !== void 0) {
|
|
28570
|
-
const scheduleRefusal = refuseSchedule(options, patch.windows);
|
|
28571
|
-
if (scheduleRefusal) return scheduleRefusal;
|
|
28572
|
-
}
|
|
28573
|
-
return null;
|
|
28574
|
-
}
|
|
28575
|
-
function unwritable(what, reason) {
|
|
28576
|
-
return reason ? `this camera cannot change ${what}: ${reason}` : `this camera cannot change ${what}`;
|
|
28577
|
-
}
|
|
28578
|
-
function refuseNumeric(what, value, support, range, allowed) {
|
|
28579
|
-
if (value === void 0) return null;
|
|
28580
|
-
if (!support.writable) return unwritable(what, support.reason);
|
|
28581
|
-
if (!Number.isFinite(value)) return `${what} must be a number, got ${String(value)}`;
|
|
28582
|
-
if (allowed) {
|
|
28583
|
-
if (allowed.values.includes(value)) return null;
|
|
28584
|
-
const say = (v) => allowed.sentinel !== void 0 && v === allowed.sentinel.value ? allowed.sentinel.meaning === "no-limit" ? "no limit" : "off" : String(v);
|
|
28585
|
-
return `this camera accepts ${what} only as ${allowed.values.map(say).join(", ")}; ${say(value)} is not one of them`;
|
|
28586
|
-
}
|
|
28587
|
-
if (!range) return null;
|
|
28588
|
-
if (value < range.min || value > range.max) return `this camera accepts ${what} between ${String(range.min)} and ${String(range.max)}; ${String(value)} is outside that`;
|
|
28589
|
-
if (range.step > 0 && (value - range.min) % range.step !== 0) return `this camera accepts ${what} in steps of ${String(range.step)} from ${String(range.min)}; ${String(value)} is not one of them`;
|
|
28590
|
-
return null;
|
|
28591
|
-
}
|
|
28592
|
-
function refuseSchedule(options, windows) {
|
|
28593
|
-
const schedule = options.schedule;
|
|
28594
|
-
if (!schedule.support.writable) return unwritable("the recording schedule", schedule.support.reason);
|
|
28595
|
-
const allowed = new Set(schedule.triggers);
|
|
28596
|
-
for (const window of windows) {
|
|
28597
|
-
if (!allowed.has(window.trigger)) {
|
|
28598
|
-
const offer = schedule.triggers.length > 0 ? schedule.triggers.join(", ") : "none";
|
|
28599
|
-
return `this camera cannot record on "${window.trigger}"; it records on: ${offer}`;
|
|
28600
|
-
}
|
|
28601
|
-
if (window.endMinute <= window.startMinute) return `a window on ${dayName(window.day)} ends at or before it starts (${String(window.startMinute)} → ${String(window.endMinute)})`;
|
|
28602
|
-
const step = schedule.granularityMinutes;
|
|
28603
|
-
if (step > 1 && (window.startMinute % step !== 0 || window.endMinute % step !== 0)) return `this camera's schedule only moves in ${String(step)}-minute steps; the ${dayName(window.day)} window ${formatMinutes(window.startMinute)}–${formatMinutes(window.endMinute)} is not aligned to them`;
|
|
28604
|
-
}
|
|
28605
|
-
if (!schedule.supportsOverlappingTriggers) {
|
|
28606
|
-
const clash = findOverlapWithDifferentTrigger(windows);
|
|
28607
|
-
if (clash) return `this camera stores one trigger per time range, so "${clash.a.trigger}" and "${clash.b.trigger}" cannot both cover ${dayName(clash.a.day)} ${formatMinutes(Math.max(clash.a.startMinute, clash.b.startMinute))}–${formatMinutes(Math.min(clash.a.endMinute, clash.b.endMinute))}`;
|
|
28608
|
-
}
|
|
28609
|
-
return null;
|
|
28610
|
-
}
|
|
28611
|
-
function findOverlapWithDifferentTrigger(windows) {
|
|
28612
|
-
for (let i = 0; i < windows.length; i += 1) for (let j = i + 1; j < windows.length; j += 1) {
|
|
28613
|
-
const a = windows[i];
|
|
28614
|
-
const b = windows[j];
|
|
28615
|
-
if (!a || !b) continue;
|
|
28616
|
-
if (a.day !== b.day) continue;
|
|
28617
|
-
if (a.trigger === b.trigger) continue;
|
|
28618
|
-
if (a.startMinute < b.endMinute && b.startMinute < a.endMinute) return {
|
|
28619
|
-
a,
|
|
28620
|
-
b
|
|
28621
|
-
};
|
|
28622
|
-
}
|
|
28623
|
-
return null;
|
|
28624
|
-
}
|
|
28625
|
-
function dayName(day) {
|
|
28626
|
-
return DAY_NAMES[day] ?? `day ${String(day)}`;
|
|
28627
|
-
}
|
|
28628
|
-
/** `510` → `08:30`. For messages, not for the wire. */
|
|
28629
|
-
function formatMinutes(minute) {
|
|
28630
|
-
const hour = Math.floor(minute / 60);
|
|
28631
|
-
const rest = minute % 60;
|
|
28632
|
-
return `${String(hour).padStart(2, "0")}:${String(rest).padStart(2, "0")}`;
|
|
28633
|
-
}
|
|
28634
|
-
/**
|
|
28635
|
-
* Parse a Hikvision `<TimeOfDay>` into minutes since midnight.
|
|
28636
|
-
*
|
|
28637
|
-
* The firmware is not self-consistent and both spellings are real, on
|
|
28638
|
-
* the same camera in the same block: a start time reads `00:00:00` and
|
|
28639
|
-
* the matching end time reads `24:00`. Seconds are accepted and
|
|
28640
|
-
* discarded — the cap's resolution is minutes — and `24:00` maps to
|
|
28641
|
-
* {@link MINUTES_PER_DAY}, not to 0.
|
|
28642
|
-
*
|
|
28643
|
-
* Returns null for anything else, which a caller reports as a window it
|
|
28644
|
-
* could not read rather than as midnight.
|
|
28645
|
-
*/
|
|
28646
|
-
function timeOfDayToMinutes(value) {
|
|
28647
|
-
const match = /^(\d{1,2}):(\d{2})(?::(\d{2}))?$/.exec(value.trim());
|
|
28648
|
-
if (!match) return null;
|
|
28649
|
-
const hour = Number(match[1]);
|
|
28650
|
-
const minute = Number(match[2]);
|
|
28651
|
-
if (!Number.isInteger(hour) || !Number.isInteger(minute)) return null;
|
|
28652
|
-
if (minute > 59) return null;
|
|
28653
|
-
const total = hour * 60 + minute;
|
|
28654
|
-
if (total > 1440) return null;
|
|
28655
|
-
return total;
|
|
28656
|
-
}
|
|
28657
|
-
/**
|
|
28658
|
-
* Render minutes back as a Hikvision `TimeOfDay`.
|
|
28659
|
-
*
|
|
28660
|
-
* Emits the camera's own two spellings: `24:00` for end-of-day, because
|
|
28661
|
-
* that is what the firmware writes and `24:00:00` is not observed, and
|
|
28662
|
-
* `HH:MM:SS` otherwise.
|
|
28663
|
-
*/
|
|
28664
|
-
function minutesToTimeOfDay(minute) {
|
|
28665
|
-
if (minute >= 1440) return "24:00";
|
|
28666
|
-
const hour = Math.floor(minute / 60);
|
|
28667
|
-
const rest = minute % 60;
|
|
28668
|
-
return `${String(hour).padStart(2, "0")}:${String(rest).padStart(2, "0")}:00`;
|
|
28669
|
-
}
|
|
28670
|
-
/** `'Monday'` → 0. Case-insensitive. Null for anything unrecognised. */
|
|
28671
|
-
function dayOfWeekToIndex(value) {
|
|
28672
|
-
const needle = value.trim().toLowerCase();
|
|
28673
|
-
const index = DAY_NAMES.findIndex((name) => name.toLowerCase() === needle);
|
|
28674
|
-
return index >= 0 ? index : null;
|
|
28675
|
-
}
|
|
28676
|
-
/**
|
|
28677
|
-
* Which fields of a patch the camera did NOT take verbatim.
|
|
28678
|
-
*
|
|
28679
|
-
* Measured on a Hikvision I91DN (1436, 2026-09-22): a `PUT` of
|
|
28680
|
-
* `PreRecordTimeSeconds: 8` answered `200`, `statusCode 1`, `OK` — and stored
|
|
28681
|
-
* **5**. Neither the asked value nor the previous one. The camera declares no
|
|
28682
|
-
* allowed set for that field, so there is nothing to refuse against before the
|
|
28683
|
-
* wire: `/capabilities` returns a plain value where a constrained field would
|
|
28684
|
-
* carry an `opt=` list.
|
|
28685
|
-
*
|
|
28686
|
-
* So the only honest moment is after the read-back, and re-reading alone is
|
|
28687
|
-
* not enough — it makes the difference VISIBLE while leaving it unexplained.
|
|
28688
|
-
* A write that reports success for a value the camera never took is the same
|
|
28689
|
-
* silent substitution D599 removed from the clip path, wearing a different hat.
|
|
28690
|
-
*
|
|
28691
|
-
* Compares only the fields the patch actually named: a field nobody asked
|
|
28692
|
-
* about cannot have been clamped, and a read-back that could not answer it is
|
|
28693
|
-
* `stored: null` rather than a claim.
|
|
28694
|
-
*/
|
|
28695
|
-
function describeOnboardClamp(patch, landed) {
|
|
28696
|
-
const out = [];
|
|
28697
|
-
for (const [field, asked] of Object.entries(patch)) {
|
|
28698
|
-
if (asked === void 0) continue;
|
|
28699
|
-
if (typeof asked !== "number" && typeof asked !== "boolean" && typeof asked !== "string") continue;
|
|
28700
|
-
const raw = landed === null ? void 0 : landed[field];
|
|
28701
|
-
const stored = typeof raw === "number" || typeof raw === "boolean" || typeof raw === "string" ? raw : null;
|
|
28702
|
-
if (stored !== asked) out.push({
|
|
28703
|
-
field,
|
|
28704
|
-
asked,
|
|
28705
|
-
stored
|
|
28706
|
-
});
|
|
28707
|
-
}
|
|
28708
|
-
return out;
|
|
28709
|
-
}
|
|
28710
|
-
/**
|
|
28711
|
-
* Generic device-level status snapshot. Auto-registered by `BaseDevice`
|
|
28712
|
-
* for every device, regardless of provider — the kernel needs a uniform
|
|
28713
|
-
* cap-keyed slice for the basic device flags every consumer expects to
|
|
28714
|
-
* read across processes (the `online` flag in particular). Driver-specific
|
|
28715
|
-
* caps (`battery`, `doorbell`, …) carry their domain-specific state on
|
|
28716
|
-
* their own slices.
|
|
28717
|
-
*
|
|
28718
|
-
* Pattern is identical to `battery`: schema-bearing `runtimeState`,
|
|
28719
|
-
* empty `methods`, single change event. Reads land at
|
|
28720
|
-
* `runtimeState.getCapState('device-status')`; writes at
|
|
28721
|
-
* `runtimeState.setCapState('device-status', …)`. Cross-process
|
|
28722
|
-
* consumers reach the same data via the `device-state` cap router
|
|
28723
|
-
* (`getCapSlice({deviceId, capName: 'device-status'})`).
|
|
28724
|
-
*/
|
|
28725
|
-
var DeviceStatusSchema = object({
|
|
28726
|
-
/**
|
|
28727
|
-
* Device-level liveness. Drivers flip via `markOnline(boolean)` on
|
|
28728
|
-
* `BaseDevice`. Provider semantics vary — RTSP aggregates broker
|
|
28729
|
-
* stream-health, Reolink reads firmware push events, ONVIF tracks
|
|
28730
|
-
* ping responses. This cap intentionally does NOT prescribe which
|
|
28731
|
-
* signal drives the flag.
|
|
28732
|
-
*/
|
|
28733
|
-
online: boolean(),
|
|
28734
|
-
/** Ms epoch of the last `online` transition. Lets consumers tell
|
|
28735
|
-
* apart "just came online" from "still online". */
|
|
28736
|
-
lastChangedAt: number()
|
|
28737
|
-
});
|
|
28738
|
-
var deviceStatusCapability = {
|
|
28739
|
-
name: "device-status",
|
|
28740
|
-
scope: "device",
|
|
28741
|
-
deviceNative: true,
|
|
28742
|
-
mode: "singleton",
|
|
28743
|
-
methods: {},
|
|
28744
|
-
events: {
|
|
28745
|
-
/** Emitted when `online` transitions. Mirrors the semantics of
|
|
28746
|
-
* `battery.onStatusChanged`. */
|
|
28747
|
-
onStatusChanged: { data: object({
|
|
28748
|
-
deviceId: number(),
|
|
28749
|
-
status: DeviceStatusSchema
|
|
28750
|
-
}) } },
|
|
28751
|
-
status: {
|
|
28752
|
-
schema: DeviceStatusSchema,
|
|
28753
|
-
kind: "push"
|
|
28754
|
-
},
|
|
28755
|
-
runtimeState: DeviceStatusSchema,
|
|
28756
|
-
/**
|
|
28757
|
-
* Runtime-state durability: **restored** — the previous observation is what makes the first reading after a restart a COMPARISON instead of a phantom transition (D130). 32 real flips across 16 devices in 25 min — the busiest slice in the cold half.
|
|
28758
|
-
*
|
|
28759
|
-
* See `RuntimeStateDurability`. Enforced by
|
|
28760
|
-
* `scripts/check-runtime-state-durability.ts`.
|
|
28761
|
-
*/
|
|
28762
|
-
durability: "restored",
|
|
28763
|
-
/** Clock fields: written, but excluded from the compare that decides
|
|
28764
|
-
* whether persisting is worth a SQLite commit. */
|
|
28765
|
-
volatileStateFields: ["lastChangedAt"]
|
|
28766
|
-
};
|
|
28767
|
-
/**
|
|
28768
|
-
* Doorbell button cap. Two kinds of providers coexist behind this cap
|
|
28769
|
-
* name (same pattern as `snapshot`):
|
|
28770
|
-
*
|
|
28771
|
-
* - **Native** providers: registered per-device by device-driver
|
|
28772
|
-
* addons via `ctx.registerNativeCap` — either on a
|
|
28773
|
-
* `DeviceType.Button` accessory with `role: DeviceRole.Doorbell`,
|
|
28774
|
-
* or directly on the camera (Reolink registers at camera level).
|
|
28775
|
-
* Emits an `onPressed` event every time the firmware pushes a
|
|
28776
|
-
* ring; status tracks the last press and a pressCount since start
|
|
28777
|
-
* (diagnostic).
|
|
28778
|
-
*
|
|
28779
|
-
* - **Wrapper** provider: the `virtual-doorbell` system builtin
|
|
28780
|
-
* (`@camstack/system/builtins/doorbell`). Turns ANY binary-ish
|
|
28781
|
-
* device (contact / switch / event-emitter …) into a doorbell for
|
|
28782
|
-
* a camera. `defaultActive: false` — the operator explicitly binds
|
|
28783
|
-
* it per camera in the device-bindings UI, then picks the source
|
|
28784
|
-
* device + trigger in the per-device settings.
|
|
28785
|
-
*
|
|
28786
|
-
* The DeviceEventPropagator re-emits `onPressed` on the camera parent
|
|
28787
|
-
* — subscribers listening at the camera level receive ring events
|
|
28788
|
-
* with `via[]` populated. No code on the parent needed.
|
|
28789
|
-
*/
|
|
28790
|
-
var DoorbellStatusSchema = object({
|
|
28791
|
-
/** Ms epoch of the last press. null = never observed since this provider started. */
|
|
28792
|
-
lastPressedAt: number().nullable(),
|
|
28793
|
-
/** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
|
|
28794
|
-
pressCountSinceStart: number()
|
|
28795
|
-
});
|
|
28796
|
-
var DoorbellPressEventSchema = object({
|
|
28797
|
-
deviceId: number(),
|
|
28798
|
-
timestamp: number()
|
|
28799
|
-
});
|
|
28800
|
-
var doorbellCapability = {
|
|
28801
|
-
name: "doorbell",
|
|
28802
|
-
scope: "device",
|
|
28803
|
-
deviceNative: true,
|
|
28804
|
-
mode: "singleton",
|
|
28805
|
-
kind: "wrapper",
|
|
28806
|
-
defaultActive: false,
|
|
28807
|
-
deviceTypes: [DeviceType.Button, DeviceType.Camera],
|
|
28808
|
-
exposesDeviceSettings: true,
|
|
28809
|
-
methods: {},
|
|
28810
|
-
events: {
|
|
28811
|
-
/**
|
|
28812
|
-
* Fires once per physical press. Reolink delivers via Baichuan
|
|
28813
|
-
* push (`ReolinkSimpleEvent.type === 'doorbell'`). There is no
|
|
28814
|
-
* release/duration — it's a pulse.
|
|
28815
|
-
*/
|
|
28816
|
-
onPressed: { data: DoorbellPressEventSchema } },
|
|
28817
|
-
status: {
|
|
28818
|
-
schema: DoorbellStatusSchema,
|
|
28819
|
-
kind: "push"
|
|
28820
|
-
},
|
|
28821
|
-
/**
|
|
28822
|
-
* Runtime-state slice — last press timestamp + lifetime press count.
|
|
28823
|
-
* Mirrored by the kernel and readable via
|
|
28824
|
-
* `device.state.doorbell.value`. UIs can show "last ring 5m ago"
|
|
28825
|
-
* without subscribing.
|
|
28826
|
-
*/
|
|
28827
|
-
runtimeState: DoorbellStatusSchema,
|
|
28828
|
-
/**
|
|
28829
|
-
* Runtime-state durability: **restored** — a monotonic accumulator: the slice IS the record. `lastPressedAt` is content here, not a clock, so it is deliberately NOT volatile.
|
|
28830
|
-
*
|
|
28831
|
-
* See `RuntimeStateDurability`. Enforced by
|
|
28832
|
-
* `scripts/check-runtime-state-durability.ts`.
|
|
28833
|
-
*/
|
|
28834
|
-
durability: "restored"
|
|
28835
|
-
};
|
|
28836
|
-
/**
|
|
28837
|
-
* Enum-state sensor — a string value picked from a finite option set.
|
|
28838
|
-
* Drives HA `sensor` entries with `state_class: enum` (HVAC action
|
|
28839
|
-
* states, weather conditions, contact-source channels, mode strings).
|
|
28840
|
-
* The option set is stable across observations; it is persisted in the
|
|
28841
|
-
* device config blob (via the control slice at adoption) and is NOT
|
|
28842
|
-
* stored in `sourceInfo`.
|
|
28843
|
-
*/
|
|
28844
|
-
/** Locale-render shape for an ISO `value` carried by a `DateTimeSensor`-role
|
|
28845
|
-
* enum sensor: `date` (date-only), `time` (time-only), `datetime` (both). */
|
|
28846
|
-
var EnumSensorDateTimeFormatSchema = _enum([
|
|
28847
|
-
"date",
|
|
28848
|
-
"time",
|
|
28849
|
-
"datetime"
|
|
28850
|
-
]);
|
|
28851
|
-
var EnumSensorStatusSchema = object({
|
|
28852
|
-
value: string(),
|
|
28853
|
-
/**
|
|
28854
|
-
* Set for `DateTimeSensor`-role sensors so the UI renders the ISO `value`
|
|
28855
|
-
* as a locale date/time/datetime; absent for plain enum sensors. HA
|
|
28856
|
-
* `device_class=timestamp` → `'datetime'`, `device_class=date` → `'date'`,
|
|
28857
|
-
* a time-only sensor → `'time'`.
|
|
28858
|
-
*/
|
|
28859
|
-
format: EnumSensorDateTimeFormatSchema.optional(),
|
|
28860
|
-
/** Ms epoch when the slice was last updated. */
|
|
28861
|
-
lastFetchedAt: number()
|
|
28862
|
-
});
|
|
28863
|
-
var enumSensorCapability = {
|
|
28864
|
-
name: "enum-sensor",
|
|
28865
|
-
scope: "device",
|
|
28866
|
-
deviceNative: true,
|
|
28867
|
-
mode: "singleton",
|
|
28868
|
-
deviceTypes: [DeviceType.Sensor],
|
|
28869
|
-
methods: {},
|
|
28870
|
-
status: {
|
|
28871
|
-
schema: EnumSensorStatusSchema,
|
|
28872
|
-
kind: "push"
|
|
28873
|
-
},
|
|
28874
|
-
runtimeState: EnumSensorStatusSchema,
|
|
28875
|
-
/**
|
|
28876
|
-
* Runtime-state durability: **restored** — as `numeric-sensor`; 80 devices.
|
|
28877
|
-
*
|
|
28878
|
-
* See `RuntimeStateDurability`. Enforced by
|
|
28879
|
-
* `scripts/check-runtime-state-durability.ts`.
|
|
28880
|
-
*/
|
|
28881
|
-
durability: "restored",
|
|
28882
|
-
/** Clock fields: written, but excluded from the compare that decides
|
|
28883
|
-
* whether persisting is worth a SQLite commit. */
|
|
28884
|
-
volatileStateFields: ["lastFetchedAt"]
|
|
28885
|
-
};
|
|
28886
|
-
/**
|
|
28887
|
-
* Generic stateless event emitter. Installed on a `DeviceType.EventEmitter`
|
|
28888
|
-
* device. Carries the device's EXACT declared event vocabulary verbatim
|
|
28889
|
-
* (NO normalization). Two shapes:
|
|
28890
|
-
* - structured source (HA `event.*` entity) → `eventTypes` is the fixed
|
|
28891
|
-
* declared vocabulary (e.g. ['press_short','press_long',...]).
|
|
28892
|
-
* - generic/legacy source (HA bus events, e.g. zha_event) → `eventTypes`
|
|
28893
|
-
* is [] (open) and `lastEvent.data` carries the complex payload.
|
|
28894
|
-
* `seq` is monotonic so two identical events still produce distinct slice writes.
|
|
28895
|
-
*/
|
|
28896
|
-
var EventFireSchema = object({
|
|
28897
|
-
deviceId: number(),
|
|
28898
|
-
eventType: string(),
|
|
28899
|
-
data: record(string(), unknown()).nullable(),
|
|
28900
|
-
timestamp: number(),
|
|
28901
|
-
seq: number()
|
|
28902
|
-
});
|
|
28903
|
-
var EventEmitterStatusSchema = object({
|
|
28904
|
-
eventTypes: array(string()),
|
|
28905
|
-
lastEvent: EventFireSchema.nullable(),
|
|
28906
|
-
eventCountSinceStart: number()
|
|
28907
|
-
});
|
|
28908
|
-
var eventEmitterCapability = {
|
|
28909
|
-
name: "event-emitter",
|
|
28910
|
-
scope: "device",
|
|
28911
|
-
deviceNative: true,
|
|
28912
|
-
mode: "singleton",
|
|
28913
|
-
deviceTypes: [DeviceType.EventEmitter],
|
|
28914
|
-
methods: {},
|
|
28915
|
-
events: { onEvent: { data: EventFireSchema } },
|
|
28916
|
-
status: {
|
|
28917
|
-
schema: EventEmitterStatusSchema,
|
|
28918
|
-
kind: "push"
|
|
28919
|
-
},
|
|
28920
|
-
runtimeState: EventEmitterStatusSchema,
|
|
28921
|
-
/**
|
|
28922
|
-
* Runtime-state durability: **session** — `eventCountSinceStart` names its own scope.
|
|
28923
|
-
*
|
|
28924
|
-
* See `RuntimeStateDurability`. Enforced by
|
|
28925
|
-
* `scripts/check-runtime-state-durability.ts`.
|
|
28592
|
+
* See `RuntimeStateDurability`. Enforced by
|
|
28593
|
+
* `scripts/check-runtime-state-durability.ts`.
|
|
28926
28594
|
*/
|
|
28927
28595
|
durability: "session"
|
|
28928
28596
|
};
|
|
28929
|
-
var EventItemSchema = object({
|
|
28930
|
-
id: string(),
|
|
28931
|
-
type: string(),
|
|
28932
|
-
timestamp: number(),
|
|
28933
|
-
label: string().optional(),
|
|
28934
|
-
thumbnailUrl: string().optional(),
|
|
28935
|
-
clipUrl: string().optional(),
|
|
28936
|
-
metadata: record(string(), unknown()).optional()
|
|
28937
|
-
});
|
|
28938
|
-
DeviceType.Camera, method(object({
|
|
28939
|
-
deviceId: number(),
|
|
28940
|
-
from: number().optional(),
|
|
28941
|
-
to: number().optional(),
|
|
28942
|
-
limit: number().optional()
|
|
28943
|
-
}), array(EventItemSchema)), method(object({
|
|
28944
|
-
deviceId: number(),
|
|
28945
|
-
eventId: string()
|
|
28946
|
-
}), object({
|
|
28947
|
-
base64: string(),
|
|
28948
|
-
contentType: string()
|
|
28949
|
-
}).nullable()), method(object({
|
|
28950
|
-
deviceId: number(),
|
|
28951
|
-
eventId: string()
|
|
28952
|
-
}), string().nullable());
|
|
28953
28597
|
var IdentitySchema = object({
|
|
28954
28598
|
id: string(),
|
|
28955
28599
|
name: string(),
|
|
@@ -31227,143 +30871,6 @@ var motionTriggerCapability = {
|
|
|
31227
30871
|
durability: "session"
|
|
31228
30872
|
};
|
|
31229
30873
|
/**
|
|
31230
|
-
* camera-grid-layout — the geometry of a COMPOSITE camera, on the camera's own
|
|
31231
|
-
* page.
|
|
31232
|
-
*
|
|
31233
|
-
* ## Why this is a capability and not an addon settings schema
|
|
31234
|
-
*
|
|
31235
|
-
* It was one, and it did not render. The addon declared the editor as a
|
|
31236
|
-
* `type: 'widget'` field inside its own `deviceSettingsSchema()`; the hub
|
|
31237
|
-
* returned that section correctly and `ConfigFormField` renders `type:'widget'`
|
|
31238
|
-
* perfectly well — and nothing ever asked camera-grid for it. The Cluster →
|
|
31239
|
-
* Pipeline → Device Overrides page interrogates a HAND-WRITTEN list of four
|
|
31240
|
-
* addons (`PIPELINE_CLUSTER_DEVICE_ADDONS`), whose own comment says an addon
|
|
31241
|
-
* not on it "falls off silently".
|
|
31242
|
-
*
|
|
31243
|
-
* Adding a fifth name to that list would have been the wrong fix twice over:
|
|
31244
|
-
* that page is per-camera DETECTION tuning, and a grid's geometry belongs
|
|
31245
|
-
* beside PTZ and motion zones on the camera itself. The device page is
|
|
31246
|
-
* BINDING-driven (D12), so the way in is a capability bound to the device —
|
|
31247
|
-
* and this cap carries its section the way `recording` does, by RETURNING it
|
|
31248
|
-
* from `getDeviceSettingsContribution`.
|
|
31249
|
-
*
|
|
31250
|
-
* Seven other widgets are still declared the other way, through a
|
|
31251
|
-
* `deviceConfig.ui` block the framework derives a section from. That route
|
|
31252
|
-
* gives the addon no say in where its own panel lands and no way to decline
|
|
31253
|
-
* for a device the panel does not suit, which is why this one does not use it.
|
|
31254
|
-
*
|
|
31255
|
-
* ## Why one addon may implement it
|
|
31256
|
-
*
|
|
31257
|
-
* It is a device-scoped NATIVE cap, registered by the grid camera device
|
|
31258
|
-
* itself. Nothing else declares a composite camera, so nothing else has a
|
|
31259
|
-
* layout — and the device-scoped route means the widget asks THE camera, not
|
|
31260
|
-
* "the camera-grid addon", which is what let the old custom-action pair be
|
|
31261
|
-
* reached only by a caller that already knew the addon id.
|
|
31262
|
-
*
|
|
31263
|
-
* ## The tab
|
|
31264
|
-
*
|
|
31265
|
-
* `streaming`, not a top-tab of its own. A grid's geometry IS what its stream
|
|
31266
|
-
* is, so the Streaming tab is where it belongs; a `grid` top-tab would need an
|
|
31267
|
-
* entry in `WELL_KNOWN_TAB_MAP` or the device page renders the raw id as the
|
|
31268
|
-
* label (measured on the robot camera, 2026-09-06 — a tab called "navigation"
|
|
31269
|
-
* next to "PTZ").
|
|
31270
|
-
*/
|
|
31271
|
-
/** A rectangle in normalized [0,1] coordinates of whatever contains it. */
|
|
31272
|
-
var GridNormalizedRectSchema = object({
|
|
31273
|
-
x: number().min(0).max(1),
|
|
31274
|
-
y: number().min(0).max(1),
|
|
31275
|
-
width: number().gt(0).max(1),
|
|
31276
|
-
height: number().gt(0).max(1)
|
|
31277
|
-
});
|
|
31278
|
-
/**
|
|
31279
|
-
* One source camera, the part of its picture taken, and where that part lands.
|
|
31280
|
-
*
|
|
31281
|
-
* Both rectangles are NORMALIZED (D519): a source camera can change resolution
|
|
31282
|
-
* — a profile switch, a firmware update, a substream that comes back different
|
|
31283
|
-
* — and a stored PIXEL rectangle would quietly start cutting the wrong region,
|
|
31284
|
-
* which is the class of bug nobody files.
|
|
31285
|
-
*/
|
|
31286
|
-
var GridLayoutCellSchema = object({
|
|
31287
|
-
deviceId: number().int().positive(),
|
|
31288
|
-
/** The part of the SOURCE taken, normalized against the source. */
|
|
31289
|
-
source: GridNormalizedRectSchema,
|
|
31290
|
-
/** Where it lands, normalized against the CANVAS. */
|
|
31291
|
-
cell: GridNormalizedRectSchema
|
|
31292
|
-
});
|
|
31293
|
-
/**
|
|
31294
|
-
* Which profiles this grid can actually compose, and why not.
|
|
31295
|
-
*
|
|
31296
|
-
* A grid's `high` composes its sources' `high` and its `low` their `low`, so a
|
|
31297
|
-
* profile is on offer only when EVERY source can serve it. The refusal NAMES
|
|
31298
|
-
* the sources, because "this grid has no low" is not a finding — "615 has no
|
|
31299
|
-
* low" is, and it is the one an operator can act on.
|
|
31300
|
-
*/
|
|
31301
|
-
var GridProfileOfferSchema = object({
|
|
31302
|
-
profile: _enum([
|
|
31303
|
-
"high",
|
|
31304
|
-
"mid",
|
|
31305
|
-
"low"
|
|
31306
|
-
]),
|
|
31307
|
-
offered: boolean(),
|
|
31308
|
-
/** Sources that cannot serve it. Empty when it is offered, or when there are no cells. */
|
|
31309
|
-
missingSources: array(number().int().positive()),
|
|
31310
|
-
/**
|
|
31311
|
-
* The canvas this profile composes onto, `WxH`, or empty when it is not
|
|
31312
|
-
* offered. DERIVED from the cells and the sources' own size at this profile —
|
|
31313
|
-
* it is reported because nothing else in the system would ever say what the
|
|
31314
|
-
* grid came out as, and because it is the number an operator would otherwise
|
|
31315
|
-
* expect to type.
|
|
31316
|
-
*/
|
|
31317
|
-
canvas: string(),
|
|
31318
|
-
/**
|
|
31319
|
-
* Whether this profile is PUBLISHED, of the ones the grid could serve.
|
|
31320
|
-
*
|
|
31321
|
-
* A grid's `high` is composed of its sources' `high`, so on a 4K fleet it is
|
|
31322
|
-
* a 4K canvas built from 4K decodes — something to opt into, not something a
|
|
31323
|
-
* viewer's adaptive should be handed by climbing to the top rung it can see.
|
|
31324
|
-
* Default is `mid` + `low`.
|
|
31325
|
-
*/
|
|
31326
|
-
published: boolean()
|
|
31327
|
-
});
|
|
31328
|
-
var GridLayoutViewSchema = object({
|
|
31329
|
-
/** The persisted grid row this camera was declared from. */
|
|
31330
|
-
instanceId: string(),
|
|
31331
|
-
deviceId: number().int().nonnegative(),
|
|
31332
|
-
name: string(),
|
|
31333
|
-
/**
|
|
31334
|
-
* NO canvas size. A grid's resolution is not authored: each profile derives
|
|
31335
|
-
* its own from the cells and its sources' dimensions. The two numbers that
|
|
31336
|
-
* used to be here were a text field that silently decided both how much the
|
|
31337
|
-
* composite cost and how sharp it was — see `profiles[].canvas` for what it
|
|
31338
|
-
* came out as.
|
|
31339
|
-
*/
|
|
31340
|
-
fps: number().int(),
|
|
31341
|
-
cells: array(GridLayoutCellSchema),
|
|
31342
|
-
/** What the catalog will publish, and what it refuses to. Read-only. */
|
|
31343
|
-
profiles: array(GridProfileOfferSchema)
|
|
31344
|
-
});
|
|
31345
|
-
var GridLayoutPatchSchema = object({
|
|
31346
|
-
deviceId: number().int().nonnegative(),
|
|
31347
|
-
name: string().min(1).max(160).optional(),
|
|
31348
|
-
fps: number().int().min(1).max(60).optional(),
|
|
31349
|
-
/** Which profiles to publish. See `GridProfileOffer.published`. */
|
|
31350
|
-
publishedProfiles: array(_enum([
|
|
31351
|
-
"high",
|
|
31352
|
-
"mid",
|
|
31353
|
-
"low"
|
|
31354
|
-
])).max(3).optional(),
|
|
31355
|
-
/**
|
|
31356
|
-
* The whole cell list at once. A per-cell patch would need an ordering the
|
|
31357
|
-
* editor does not have, and a half-applied layout is a picture nobody asked
|
|
31358
|
-
* for.
|
|
31359
|
-
*/
|
|
31360
|
-
cells: array(GridLayoutCellSchema).max(16)
|
|
31361
|
-
});
|
|
31362
|
-
DeviceType.Camera, method(object({ deviceId: number().int().nonnegative() }), GridLayoutViewSchema.nullable(), { auth: "admin" }), method(GridLayoutPatchSchema, GridLayoutViewSchema, {
|
|
31363
|
-
kind: "mutation",
|
|
31364
|
-
auth: "admin"
|
|
31365
|
-
});
|
|
31366
|
-
/**
|
|
31367
30874
|
* Motion-zones share the same MaskShape vocabulary as privacy-mask — the
|
|
31368
30875
|
* on-camera motion-detection mask is a single `grid` region (a row-major
|
|
31369
30876
|
* boolean cell lattice the camera's onboard VMD evaluates). Composing it as
|
|
@@ -33909,37 +33416,37 @@ var rebootCapability = {
|
|
|
33909
33416
|
auth: "admin"
|
|
33910
33417
|
}) }
|
|
33911
33418
|
};
|
|
33912
|
-
/**
|
|
33913
|
-
* `recording` cap — footage availability + HLS playback manifests + per-device
|
|
33914
|
-
* recording config. NOTE on events (source of truth, R5/C3): this cap carries
|
|
33915
|
-
* NO event surface — `getPlaybackManifest` returns playlist URLs only. Timeline
|
|
33916
|
-
* events (motion/object/audio) come from `pipelineAnalytics` (durable SQLite
|
|
33917
|
-
* rows) and are the ONLY event surface — the recorder has none. The in-RAM
|
|
33918
|
-
* playback markers it used to build were deleted on 2026-08-29 because nothing
|
|
33919
|
-
* ever read them. Event<->footage joins are by time, padded with the shared
|
|
33920
|
-
* `EVENT_PAD_MS` (`interfaces/recording-config.ts`).
|
|
33921
|
-
*/
|
|
33922
|
-
var RecordingStatusSchema = object({
|
|
33923
|
-
deviceId: number(),
|
|
33924
|
-
enabled: boolean(),
|
|
33925
|
-
/** THE derived storage mode, from the one definition
|
|
33926
|
-
* (`deriveRecordingMode`) — never a second enum. A duplicated list is how
|
|
33927
|
-
* `on-device-decision` could have reached the recorder and not the status. */
|
|
33928
|
-
activeMode: RecordingStorageModeSchema,
|
|
33929
|
-
nodeId: string(),
|
|
33930
|
-
storageBytes: number()
|
|
33931
|
-
});
|
|
33932
33419
|
var RecordingRangeSchema = object({
|
|
33933
33420
|
profile: string(),
|
|
33934
33421
|
startMs: number(),
|
|
33935
33422
|
endMs: number()
|
|
33936
33423
|
});
|
|
33424
|
+
/**
|
|
33425
|
+
* How a source ANSWERED, on every singular read of this cap.
|
|
33426
|
+
*
|
|
33427
|
+
* `'read'` — it looked. `ranges: []` / `days: []` is then a real claim: this
|
|
33428
|
+
* source has no coverage in the window. `'unreadable'` — nobody could look
|
|
33429
|
+
* (the camera was unreachable, the calendar rung threw, the location is
|
|
33430
|
+
* unmounted, the node is still on the old build), and the emptiness beside it
|
|
33431
|
+
* means NOTHING.
|
|
33432
|
+
*
|
|
33433
|
+
* The batch rows have carried this since the grid existed; the SINGULAR
|
|
33434
|
+
* answers gained it with the collection (D625 §10.4), because they are the
|
|
33435
|
+
* ones the single-camera picker uses and because a half-converted fleet makes
|
|
33436
|
+
* "nobody looked" common for the length of a deploy. Without it the timeline
|
|
33437
|
+
* has no vocabulary for it, and `(data ?? [])` in a viewer turns a rollout into
|
|
33438
|
+
* a fleet of cameras that appear to have lost their recordings (D315, D393).
|
|
33439
|
+
*/
|
|
33440
|
+
var RecordingReadSchema = _enum(["read", "unreadable"]);
|
|
33937
33441
|
var RecordingAvailabilitySchema = object({
|
|
33938
33442
|
deviceId: number(),
|
|
33443
|
+
/** See {@link RecordingReadSchema}. An `'unreadable'` answer carries an empty
|
|
33444
|
+
* `ranges` that means nothing — never draw it as "no footage". */
|
|
33445
|
+
read: RecordingReadSchema,
|
|
33939
33446
|
ranges: array(RecordingRangeSchema),
|
|
33940
33447
|
/**
|
|
33941
|
-
* Every profile this camera has footage in — not only the one
|
|
33942
|
-
* describes (D433).
|
|
33448
|
+
* Every profile this camera has footage in AT THIS SOURCE — not only the one
|
|
33449
|
+
* `ranges` describes (D433).
|
|
33943
33450
|
*
|
|
33944
33451
|
* `ranges` answers for ONE profile by design: the timeline is a single bar,
|
|
33945
33452
|
* and enumerating all of them triples the directory reads for a bar that
|
|
@@ -33954,17 +33461,287 @@ var RecordingAvailabilitySchema = object({
|
|
|
33954
33461
|
*/
|
|
33955
33462
|
profilesWithFootage: array(string())
|
|
33956
33463
|
});
|
|
33957
|
-
var RecordingDaysSchema = object({
|
|
33464
|
+
var RecordingDaysSchema = object({
|
|
33465
|
+
deviceId: number(),
|
|
33466
|
+
/** See {@link RecordingReadSchema}. `days: []` on an `'unreadable'` answer is
|
|
33467
|
+
* "nobody could look", and the date-picker must not spell it the same as
|
|
33468
|
+
* "no footage this month". */
|
|
33469
|
+
read: RecordingReadSchema,
|
|
33470
|
+
/** Local-midnight epochs (UTC ms) of days that have ≥1 recorded segment. */
|
|
33471
|
+
days: array(number())
|
|
33472
|
+
});
|
|
33473
|
+
var RecordingManifestSchema = object({
|
|
33474
|
+
deviceId: number(),
|
|
33475
|
+
/** Local filesystem path to the master playlist; null when no recording exists for the requested range. */
|
|
33476
|
+
localMasterPath: string().nullable(),
|
|
33477
|
+
/** HTTP(S) URL to the master playlist on the recording node's playback server
|
|
33478
|
+
* (the PRIMARY candidate); null when no recording / server. Carries the
|
|
33479
|
+
* scoped playback token in its path. */
|
|
33480
|
+
playbackUrl: string().nullable(),
|
|
33481
|
+
/**
|
|
33482
|
+
* Candidate master-playlist URLs the client tries in order (LAN first, then
|
|
33483
|
+
* remote — Tailscale/Cloudflare if the operator configured extra hosts), each
|
|
33484
|
+
* carrying the same scoped token. `playbackUrl` is the first entry. Empty when
|
|
33485
|
+
* there is no recording / server.
|
|
33486
|
+
*/
|
|
33487
|
+
playbackEndpoints: array(string())
|
|
33488
|
+
});
|
|
33489
|
+
var RecordingSourceAvailabilitySchema = object({
|
|
33490
|
+
state: _enum([
|
|
33491
|
+
"ok",
|
|
33492
|
+
"sleeping",
|
|
33493
|
+
"unreachable",
|
|
33494
|
+
"no-storage",
|
|
33495
|
+
"index-empty"
|
|
33496
|
+
]),
|
|
33497
|
+
/** Free text, shown verbatim. Names the camera's own refusal when there is one. */
|
|
33498
|
+
reason: string().optional(),
|
|
33499
|
+
/** When this source's coverage was last CONFIRMED. A cached answer is never
|
|
33500
|
+
* drawn as current: the surface shows the age whenever it is older than the
|
|
33501
|
+
* refresh interval. The clip catalog's `catalogAsOf`, under the name the
|
|
33502
|
+
* timeline uses for it. */
|
|
33503
|
+
coverageAsOf: number().optional()
|
|
33504
|
+
});
|
|
33505
|
+
/**
|
|
33506
|
+
* One SOURCE of recorded coverage for a camera — a row of the picker.
|
|
33507
|
+
*
|
|
33508
|
+
* A provider lists the sources IT serves for that device, and answers for each
|
|
33509
|
+
* of them whether it can answer at all. A provider with nothing to offer on a
|
|
33510
|
+
* camera returns `[]` — it is not that camera's business. The five availability
|
|
33511
|
+
* states are `ClipSourceAvailability`'s verbatim: they mean exactly the same
|
|
33512
|
+
* things about a coverage index as about a clip catalog, and `sleeping` in
|
|
33513
|
+
* particular is what stops a battery camera being woken to paint a bar.
|
|
33514
|
+
*/
|
|
33515
|
+
var RecordingSourceSchema = object({
|
|
33516
|
+
/** The source id. {@link RECORDING_SOURCE_CAMSTACK} for ours (RESERVED), a
|
|
33517
|
+
* vendor namespace (`native:reolink:onboard`, …) for a camera's own store. */
|
|
33518
|
+
source: string(),
|
|
33519
|
+
/** Operator-facing name of the source ("CamStack recordings", "SD card"). */
|
|
33520
|
+
label: string(),
|
|
33521
|
+
/**
|
|
33522
|
+
* The addon that SERVES this row, and the value a later call passes as
|
|
33523
|
+
* `provider`.
|
|
33524
|
+
*
|
|
33525
|
+
* Optional for version skew only. The collection dispatcher stamps it from
|
|
33526
|
+
* the registry, so a row that travelled through the fan-out carries the
|
|
33527
|
+
* authoritative id whatever the provider filled in (D557 §4).
|
|
33528
|
+
*/
|
|
33529
|
+
addonId: string().optional(),
|
|
33530
|
+
availability: RecordingSourceAvailabilitySchema
|
|
33531
|
+
});
|
|
33532
|
+
/**
|
|
33533
|
+
* What a surface may DRAW for this (camera, source) — D612's rule applied to a
|
|
33534
|
+
* timeline: **the source declares what it can do, and the surface draws what
|
|
33535
|
+
* was declared. It never assumes, and never offers a gesture it will then
|
|
33536
|
+
* refuse.** D612 exists because `8` and `16` were offered as clip rates, the
|
|
33537
|
+
* broker clamped them to `4`, and no line anywhere said so.
|
|
33538
|
+
*
|
|
33539
|
+
* Asked once per (camera, source) before anything is drawn — never replaced by
|
|
33540
|
+
* a constant the surface keeps, which is the second authority D612 ends.
|
|
33541
|
+
*/
|
|
33542
|
+
var RecordingSourceOptionsSchema = object({
|
|
33543
|
+
/** How this source's media reaches the player.
|
|
33544
|
+
* `archive` = our own indexed segment tree; `stream` = the provider's
|
|
33545
|
+
* forward-only fMP4 (D597); `realtime` = a replay bound to wall clock. */
|
|
33546
|
+
transport: _enum([
|
|
33547
|
+
"archive",
|
|
33548
|
+
"stream",
|
|
33549
|
+
"realtime"
|
|
33550
|
+
]),
|
|
33551
|
+
/** What the BAR means. `continuous` = gaps are holes in a recording;
|
|
33552
|
+
* `sparse` = gaps are the absence of one, and must be drawn as such.
|
|
33553
|
+
*
|
|
33554
|
+
* Not an onboard-only concession: measured 2026-09-24, OUR bar covers 98.8 %
|
|
33555
|
+
* of 592's day and 1.2 % of 1436's. It is a fact about a (source, camera)
|
|
33556
|
+
* pair, and ours answers it per camera from `deriveRecordingMode`. */
|
|
33557
|
+
coverage: _enum(["continuous", "sparse"]),
|
|
33558
|
+
/** Where the playhead may be put.
|
|
33559
|
+
* `free` — anywhere, to the frame.
|
|
33560
|
+
* `forward` — only ahead of the current position.
|
|
33561
|
+
* `segment` — a position SNAPS to the head of the covering segment; a finer
|
|
33562
|
+
* ask is accepted by the camera and SILENTLY IGNORED. Measured
|
|
33563
|
+
* on 1436 (Hikvision V5.7.1, 2026-09-23): a window-narrowed
|
|
33564
|
+
* `ContentMgmt/search` returns a row and a `playbackURI`, the
|
|
33565
|
+
* replay opens 200 and delivers media — and the burned-in OSD of
|
|
33566
|
+
* the first frame reads the SEGMENT HEAD every time. Calling
|
|
33567
|
+
* that `forward` would tell the surface it may move the playhead
|
|
33568
|
+
* ahead within a loaded segment, which it may not. */
|
|
33569
|
+
seek: _enum([
|
|
33570
|
+
"free",
|
|
33571
|
+
"forward",
|
|
33572
|
+
"segment"
|
|
33573
|
+
]),
|
|
33574
|
+
/** Frame-step BACKWARD is meaningful. */
|
|
33575
|
+
stepBack: boolean(),
|
|
33576
|
+
/** Whether the drag-scrub gesture is served, as opposed to refused by name. */
|
|
33577
|
+
scrub: boolean(),
|
|
33578
|
+
/** Deliverable rates, ascending, always containing `1`. The surface draws its
|
|
33579
|
+
* picker from this and from NOTHING else (D612, D620, D621). `0` is not a
|
|
33580
|
+
* member: pause is the absence of a rate. */
|
|
33581
|
+
rates: array(number().positive()).min(1).readonly(),
|
|
33582
|
+
/** TRUE when a read of this source HOLDS the camera's only playback session.
|
|
33583
|
+
* A surface with this set makes at most ONE read at a time and draws no
|
|
33584
|
+
* scrub-thumbnail strip, no hover preview, no prefetch and no background
|
|
33585
|
+
* refresh. The precedent is exact and expensive: filling one screen of
|
|
33586
|
+
* Hikvision thumbnails at 1.01× realtime consumed fifteen minutes of that
|
|
33587
|
+
* camera's only playback session (1.2.126, reported within minutes), and a
|
|
33588
|
+
* timeline is a screenful of reads by construction. */
|
|
33589
|
+
exclusive: boolean()
|
|
33590
|
+
});
|
|
33591
|
+
/**
|
|
33592
|
+
* How to PLAY the instant that was asked for, from the chosen source.
|
|
33593
|
+
*
|
|
33594
|
+
* No new media transport is built for onboard sources: the `clip` arm is a
|
|
33595
|
+
* DELEGATION to the `videoclips` transport that vendor already has (D597 /
|
|
33596
|
+
* D616 / D617). The onboard half of this collection is a PROJECTION of
|
|
33597
|
+
* `videoclips` for coverage and a delegation to it for bytes.
|
|
33598
|
+
*/
|
|
33599
|
+
var RecordingPlaybackSchema = discriminatedUnion("kind", [
|
|
33600
|
+
object({
|
|
33601
|
+
kind: literal("hls"),
|
|
33602
|
+
manifest: RecordingManifestSchema
|
|
33603
|
+
}),
|
|
33604
|
+
object({
|
|
33605
|
+
kind: literal("clip"),
|
|
33606
|
+
/** The `videoclips` source namespace this clip id belongs to. */
|
|
33607
|
+
source: string(),
|
|
33608
|
+
clipId: string(),
|
|
33609
|
+
/** Where this clip actually STARTS. On a `seek: 'segment'` source the
|
|
33610
|
+
* playhead lands here, not at the requested instant — the surface must be
|
|
33611
|
+
* TOLD, not left to discover it from a burned-in OSD. */
|
|
33612
|
+
startsAtMs: number()
|
|
33613
|
+
}),
|
|
33614
|
+
object({
|
|
33615
|
+
kind: literal("none"),
|
|
33616
|
+
reason: string()
|
|
33617
|
+
})
|
|
33618
|
+
]);
|
|
33619
|
+
DeviceType.Camera, method(object({ deviceId: number() }), array(RecordingSourceSchema).readonly(), {
|
|
33620
|
+
kind: "query",
|
|
33621
|
+
auth: "protected"
|
|
33622
|
+
}), method(object({
|
|
33623
|
+
deviceId: number(),
|
|
33624
|
+
/**
|
|
33625
|
+
* WHICH provider to ask — the `addonId` a {@link RecordingSourceSchema}
|
|
33626
|
+
* row carries, never a source id and never a list. **REQUIRED**, in the
|
|
33627
|
+
* schema, where the generated types make it unomittable rather than
|
|
33628
|
+
* merely discouraged (D554 amended).
|
|
33629
|
+
*
|
|
33630
|
+
* It was learned the expensive way on `videoclips.listClips`: measured
|
|
33631
|
+
* on the live hub 2026-09-20, device 592 bound to `recorder` AND
|
|
33632
|
+
* `provider-reolink`, a bare call with `limit: 3` answered SIX rows,
|
|
33633
|
+
* three from each source, merged — `device-collection-dispatch.ts`
|
|
33634
|
+
* leaves an unpinned fan-out un-narrowed, so absence buys the union the
|
|
33635
|
+
* method exists not to be. An un-narrowed `getAvailability` would do
|
|
33636
|
+
* that to a TIMELINE: our ranges and the card's clips unioned into one
|
|
33637
|
+
* bar, which is "two sources are never drawn together" broken in the
|
|
33638
|
+
* one place it matters most.
|
|
33639
|
+
*
|
|
33640
|
+
* A provider the device is not bound to is refused BY NAME (D552's
|
|
33641
|
+
* `rejectUnresolvedAddonPin`), never answered by another one.
|
|
33642
|
+
*/
|
|
33643
|
+
provider: string().min(1),
|
|
33644
|
+
fromMs: number(),
|
|
33645
|
+
toMs: number(),
|
|
33646
|
+
/**
|
|
33647
|
+
* Answer for THIS profile instead of the source's preferred one (D433).
|
|
33648
|
+
* Absent keeps the timeline's behaviour — one bar, one profile, one set
|
|
33649
|
+
* of reads. `profilesWithFootage` on the answer says what may be asked
|
|
33650
|
+
* for.
|
|
33651
|
+
*/
|
|
33652
|
+
profile: string().optional()
|
|
33653
|
+
}), RecordingAvailabilitySchema, {
|
|
33654
|
+
kind: "query",
|
|
33655
|
+
auth: "protected"
|
|
33656
|
+
}), method(object({
|
|
33657
|
+
deviceId: number(),
|
|
33658
|
+
provider: string().min(1),
|
|
33659
|
+
fromMs: number(),
|
|
33660
|
+
toMs: number(),
|
|
33661
|
+
tzOffsetMinutes: number()
|
|
33662
|
+
}), RecordingDaysSchema, {
|
|
33663
|
+
kind: "query",
|
|
33664
|
+
auth: "protected"
|
|
33665
|
+
}), method(object({
|
|
33666
|
+
deviceId: number(),
|
|
33667
|
+
provider: string().min(1),
|
|
33668
|
+
fromMs: number(),
|
|
33669
|
+
toMs: number(),
|
|
33670
|
+
profile: CamProfileSchema.optional()
|
|
33671
|
+
}), RecordingPlaybackSchema, {
|
|
33672
|
+
kind: "query",
|
|
33673
|
+
auth: "protected"
|
|
33674
|
+
}), method(object({
|
|
33675
|
+
deviceId: number(),
|
|
33676
|
+
provider: string().min(1)
|
|
33677
|
+
}), RecordingSourceOptionsSchema, {
|
|
33678
|
+
kind: "query",
|
|
33679
|
+
auth: "protected"
|
|
33680
|
+
});
|
|
33681
|
+
/**
|
|
33682
|
+
* `recording-archive` — OUR archive, and the intent that fills it.
|
|
33683
|
+
*
|
|
33684
|
+
* The system-singleton half of the 2026-09-24 cut (D625). `recording` used to
|
|
33685
|
+
* be one 33-method system singleton holding two unrelated subjects: three
|
|
33686
|
+
* per-camera READS about coverage and playback, and everything else — storage
|
|
33687
|
+
* locations, retention, relocation, rebalance, the ops log, the placement
|
|
33688
|
+
* table and the byte-plane primitives our scrub and export are built on.
|
|
33689
|
+
*
|
|
33690
|
+
* The reads became a device-scoped COLLECTION, so a camera's own card can be a
|
|
33691
|
+
* source beside ours (`recording.cap.ts`). Everything that is about OUR store,
|
|
33692
|
+
* or unimplementable by a camera, stayed here.
|
|
33693
|
+
*
|
|
33694
|
+
* ## On the name
|
|
33695
|
+
*
|
|
33696
|
+
* `recording-storage` was the obvious choice and is wrong: this cap also holds
|
|
33697
|
+
* `getDeviceConfig`/`setDeviceConfig`, which are recording INTENT — bands,
|
|
33698
|
+
* retention, the D62 switch authority — and a name that says "storage" invites
|
|
33699
|
+
* the next reader to move them out again. An archive is a thing we keep, and
|
|
33700
|
+
* what we keep it under is a policy; the name covers both halves honestly and
|
|
33701
|
+
* sits in the existing family (`recording-onboard`, `recording-export`,
|
|
33702
|
+
* `recording-signal`).
|
|
33703
|
+
*
|
|
33704
|
+
* ## What must NOT happen to it
|
|
33705
|
+
*
|
|
33706
|
+
* It stays a SINGLETON. It is registered by `recorder`, which is
|
|
33707
|
+
* `placement: 'any-node'` and runs on every recording node; the hub dispatches
|
|
33708
|
+
* to one of them. Putting the ledger, the placement table or the relocation
|
|
33709
|
+
* jobs behind a fan-out is the one genuinely dangerous move in this cut.
|
|
33710
|
+
*
|
|
33711
|
+
* `getDeviceConfig` / `setDeviceConfig` in particular are the D62 recording
|
|
33712
|
+
* authority (`CameraSwitch.authority`). If a write reached a different provider
|
|
33713
|
+
* than the read — which a collection fan-out permits — two authorities would
|
|
33714
|
+
* decide when one camera records, and the symptom (recording silently off, or
|
|
33715
|
+
* a `bands` array clobbered by a partial write) is durable and silent. Keeping
|
|
33716
|
+
* them here means the worst case during a rollout is a 412: the switch refuses
|
|
33717
|
+
* to flip and SAYS so. **Do not move them into the collection, at any point,
|
|
33718
|
+
* for any reason.**
|
|
33719
|
+
*
|
|
33720
|
+
* ## The two batch reads
|
|
33721
|
+
*
|
|
33722
|
+
* `getAvailabilityBatch` / `getDaysWithRecordingsBatch` take `deviceIds:
|
|
33723
|
+
* number[]` with no single `deviceId`, and a device-scoped mount routes
|
|
33724
|
+
* through `getProviderForDevice(deviceId)` — there is nothing for it to route
|
|
33725
|
+
* on. They stay here, and on this cap the batch is explicitly OURS: a grid has
|
|
33726
|
+
* no per-camera picker, and a caller that wants another source's coverage asks
|
|
33727
|
+
* `recording.getAvailability` per device with that source's `provider`.
|
|
33728
|
+
*/
|
|
33729
|
+
var RecordingStatusSchema = object({
|
|
33958
33730
|
deviceId: number(),
|
|
33959
|
-
|
|
33960
|
-
|
|
33731
|
+
enabled: boolean(),
|
|
33732
|
+
/** THE derived storage mode, from the one definition
|
|
33733
|
+
* (`deriveRecordingMode`) — never a second enum. A duplicated list is how
|
|
33734
|
+
* `on-device-decision` could have reached the recorder and not the status. */
|
|
33735
|
+
activeMode: RecordingStorageModeSchema,
|
|
33736
|
+
nodeId: string(),
|
|
33737
|
+
storageBytes: number()
|
|
33961
33738
|
});
|
|
33962
33739
|
/**
|
|
33963
33740
|
* One camera's row in a `getAvailabilityBatch` answer.
|
|
33964
33741
|
*
|
|
33965
|
-
* `ranges` is EXACTLY what `getAvailability` returns for that camera
|
|
33966
|
-
* batch collapses the transport, not the work — plus the
|
|
33967
|
-
*
|
|
33742
|
+
* `ranges` is EXACTLY what `recording.getAvailability` returns for that camera
|
|
33743
|
+
* at OUR source — the batch collapses the transport, not the work — plus the
|
|
33744
|
+
* `read` mark the singular answer now carries too (D625):
|
|
33968
33745
|
*
|
|
33969
33746
|
* - `read: 'read'` — answered. `ranges: []` means "read, and this camera has
|
|
33970
33747
|
* no footage in the window", which is a real claim.
|
|
@@ -33996,22 +33773,6 @@ var RecordingDaysForDeviceSchema = object({
|
|
|
33996
33773
|
/** Local-midnight epochs (UTC ms) of days that have ≥1 recorded segment. */
|
|
33997
33774
|
days: array(number()).readonly()
|
|
33998
33775
|
});
|
|
33999
|
-
var RecordingManifestSchema = object({
|
|
34000
|
-
deviceId: number(),
|
|
34001
|
-
/** Local filesystem path to the master playlist; null when no recording exists for the requested range. */
|
|
34002
|
-
localMasterPath: string().nullable(),
|
|
34003
|
-
/** HTTP(S) URL to the master playlist on the recording node's playback server
|
|
34004
|
-
* (the PRIMARY candidate); null when no recording / server. Carries the
|
|
34005
|
-
* scoped playback token in its path. */
|
|
34006
|
-
playbackUrl: string().nullable(),
|
|
34007
|
-
/**
|
|
34008
|
-
* Candidate master-playlist URLs the client tries in order (LAN first, then
|
|
34009
|
-
* remote — Tailscale/Cloudflare if the operator configured extra hosts), each
|
|
34010
|
-
* carrying the same scoped token. `playbackUrl` is the first entry. Empty when
|
|
34011
|
-
* there is no recording / server.
|
|
34012
|
-
*/
|
|
34013
|
-
playbackEndpoints: array(string())
|
|
34014
|
-
});
|
|
34015
33776
|
/**
|
|
34016
33777
|
* Recording storage usage for one camera — what the ARCHIVE holds for it,
|
|
34017
33778
|
* across every profile and every resolvable location on this node.
|
|
@@ -34270,34 +34031,12 @@ var ReadWindowBytesResultSchema = discriminatedUnion("kind", [object({
|
|
|
34270
34031
|
segmentEndMs: number()
|
|
34271
34032
|
})]);
|
|
34272
34033
|
method(object({
|
|
34273
|
-
deviceId: number(),
|
|
34274
|
-
fromMs: number(),
|
|
34275
|
-
toMs: number(),
|
|
34276
|
-
/**
|
|
34277
|
-
* Answer for THIS profile instead of the preferred one (D433). Absent
|
|
34278
|
-
* keeps the timeline's behaviour — one bar, one profile, one set of
|
|
34279
|
-
* reads. `profilesWithFootage` on the answer says what may be asked
|
|
34280
|
-
* for.
|
|
34281
|
-
*/
|
|
34282
|
-
profile: string().optional()
|
|
34283
|
-
}), RecordingAvailabilitySchema, {
|
|
34284
|
-
kind: "query",
|
|
34285
|
-
auth: "protected"
|
|
34286
|
-
}), method(object({
|
|
34287
34034
|
deviceIds: array(number()).min(1).max(200),
|
|
34288
34035
|
fromMs: number(),
|
|
34289
34036
|
toMs: number()
|
|
34290
34037
|
}), array(RecordingAvailabilityForDeviceSchema).readonly(), {
|
|
34291
34038
|
kind: "query",
|
|
34292
34039
|
auth: "protected"
|
|
34293
|
-
}), method(object({
|
|
34294
|
-
deviceId: number(),
|
|
34295
|
-
fromMs: number(),
|
|
34296
|
-
toMs: number(),
|
|
34297
|
-
tzOffsetMinutes: number()
|
|
34298
|
-
}), RecordingDaysSchema, {
|
|
34299
|
-
kind: "query",
|
|
34300
|
-
auth: "protected"
|
|
34301
34040
|
}), method(object({
|
|
34302
34041
|
deviceIds: array(number()).min(1).max(200),
|
|
34303
34042
|
fromMs: number(),
|
|
@@ -34306,13 +34045,6 @@ method(object({
|
|
|
34306
34045
|
}), array(RecordingDaysForDeviceSchema).readonly(), {
|
|
34307
34046
|
kind: "query",
|
|
34308
34047
|
auth: "protected"
|
|
34309
|
-
}), method(object({
|
|
34310
|
-
deviceId: number(),
|
|
34311
|
-
fromMs: number(),
|
|
34312
|
-
toMs: number()
|
|
34313
|
-
}), RecordingManifestSchema, {
|
|
34314
|
-
kind: "query",
|
|
34315
|
-
auth: "protected"
|
|
34316
34048
|
}), method(object({}), RecordingStorageUsageSchema, {
|
|
34317
34049
|
kind: "query",
|
|
34318
34050
|
auth: "admin"
|
|
@@ -34524,245 +34256,761 @@ var ExportTimelapseSchema = object({
|
|
|
34524
34256
|
* silent. `maxLifeMs` bounds how long the finished file is kept;
|
|
34525
34257
|
* `deleteAfterDownload` removes it shortly after the first complete download.
|
|
34526
34258
|
*/
|
|
34527
|
-
var ExportOptionsSchema = object({
|
|
34528
|
-
speed: ExportSpeedSchema.optional(),
|
|
34529
|
-
timelapse: ExportTimelapseSchema.optional(),
|
|
34530
|
-
includeAudio: boolean(),
|
|
34531
|
-
maxLifeMs: number().int().positive(),
|
|
34532
|
-
deleteAfterDownload: boolean(),
|
|
34533
|
-
title: string().max(200).optional(),
|
|
34534
|
-
/** Notification-output target ids to ping when this export becomes ready. */
|
|
34535
|
-
notifyTargetIds: array(string().min(1)).max(20).optional()
|
|
34536
|
-
}).superRefine((v, ctx) => {
|
|
34537
|
-
if (v.speed !== void 0 && v.timelapse !== void 0) ctx.addIssue({
|
|
34538
|
-
code: ZodIssueCode.custom,
|
|
34539
|
-
message: "speed and timelapse are mutually exclusive",
|
|
34540
|
-
path: ["timelapse"]
|
|
34541
|
-
});
|
|
34259
|
+
var ExportOptionsSchema = object({
|
|
34260
|
+
speed: ExportSpeedSchema.optional(),
|
|
34261
|
+
timelapse: ExportTimelapseSchema.optional(),
|
|
34262
|
+
includeAudio: boolean(),
|
|
34263
|
+
maxLifeMs: number().int().positive(),
|
|
34264
|
+
deleteAfterDownload: boolean(),
|
|
34265
|
+
title: string().max(200).optional(),
|
|
34266
|
+
/** Notification-output target ids to ping when this export becomes ready. */
|
|
34267
|
+
notifyTargetIds: array(string().min(1)).max(20).optional()
|
|
34268
|
+
}).superRefine((v, ctx) => {
|
|
34269
|
+
if (v.speed !== void 0 && v.timelapse !== void 0) ctx.addIssue({
|
|
34270
|
+
code: ZodIssueCode.custom,
|
|
34271
|
+
message: "speed and timelapse are mutually exclusive",
|
|
34272
|
+
path: ["timelapse"]
|
|
34273
|
+
});
|
|
34274
|
+
});
|
|
34275
|
+
var ExportStateSchema = _enum([
|
|
34276
|
+
"queued",
|
|
34277
|
+
"rendering",
|
|
34278
|
+
"ready",
|
|
34279
|
+
"failed",
|
|
34280
|
+
"expired",
|
|
34281
|
+
"deleted"
|
|
34282
|
+
]);
|
|
34283
|
+
/**
|
|
34284
|
+
* WHAT an export is — the authority, as opposed to the four top-level fields
|
|
34285
|
+
* the Library sorts and labels on (D558 § 2.2).
|
|
34286
|
+
*
|
|
34287
|
+
* Read it through {@link exportSubjectOf}, never off the record directly: the
|
|
34288
|
+
* field is optional for the history rows written before it existed, and that
|
|
34289
|
+
* absence has exactly one interpreter.
|
|
34290
|
+
*/
|
|
34291
|
+
var ExportSubjectSchema = discriminatedUnion("kind", [object({
|
|
34292
|
+
kind: literal("footage"),
|
|
34293
|
+
deviceId: number(),
|
|
34294
|
+
profiles: array(string()).min(1),
|
|
34295
|
+
fromMs: number(),
|
|
34296
|
+
toMs: number()
|
|
34297
|
+
}), object({
|
|
34298
|
+
kind: literal("clip"),
|
|
34299
|
+
deviceId: number(),
|
|
34300
|
+
provider: string().min(1),
|
|
34301
|
+
source: string().min(1),
|
|
34302
|
+
sourceLabel: string().min(1),
|
|
34303
|
+
clipId: string().min(1),
|
|
34304
|
+
/**
|
|
34305
|
+
* WHERE IN THE CATALOG to confirm this clip — the day window the surface was
|
|
34306
|
+
* already listing when the operator picked the segment.
|
|
34307
|
+
*
|
|
34308
|
+
* It is **not** a time range control and it never becomes one: the record's
|
|
34309
|
+
* `fromMs`/`toMs` come from the catalog ROW and from nothing a caller
|
|
34310
|
+
* supplied (D558 § 5.4.3), and a window that does not contain the clip is a
|
|
34311
|
+
* `catalog-miss`, not a silently wider search. It exists because
|
|
34312
|
+
* `videoclips.listClips` takes `since`/`until` and has no by-handle twin:
|
|
34313
|
+
* the catalog check D558 asks for is literally that call, and a call needs a
|
|
34314
|
+
* window. The surface has one — `ClipsBrowser`'s `dayWindow`, one local
|
|
34315
|
+
* wall-clock day, which is also the only width measured to be cheap (one
|
|
34316
|
+
* day on 592 lists 171 clips in 712 ms, a busy day 546 in 2.0 s; twenty days
|
|
34317
|
+
* of one child's events took 3.6–5.4 s).
|
|
34318
|
+
*/
|
|
34319
|
+
catalogWindow: object({
|
|
34320
|
+
sinceMs: number(),
|
|
34321
|
+
untilMs: number()
|
|
34322
|
+
}),
|
|
34323
|
+
profile: _enum([
|
|
34324
|
+
"high",
|
|
34325
|
+
"mid",
|
|
34326
|
+
"low"
|
|
34327
|
+
]),
|
|
34328
|
+
/**
|
|
34329
|
+
* The operator's authorisation to wake a sleeping camera for this export.
|
|
34330
|
+
* ONE definition, in the cap that owns the clip read ({@link ClipWakeSchema}),
|
|
34331
|
+
* because the gate that honours it is the clip provider's sleep gate — a
|
|
34332
|
+
* second enum here would be a second contract. Absent by default; never
|
|
34333
|
+
* settable by a scheduler or a retry.
|
|
34334
|
+
*
|
|
34335
|
+
* **One authorised yes is ONE wake.** A failed clip export is retried only by
|
|
34336
|
+
* an operator act that asks again; a queued job that outlived its wake fails
|
|
34337
|
+
* with a reason rather than waking on its turn; and this subject carries
|
|
34338
|
+
* exactly one profile precisely so one tap is never two fetches (D558 § 5.2).
|
|
34339
|
+
*/
|
|
34340
|
+
wake: ClipWakeSchema.optional()
|
|
34341
|
+
})]);
|
|
34342
|
+
/**
|
|
34343
|
+
* One export job / history row.
|
|
34344
|
+
*
|
|
34345
|
+
* **`subject` is the AUTHORITY on what was exported. `deviceId`, `profile`,
|
|
34346
|
+
* `fromMs` and `toMs` are its PROJECTION** — kept top-level because the whole
|
|
34347
|
+
* Library sorts and labels on them (`library-items.ts` orders an export by
|
|
34348
|
+
* `fromMs`; `export-format.ts` draws `rangeLabel` from the pair), and a row
|
|
34349
|
+
* that did not fill them would sort under the epoch and render a blank range.
|
|
34350
|
+
* Write to the subject and read from the projection and the two will disagree;
|
|
34351
|
+
* the projection is derived at creation and never edited afterwards.
|
|
34352
|
+
*
|
|
34353
|
+
* And they mean DIFFERENT FACTS for the two kinds, which is the part a reader
|
|
34354
|
+
* who knows only the recording export will get wrong:
|
|
34355
|
+
*
|
|
34356
|
+
* | field | `kind:'footage'` | `kind:'clip'` |
|
|
34357
|
+
* | --- | --- | --- |
|
|
34358
|
+
* | `fromMs`/`toMs` | the stretch the operator ASKED for | the camera's own boundaries, always `clip.timeRange`, never anything a caller supplied |
|
|
34359
|
+
* | `profile` | the stream rendered | the twin actually SERVED (`subject.profile` is the one asked for) |
|
|
34360
|
+
*
|
|
34361
|
+
* Same type, different fact — the shape this repo keeps getting wrong (D385's
|
|
34362
|
+
* two authorities, D224's second copy).
|
|
34363
|
+
*/
|
|
34364
|
+
var ExportRecordSchema = object({
|
|
34365
|
+
id: string(),
|
|
34366
|
+
deviceId: number(),
|
|
34367
|
+
profile: string(),
|
|
34368
|
+
fromMs: number(),
|
|
34369
|
+
toMs: number(),
|
|
34370
|
+
/**
|
|
34371
|
+
* What this export IS. Optional ONLY for the rows written before D558: the
|
|
34372
|
+
* store parses every row through this schema on every read, so a required
|
|
34373
|
+
* field would make the export AUDIT — which is the whole reason rows survive
|
|
34374
|
+
* file deletion — unreadable in one release. Absence means `footage`, and
|
|
34375
|
+
* {@link exportSubjectOf} is the one place that says so.
|
|
34376
|
+
*/
|
|
34377
|
+
subject: ExportSubjectSchema.optional(),
|
|
34378
|
+
options: ExportOptionsSchema,
|
|
34379
|
+
state: ExportStateSchema,
|
|
34380
|
+
/** 0–100 while rendering; null otherwise. */
|
|
34381
|
+
progressPct: number().nullable(),
|
|
34382
|
+
/** File size once ready; null before. */
|
|
34383
|
+
fileBytes: number().nullable(),
|
|
34384
|
+
expiresAt: number(),
|
|
34385
|
+
deleteAfterDownload: boolean(),
|
|
34386
|
+
/** Epoch of the first complete download; null until then. */
|
|
34387
|
+
downloadedAt: number().nullable(),
|
|
34388
|
+
createdAt: number(),
|
|
34389
|
+
/** User id/name that requested the export. */
|
|
34390
|
+
createdBy: string(),
|
|
34391
|
+
/** Failure reason when state is 'failed'; null otherwise. */
|
|
34392
|
+
error: string().nullable()
|
|
34393
|
+
});
|
|
34394
|
+
_enum([
|
|
34395
|
+
"catalog-miss",
|
|
34396
|
+
"catalog-unreachable",
|
|
34397
|
+
"no-file-for-window",
|
|
34398
|
+
"clip-in-progress",
|
|
34399
|
+
"unsupported-option",
|
|
34400
|
+
"sleeping",
|
|
34401
|
+
"camera-refused",
|
|
34402
|
+
"fetch-failed",
|
|
34403
|
+
"too-large-to-transfer",
|
|
34404
|
+
"wake-expired"
|
|
34405
|
+
]);
|
|
34406
|
+
/** `<token>: <prose>` — the ONE composition of a clip export's failure string. */
|
|
34407
|
+
function clipExportFailure(code, detail) {
|
|
34408
|
+
return detail.length > 0 ? `${code}: ${detail}` : code;
|
|
34409
|
+
}
|
|
34410
|
+
/** Candidate download URLs (LAN first, then operator extra hosts). */
|
|
34411
|
+
var ExportDownloadSchema = object({
|
|
34412
|
+
url: string(),
|
|
34413
|
+
endpoints: array(string())
|
|
34414
|
+
});
|
|
34415
|
+
/**
|
|
34416
|
+
* A finished export's bytes, inline.
|
|
34417
|
+
*
|
|
34418
|
+
* `bytes` is the DECODED length — the number the caller bounds and logs
|
|
34419
|
+
* against, so nobody has to infer it from the base64 length.
|
|
34420
|
+
*/
|
|
34421
|
+
var ExportBytesSchema = object({
|
|
34422
|
+
base64: string(),
|
|
34423
|
+
contentType: string(),
|
|
34424
|
+
/** Suggested filename, extension included. */
|
|
34425
|
+
name: string(),
|
|
34426
|
+
bytes: number().int().nonnegative()
|
|
34427
|
+
});
|
|
34428
|
+
/** Canonical `profiles[]`, falling back to the legacy singular `profile`. */
|
|
34429
|
+
function resolveExportProfiles(input) {
|
|
34430
|
+
if (input.profiles !== void 0 && input.profiles.length > 0) return [...input.profiles];
|
|
34431
|
+
if (typeof input.profile === "string" && input.profile.length > 0) return [input.profile];
|
|
34432
|
+
return [];
|
|
34433
|
+
}
|
|
34434
|
+
method(object({
|
|
34435
|
+
deviceId: number(),
|
|
34436
|
+
/** @deprecated Prefer `profiles`. Kept so timelapse/notifiers keep working. */
|
|
34437
|
+
profile: string().optional(),
|
|
34438
|
+
profiles: array(string()).min(1).optional(),
|
|
34439
|
+
/** Footage only — a clip's boundaries are the camera's. */
|
|
34440
|
+
fromMs: number().optional(),
|
|
34441
|
+
toMs: number().optional(),
|
|
34442
|
+
/** What to export. Absent means the legacy flat footage request. */
|
|
34443
|
+
subject: ExportSubjectSchema.optional(),
|
|
34444
|
+
options: ExportOptionsSchema
|
|
34445
|
+
}).superRefine((v, ctx) => {
|
|
34446
|
+
if (v.subject?.kind === "clip") {
|
|
34447
|
+
if (v.subject.deviceId !== v.deviceId) ctx.addIssue({
|
|
34448
|
+
code: ZodIssueCode.custom,
|
|
34449
|
+
message: `subject.deviceId (${v.subject.deviceId}) must equal deviceId (${v.deviceId}) — the top-level field is what per-device scope enforcement reads`,
|
|
34450
|
+
path: ["subject", "deviceId"]
|
|
34451
|
+
});
|
|
34452
|
+
if (v.fromMs !== void 0 || v.toMs !== void 0) ctx.addIssue({
|
|
34453
|
+
code: ZodIssueCode.custom,
|
|
34454
|
+
message: "a clip export asks for no time range: the camera chose the boundaries and they are read from the catalog row",
|
|
34455
|
+
path: ["fromMs"]
|
|
34456
|
+
});
|
|
34457
|
+
return;
|
|
34458
|
+
}
|
|
34459
|
+
if (v.subject?.kind === "footage" && v.subject.deviceId !== v.deviceId) ctx.addIssue({
|
|
34460
|
+
code: ZodIssueCode.custom,
|
|
34461
|
+
message: `subject.deviceId (${v.subject.deviceId}) must equal deviceId (${v.deviceId})`,
|
|
34462
|
+
path: ["subject", "deviceId"]
|
|
34463
|
+
});
|
|
34464
|
+
const fromMs = v.subject?.kind === "footage" ? v.subject.fromMs : v.fromMs;
|
|
34465
|
+
const toMs = v.subject?.kind === "footage" ? v.subject.toMs : v.toMs;
|
|
34466
|
+
if (typeof fromMs !== "number" || typeof toMs !== "number") ctx.addIssue({
|
|
34467
|
+
code: ZodIssueCode.custom,
|
|
34468
|
+
message: "a footage export needs fromMs and toMs",
|
|
34469
|
+
path: ["fromMs"]
|
|
34470
|
+
});
|
|
34471
|
+
if ((v.subject?.kind === "footage" ? [...v.subject.profiles] : resolveExportProfiles(v)).length < 1) ctx.addIssue({
|
|
34472
|
+
code: ZodIssueCode.custom,
|
|
34473
|
+
message: "pass profiles[] (min 1) or legacy profile",
|
|
34474
|
+
path: ["profiles"]
|
|
34475
|
+
});
|
|
34476
|
+
}), ExportRecordSchema, {
|
|
34477
|
+
kind: "mutation",
|
|
34478
|
+
auth: "protected"
|
|
34479
|
+
}), method(object({ deviceId: number().optional() }), array(ExportRecordSchema), {
|
|
34480
|
+
kind: "query",
|
|
34481
|
+
auth: "protected"
|
|
34482
|
+
}), method(object({ exportId: string() }), ExportRecordSchema, {
|
|
34483
|
+
kind: "query",
|
|
34484
|
+
auth: "protected"
|
|
34485
|
+
}), method(object({ exportId: string() }), ExportRecordSchema, {
|
|
34486
|
+
kind: "mutation",
|
|
34487
|
+
auth: "protected"
|
|
34488
|
+
}), method(object({ exportId: string() }), ExportRecordSchema, {
|
|
34489
|
+
kind: "mutation",
|
|
34490
|
+
auth: "protected"
|
|
34491
|
+
}), method(object({ exportId: string() }), ExportDownloadSchema, {
|
|
34492
|
+
kind: "query",
|
|
34493
|
+
auth: "protected"
|
|
34494
|
+
}), method(object({ exportId: string() }), ExportBytesSchema, {
|
|
34495
|
+
kind: "query",
|
|
34496
|
+
auth: "protected"
|
|
34497
|
+
});
|
|
34498
|
+
/**
|
|
34499
|
+
* Vendor-neutral **onboard** recording + storage cap — what the CAMERA
|
|
34500
|
+
* writes to the CAMERA's own card, on the camera's own schedule.
|
|
34501
|
+
*
|
|
34502
|
+
* This is NOT `recording.cap.ts`. That one is CamStack's recorder: our
|
|
34503
|
+
* footage ledger, our storage locations, our retention. This one has a
|
|
34504
|
+
* different authority — the camera's firmware — and per D62 it stores
|
|
34505
|
+
* nothing of its own. Every value here is read from the camera and every
|
|
34506
|
+
* write goes back to the camera; there is no CamStack-side mirror that
|
|
34507
|
+
* could disagree with the device.
|
|
34508
|
+
*
|
|
34509
|
+
* ## One shape, two firmwares
|
|
34510
|
+
*
|
|
34511
|
+
* Measured 2026-09-22 against the live fleet:
|
|
34512
|
+
*
|
|
34513
|
+
* | fact | Hikvision (ISAPI) | Reolink (Baichuan) |
|
|
34514
|
+
* | --- | --- | --- |
|
|
34515
|
+
* | storage | `ContentMgmt/Storage` `<hdd>` rows: status, capacity, freeSpace (MB) | `getHddInfoList` (cmd 102): `mount`, `format`, `capacity` GB + `capacityM` MB remainder |
|
|
34516
|
+
* | tracks | several (101 **and** 103 on both 1436 and 3833), each with its own schedule | one per channel |
|
|
34517
|
+
* | schedule | per track, 7 `ScheduleAction` blocks: DayOfWeek + TimeOfDay range + ONE `ActionRecordingMode` | per trigger type, a 168-char weekly HOUR mask |
|
|
34518
|
+
* | triggers | `CMR`, `MOTION` | `Normal`, `MD`, `people`, `vehicle`, `dog_cat`, `crossline`, `intrude`, `loitering` |
|
|
34519
|
+
* | pre-record | `PreRecordTimeSeconds` | `preRecordTime` |
|
|
34520
|
+
* | post-record | `PostRecordTimeSeconds` | `recordDelayTime` |
|
|
34521
|
+
* | overwrite | per track `LoopEnable` | `cycle`, with `cycleList` enumerating the accepted values |
|
|
34522
|
+
* | segment length | not exposed on V5.7.1 | `packageTime` (minutes) |
|
|
34523
|
+
*
|
|
34524
|
+
* The two schedule models look different and are the same thing in
|
|
34525
|
+
* different coordinates: both answer "for this trigger, during which
|
|
34526
|
+
* weekly windows does the camera record". {@link RecordWindow} is that
|
|
34527
|
+
* question in one shape — Hikvision's ranges map straight onto it,
|
|
34528
|
+
* Reolink's mask expands into hour-aligned windows.
|
|
34529
|
+
*
|
|
34530
|
+
* ## Union, not intersection
|
|
34531
|
+
*
|
|
34532
|
+
* **The same fields exist on every camera.** What differs per device is
|
|
34533
|
+
* which VALUES that device accepts, and that is what {@link
|
|
34534
|
+
* RecordingOnboardOptions} reports — a `{ readable, writable, reason }`
|
|
34535
|
+
* per field plus the schedule's own limits. A control a camera cannot
|
|
34536
|
+
* honour is rendered DISABLED WITH ITS REASON, never missing and never
|
|
34537
|
+
* dead: disabled must not look like broken.
|
|
34538
|
+
*
|
|
34539
|
+
* ## Refusal by name
|
|
34540
|
+
*
|
|
34541
|
+
* A write a camera cannot honour is refused with a sentence the operator
|
|
34542
|
+
* can read — never accepted and dropped. Both providers refuse through
|
|
34543
|
+
* {@link describeOnboardRefusal}, so the vocabulary is one function and
|
|
34544
|
+
* one test, not two hand-written vendor opinions.
|
|
34545
|
+
*
|
|
34546
|
+
* Follows the D14 `deviceConfig` archetype (see `stream-params.cap.ts`):
|
|
34547
|
+
* `getOptions` advertises per-camera availability, `getStatus` (auto-
|
|
34548
|
+
* injected from `status`) reports the live values, and a single
|
|
34549
|
+
* `setSettings` mutation applies a partial change. No hand-written
|
|
34550
|
+
* settings-contribution methods.
|
|
34551
|
+
*/
|
|
34552
|
+
/**
|
|
34553
|
+
* What makes the camera start recording during a window.
|
|
34554
|
+
*
|
|
34555
|
+
* The union of both vendors' vocabularies. `continuous` is Hikvision's
|
|
34556
|
+
* `CMR` and Reolink's `Normal`; `motion` is `MOTION` / `MD`. The
|
|
34557
|
+
* object-class triggers are Reolink-only today and the smart-event ones
|
|
34558
|
+
* (`lineCrossing`, `intrusion`, `loitering`) are Reolink-only on the
|
|
34559
|
+
* firmwares measured — a camera that cannot record on a trigger simply
|
|
34560
|
+
* does not list it in `options.schedule.triggers`, and a window naming
|
|
34561
|
+
* it is REFUSED, not dropped.
|
|
34562
|
+
*/
|
|
34563
|
+
var RecordTriggerSchema = _enum([
|
|
34564
|
+
"continuous",
|
|
34565
|
+
"motion",
|
|
34566
|
+
"person",
|
|
34567
|
+
"vehicle",
|
|
34568
|
+
"animal",
|
|
34569
|
+
"lineCrossing",
|
|
34570
|
+
"intrusion",
|
|
34571
|
+
"loitering",
|
|
34572
|
+
"alarmInput"
|
|
34573
|
+
]);
|
|
34574
|
+
/**
|
|
34575
|
+
* One weekly recording window: "on `day`, from `startMinute` to
|
|
34576
|
+
* `endMinute`, record on `trigger`".
|
|
34577
|
+
*
|
|
34578
|
+
* `day` is 0 = Monday … 6 = Sunday (ISO order, which is also the order
|
|
34579
|
+
* both firmwares enumerate). Minutes are local camera time since
|
|
34580
|
+
* midnight; `endMinute` may be 1440, meaning end of day — that is
|
|
34581
|
+
* Hikvision's literal `24:00` and Reolink's 24th mask slot, and
|
|
34582
|
+
* collapsing it to 0 would turn a whole-day window into an empty one.
|
|
34583
|
+
*/
|
|
34584
|
+
var RecordWindowSchema = object({
|
|
34585
|
+
trigger: RecordTriggerSchema,
|
|
34586
|
+
day: number().int().min(0).max(6),
|
|
34587
|
+
startMinute: number().int().min(0).max(1439),
|
|
34588
|
+
endMinute: number().int().min(1).max(1440)
|
|
34589
|
+
});
|
|
34590
|
+
/** Status of one physical volume, as the camera itself describes it. */
|
|
34591
|
+
var OnboardStorageVolumeSchema = object({
|
|
34592
|
+
/** The camera's own id for the volume (`hdd/id`, Reolink `HddInfo/number`). */
|
|
34593
|
+
id: string(),
|
|
34594
|
+
/** The camera's own name for it, when it gives one (`hddName`). */
|
|
34595
|
+
label: string().optional(),
|
|
34596
|
+
status: _enum([
|
|
34597
|
+
"ok",
|
|
34598
|
+
"unformatted",
|
|
34599
|
+
"error",
|
|
34600
|
+
"offline",
|
|
34601
|
+
"unknown"
|
|
34602
|
+
]),
|
|
34603
|
+
/**
|
|
34604
|
+
* Total size in MB, or **null when the camera did not say**.
|
|
34605
|
+
*
|
|
34606
|
+
* Never 0 for an unreadable value: a measurement that failed is not a
|
|
34607
|
+
* measurement (D393), and a card whose size is unknown must not be
|
|
34608
|
+
* rendered as a card of size zero.
|
|
34609
|
+
*/
|
|
34610
|
+
capacityMb: number().nullable(),
|
|
34611
|
+
/**
|
|
34612
|
+
* Free space in MB, or null when unknown.
|
|
34613
|
+
*
|
|
34614
|
+
* **Not a proxy for "has footage".** Measured 2026-09-22: 1436 and
|
|
34615
|
+
* 1439 both report exactly 11776 MB free — the fixed reserve a looping
|
|
34616
|
+
* card converges on once it has wrapped. At loop steady state the
|
|
34617
|
+
* number is identical whether the camera recorded yesterday or stopped
|
|
34618
|
+
* a month ago.
|
|
34619
|
+
*/
|
|
34620
|
+
freeMb: number().nullable(),
|
|
34621
|
+
/** True when the camera reports the volume writable (`property` RW). */
|
|
34622
|
+
writable: boolean().optional()
|
|
34623
|
+
});
|
|
34624
|
+
/**
|
|
34625
|
+
* What the camera is doing with its own storage, right now.
|
|
34626
|
+
*
|
|
34627
|
+
* Every scalar is nullable and **null means the camera did not answer**,
|
|
34628
|
+
* never a default. A form that seeds `0` from an unanswered read invites
|
|
34629
|
+
* the operator to save that 0 back onto the camera.
|
|
34630
|
+
*/
|
|
34631
|
+
var RecordingOnboardStatusSchema = object({
|
|
34632
|
+
storage: discriminatedUnion("kind", [
|
|
34633
|
+
object({
|
|
34634
|
+
kind: literal("present"),
|
|
34635
|
+
volumes: array(OnboardStorageVolumeSchema)
|
|
34636
|
+
}),
|
|
34637
|
+
object({
|
|
34638
|
+
kind: literal("absent"),
|
|
34639
|
+
reason: string()
|
|
34640
|
+
}),
|
|
34641
|
+
object({
|
|
34642
|
+
kind: literal("unknown"),
|
|
34643
|
+
reason: string()
|
|
34644
|
+
})
|
|
34645
|
+
]),
|
|
34646
|
+
tracks: array(object({
|
|
34647
|
+
id: string(),
|
|
34648
|
+
enabled: boolean(),
|
|
34649
|
+
isVideo: boolean(),
|
|
34650
|
+
/** From the camera's own track description. Null when it does not say. */
|
|
34651
|
+
codec: string().nullable(),
|
|
34652
|
+
resolution: string().nullable(),
|
|
34653
|
+
/** Per-track overwrite flag, where the firmware keeps it per track. */
|
|
34654
|
+
overwriteWhenFull: boolean().nullable()
|
|
34655
|
+
})),
|
|
34656
|
+
/**
|
|
34657
|
+
* The track the write path targets — the enabled VIDEO one. Null when
|
|
34658
|
+
* no track could be identified, which is itself a refusal reason.
|
|
34659
|
+
*/
|
|
34660
|
+
primaryTrackId: string().nullable(),
|
|
34661
|
+
/** Master "record to the card at all" switch. */
|
|
34662
|
+
enabled: boolean().nullable(),
|
|
34663
|
+
overwriteWhenFull: boolean().nullable(),
|
|
34664
|
+
preRecordSec: number().nullable(),
|
|
34665
|
+
postRecordSec: number().nullable(),
|
|
34666
|
+
/** Length of one recorded file, in minutes. */
|
|
34667
|
+
segmentMinutes: number().nullable(),
|
|
34668
|
+
/** The primary track's weekly windows, flattened. */
|
|
34669
|
+
windows: array(RecordWindowSchema),
|
|
34670
|
+
/**
|
|
34671
|
+
* How many windows the camera described that CamStack could NOT read —
|
|
34672
|
+
* an unrecognised trigger, an unparseable clock, a weekday it does not
|
|
34673
|
+
* name.
|
|
34674
|
+
*
|
|
34675
|
+
* A dropped window is work the reader threw away, and a schedule that
|
|
34676
|
+
* silently shows fewer rows than the camera holds is how an operator
|
|
34677
|
+
* saves back a schedule shorter than the one they were looking at
|
|
34678
|
+
* (D391). Non-zero means the window list is INCOMPLETE and a write
|
|
34679
|
+
* that replaces it would delete what was not shown — which is why a
|
|
34680
|
+
* provider reporting a non-zero count also reports the schedule as not
|
|
34681
|
+
* writable.
|
|
34682
|
+
*/
|
|
34683
|
+
unreadableWindows: number(),
|
|
34684
|
+
/**
|
|
34685
|
+
* The camera is scheduled to record and has NO usable storage.
|
|
34686
|
+
*
|
|
34687
|
+
* A first-class fact because it is the fleet's most common silent
|
|
34688
|
+
* defect: measured 2026-09-22, 1441 and 3831 are both motion-recording
|
|
34689
|
+
* to a card that is not there. Neither the schedule nor the storage
|
|
34690
|
+
* read says anything wrong on its own; only the pair does.
|
|
34691
|
+
*/
|
|
34692
|
+
recordingToNowhere: boolean(),
|
|
34693
|
+
lastFetchedAt: number()
|
|
34694
|
+
});
|
|
34695
|
+
/** Numeric range descriptor — `{ min, max, step }` per the getOptions convention. */
|
|
34696
|
+
var RangeSchema = object({
|
|
34697
|
+
min: number(),
|
|
34698
|
+
max: number(),
|
|
34699
|
+
step: number()
|
|
34700
|
+
});
|
|
34701
|
+
/**
|
|
34702
|
+
* The values a camera actually takes for a numeric field, when they are a SET
|
|
34703
|
+
* rather than a range.
|
|
34704
|
+
*
|
|
34705
|
+
* `{min,max,step}` cannot say what these two firmwares do. Measured on 1436
|
|
34706
|
+
* (I91DN) on 2026-09-22 by writing each value and reading it back:
|
|
34707
|
+
*
|
|
34708
|
+
* - pre-record: `0, 5, 10, 15, 20, 25, 30` and `2147483647` (INT32_MAX, the
|
|
34709
|
+
* camera's "no limit" — `-1` and `4294967295` both land on it);
|
|
34710
|
+
* - post-record: `5, 10, 30, 60, 120, 300, 600`.
|
|
34711
|
+
*
|
|
34712
|
+
* Neither is expressible as a step: the first has a sentinel two billion away
|
|
34713
|
+
* from its neighbours, the second doubles and then jumps. A range that tried
|
|
34714
|
+
* would forbid values the camera takes AND permit values it silently replaces
|
|
34715
|
+
* with 5 — wrong in both directions at once.
|
|
34716
|
+
*
|
|
34717
|
+
* `sentinel` names the member that is not a duration, so a surface can render
|
|
34718
|
+
* "no limit" instead of `2147483647` seconds.
|
|
34719
|
+
*/
|
|
34720
|
+
var AllowedValuesSchema = object({
|
|
34721
|
+
values: array(number()).min(1),
|
|
34722
|
+
sentinel: object({
|
|
34723
|
+
value: number(),
|
|
34724
|
+
meaning: _enum(["no-limit", "disabled"])
|
|
34725
|
+
}).optional()
|
|
34542
34726
|
});
|
|
34543
|
-
var ExportStateSchema = _enum([
|
|
34544
|
-
"queued",
|
|
34545
|
-
"rendering",
|
|
34546
|
-
"ready",
|
|
34547
|
-
"failed",
|
|
34548
|
-
"expired",
|
|
34549
|
-
"deleted"
|
|
34550
|
-
]);
|
|
34551
34727
|
/**
|
|
34552
|
-
*
|
|
34553
|
-
* the Library sorts and labels on (D558 § 2.2).
|
|
34728
|
+
* Per-field availability on ONE camera.
|
|
34554
34729
|
*
|
|
34555
|
-
*
|
|
34556
|
-
*
|
|
34557
|
-
*
|
|
34730
|
+
* The field exists on every camera — this says whether this one can be
|
|
34731
|
+
* read and whether it can be written, and `reason` says why not when
|
|
34732
|
+
* either is false. The UI renders the control DISABLED with the reason
|
|
34733
|
+
* rather than hiding it, so a limitation is legible instead of looking
|
|
34734
|
+
* like a missing feature.
|
|
34558
34735
|
*/
|
|
34559
|
-
var
|
|
34560
|
-
|
|
34561
|
-
|
|
34562
|
-
|
|
34563
|
-
|
|
34564
|
-
|
|
34565
|
-
|
|
34566
|
-
|
|
34567
|
-
|
|
34568
|
-
provider: string().min(1),
|
|
34569
|
-
source: string().min(1),
|
|
34570
|
-
sourceLabel: string().min(1),
|
|
34571
|
-
clipId: string().min(1),
|
|
34736
|
+
var OnboardFieldSupportSchema = object({
|
|
34737
|
+
readable: boolean(),
|
|
34738
|
+
writable: boolean(),
|
|
34739
|
+
/** Required whenever `readable` or `writable` is false. */
|
|
34740
|
+
reason: string().optional()
|
|
34741
|
+
});
|
|
34742
|
+
/** What this camera's schedule model can express. */
|
|
34743
|
+
var OnboardScheduleSupportSchema = object({
|
|
34744
|
+
support: OnboardFieldSupportSchema,
|
|
34572
34745
|
/**
|
|
34573
|
-
*
|
|
34574
|
-
* already listing when the operator picked the segment.
|
|
34746
|
+
* The smallest time step the camera can express, in minutes.
|
|
34575
34747
|
*
|
|
34576
|
-
*
|
|
34577
|
-
*
|
|
34578
|
-
*
|
|
34579
|
-
*
|
|
34580
|
-
*
|
|
34581
|
-
* the catalog check D558 asks for is literally that call, and a call needs a
|
|
34582
|
-
* window. The surface has one — `ClipsBrowser`'s `dayWindow`, one local
|
|
34583
|
-
* wall-clock day, which is also the only width measured to be cheap (one
|
|
34584
|
-
* day on 592 lists 171 clips in 712 ms, a busy day 546 in 2.0 s; twenty days
|
|
34585
|
-
* of one child's events took 3.6–5.4 s).
|
|
34748
|
+
* Hikvision takes arbitrary minutes (`00:05:00`–`23:57:00` observed on
|
|
34749
|
+
* 1436's track 103). Reolink's schedule is a 7×24 HOUR mask, so 60. A
|
|
34750
|
+
* window whose edges are not a multiple of this is REFUSED rather than
|
|
34751
|
+
* quietly rounded — rounding is how an operator's 06:30 becomes 06:00
|
|
34752
|
+
* and nothing says so.
|
|
34586
34753
|
*/
|
|
34587
|
-
|
|
34588
|
-
|
|
34589
|
-
|
|
34590
|
-
}),
|
|
34591
|
-
profile: _enum([
|
|
34592
|
-
"high",
|
|
34593
|
-
"mid",
|
|
34594
|
-
"low"
|
|
34595
|
-
]),
|
|
34754
|
+
granularityMinutes: number(),
|
|
34755
|
+
/** Triggers this camera can record on. A window naming another is refused. */
|
|
34756
|
+
triggers: array(RecordTriggerSchema),
|
|
34596
34757
|
/**
|
|
34597
|
-
*
|
|
34598
|
-
*
|
|
34599
|
-
*
|
|
34600
|
-
|
|
34601
|
-
|
|
34758
|
+
* False when the camera stores ONE trigger per time range, so two
|
|
34759
|
+
* windows overlapping on the same day cannot carry different triggers.
|
|
34760
|
+
* True on Reolink, whose mask is per-trigger and independent.
|
|
34761
|
+
*/
|
|
34762
|
+
supportsOverlappingTriggers: boolean()
|
|
34763
|
+
});
|
|
34764
|
+
var RecordingOnboardOptionsSchema = object({
|
|
34765
|
+
enabled: OnboardFieldSupportSchema,
|
|
34766
|
+
overwriteWhenFull: OnboardFieldSupportSchema,
|
|
34767
|
+
preRecordSec: OnboardFieldSupportSchema,
|
|
34768
|
+
preRecordSecRange: RangeSchema.optional(),
|
|
34769
|
+
/** Preferred over the range when the camera takes a SET, not a span. */
|
|
34770
|
+
preRecordSecAllowed: AllowedValuesSchema.optional(),
|
|
34771
|
+
postRecordSec: OnboardFieldSupportSchema,
|
|
34772
|
+
postRecordSecRange: RangeSchema.optional(),
|
|
34773
|
+
/** Preferred over the range when the camera takes a SET, not a span. */
|
|
34774
|
+
postRecordSecAllowed: AllowedValuesSchema.optional(),
|
|
34775
|
+
segmentMinutes: OnboardFieldSupportSchema,
|
|
34776
|
+
segmentMinutesRange: RangeSchema.optional(),
|
|
34777
|
+
/** Preferred over the range when the camera takes a SET, not a span. */
|
|
34778
|
+
segmentMinutesAllowed: AllowedValuesSchema.optional(),
|
|
34779
|
+
schedule: OnboardScheduleSupportSchema
|
|
34780
|
+
});
|
|
34781
|
+
/**
|
|
34782
|
+
* A partial change. Every field optional.
|
|
34783
|
+
*
|
|
34784
|
+
* Unlike the other `deviceConfig` caps, a provider here does **NOT**
|
|
34785
|
+
* silently ignore a field it cannot support — it refuses, by name,
|
|
34786
|
+
* through {@link describeOnboardRefusal}. Silence on a recording setting
|
|
34787
|
+
* is the failure D62 exists to prevent: the operator believes the camera
|
|
34788
|
+
* is recording the way the form says, and it is not.
|
|
34789
|
+
*/
|
|
34790
|
+
var RecordingOnboardPatchSchema = object({
|
|
34791
|
+
enabled: boolean().optional(),
|
|
34792
|
+
overwriteWhenFull: boolean().optional(),
|
|
34793
|
+
preRecordSec: number().optional(),
|
|
34794
|
+
postRecordSec: number().optional(),
|
|
34795
|
+
segmentMinutes: number().optional(),
|
|
34796
|
+
/** The complete new window set for the primary track — not a delta. */
|
|
34797
|
+
windows: array(RecordWindowSchema).optional()
|
|
34798
|
+
});
|
|
34799
|
+
var recordingOnboardCapability = {
|
|
34800
|
+
name: "recording-onboard",
|
|
34801
|
+
scope: "device",
|
|
34802
|
+
deviceNative: true,
|
|
34803
|
+
mode: "singleton",
|
|
34804
|
+
deviceTypes: [DeviceType.Camera],
|
|
34805
|
+
deviceConfig: { ui: {
|
|
34806
|
+
kind: "derived-form",
|
|
34807
|
+
builderId: "recording-onboard",
|
|
34808
|
+
tab: "recording"
|
|
34809
|
+
} },
|
|
34810
|
+
methods: {
|
|
34811
|
+
getOptions: method(object({ deviceId: number() }), RecordingOnboardOptionsSchema),
|
|
34812
|
+
setSettings: method(object({
|
|
34813
|
+
deviceId: number(),
|
|
34814
|
+
settings: RecordingOnboardPatchSchema
|
|
34815
|
+
}), _void(), {
|
|
34816
|
+
kind: "mutation",
|
|
34817
|
+
auth: "admin"
|
|
34818
|
+
})
|
|
34819
|
+
},
|
|
34820
|
+
status: {
|
|
34821
|
+
schema: RecordingOnboardStatusSchema,
|
|
34822
|
+
kind: "poll"
|
|
34823
|
+
},
|
|
34824
|
+
runtimeState: RecordingOnboardStatusSchema,
|
|
34825
|
+
/**
|
|
34826
|
+
* Runtime-state durability: **restored** — operator-set camera-side
|
|
34827
|
+
* recording config; mutation-driven, and the storage half is the last
|
|
34828
|
+
* thing the camera said about its own card.
|
|
34602
34829
|
*
|
|
34603
|
-
*
|
|
34604
|
-
*
|
|
34605
|
-
* with a reason rather than waking on its turn; and this subject carries
|
|
34606
|
-
* exactly one profile precisely so one tap is never two fetches (D558 § 5.2).
|
|
34830
|
+
* See `RuntimeStateDurability`. Enforced by
|
|
34831
|
+
* `scripts/check-runtime-state-durability.ts`.
|
|
34607
34832
|
*/
|
|
34608
|
-
|
|
34609
|
-
|
|
34833
|
+
durability: "restored",
|
|
34834
|
+
/** Clock fields: written, but excluded from the compare that decides
|
|
34835
|
+
* whether persisting is worth a SQLite commit. */
|
|
34836
|
+
volatileStateFields: ["lastFetchedAt"]
|
|
34837
|
+
};
|
|
34610
34838
|
/**
|
|
34611
|
-
*
|
|
34839
|
+
* Day-of-week names in the cap's index order (0 = Monday), for messages
|
|
34840
|
+
* an operator reads and for Hikvision's `<DayOfWeek>` element.
|
|
34841
|
+
*/
|
|
34842
|
+
var DAY_NAMES = [
|
|
34843
|
+
"Monday",
|
|
34844
|
+
"Tuesday",
|
|
34845
|
+
"Wednesday",
|
|
34846
|
+
"Thursday",
|
|
34847
|
+
"Friday",
|
|
34848
|
+
"Saturday",
|
|
34849
|
+
"Sunday"
|
|
34850
|
+
];
|
|
34851
|
+
/**
|
|
34852
|
+
* Does `patch` ask this camera for something it cannot do?
|
|
34612
34853
|
*
|
|
34613
|
-
*
|
|
34614
|
-
*
|
|
34615
|
-
*
|
|
34616
|
-
*
|
|
34617
|
-
*
|
|
34618
|
-
* Write to the subject and read from the projection and the two will disagree;
|
|
34619
|
-
* the projection is derived at creation and never edited afterwards.
|
|
34854
|
+
* Returns the operator-readable reason, or `null` when every field in
|
|
34855
|
+
* the patch is within what `options` says this camera accepts. A
|
|
34856
|
+
* provider calls this BEFORE touching the camera and throws the string:
|
|
34857
|
+
* refusing is the point, and refusing identically on both vendors is why
|
|
34858
|
+
* this is one function.
|
|
34620
34859
|
*
|
|
34621
|
-
*
|
|
34622
|
-
*
|
|
34860
|
+
* The order of checks is the order an operator would read them: the
|
|
34861
|
+
* scalar knobs first, then the schedule, because a schedule complaint is
|
|
34862
|
+
* longer and a scalar one is usually the real problem.
|
|
34863
|
+
*/
|
|
34864
|
+
function describeOnboardRefusal(options, patch) {
|
|
34865
|
+
if (patch.enabled !== void 0 && !options.enabled.writable) return unwritable("the master recording switch", options.enabled.reason);
|
|
34866
|
+
if (patch.overwriteWhenFull !== void 0 && !options.overwriteWhenFull.writable) return unwritable("overwrite-when-full", options.overwriteWhenFull.reason);
|
|
34867
|
+
const preRefusal = refuseNumeric("pre-record seconds", patch.preRecordSec, options.preRecordSec, options.preRecordSecRange, options.preRecordSecAllowed);
|
|
34868
|
+
if (preRefusal) return preRefusal;
|
|
34869
|
+
const postRefusal = refuseNumeric("post-record seconds", patch.postRecordSec, options.postRecordSec, options.postRecordSecRange, options.postRecordSecAllowed);
|
|
34870
|
+
if (postRefusal) return postRefusal;
|
|
34871
|
+
const segmentRefusal = refuseNumeric("segment length (minutes)", patch.segmentMinutes, options.segmentMinutes, options.segmentMinutesRange, options.segmentMinutesAllowed);
|
|
34872
|
+
if (segmentRefusal) return segmentRefusal;
|
|
34873
|
+
if (patch.windows !== void 0) {
|
|
34874
|
+
const scheduleRefusal = refuseSchedule(options, patch.windows);
|
|
34875
|
+
if (scheduleRefusal) return scheduleRefusal;
|
|
34876
|
+
}
|
|
34877
|
+
return null;
|
|
34878
|
+
}
|
|
34879
|
+
function unwritable(what, reason) {
|
|
34880
|
+
return reason ? `this camera cannot change ${what}: ${reason}` : `this camera cannot change ${what}`;
|
|
34881
|
+
}
|
|
34882
|
+
function refuseNumeric(what, value, support, range, allowed) {
|
|
34883
|
+
if (value === void 0) return null;
|
|
34884
|
+
if (!support.writable) return unwritable(what, support.reason);
|
|
34885
|
+
if (!Number.isFinite(value)) return `${what} must be a number, got ${String(value)}`;
|
|
34886
|
+
if (allowed) {
|
|
34887
|
+
if (allowed.values.includes(value)) return null;
|
|
34888
|
+
const say = (v) => allowed.sentinel !== void 0 && v === allowed.sentinel.value ? allowed.sentinel.meaning === "no-limit" ? "no limit" : "off" : String(v);
|
|
34889
|
+
return `this camera accepts ${what} only as ${allowed.values.map(say).join(", ")}; ${say(value)} is not one of them`;
|
|
34890
|
+
}
|
|
34891
|
+
if (!range) return null;
|
|
34892
|
+
if (value < range.min || value > range.max) return `this camera accepts ${what} between ${String(range.min)} and ${String(range.max)}; ${String(value)} is outside that`;
|
|
34893
|
+
if (range.step > 0 && (value - range.min) % range.step !== 0) return `this camera accepts ${what} in steps of ${String(range.step)} from ${String(range.min)}; ${String(value)} is not one of them`;
|
|
34894
|
+
return null;
|
|
34895
|
+
}
|
|
34896
|
+
function refuseSchedule(options, windows) {
|
|
34897
|
+
const schedule = options.schedule;
|
|
34898
|
+
if (!schedule.support.writable) return unwritable("the recording schedule", schedule.support.reason);
|
|
34899
|
+
const allowed = new Set(schedule.triggers);
|
|
34900
|
+
for (const window of windows) {
|
|
34901
|
+
if (!allowed.has(window.trigger)) {
|
|
34902
|
+
const offer = schedule.triggers.length > 0 ? schedule.triggers.join(", ") : "none";
|
|
34903
|
+
return `this camera cannot record on "${window.trigger}"; it records on: ${offer}`;
|
|
34904
|
+
}
|
|
34905
|
+
if (window.endMinute <= window.startMinute) return `a window on ${dayName(window.day)} ends at or before it starts (${String(window.startMinute)} → ${String(window.endMinute)})`;
|
|
34906
|
+
const step = schedule.granularityMinutes;
|
|
34907
|
+
if (step > 1 && (window.startMinute % step !== 0 || window.endMinute % step !== 0)) return `this camera's schedule only moves in ${String(step)}-minute steps; the ${dayName(window.day)} window ${formatMinutes(window.startMinute)}–${formatMinutes(window.endMinute)} is not aligned to them`;
|
|
34908
|
+
}
|
|
34909
|
+
if (!schedule.supportsOverlappingTriggers) {
|
|
34910
|
+
const clash = findOverlapWithDifferentTrigger(windows);
|
|
34911
|
+
if (clash) return `this camera stores one trigger per time range, so "${clash.a.trigger}" and "${clash.b.trigger}" cannot both cover ${dayName(clash.a.day)} ${formatMinutes(Math.max(clash.a.startMinute, clash.b.startMinute))}–${formatMinutes(Math.min(clash.a.endMinute, clash.b.endMinute))}`;
|
|
34912
|
+
}
|
|
34913
|
+
return null;
|
|
34914
|
+
}
|
|
34915
|
+
function findOverlapWithDifferentTrigger(windows) {
|
|
34916
|
+
for (let i = 0; i < windows.length; i += 1) for (let j = i + 1; j < windows.length; j += 1) {
|
|
34917
|
+
const a = windows[i];
|
|
34918
|
+
const b = windows[j];
|
|
34919
|
+
if (!a || !b) continue;
|
|
34920
|
+
if (a.day !== b.day) continue;
|
|
34921
|
+
if (a.trigger === b.trigger) continue;
|
|
34922
|
+
if (a.startMinute < b.endMinute && b.startMinute < a.endMinute) return {
|
|
34923
|
+
a,
|
|
34924
|
+
b
|
|
34925
|
+
};
|
|
34926
|
+
}
|
|
34927
|
+
return null;
|
|
34928
|
+
}
|
|
34929
|
+
function dayName(day) {
|
|
34930
|
+
return DAY_NAMES[day] ?? `day ${String(day)}`;
|
|
34931
|
+
}
|
|
34932
|
+
/** `510` → `08:30`. For messages, not for the wire. */
|
|
34933
|
+
function formatMinutes(minute) {
|
|
34934
|
+
const hour = Math.floor(minute / 60);
|
|
34935
|
+
const rest = minute % 60;
|
|
34936
|
+
return `${String(hour).padStart(2, "0")}:${String(rest).padStart(2, "0")}`;
|
|
34937
|
+
}
|
|
34938
|
+
/**
|
|
34939
|
+
* Parse a Hikvision `<TimeOfDay>` into minutes since midnight.
|
|
34623
34940
|
*
|
|
34624
|
-
*
|
|
34625
|
-
*
|
|
34626
|
-
*
|
|
34627
|
-
*
|
|
34941
|
+
* The firmware is not self-consistent and both spellings are real, on
|
|
34942
|
+
* the same camera in the same block: a start time reads `00:00:00` and
|
|
34943
|
+
* the matching end time reads `24:00`. Seconds are accepted and
|
|
34944
|
+
* discarded — the cap's resolution is minutes — and `24:00` maps to
|
|
34945
|
+
* {@link MINUTES_PER_DAY}, not to 0.
|
|
34628
34946
|
*
|
|
34629
|
-
*
|
|
34630
|
-
*
|
|
34947
|
+
* Returns null for anything else, which a caller reports as a window it
|
|
34948
|
+
* could not read rather than as midnight.
|
|
34631
34949
|
*/
|
|
34632
|
-
|
|
34633
|
-
|
|
34634
|
-
|
|
34635
|
-
|
|
34636
|
-
|
|
34637
|
-
|
|
34638
|
-
|
|
34639
|
-
|
|
34640
|
-
|
|
34641
|
-
|
|
34642
|
-
* file deletion — unreadable in one release. Absence means `footage`, and
|
|
34643
|
-
* {@link exportSubjectOf} is the one place that says so.
|
|
34644
|
-
*/
|
|
34645
|
-
subject: ExportSubjectSchema.optional(),
|
|
34646
|
-
options: ExportOptionsSchema,
|
|
34647
|
-
state: ExportStateSchema,
|
|
34648
|
-
/** 0–100 while rendering; null otherwise. */
|
|
34649
|
-
progressPct: number().nullable(),
|
|
34650
|
-
/** File size once ready; null before. */
|
|
34651
|
-
fileBytes: number().nullable(),
|
|
34652
|
-
expiresAt: number(),
|
|
34653
|
-
deleteAfterDownload: boolean(),
|
|
34654
|
-
/** Epoch of the first complete download; null until then. */
|
|
34655
|
-
downloadedAt: number().nullable(),
|
|
34656
|
-
createdAt: number(),
|
|
34657
|
-
/** User id/name that requested the export. */
|
|
34658
|
-
createdBy: string(),
|
|
34659
|
-
/** Failure reason when state is 'failed'; null otherwise. */
|
|
34660
|
-
error: string().nullable()
|
|
34661
|
-
});
|
|
34662
|
-
_enum([
|
|
34663
|
-
"catalog-miss",
|
|
34664
|
-
"catalog-unreachable",
|
|
34665
|
-
"no-file-for-window",
|
|
34666
|
-
"clip-in-progress",
|
|
34667
|
-
"unsupported-option",
|
|
34668
|
-
"sleeping",
|
|
34669
|
-
"camera-refused",
|
|
34670
|
-
"fetch-failed",
|
|
34671
|
-
"too-large-to-transfer",
|
|
34672
|
-
"wake-expired"
|
|
34673
|
-
]);
|
|
34674
|
-
/** `<token>: <prose>` — the ONE composition of a clip export's failure string. */
|
|
34675
|
-
function clipExportFailure(code, detail) {
|
|
34676
|
-
return detail.length > 0 ? `${code}: ${detail}` : code;
|
|
34950
|
+
function timeOfDayToMinutes(value) {
|
|
34951
|
+
const match = /^(\d{1,2}):(\d{2})(?::(\d{2}))?$/.exec(value.trim());
|
|
34952
|
+
if (!match) return null;
|
|
34953
|
+
const hour = Number(match[1]);
|
|
34954
|
+
const minute = Number(match[2]);
|
|
34955
|
+
if (!Number.isInteger(hour) || !Number.isInteger(minute)) return null;
|
|
34956
|
+
if (minute > 59) return null;
|
|
34957
|
+
const total = hour * 60 + minute;
|
|
34958
|
+
if (total > 1440) return null;
|
|
34959
|
+
return total;
|
|
34677
34960
|
}
|
|
34678
|
-
/** Candidate download URLs (LAN first, then operator extra hosts). */
|
|
34679
|
-
var ExportDownloadSchema = object({
|
|
34680
|
-
url: string(),
|
|
34681
|
-
endpoints: array(string())
|
|
34682
|
-
});
|
|
34683
34961
|
/**
|
|
34684
|
-
*
|
|
34962
|
+
* Render minutes back as a Hikvision `TimeOfDay`.
|
|
34685
34963
|
*
|
|
34686
|
-
*
|
|
34687
|
-
*
|
|
34964
|
+
* Emits the camera's own two spellings: `24:00` for end-of-day, because
|
|
34965
|
+
* that is what the firmware writes and `24:00:00` is not observed, and
|
|
34966
|
+
* `HH:MM:SS` otherwise.
|
|
34688
34967
|
*/
|
|
34689
|
-
|
|
34690
|
-
|
|
34691
|
-
|
|
34692
|
-
|
|
34693
|
-
|
|
34694
|
-
bytes: number().int().nonnegative()
|
|
34695
|
-
});
|
|
34696
|
-
/** Canonical `profiles[]`, falling back to the legacy singular `profile`. */
|
|
34697
|
-
function resolveExportProfiles(input) {
|
|
34698
|
-
if (input.profiles !== void 0 && input.profiles.length > 0) return [...input.profiles];
|
|
34699
|
-
if (typeof input.profile === "string" && input.profile.length > 0) return [input.profile];
|
|
34700
|
-
return [];
|
|
34968
|
+
function minutesToTimeOfDay(minute) {
|
|
34969
|
+
if (minute >= 1440) return "24:00";
|
|
34970
|
+
const hour = Math.floor(minute / 60);
|
|
34971
|
+
const rest = minute % 60;
|
|
34972
|
+
return `${String(hour).padStart(2, "0")}:${String(rest).padStart(2, "0")}:00`;
|
|
34701
34973
|
}
|
|
34702
|
-
|
|
34703
|
-
|
|
34704
|
-
|
|
34705
|
-
|
|
34706
|
-
|
|
34707
|
-
|
|
34708
|
-
|
|
34709
|
-
|
|
34710
|
-
|
|
34711
|
-
|
|
34712
|
-
|
|
34713
|
-
|
|
34714
|
-
|
|
34715
|
-
|
|
34716
|
-
|
|
34717
|
-
|
|
34718
|
-
|
|
34719
|
-
|
|
34720
|
-
|
|
34721
|
-
|
|
34722
|
-
|
|
34723
|
-
|
|
34974
|
+
/** `'Monday'` → 0. Case-insensitive. Null for anything unrecognised. */
|
|
34975
|
+
function dayOfWeekToIndex(value) {
|
|
34976
|
+
const needle = value.trim().toLowerCase();
|
|
34977
|
+
const index = DAY_NAMES.findIndex((name) => name.toLowerCase() === needle);
|
|
34978
|
+
return index >= 0 ? index : null;
|
|
34979
|
+
}
|
|
34980
|
+
/**
|
|
34981
|
+
* Which fields of a patch the camera did NOT take verbatim.
|
|
34982
|
+
*
|
|
34983
|
+
* Measured on a Hikvision I91DN (1436, 2026-09-22): a `PUT` of
|
|
34984
|
+
* `PreRecordTimeSeconds: 8` answered `200`, `statusCode 1`, `OK` — and stored
|
|
34985
|
+
* **5**. Neither the asked value nor the previous one. The camera declares no
|
|
34986
|
+
* allowed set for that field, so there is nothing to refuse against before the
|
|
34987
|
+
* wire: `/capabilities` returns a plain value where a constrained field would
|
|
34988
|
+
* carry an `opt=` list.
|
|
34989
|
+
*
|
|
34990
|
+
* So the only honest moment is after the read-back, and re-reading alone is
|
|
34991
|
+
* not enough — it makes the difference VISIBLE while leaving it unexplained.
|
|
34992
|
+
* A write that reports success for a value the camera never took is the same
|
|
34993
|
+
* silent substitution D599 removed from the clip path, wearing a different hat.
|
|
34994
|
+
*
|
|
34995
|
+
* Compares only the fields the patch actually named: a field nobody asked
|
|
34996
|
+
* about cannot have been clamped, and a read-back that could not answer it is
|
|
34997
|
+
* `stored: null` rather than a claim.
|
|
34998
|
+
*/
|
|
34999
|
+
function describeOnboardClamp(patch, landed) {
|
|
35000
|
+
const out = [];
|
|
35001
|
+
for (const [field, asked] of Object.entries(patch)) {
|
|
35002
|
+
if (asked === void 0) continue;
|
|
35003
|
+
if (typeof asked !== "number" && typeof asked !== "boolean" && typeof asked !== "string") continue;
|
|
35004
|
+
const raw = landed === null ? void 0 : landed[field];
|
|
35005
|
+
const stored = typeof raw === "number" || typeof raw === "boolean" || typeof raw === "string" ? raw : null;
|
|
35006
|
+
if (stored !== asked) out.push({
|
|
35007
|
+
field,
|
|
35008
|
+
asked,
|
|
35009
|
+
stored
|
|
34724
35010
|
});
|
|
34725
|
-
return;
|
|
34726
35011
|
}
|
|
34727
|
-
|
|
34728
|
-
|
|
34729
|
-
message: `subject.deviceId (${v.subject.deviceId}) must equal deviceId (${v.deviceId})`,
|
|
34730
|
-
path: ["subject", "deviceId"]
|
|
34731
|
-
});
|
|
34732
|
-
const fromMs = v.subject?.kind === "footage" ? v.subject.fromMs : v.fromMs;
|
|
34733
|
-
const toMs = v.subject?.kind === "footage" ? v.subject.toMs : v.toMs;
|
|
34734
|
-
if (typeof fromMs !== "number" || typeof toMs !== "number") ctx.addIssue({
|
|
34735
|
-
code: ZodIssueCode.custom,
|
|
34736
|
-
message: "a footage export needs fromMs and toMs",
|
|
34737
|
-
path: ["fromMs"]
|
|
34738
|
-
});
|
|
34739
|
-
if ((v.subject?.kind === "footage" ? [...v.subject.profiles] : resolveExportProfiles(v)).length < 1) ctx.addIssue({
|
|
34740
|
-
code: ZodIssueCode.custom,
|
|
34741
|
-
message: "pass profiles[] (min 1) or legacy profile",
|
|
34742
|
-
path: ["profiles"]
|
|
34743
|
-
});
|
|
34744
|
-
}), ExportRecordSchema, {
|
|
34745
|
-
kind: "mutation",
|
|
34746
|
-
auth: "protected"
|
|
34747
|
-
}), method(object({ deviceId: number().optional() }), array(ExportRecordSchema), {
|
|
34748
|
-
kind: "query",
|
|
34749
|
-
auth: "protected"
|
|
34750
|
-
}), method(object({ exportId: string() }), ExportRecordSchema, {
|
|
34751
|
-
kind: "query",
|
|
34752
|
-
auth: "protected"
|
|
34753
|
-
}), method(object({ exportId: string() }), ExportRecordSchema, {
|
|
34754
|
-
kind: "mutation",
|
|
34755
|
-
auth: "protected"
|
|
34756
|
-
}), method(object({ exportId: string() }), ExportRecordSchema, {
|
|
34757
|
-
kind: "mutation",
|
|
34758
|
-
auth: "protected"
|
|
34759
|
-
}), method(object({ exportId: string() }), ExportDownloadSchema, {
|
|
34760
|
-
kind: "query",
|
|
34761
|
-
auth: "protected"
|
|
34762
|
-
}), method(object({ exportId: string() }), ExportBytesSchema, {
|
|
34763
|
-
kind: "query",
|
|
34764
|
-
auth: "protected"
|
|
34765
|
-
});
|
|
35012
|
+
return out;
|
|
35013
|
+
}
|
|
34766
35014
|
/**
|
|
34767
35015
|
* A camera's own "record me NOW" LEVEL — a signal the device raises while
|
|
34768
35016
|
* something it knows about is happening (a robot vacuum cleaning, a machine
|
|
@@ -42655,24 +42903,6 @@ Object.freeze({
|
|
|
42655
42903
|
addonId: null,
|
|
42656
42904
|
access: "view"
|
|
42657
42905
|
},
|
|
42658
|
-
"events.getEventClipUrl": {
|
|
42659
|
-
capName: "events",
|
|
42660
|
-
capScope: "device",
|
|
42661
|
-
addonId: null,
|
|
42662
|
-
access: "view"
|
|
42663
|
-
},
|
|
42664
|
-
"events.getEvents": {
|
|
42665
|
-
capName: "events",
|
|
42666
|
-
capScope: "device",
|
|
42667
|
-
addonId: null,
|
|
42668
|
-
access: "view"
|
|
42669
|
-
},
|
|
42670
|
-
"events.getEventThumbnail": {
|
|
42671
|
-
capName: "events",
|
|
42672
|
-
capScope: "device",
|
|
42673
|
-
addonId: null,
|
|
42674
|
-
access: "view"
|
|
42675
|
-
},
|
|
42676
42906
|
"faceGallery.assignFace": {
|
|
42677
42907
|
capName: "face-gallery",
|
|
42678
42908
|
capScope: "system",
|
|
@@ -45547,224 +45777,236 @@ Object.freeze({
|
|
|
45547
45777
|
addonId: null,
|
|
45548
45778
|
access: "create"
|
|
45549
45779
|
},
|
|
45550
|
-
"recording.
|
|
45780
|
+
"recording.getAvailability": {
|
|
45551
45781
|
capName: "recording",
|
|
45552
|
-
capScope: "
|
|
45782
|
+
capScope: "device",
|
|
45553
45783
|
addonId: null,
|
|
45554
|
-
access: "
|
|
45784
|
+
access: "view"
|
|
45555
45785
|
},
|
|
45556
|
-
"recording.
|
|
45786
|
+
"recording.getDaysWithRecordings": {
|
|
45557
45787
|
capName: "recording",
|
|
45558
|
-
capScope: "
|
|
45788
|
+
capScope: "device",
|
|
45559
45789
|
addonId: null,
|
|
45560
|
-
access: "
|
|
45790
|
+
access: "view"
|
|
45561
45791
|
},
|
|
45562
|
-
"recording.
|
|
45792
|
+
"recording.getPlayback": {
|
|
45563
45793
|
capName: "recording",
|
|
45564
|
-
capScope: "
|
|
45794
|
+
capScope: "device",
|
|
45565
45795
|
addonId: null,
|
|
45566
|
-
access: "
|
|
45796
|
+
access: "view"
|
|
45567
45797
|
},
|
|
45568
|
-
"recording.
|
|
45798
|
+
"recording.getPlaybackOptions": {
|
|
45569
45799
|
capName: "recording",
|
|
45570
|
-
capScope: "
|
|
45800
|
+
capScope: "device",
|
|
45571
45801
|
addonId: null,
|
|
45572
|
-
access: "
|
|
45802
|
+
access: "view"
|
|
45573
45803
|
},
|
|
45574
|
-
"recording.
|
|
45804
|
+
"recording.listSources": {
|
|
45575
45805
|
capName: "recording",
|
|
45576
|
-
capScope: "
|
|
45806
|
+
capScope: "device",
|
|
45577
45807
|
addonId: null,
|
|
45578
45808
|
access: "view"
|
|
45579
45809
|
},
|
|
45580
|
-
"
|
|
45581
|
-
capName: "recording",
|
|
45810
|
+
"recordingArchive.applyDeviceSettingsPatch": {
|
|
45811
|
+
capName: "recording-archive",
|
|
45582
45812
|
capScope: "system",
|
|
45583
45813
|
addonId: null,
|
|
45584
|
-
access: "
|
|
45814
|
+
access: "create"
|
|
45585
45815
|
},
|
|
45586
|
-
"
|
|
45587
|
-
capName: "recording",
|
|
45816
|
+
"recordingArchive.cancelRelocateJob": {
|
|
45817
|
+
capName: "recording-archive",
|
|
45588
45818
|
capScope: "system",
|
|
45589
45819
|
addonId: null,
|
|
45590
|
-
access: "
|
|
45820
|
+
access: "create"
|
|
45591
45821
|
},
|
|
45592
|
-
"
|
|
45593
|
-
capName: "recording",
|
|
45822
|
+
"recordingArchive.cancelStorageMigrationMove": {
|
|
45823
|
+
capName: "recording-archive",
|
|
45824
|
+
capScope: "system",
|
|
45825
|
+
addonId: null,
|
|
45826
|
+
access: "create"
|
|
45827
|
+
},
|
|
45828
|
+
"recordingArchive.deleteFootprint": {
|
|
45829
|
+
capName: "recording-archive",
|
|
45830
|
+
capScope: "system",
|
|
45831
|
+
addonId: null,
|
|
45832
|
+
access: "delete"
|
|
45833
|
+
},
|
|
45834
|
+
"recordingArchive.getAvailabilityBatch": {
|
|
45835
|
+
capName: "recording-archive",
|
|
45594
45836
|
capScope: "system",
|
|
45595
45837
|
addonId: null,
|
|
45596
45838
|
access: "view"
|
|
45597
45839
|
},
|
|
45598
|
-
"
|
|
45599
|
-
capName: "recording",
|
|
45840
|
+
"recordingArchive.getDaysWithRecordingsBatch": {
|
|
45841
|
+
capName: "recording-archive",
|
|
45600
45842
|
capScope: "system",
|
|
45601
45843
|
addonId: null,
|
|
45602
45844
|
access: "view"
|
|
45603
45845
|
},
|
|
45604
|
-
"
|
|
45605
|
-
capName: "recording",
|
|
45846
|
+
"recordingArchive.getDeviceConfig": {
|
|
45847
|
+
capName: "recording-archive",
|
|
45606
45848
|
capScope: "system",
|
|
45607
45849
|
addonId: null,
|
|
45608
45850
|
access: "view"
|
|
45609
45851
|
},
|
|
45610
|
-
"
|
|
45611
|
-
capName: "recording",
|
|
45852
|
+
"recordingArchive.getDeviceLiveContribution": {
|
|
45853
|
+
capName: "recording-archive",
|
|
45612
45854
|
capScope: "system",
|
|
45613
45855
|
addonId: null,
|
|
45614
45856
|
access: "view"
|
|
45615
45857
|
},
|
|
45616
|
-
"
|
|
45617
|
-
capName: "recording",
|
|
45858
|
+
"recordingArchive.getDeviceSettingsContribution": {
|
|
45859
|
+
capName: "recording-archive",
|
|
45618
45860
|
capScope: "system",
|
|
45619
45861
|
addonId: null,
|
|
45620
45862
|
access: "view"
|
|
45621
45863
|
},
|
|
45622
|
-
"
|
|
45623
|
-
capName: "recording",
|
|
45864
|
+
"recordingArchive.getPlacement": {
|
|
45865
|
+
capName: "recording-archive",
|
|
45624
45866
|
capScope: "system",
|
|
45625
45867
|
addonId: null,
|
|
45626
45868
|
access: "view"
|
|
45627
45869
|
},
|
|
45628
|
-
"
|
|
45629
|
-
capName: "recording",
|
|
45870
|
+
"recordingArchive.getRelocateResidue": {
|
|
45871
|
+
capName: "recording-archive",
|
|
45630
45872
|
capScope: "system",
|
|
45631
45873
|
addonId: null,
|
|
45632
45874
|
access: "view"
|
|
45633
45875
|
},
|
|
45634
|
-
"
|
|
45635
|
-
capName: "recording",
|
|
45876
|
+
"recordingArchive.getStatus": {
|
|
45877
|
+
capName: "recording-archive",
|
|
45636
45878
|
capScope: "system",
|
|
45637
45879
|
addonId: null,
|
|
45638
45880
|
access: "view"
|
|
45639
45881
|
},
|
|
45640
|
-
"
|
|
45641
|
-
capName: "recording",
|
|
45882
|
+
"recordingArchive.getStorageMigrationMoveStatus": {
|
|
45883
|
+
capName: "recording-archive",
|
|
45642
45884
|
capScope: "system",
|
|
45643
45885
|
addonId: null,
|
|
45644
45886
|
access: "view"
|
|
45645
45887
|
},
|
|
45646
|
-
"
|
|
45647
|
-
capName: "recording",
|
|
45888
|
+
"recordingArchive.getStorageUsage": {
|
|
45889
|
+
capName: "recording-archive",
|
|
45648
45890
|
capScope: "system",
|
|
45649
45891
|
addonId: null,
|
|
45650
45892
|
access: "view"
|
|
45651
45893
|
},
|
|
45652
|
-
"
|
|
45653
|
-
capName: "recording",
|
|
45894
|
+
"recordingArchive.listOpsLog": {
|
|
45895
|
+
capName: "recording-archive",
|
|
45654
45896
|
capScope: "system",
|
|
45655
45897
|
addonId: null,
|
|
45656
45898
|
access: "view"
|
|
45657
45899
|
},
|
|
45658
|
-
"
|
|
45659
|
-
capName: "recording",
|
|
45900
|
+
"recordingArchive.listRelocateJobs": {
|
|
45901
|
+
capName: "recording-archive",
|
|
45660
45902
|
capScope: "system",
|
|
45661
45903
|
addonId: null,
|
|
45662
45904
|
access: "view"
|
|
45663
45905
|
},
|
|
45664
|
-
"
|
|
45665
|
-
capName: "recording",
|
|
45906
|
+
"recordingArchive.locateSegment": {
|
|
45907
|
+
capName: "recording-archive",
|
|
45666
45908
|
capScope: "system",
|
|
45667
45909
|
addonId: null,
|
|
45668
45910
|
access: "view"
|
|
45669
45911
|
},
|
|
45670
|
-
"
|
|
45671
|
-
capName: "recording",
|
|
45912
|
+
"recordingArchive.pauseForStorageMigration": {
|
|
45913
|
+
capName: "recording-archive",
|
|
45672
45914
|
capScope: "system",
|
|
45673
45915
|
addonId: null,
|
|
45674
45916
|
access: "create"
|
|
45675
45917
|
},
|
|
45676
|
-
"
|
|
45677
|
-
capName: "recording",
|
|
45918
|
+
"recordingArchive.planStorageRebalance": {
|
|
45919
|
+
capName: "recording-archive",
|
|
45678
45920
|
capScope: "system",
|
|
45679
45921
|
addonId: null,
|
|
45680
45922
|
access: "view"
|
|
45681
45923
|
},
|
|
45682
|
-
"
|
|
45683
|
-
capName: "recording",
|
|
45924
|
+
"recordingArchive.pruneFootage": {
|
|
45925
|
+
capName: "recording-archive",
|
|
45684
45926
|
capScope: "system",
|
|
45685
45927
|
addonId: null,
|
|
45686
45928
|
access: "create"
|
|
45687
45929
|
},
|
|
45688
|
-
"
|
|
45689
|
-
capName: "recording",
|
|
45930
|
+
"recordingArchive.readGopBytes": {
|
|
45931
|
+
capName: "recording-archive",
|
|
45690
45932
|
capScope: "system",
|
|
45691
45933
|
addonId: null,
|
|
45692
45934
|
access: "view"
|
|
45693
45935
|
},
|
|
45694
|
-
"
|
|
45695
|
-
capName: "recording",
|
|
45936
|
+
"recordingArchive.readSegmentBytes": {
|
|
45937
|
+
capName: "recording-archive",
|
|
45696
45938
|
capScope: "system",
|
|
45697
45939
|
addonId: null,
|
|
45698
45940
|
access: "view"
|
|
45699
45941
|
},
|
|
45700
|
-
"
|
|
45701
|
-
capName: "recording",
|
|
45942
|
+
"recordingArchive.readWindowBytes": {
|
|
45943
|
+
capName: "recording-archive",
|
|
45702
45944
|
capScope: "system",
|
|
45703
45945
|
addonId: null,
|
|
45704
45946
|
access: "view"
|
|
45705
45947
|
},
|
|
45706
|
-
"
|
|
45707
|
-
capName: "recording",
|
|
45948
|
+
"recordingArchive.reconcileLedgerAgainstDisk": {
|
|
45949
|
+
capName: "recording-archive",
|
|
45708
45950
|
capScope: "system",
|
|
45709
45951
|
addonId: null,
|
|
45710
45952
|
access: "create"
|
|
45711
45953
|
},
|
|
45712
|
-
"
|
|
45713
|
-
capName: "recording",
|
|
45954
|
+
"recordingArchive.refreshStorageLocationsForMigration": {
|
|
45955
|
+
capName: "recording-archive",
|
|
45714
45956
|
capScope: "system",
|
|
45715
45957
|
addonId: null,
|
|
45716
45958
|
access: "create"
|
|
45717
45959
|
},
|
|
45718
|
-
"
|
|
45719
|
-
capName: "recording",
|
|
45960
|
+
"recordingArchive.relocateFootage": {
|
|
45961
|
+
capName: "recording-archive",
|
|
45720
45962
|
capScope: "system",
|
|
45721
45963
|
addonId: null,
|
|
45722
45964
|
access: "create"
|
|
45723
45965
|
},
|
|
45724
|
-
"
|
|
45725
|
-
capName: "recording",
|
|
45966
|
+
"recordingArchive.renderClip": {
|
|
45967
|
+
capName: "recording-archive",
|
|
45726
45968
|
capScope: "system",
|
|
45727
45969
|
addonId: null,
|
|
45728
45970
|
access: "create"
|
|
45729
45971
|
},
|
|
45730
|
-
"
|
|
45731
|
-
capName: "recording",
|
|
45972
|
+
"recordingArchive.renderGif": {
|
|
45973
|
+
capName: "recording-archive",
|
|
45732
45974
|
capScope: "system",
|
|
45733
45975
|
addonId: null,
|
|
45734
45976
|
access: "create"
|
|
45735
45977
|
},
|
|
45736
|
-
"
|
|
45737
|
-
capName: "recording",
|
|
45978
|
+
"recordingArchive.rescanStorage": {
|
|
45979
|
+
capName: "recording-archive",
|
|
45738
45980
|
capScope: "system",
|
|
45739
45981
|
addonId: null,
|
|
45740
45982
|
access: "create"
|
|
45741
45983
|
},
|
|
45742
|
-
"
|
|
45743
|
-
capName: "recording",
|
|
45984
|
+
"recordingArchive.resumeForStorageMigration": {
|
|
45985
|
+
capName: "recording-archive",
|
|
45744
45986
|
capScope: "system",
|
|
45745
45987
|
addonId: null,
|
|
45746
45988
|
access: "create"
|
|
45747
45989
|
},
|
|
45748
|
-
"
|
|
45749
|
-
capName: "recording",
|
|
45990
|
+
"recordingArchive.setDeviceConfig": {
|
|
45991
|
+
capName: "recording-archive",
|
|
45750
45992
|
capScope: "system",
|
|
45751
45993
|
addonId: null,
|
|
45752
45994
|
access: "create"
|
|
45753
45995
|
},
|
|
45754
|
-
"
|
|
45755
|
-
capName: "recording",
|
|
45996
|
+
"recordingArchive.setDevicePlacement": {
|
|
45997
|
+
capName: "recording-archive",
|
|
45756
45998
|
capScope: "system",
|
|
45757
45999
|
addonId: null,
|
|
45758
46000
|
access: "create"
|
|
45759
46001
|
},
|
|
45760
|
-
"
|
|
45761
|
-
capName: "recording",
|
|
46002
|
+
"recordingArchive.startStorageMigrationMove": {
|
|
46003
|
+
capName: "recording-archive",
|
|
45762
46004
|
capScope: "system",
|
|
45763
46005
|
addonId: null,
|
|
45764
46006
|
access: "create"
|
|
45765
46007
|
},
|
|
45766
|
-
"
|
|
45767
|
-
capName: "recording",
|
|
46008
|
+
"recordingArchive.startStorageRebalance": {
|
|
46009
|
+
capName: "recording-archive",
|
|
45768
46010
|
capScope: "system",
|
|
45769
46011
|
addonId: null,
|
|
45770
46012
|
access: "create"
|
|
@@ -48069,21 +48311,6 @@ Object.freeze({
|
|
|
48069
48311
|
form: "single",
|
|
48070
48312
|
optional: false
|
|
48071
48313
|
}],
|
|
48072
|
-
"events.getEventClipUrl": [{
|
|
48073
|
-
name: "deviceId",
|
|
48074
|
-
form: "single",
|
|
48075
|
-
optional: false
|
|
48076
|
-
}],
|
|
48077
|
-
"events.getEvents": [{
|
|
48078
|
-
name: "deviceId",
|
|
48079
|
-
form: "single",
|
|
48080
|
-
optional: false
|
|
48081
|
-
}],
|
|
48082
|
-
"events.getEventThumbnail": [{
|
|
48083
|
-
name: "deviceId",
|
|
48084
|
-
form: "single",
|
|
48085
|
-
optional: false
|
|
48086
|
-
}],
|
|
48087
48314
|
"faceGallery.getFaceByTrack": [{
|
|
48088
48315
|
name: "deviceId",
|
|
48089
48316
|
form: "single",
|
|
@@ -49002,107 +49229,117 @@ Object.freeze({
|
|
|
49002
49229
|
form: "single",
|
|
49003
49230
|
optional: false
|
|
49004
49231
|
}],
|
|
49005
|
-
"recording.
|
|
49232
|
+
"recording.getAvailability": [{
|
|
49006
49233
|
name: "deviceId",
|
|
49007
49234
|
form: "single",
|
|
49008
49235
|
optional: false
|
|
49009
49236
|
}],
|
|
49010
|
-
"recording.
|
|
49237
|
+
"recording.getDaysWithRecordings": [{
|
|
49011
49238
|
name: "deviceId",
|
|
49012
49239
|
form: "single",
|
|
49013
49240
|
optional: false
|
|
49014
49241
|
}],
|
|
49015
|
-
"recording.
|
|
49016
|
-
name: "
|
|
49017
|
-
form: "
|
|
49242
|
+
"recording.getPlayback": [{
|
|
49243
|
+
name: "deviceId",
|
|
49244
|
+
form: "single",
|
|
49018
49245
|
optional: false
|
|
49019
49246
|
}],
|
|
49020
|
-
"recording.
|
|
49247
|
+
"recording.getPlaybackOptions": [{
|
|
49021
49248
|
name: "deviceId",
|
|
49022
49249
|
form: "single",
|
|
49023
49250
|
optional: false
|
|
49024
49251
|
}],
|
|
49025
|
-
"recording.
|
|
49026
|
-
name: "
|
|
49027
|
-
form: "
|
|
49252
|
+
"recording.listSources": [{
|
|
49253
|
+
name: "deviceId",
|
|
49254
|
+
form: "single",
|
|
49028
49255
|
optional: false
|
|
49029
49256
|
}],
|
|
49030
|
-
"
|
|
49257
|
+
"recordingArchive.deleteFootprint": [{
|
|
49031
49258
|
name: "deviceId",
|
|
49032
49259
|
form: "single",
|
|
49033
49260
|
optional: false
|
|
49034
49261
|
}],
|
|
49035
|
-
"
|
|
49262
|
+
"recordingArchive.getAvailabilityBatch": [{
|
|
49263
|
+
name: "deviceIds",
|
|
49264
|
+
form: "array",
|
|
49265
|
+
optional: false
|
|
49266
|
+
}],
|
|
49267
|
+
"recordingArchive.getDaysWithRecordingsBatch": [{
|
|
49268
|
+
name: "deviceIds",
|
|
49269
|
+
form: "array",
|
|
49270
|
+
optional: false
|
|
49271
|
+
}],
|
|
49272
|
+
"recordingArchive.getDeviceConfig": [{
|
|
49036
49273
|
name: "deviceId",
|
|
49037
49274
|
form: "single",
|
|
49038
49275
|
optional: false
|
|
49039
49276
|
}],
|
|
49040
|
-
"
|
|
49277
|
+
"recordingArchive.listOpsLog": [{
|
|
49041
49278
|
name: "deviceId",
|
|
49042
49279
|
form: "single",
|
|
49043
49280
|
optional: true
|
|
49044
49281
|
}],
|
|
49045
|
-
"
|
|
49282
|
+
"recordingArchive.locateSegment": [{
|
|
49046
49283
|
name: "deviceId",
|
|
49047
49284
|
form: "single",
|
|
49048
49285
|
optional: false
|
|
49049
49286
|
}],
|
|
49050
|
-
"
|
|
49287
|
+
"recordingArchive.pruneFootage": [{
|
|
49051
49288
|
name: "deviceId",
|
|
49052
49289
|
form: "single",
|
|
49053
49290
|
optional: false
|
|
49054
49291
|
}],
|
|
49055
|
-
"
|
|
49292
|
+
"recordingArchive.readGopBytes": [{
|
|
49056
49293
|
name: "deviceId",
|
|
49057
49294
|
form: "single",
|
|
49058
49295
|
optional: false
|
|
49059
49296
|
}],
|
|
49060
|
-
"
|
|
49297
|
+
"recordingArchive.readSegmentBytes": [{
|
|
49061
49298
|
name: "deviceId",
|
|
49062
49299
|
form: "single",
|
|
49063
49300
|
optional: false
|
|
49064
49301
|
}],
|
|
49065
|
-
"
|
|
49302
|
+
"recordingArchive.readWindowBytes": [{
|
|
49066
49303
|
name: "deviceId",
|
|
49067
49304
|
form: "single",
|
|
49068
49305
|
optional: false
|
|
49069
49306
|
}],
|
|
49070
|
-
"
|
|
49307
|
+
"recordingArchive.reconcileLedgerAgainstDisk": [{
|
|
49071
49308
|
name: "deviceId",
|
|
49072
49309
|
form: "single",
|
|
49073
49310
|
optional: true
|
|
49074
49311
|
}],
|
|
49075
|
-
"
|
|
49312
|
+
"recordingArchive.relocateFootage": [{
|
|
49076
49313
|
name: "deviceId",
|
|
49077
49314
|
form: "single",
|
|
49078
49315
|
optional: true
|
|
49079
49316
|
}],
|
|
49080
|
-
"
|
|
49317
|
+
"recordingArchive.renderClip": [{
|
|
49081
49318
|
name: "deviceId",
|
|
49082
49319
|
form: "single",
|
|
49083
49320
|
optional: false
|
|
49084
49321
|
}],
|
|
49085
|
-
"
|
|
49322
|
+
"recordingArchive.renderGif": [{
|
|
49086
49323
|
name: "deviceId",
|
|
49087
49324
|
form: "single",
|
|
49088
49325
|
optional: false
|
|
49089
49326
|
}],
|
|
49090
|
-
"
|
|
49327
|
+
"recordingArchive.rescanStorage": [{
|
|
49091
49328
|
name: "deviceId",
|
|
49092
49329
|
form: "single",
|
|
49093
49330
|
optional: false
|
|
49094
49331
|
}],
|
|
49095
|
-
"
|
|
49332
|
+
"recordingArchive.setDeviceConfig": [{
|
|
49096
49333
|
name: "deviceId",
|
|
49097
49334
|
form: "single",
|
|
49098
49335
|
optional: false
|
|
49099
49336
|
}],
|
|
49100
|
-
"
|
|
49337
|
+
"recordingArchive.setDevicePlacement": [{
|
|
49101
49338
|
name: "deviceId",
|
|
49102
49339
|
form: "single",
|
|
49103
49340
|
optional: false
|
|
49104
49341
|
}],
|
|
49105
|
-
"
|
|
49342
|
+
"recordingArchive.startStorageMigrationMove": [{
|
|
49106
49343
|
name: "deviceId",
|
|
49107
49344
|
form: "single",
|
|
49108
49345
|
optional: true
|
|
@@ -50722,8 +50959,14 @@ function createClipThumbHandler(deps) {
|
|
|
50722
50959
|
* The 204, with everything the tile needs to decide what to draw next.
|
|
50723
50960
|
*
|
|
50724
50961
|
* A FINAL refusal is work that was dropped, so it is warned, per camera. A
|
|
50725
|
-
* DEFERRED one dropped nothing — the
|
|
50726
|
-
* replay
|
|
50962
|
+
* DEFERRED one dropped nothing — the camera's one playback slot is busy, or an
|
|
50963
|
+
* operator's tap evicted this mint mid-replay — and warning it would put a
|
|
50964
|
+
* line on the log per tile of a page.
|
|
50965
|
+
*
|
|
50966
|
+
* There was briefly a third rule here, exempting `media-not-held` from the
|
|
50967
|
+
* warn because it was the steady state of every list. That code is gone
|
|
50968
|
+
* because its cause is: a clip whose bytes are not held now MINTS, in about
|
|
50969
|
+
* half a second off the camera, instead of refusing.
|
|
50727
50970
|
*/
|
|
50728
50971
|
function writeStillRefusal(res, refusal, deviceId, logger, clipKey) {
|
|
50729
50972
|
const line = "videoclips: thumbnail not minted";
|
|
@@ -50961,25 +51204,58 @@ var CLIP_STREAM_PCMU_RATE_HZ = 8e3;
|
|
|
50961
51204
|
/**
|
|
50962
51205
|
* How much of an input ffmpeg may READ before it will write a header.
|
|
50963
51206
|
*
|
|
50964
|
-
* ffmpeg probes every input to discover what is in it
|
|
50965
|
-
* enormous for this use — `probesize` 5 MB, `analyzeduration` 5 s —
|
|
51207
|
+
* ffmpeg probes every input to discover what is in it, and both defaults are
|
|
51208
|
+
* enormous for this use — `probesize` 5 MB, `analyzeduration` 5 s — which here
|
|
50966
51209
|
* are paid in the operator's wait, because a Hikvision replay arrives at 1×
|
|
50967
|
-
*
|
|
50968
|
-
*
|
|
50969
|
-
*
|
|
50970
|
-
*
|
|
50971
|
-
*
|
|
50972
|
-
*
|
|
50973
|
-
*
|
|
50974
|
-
*
|
|
50975
|
-
*
|
|
50976
|
-
*
|
|
50977
|
-
*
|
|
50978
|
-
* the first
|
|
50979
|
-
*
|
|
50980
|
-
*
|
|
50981
|
-
|
|
50982
|
-
|
|
51210
|
+
* and "5 MB of input" is seconds of wall clock. `-analyzeduration 0` goes with
|
|
51211
|
+
* it: the demuxer is named (`-f hevc`/`-f h264`, from the SDP's own
|
|
51212
|
+
* `a=rtpmap`), the rate is named (`-r`, measured), and the µ-law input is
|
|
51213
|
+
* named down to its sample rate. A probe can only re-derive what was stated.
|
|
51214
|
+
*
|
|
51215
|
+
* **256 KiB, and the number is a compromise between two measurements.** This
|
|
51216
|
+
* shipped at 32 KiB, which is six per cent of ONE access unit — the first unit
|
|
51217
|
+
* of a 3840×2160 HEVC replay on 1436 measures **550 354 bytes**, a whole 4K
|
|
51218
|
+
* keyframe with its parameter sets — and a bound that cannot hold a single
|
|
51219
|
+
* frame is uncomfortable whatever it gets away with. But widening it is not
|
|
51220
|
+
* free and it fixes nothing: measured against the pinned jellyfin 8.1.2 build
|
|
51221
|
+
* on the real camera, first byte to the peer was **721 ms at 32 KiB, 752 ms at
|
|
51222
|
+
* 256 KiB, 1 126 ms at 768 KiB**. 256 KiB buys eight times the headroom for
|
|
51223
|
+
* 31 ms.
|
|
51224
|
+
*
|
|
51225
|
+
* **It is explicitly NOT the cause of the header-and-no-media failure** that
|
|
51226
|
+
* cost the fleet an afternoon, and it was the first suspect. Every probe size
|
|
51227
|
+
* from 32 KiB to 768 KiB reproduced that fault identically, and removing the
|
|
51228
|
+
* flags altogether reproduced it too; the cause was
|
|
51229
|
+
* {@link CLIP_STREAM_MAX_INTERLEAVE_DELTA_US}. Written down so the hypothesis
|
|
51230
|
+
* is not re-tried.
|
|
51231
|
+
*/
|
|
51232
|
+
var CLIP_MUX_PROBE_BYTES = 256 * 1024;
|
|
51233
|
+
/**
|
|
51234
|
+
* How long the muxer may hold one track's packets WAITING for the other.
|
|
51235
|
+
*
|
|
51236
|
+
* **This is the whole reason a clip with sound would not play.** Measured on
|
|
51237
|
+
* 1436, 2026-09-23, through the real producer against the real camera with the
|
|
51238
|
+
* pinned build: a SILENT stream delivered 1 299 KiB to the peer by the
|
|
51239
|
+
* halfway point of a six-second clip, and the same clip with `opus` or `pcmu`
|
|
51240
|
+
* delivered **1 KiB** — the init segment, and nothing else — until the inputs
|
|
51241
|
+
* ENDED, at which point all 3.78 MB arrived in one burst. From the operator's
|
|
51242
|
+
* own session: 129 access units in, `bytesOut: 1298` out, `pushed: 0` on the
|
|
51243
|
+
* broker, and a player that gave up after 10.6 s with nothing to show.
|
|
51244
|
+
*
|
|
51245
|
+
* ffmpeg buffers packets to interleave two inputs, and with video on stdin and
|
|
51246
|
+
* µ-law on `pipe:3` it decided to wait rather than write. It is not a rate
|
|
51247
|
+
* mismatch — the two timelines measured 4.80 s of video against 4.80 s of
|
|
51248
|
+
* audio, a ratio of 1.000 — it is the muxer's own interleaving window, and for
|
|
51249
|
+
* a LIVE fragmented stream any window at all is wrong.
|
|
51250
|
+
*
|
|
51251
|
+
* **`0` does not mean "no window". It means UNLIMITED**, and it reproduced the
|
|
51252
|
+
* fault exactly. The value has to be small and positive. 100 ms is two and a
|
|
51253
|
+
* half of this camera's 40 ms µ-law frames — long enough that ordinary jitter
|
|
51254
|
+
* does not split a fragment, short enough that no consumer notices.
|
|
51255
|
+
*
|
|
51256
|
+
* With it, all three audio asks deliver ~1 278 KiB by the same halfway point.
|
|
51257
|
+
*/
|
|
51258
|
+
var CLIP_STREAM_MAX_INTERLEAVE_DELTA_US = 1e5;
|
|
50983
51259
|
/**
|
|
50984
51260
|
* How long a fragment may run before it is CLOSED, keyframe or not.
|
|
50985
51261
|
*
|
|
@@ -51070,6 +51346,8 @@ function buildClipStreamMuxArgs(input) {
|
|
|
51070
51346
|
CLIP_STREAM_MOVFLAGS,
|
|
51071
51347
|
"-frag_duration",
|
|
51072
51348
|
String(CLIP_STREAM_FRAG_DURATION_US),
|
|
51349
|
+
"-max_interleave_delta",
|
|
51350
|
+
String(CLIP_STREAM_MAX_INTERLEAVE_DELTA_US),
|
|
51073
51351
|
"-flush_packets",
|
|
51074
51352
|
"1",
|
|
51075
51353
|
"-f",
|
|
@@ -51131,12 +51409,19 @@ function createDrainGate(deps) {
|
|
|
51131
51409
|
return {
|
|
51132
51410
|
wrote(accepted) {
|
|
51133
51411
|
if (accepted || handle !== null || stalled) return;
|
|
51134
|
-
|
|
51135
|
-
handle =
|
|
51136
|
-
|
|
51137
|
-
|
|
51138
|
-
|
|
51139
|
-
|
|
51412
|
+
const arm = () => {
|
|
51413
|
+
handle = setTimeout(() => {
|
|
51414
|
+
handle = null;
|
|
51415
|
+
if (stalled) return;
|
|
51416
|
+
if (deps.stillMoving?.() === true) {
|
|
51417
|
+
arm();
|
|
51418
|
+
return;
|
|
51419
|
+
}
|
|
51420
|
+
stalled = true;
|
|
51421
|
+
deps.onStall();
|
|
51422
|
+
}, deps.timeoutMs);
|
|
51423
|
+
};
|
|
51424
|
+
arm();
|
|
51140
51425
|
},
|
|
51141
51426
|
drained() {
|
|
51142
51427
|
disarm();
|
|
@@ -52111,26 +52396,8 @@ async function prepareClipFile(input, deps) {
|
|
|
52111
52396
|
detail: err instanceof Error ? err.message : String(err)
|
|
52112
52397
|
};
|
|
52113
52398
|
}
|
|
52114
|
-
const abort = () => void session.close();
|
|
52115
|
-
deps.signal?.addEventListener("abort", abort, { once: true });
|
|
52116
52399
|
const end = await session.ended;
|
|
52117
|
-
deps.signal?.removeEventListener("abort", abort);
|
|
52118
52400
|
await session.close();
|
|
52119
|
-
if (deps.signal?.aborted === true) {
|
|
52120
|
-
deps.logger.debug("videoclips: a clip fetch gave the slot back", {
|
|
52121
|
-
tags,
|
|
52122
|
-
meta: {
|
|
52123
|
-
...meta,
|
|
52124
|
-
branch: "preempted",
|
|
52125
|
-
accessUnits: units.length
|
|
52126
|
-
}
|
|
52127
|
-
});
|
|
52128
|
-
return {
|
|
52129
|
-
kind: "refused",
|
|
52130
|
-
code: "fetch-failed",
|
|
52131
|
-
detail: "preempted: the camera’s one replay slot was wanted by a stream"
|
|
52132
|
-
};
|
|
52133
|
-
}
|
|
52134
52401
|
if (end.kind === "failed") return {
|
|
52135
52402
|
kind: "refused",
|
|
52136
52403
|
code: "camera-refused",
|
|
@@ -52245,19 +52512,7 @@ async function prepareClipFile(input, deps) {
|
|
|
52245
52512
|
* than that is a holder that is still playing.
|
|
52246
52513
|
*/
|
|
52247
52514
|
var REPLAY_LANE_WAIT_MS = RTSP_TEARDOWN_FLUSH_MS + 1e3;
|
|
52248
|
-
/**
|
|
52249
|
-
* Which purposes are SPECULATIVE — work nobody is waiting on.
|
|
52250
|
-
*
|
|
52251
|
-
* A still is minted for a tile that is not on screen yet. A stream and a file
|
|
52252
|
-
* are an operator who has already tapped. When the two want the same camera,
|
|
52253
|
-
* the operator wins: the speculative holder is asked to give the slot back
|
|
52254
|
-
* (`yield`) and the ask waits for it, instead of being refused for want of
|
|
52255
|
-
* work that could have been done a minute later.
|
|
52256
|
-
*
|
|
52257
|
-
* Without this, opening a list of clips would start a realtime fetch per tile
|
|
52258
|
-
* and every playback tap during it would meet `replay-busy` — which is a
|
|
52259
|
-
* regression traded for a thumbnail, and not a trade anyone asked for.
|
|
52260
|
-
*/
|
|
52515
|
+
/** Work nobody is waiting on, which an operator's tap may evict. */
|
|
52261
52516
|
var SPECULATIVE = new Set(["still"]);
|
|
52262
52517
|
function createReplayLane(deps) {
|
|
52263
52518
|
const now = deps.now ?? (() => Date.now());
|
|
@@ -52369,14 +52624,65 @@ function buildClipStillArgs(input) {
|
|
|
52369
52624
|
];
|
|
52370
52625
|
}
|
|
52371
52626
|
/**
|
|
52627
|
+
* What ffmpeg is told to cut a still out of RAW ACCESS UNITS.
|
|
52628
|
+
*
|
|
52629
|
+
* The other half of the same job. A clip whose bytes are not on this disk is
|
|
52630
|
+
* never FETCHED — that costs the camera its playback session for the clip's
|
|
52631
|
+
* whole duration — so its FIRST frame is taken off the camera in about half a
|
|
52632
|
+
* second (`clip-first-frame.ts`) and decoded here, from an elementary stream
|
|
52633
|
+
* on stdin rather than from a file.
|
|
52634
|
+
*
|
|
52635
|
+
* No `-ss`: the units ARE the head, and there is no seek inside a Hikvision
|
|
52636
|
+
* replay to reach anything else. No `-r`: one frame carries no rate, which is
|
|
52637
|
+
* the single case `clip-replay-rate.ts`'s rule does not reach.
|
|
52638
|
+
*/
|
|
52639
|
+
function buildFirstFrameStillArgs(codec) {
|
|
52640
|
+
return [
|
|
52641
|
+
"-hide_banner",
|
|
52642
|
+
"-loglevel",
|
|
52643
|
+
"error",
|
|
52644
|
+
"-nostdin",
|
|
52645
|
+
"-analyzeduration",
|
|
52646
|
+
"0",
|
|
52647
|
+
"-probesize",
|
|
52648
|
+
String(CLIP_MUX_PROBE_BYTES),
|
|
52649
|
+
"-f",
|
|
52650
|
+
codec === "h265" ? "hevc" : "h264",
|
|
52651
|
+
"-i",
|
|
52652
|
+
"pipe:0",
|
|
52653
|
+
"-frames:v",
|
|
52654
|
+
"1",
|
|
52655
|
+
"-vf",
|
|
52656
|
+
`scale=${String(640)}:-2:flags=bicubic`,
|
|
52657
|
+
"-q:v",
|
|
52658
|
+
String(4),
|
|
52659
|
+
"-f",
|
|
52660
|
+
"mjpeg",
|
|
52661
|
+
"pipe:1"
|
|
52662
|
+
];
|
|
52663
|
+
}
|
|
52664
|
+
/** The first frame the camera handed over, as a JPEG. Never throws. */
|
|
52665
|
+
async function cutStillFromAccessUnits(units, codec, deps) {
|
|
52666
|
+
return await runStillFfmpeg(buildFirstFrameStillArgs(codec), Buffer.concat(units.map((unit) => Buffer.from(unit.bytes))), deps, "the camera’s first access units");
|
|
52667
|
+
}
|
|
52668
|
+
/**
|
|
52372
52669
|
* Cut one still. Never throws: every dead end is a named refusal.
|
|
52373
52670
|
*/
|
|
52374
52671
|
async function cutClipStill(input, deps) {
|
|
52375
|
-
|
|
52672
|
+
return await runStillFfmpeg(buildClipStillArgs(input), null, deps, `${clipStillSeekSeconds(input.durationMs).toFixed(3)} s into the held file`);
|
|
52673
|
+
}
|
|
52674
|
+
/**
|
|
52675
|
+
* One bounded ffmpeg that answers with a JPEG or a named refusal.
|
|
52676
|
+
*
|
|
52677
|
+
* `stdin` carries the elementary stream when the source is the camera, and is
|
|
52678
|
+
* `null` when the source is a path. Shared, so the two cannot drift apart on
|
|
52679
|
+
* the timeout, the kill, or what an empty answer means.
|
|
52680
|
+
*/
|
|
52681
|
+
async function runStillFfmpeg(args, stdin, deps, where) {
|
|
52376
52682
|
let child;
|
|
52377
52683
|
try {
|
|
52378
52684
|
child = deps.spawnStill?.([...args]) ?? (0, node_child_process.spawn)(deps.ffmpegBinaryPath ?? "ffmpeg", [...args], { stdio: [
|
|
52379
|
-
"ignore",
|
|
52685
|
+
stdin === null ? "ignore" : "pipe",
|
|
52380
52686
|
"pipe",
|
|
52381
52687
|
"pipe"
|
|
52382
52688
|
] });
|
|
@@ -52393,6 +52699,10 @@ async function cutClipStill(input, deps) {
|
|
|
52393
52699
|
child.stderr?.on("data", (chunk) => {
|
|
52394
52700
|
stderr += chunk.toString("utf8");
|
|
52395
52701
|
});
|
|
52702
|
+
if (stdin !== null) {
|
|
52703
|
+
child.stdin?.on("error", () => {});
|
|
52704
|
+
child.stdin?.end(stdin);
|
|
52705
|
+
}
|
|
52396
52706
|
const timeoutMs = deps.timeoutMs ?? 1e4;
|
|
52397
52707
|
const exit = await new Promise((resolve) => {
|
|
52398
52708
|
const timer = setTimeout(() => resolve("timeout"), timeoutMs);
|
|
@@ -52415,19 +52725,100 @@ async function cutClipStill(input, deps) {
|
|
|
52415
52725
|
};
|
|
52416
52726
|
}
|
|
52417
52727
|
const bytes = Buffer.concat(chunks);
|
|
52728
|
+
if (bytes.byteLength > 0) return {
|
|
52729
|
+
kind: "ok",
|
|
52730
|
+
bytes
|
|
52731
|
+
};
|
|
52418
52732
|
if (exit !== 0) return {
|
|
52419
52733
|
kind: "refused",
|
|
52420
52734
|
code: "decode-failed",
|
|
52421
52735
|
detail: `ffmpeg exited ${String(exit)}: ${stderr.trim().slice(0, 300)}`
|
|
52422
52736
|
};
|
|
52423
|
-
|
|
52737
|
+
return {
|
|
52424
52738
|
kind: "refused",
|
|
52425
52739
|
code: "no-keyframe",
|
|
52426
|
-
detail: `ffmpeg read
|
|
52740
|
+
detail: `ffmpeg read ${where} and produced no frame`
|
|
52741
|
+
};
|
|
52742
|
+
}
|
|
52743
|
+
/** Never throws: every dead end is a named refusal. */
|
|
52744
|
+
async function fetchFirstFrame(input, deps) {
|
|
52745
|
+
const openReplay = deps.openReplay ?? openRtspReplay;
|
|
52746
|
+
const want = deps.accessUnits ?? 2;
|
|
52747
|
+
const timeoutMs = deps.timeoutMs ?? 5e3;
|
|
52748
|
+
const startedAt = Date.now();
|
|
52749
|
+
if (deps.signal?.aborted === true) return {
|
|
52750
|
+
kind: "refused",
|
|
52751
|
+
code: "yielded",
|
|
52752
|
+
detail: "the slot was wanted before the open"
|
|
52427
52753
|
};
|
|
52754
|
+
const units = [];
|
|
52755
|
+
let enough = null;
|
|
52756
|
+
const gotEnough = new Promise((resolve) => {
|
|
52757
|
+
enough = resolve;
|
|
52758
|
+
});
|
|
52759
|
+
let session;
|
|
52760
|
+
try {
|
|
52761
|
+
session = await openReplay({
|
|
52762
|
+
host: input.camera.host,
|
|
52763
|
+
username: input.camera.username,
|
|
52764
|
+
password: input.camera.password,
|
|
52765
|
+
playbackPath: input.row.playbackPath
|
|
52766
|
+
}, { onVideo: (unit) => {
|
|
52767
|
+
if (units.length >= want) return;
|
|
52768
|
+
units.push(unit);
|
|
52769
|
+
if (units.length >= want) enough?.();
|
|
52770
|
+
} }, {
|
|
52771
|
+
logger: deps.logger,
|
|
52772
|
+
deviceId: input.camera.deviceId
|
|
52773
|
+
});
|
|
52774
|
+
} catch (err) {
|
|
52775
|
+
return {
|
|
52776
|
+
kind: "refused",
|
|
52777
|
+
code: "camera-refused",
|
|
52778
|
+
detail: err instanceof Error ? err.message : String(err)
|
|
52779
|
+
};
|
|
52780
|
+
}
|
|
52781
|
+
let yielded = false;
|
|
52782
|
+
const onAbort = () => {
|
|
52783
|
+
yielded = true;
|
|
52784
|
+
enough?.();
|
|
52785
|
+
};
|
|
52786
|
+
deps.signal?.addEventListener("abort", onAbort, { once: true });
|
|
52787
|
+
let timer = setTimeout(() => {
|
|
52788
|
+
timer = null;
|
|
52789
|
+
enough?.();
|
|
52790
|
+
}, timeoutMs);
|
|
52791
|
+
session.ended.then(() => enough?.());
|
|
52792
|
+
await gotEnough;
|
|
52793
|
+
if (timer !== null) clearTimeout(timer);
|
|
52794
|
+
deps.signal?.removeEventListener("abort", onAbort);
|
|
52795
|
+
await session.close();
|
|
52796
|
+
const slotMs = Date.now() - startedAt;
|
|
52797
|
+
if (yielded) return {
|
|
52798
|
+
kind: "refused",
|
|
52799
|
+
code: "yielded",
|
|
52800
|
+
detail: `a playback wanted the slot after ${String(slotMs)} ms`
|
|
52801
|
+
};
|
|
52802
|
+
if (units.length === 0) return {
|
|
52803
|
+
kind: "refused",
|
|
52804
|
+
code: "camera-refused",
|
|
52805
|
+
detail: `the replay delivered no access unit inside ${String(timeoutMs)} ms`
|
|
52806
|
+
};
|
|
52807
|
+
deps.logger.debug("videoclips: took a clip’s first frame off the camera", {
|
|
52808
|
+
tags: { deviceId: input.camera.deviceId },
|
|
52809
|
+
meta: {
|
|
52810
|
+
clipKey: input.row.clipKey,
|
|
52811
|
+
units: units.length,
|
|
52812
|
+
bytes: units.reduce((sum, unit) => sum + unit.bytes.byteLength, 0),
|
|
52813
|
+
codec: session.video.codec,
|
|
52814
|
+
slotMs
|
|
52815
|
+
}
|
|
52816
|
+
});
|
|
52428
52817
|
return {
|
|
52429
52818
|
kind: "ok",
|
|
52430
|
-
|
|
52819
|
+
units,
|
|
52820
|
+
codec: session.video.codec,
|
|
52821
|
+
slotMs
|
|
52431
52822
|
};
|
|
52432
52823
|
}
|
|
52433
52824
|
function pathToken(req) {
|
|
@@ -52652,6 +53043,9 @@ var ClipStreamRun = class {
|
|
|
52652
53043
|
slotFreed = Promise.resolve();
|
|
52653
53044
|
settle = null;
|
|
52654
53045
|
bytesOut = 0;
|
|
53046
|
+
/** {@link bytesOut} the last time the audio gate's window elapsed. */
|
|
53047
|
+
bytesOutAtAudioWindow = 0;
|
|
53048
|
+
audioNotHungryLogged = false;
|
|
52655
53049
|
accessUnits = 0;
|
|
52656
53050
|
audioFramesAfterMux = 0;
|
|
52657
53051
|
audioFramesDropped = 0;
|
|
@@ -52660,6 +53054,9 @@ var ClipStreamRun = class {
|
|
|
52660
53054
|
* row's, which is a projection (D393). */
|
|
52661
53055
|
deliveredMs = null;
|
|
52662
53056
|
begun = false;
|
|
53057
|
+
/** ffmpeg's own words, bounded. Kept so EVERY exit can carry them, not just
|
|
53058
|
+
* the one that happened to be holding the closure. */
|
|
53059
|
+
stderr = "";
|
|
52663
53060
|
startedAt = Date.now();
|
|
52664
53061
|
constructor(request, deps) {
|
|
52665
53062
|
this.request = request;
|
|
@@ -52787,7 +53184,8 @@ var ClipStreamRun = class {
|
|
|
52787
53184
|
});
|
|
52788
53185
|
if (this.muxedAudio !== null) this.audioGate = createDrainGate({
|
|
52789
53186
|
timeoutMs: this.deps.drainTimeoutMs,
|
|
52790
|
-
onStall: () => this.sever("mux-audio-stalled", "ffmpeg stopped taking audio frames")
|
|
53187
|
+
onStall: () => this.sever("mux-audio-stalled", "ffmpeg stopped taking audio frames"),
|
|
53188
|
+
stillMoving: () => this.muxProducedSinceLastAudioWindow()
|
|
52791
53189
|
});
|
|
52792
53190
|
this.peerGate = createDrainGate({
|
|
52793
53191
|
timeoutMs: this.deps.drainTimeoutMs,
|
|
@@ -52802,24 +53200,65 @@ var ClipStreamRun = class {
|
|
|
52802
53200
|
audioPipe.on("drain", () => this.audioGate?.drained());
|
|
52803
53201
|
}
|
|
52804
53202
|
child.stdout?.on("data", (chunk) => this.onMuxOutput(chunk));
|
|
52805
|
-
let stderr = "";
|
|
52806
53203
|
child.stderr?.on("data", (chunk) => {
|
|
52807
|
-
stderr = `${stderr}${chunk.toString()}`.slice(-2e3);
|
|
53204
|
+
this.stderr = `${this.stderr}${chunk.toString()}`.slice(-2e3);
|
|
52808
53205
|
});
|
|
52809
|
-
child.on("close", (code) => this.onMuxClosed(code, stderr));
|
|
52810
|
-
this.request.sink.onceDrain(() => this.peerGate?.drained());
|
|
53206
|
+
child.on("close", (code) => this.onMuxClosed(code, this.stderr));
|
|
52811
53207
|
for (const unit of this.heldVideo) this.writeVideo(unit);
|
|
52812
53208
|
this.heldVideo = [];
|
|
52813
53209
|
if (this.muxedAudio !== null) for (const payload of this.heldAudio) this.writeAudio(payload);
|
|
52814
53210
|
else this.audioFramesDropped += this.heldAudio.length;
|
|
52815
53211
|
this.heldAudio = [];
|
|
52816
53212
|
}
|
|
53213
|
+
/**
|
|
53214
|
+
* Has this mux taken frames and produced no MEDIA?
|
|
53215
|
+
*
|
|
53216
|
+
* Checked as units go in, because that is the only place that knows the mux
|
|
53217
|
+
* is being fed. A header and nothing else is not a slow stream, it is a
|
|
53218
|
+
* broken one, and the peer will otherwise sit on it until it gives up with
|
|
53219
|
+
* nothing to show the operator but a blank player.
|
|
53220
|
+
*/
|
|
53221
|
+
checkMuxProducedMedia() {
|
|
53222
|
+
if (this.answered || this.mux === null) return;
|
|
53223
|
+
if (this.accessUnits < 64) return;
|
|
53224
|
+
if (this.bytesOut > 65536) return;
|
|
53225
|
+
this.sever("mux-no-media", `ffmpeg took ${String(this.accessUnits)} access units and produced ${String(this.bytesOut)} bytes — a header and no media` + (this.stderr.trim() === "" ? " (ffmpeg said nothing)" : `: ${this.stderr.trim().slice(-300)}`));
|
|
53226
|
+
}
|
|
52817
53227
|
writeVideo(unit) {
|
|
52818
53228
|
const stdin = this.mux?.stdin;
|
|
52819
53229
|
if (stdin === null || stdin === void 0 || stdin.destroyed) return;
|
|
52820
53230
|
this.accessUnits += 1;
|
|
53231
|
+
this.checkMuxProducedMedia();
|
|
53232
|
+
if (this.answered) return;
|
|
52821
53233
|
this.videoGate?.wrote(stdin.write(unit.bytes));
|
|
52822
53234
|
}
|
|
53235
|
+
/**
|
|
53236
|
+
* Did the mux hand the peer anything during the window the audio gate just
|
|
53237
|
+
* waited out?
|
|
53238
|
+
*
|
|
53239
|
+
* The gate's question is "has this hop stopped for good", and on fd 3 the
|
|
53240
|
+
* answer cannot be read from the pipe alone: 64 KiB of µ-law is eight
|
|
53241
|
+
* seconds of sound, so a muxer that is merely AHEAD on audio looks exactly
|
|
53242
|
+
* like one that has died. ffmpeg's own output settles it — bytes on stdout
|
|
53243
|
+
* are proof it is running — and each window is judged on its own, so a
|
|
53244
|
+
* mux that really stops is still cut one window later.
|
|
53245
|
+
*/
|
|
53246
|
+
muxProducedSinceLastAudioWindow() {
|
|
53247
|
+
const moved = this.bytesOut > this.bytesOutAtAudioWindow;
|
|
53248
|
+
this.bytesOutAtAudioWindow = this.bytesOut;
|
|
53249
|
+
if (moved && !this.audioNotHungryLogged) {
|
|
53250
|
+
this.audioNotHungryLogged = true;
|
|
53251
|
+
this.deps.logger.info("videoclips: the mux is not taking audio but is still producing", {
|
|
53252
|
+
tags: this.tags,
|
|
53253
|
+
meta: {
|
|
53254
|
+
...this.meta,
|
|
53255
|
+
bytesOut: this.bytesOut,
|
|
53256
|
+
accessUnits: this.accessUnits
|
|
53257
|
+
}
|
|
53258
|
+
});
|
|
53259
|
+
}
|
|
53260
|
+
return moved;
|
|
53261
|
+
}
|
|
52823
53262
|
writeAudio(payload) {
|
|
52824
53263
|
const pipe = writableStdio(this.mux?.stdio[3]);
|
|
52825
53264
|
if (pipe === null) return;
|
|
@@ -52833,7 +53272,14 @@ var ClipStreamRun = class {
|
|
|
52833
53272
|
this.request.sink.begin(clipStreamContentTypeFor(this.muxedAudio));
|
|
52834
53273
|
}
|
|
52835
53274
|
this.bytesOut += chunk.byteLength;
|
|
52836
|
-
this.
|
|
53275
|
+
const accepted = this.request.sink.write(chunk);
|
|
53276
|
+
this.peerGate?.wrote(accepted);
|
|
53277
|
+
if (accepted) return;
|
|
53278
|
+
this.mux?.stdout?.pause();
|
|
53279
|
+
this.request.sink.onceDrain(() => {
|
|
53280
|
+
this.peerGate?.drained();
|
|
53281
|
+
this.mux?.stdout?.resume();
|
|
53282
|
+
});
|
|
52837
53283
|
}
|
|
52838
53284
|
finishInputs(deliveredMs) {
|
|
52839
53285
|
if (this.answered) return;
|
|
@@ -52915,6 +53361,7 @@ var ClipStreamRun = class {
|
|
|
52915
53361
|
...this.meta,
|
|
52916
53362
|
branch,
|
|
52917
53363
|
reason: detail,
|
|
53364
|
+
muxStderr: this.stderr.trim().slice(-500),
|
|
52918
53365
|
accessUnits: this.accessUnits,
|
|
52919
53366
|
bytesOut: this.bytesOut,
|
|
52920
53367
|
elapsedMs: Date.now() - this.startedAt
|
|
@@ -53821,7 +54268,7 @@ function createClipService(deps) {
|
|
|
53821
54268
|
maxFilesPerDevice: THUMB_MAX_FILES_PER_DEVICE,
|
|
53822
54269
|
maxBytesPerDevice: THUMB_MAX_BYTES_PER_DEVICE
|
|
53823
54270
|
});
|
|
53824
|
-
const lane = createReplayLane({
|
|
54271
|
+
const lane = deps.lane ?? createReplayLane({
|
|
53825
54272
|
logger,
|
|
53826
54273
|
...deps.replayWaitMs !== void 0 ? { waitMs: deps.replayWaitMs } : {}
|
|
53827
54274
|
});
|
|
@@ -53946,30 +54393,32 @@ function createClipService(deps) {
|
|
|
53946
54393
|
detail: "no-catalog-row: list the window that holds this clip first"
|
|
53947
54394
|
};
|
|
53948
54395
|
if (await store.pathIfPresent(deviceId, clipKey) === null) {
|
|
53949
|
-
const
|
|
53950
|
-
const lease = await lane.acquire(deviceId, purpose, () => preempt.abort());
|
|
54396
|
+
const lease = await lane.acquire(deviceId, purpose);
|
|
53951
54397
|
if (lease.kind === "busy") return {
|
|
53952
54398
|
kind: "refused",
|
|
53953
54399
|
code: "replay-busy",
|
|
53954
54400
|
detail: lease.detail
|
|
53955
54401
|
};
|
|
54402
|
+
let fetched;
|
|
53956
54403
|
try {
|
|
53957
|
-
|
|
54404
|
+
fetched = await prepareClipFile({
|
|
53958
54405
|
camera: cameraFor(camera),
|
|
53959
54406
|
row,
|
|
53960
54407
|
audio: true
|
|
53961
54408
|
}, {
|
|
53962
54409
|
logger,
|
|
53963
54410
|
store,
|
|
53964
|
-
signal: preempt.signal,
|
|
53965
54411
|
...deps.ffmpegBinaryPath !== void 0 ? { ffmpegBinaryPath: deps.ffmpegBinaryPath } : {},
|
|
53966
|
-
...deps.openReplay !== void 0 ? { openReplay: deps.openReplay } : {}
|
|
54412
|
+
...deps.openReplay !== void 0 ? { openReplay: deps.openReplay } : {},
|
|
54413
|
+
...deps.spawnMux !== void 0 ? { spawnMux: deps.spawnMux } : {}
|
|
53967
54414
|
});
|
|
53968
54415
|
} finally {
|
|
53969
54416
|
lease.release();
|
|
53970
54417
|
}
|
|
54418
|
+
if (fetched.kind === "ok") await mintPassing(deviceId, clipKey, fetched);
|
|
54419
|
+
return fetched;
|
|
53971
54420
|
}
|
|
53972
|
-
|
|
54421
|
+
const cached = await prepareClipFile({
|
|
53973
54422
|
camera: cameraFor(camera),
|
|
53974
54423
|
row,
|
|
53975
54424
|
audio: true
|
|
@@ -53977,8 +54426,46 @@ function createClipService(deps) {
|
|
|
53977
54426
|
logger,
|
|
53978
54427
|
store,
|
|
53979
54428
|
...deps.ffmpegBinaryPath !== void 0 ? { ffmpegBinaryPath: deps.ffmpegBinaryPath } : {},
|
|
53980
|
-
...deps.openReplay !== void 0 ? { openReplay: deps.openReplay } : {}
|
|
54429
|
+
...deps.openReplay !== void 0 ? { openReplay: deps.openReplay } : {},
|
|
54430
|
+
...deps.spawnMux !== void 0 ? { spawnMux: deps.spawnMux } : {}
|
|
53981
54431
|
});
|
|
54432
|
+
if (cached.kind === "ok") await mintPassing(deviceId, clipKey, cached);
|
|
54433
|
+
return cached;
|
|
54434
|
+
};
|
|
54435
|
+
/**
|
|
54436
|
+
* Mint the still of a clip whose bytes have just been put on this disk.
|
|
54437
|
+
*
|
|
54438
|
+
* Cheap and idempotent: a `stat` says whether one is already held, and the
|
|
54439
|
+
* cut itself is one frame of a local file. It is AWAITED rather than fired
|
|
54440
|
+
* and forgotten, because an unhandled rejection in a detached promise is
|
|
54441
|
+
* exactly the silence D391 forbids — and because a caller that just waited
|
|
54442
|
+
* 30 s for a fetch is not harmed by 1.8 s of decode.
|
|
54443
|
+
*
|
|
54444
|
+
* A failure here NEVER fails the fetch. The caller asked for a clip, not a
|
|
54445
|
+
* picture, and a still that could not be cut is named and left absent.
|
|
54446
|
+
*/
|
|
54447
|
+
const mintPassing = async (deviceId, clipKey, file) => {
|
|
54448
|
+
if (await thumbs.has(deviceId, clipKey)) return;
|
|
54449
|
+
try {
|
|
54450
|
+
const minted = await cutHeldStill(deviceId, clipKey, file.path, file.durationMs);
|
|
54451
|
+
if (minted.ok) return;
|
|
54452
|
+
logger.debug("videoclips: no still was cut from a clip that was just fetched", {
|
|
54453
|
+
tags: { deviceId },
|
|
54454
|
+
meta: {
|
|
54455
|
+
clipKey,
|
|
54456
|
+
branch: minted.code,
|
|
54457
|
+
reason: minted.reason
|
|
54458
|
+
}
|
|
54459
|
+
});
|
|
54460
|
+
} catch (err) {
|
|
54461
|
+
logger.warn("videoclips: the passing still mint threw", {
|
|
54462
|
+
tags: { deviceId },
|
|
54463
|
+
meta: {
|
|
54464
|
+
clipKey,
|
|
54465
|
+
error: err instanceof Error ? err.message : String(err)
|
|
54466
|
+
}
|
|
54467
|
+
});
|
|
54468
|
+
}
|
|
53982
54469
|
};
|
|
53983
54470
|
/**
|
|
53984
54471
|
* `fileFor`'s vocabulary, in the one a clip EXPORT answers on.
|
|
@@ -54005,19 +54492,84 @@ function createClipService(deps) {
|
|
|
54005
54492
|
* about which clip a key means. Its whole job is to turn `fileFor`'s answer
|
|
54006
54493
|
* into the still vocabulary, and to cut one frame when there is a file.
|
|
54007
54494
|
*/
|
|
54495
|
+
/**
|
|
54496
|
+
* One clip's STILL, at the cheapest source that can give one.
|
|
54497
|
+
*
|
|
54498
|
+
* **Held bytes first, and they are free.** A clip the operator has played or
|
|
54499
|
+
* exported is already on this disk: one frame of local decode, no network.
|
|
54500
|
+
*
|
|
54501
|
+
* **Otherwise the camera's FIRST frame, for ~0.5 s of its playback slot.**
|
|
54502
|
+
* The clip is never FETCHED for a still — that was shipped once and cost
|
|
54503
|
+
* 898 s of camera time to fill one 20-row screen. A first-frame mint holds
|
|
54504
|
+
* the slot for 433–528 ms whatever the clip's length, and it is speculative:
|
|
54505
|
+
* the lane evicts it the moment an operator taps anything (`yielded`), and
|
|
54506
|
+
* an eviction or a busy slot is DEFERRED, because half a second that lost a
|
|
54507
|
+
* race is worth coming back for where twenty seconds was not.
|
|
54508
|
+
*
|
|
54509
|
+
* The midpoint the operator asked for is not reachable: a narrowed
|
|
54510
|
+
* `ContentMgmt/search` window is accepted with 200 and silently served from
|
|
54511
|
+
* the segment head (`clip-first-frame.ts` has the measurement).
|
|
54512
|
+
*/
|
|
54008
54513
|
const mintStill = async (deviceId, clipKey) => {
|
|
54009
|
-
const
|
|
54010
|
-
if (
|
|
54011
|
-
|
|
54012
|
-
|
|
54013
|
-
|
|
54014
|
-
|
|
54514
|
+
const camera = await deps.resolveCamera(deviceId);
|
|
54515
|
+
if (camera === null) return refuseStill("unknown-device", `device ${String(deviceId)} is not a Hikvision camera`);
|
|
54516
|
+
const row = rowsByKey.get(rowKey(deviceId, clipKey));
|
|
54517
|
+
if (row === void 0) return refuseStill("no-catalog-row", "no-catalog-row: list the window that holds this clip first");
|
|
54518
|
+
const held = await store.pathIfPresent(deviceId, clipKey);
|
|
54519
|
+
if (held !== null) return await cutHeldStill(deviceId, clipKey, held, null);
|
|
54520
|
+
const evict = new AbortController();
|
|
54521
|
+
const lease = await lane.acquire(deviceId, "still", () => evict.abort());
|
|
54522
|
+
if (lease.kind === "busy") return deferStill("queue-full", lease.detail, REPLAY_LANE_WAIT_MS);
|
|
54523
|
+
let frame;
|
|
54524
|
+
try {
|
|
54525
|
+
frame = await fetchFirstFrame({
|
|
54526
|
+
camera: cameraFor(camera),
|
|
54527
|
+
row
|
|
54528
|
+
}, {
|
|
54529
|
+
logger,
|
|
54530
|
+
signal: evict.signal,
|
|
54531
|
+
...deps.openReplay !== void 0 ? { openReplay: deps.openReplay } : {}
|
|
54532
|
+
});
|
|
54533
|
+
} finally {
|
|
54534
|
+
lease.release();
|
|
54535
|
+
}
|
|
54536
|
+
if (frame.kind === "refused") {
|
|
54537
|
+
if (frame.code === "yielded") return deferStill("queue-full", frame.detail, REPLAY_LANE_WAIT_MS);
|
|
54538
|
+
return refuseStill("camera-refused", frame.detail);
|
|
54015
54539
|
}
|
|
54540
|
+
const cut = await cutStillFromAccessUnits(frame.units, frame.codec, {
|
|
54541
|
+
logger,
|
|
54542
|
+
...deps.ffmpegBinaryPath !== void 0 ? { ffmpegBinaryPath: deps.ffmpegBinaryPath } : {},
|
|
54543
|
+
...deps.spawnStill !== void 0 ? { spawnStill: deps.spawnStill } : {}
|
|
54544
|
+
});
|
|
54545
|
+
if (cut.kind === "refused") return refuseStill(cut.code, cut.detail);
|
|
54546
|
+
await thumbs.put(deviceId, clipKey, cut.bytes);
|
|
54547
|
+
logger.debug("videoclips: a clip still was minted from the camera’s first frame", {
|
|
54548
|
+
tags: { deviceId },
|
|
54549
|
+
meta: {
|
|
54550
|
+
clipKey,
|
|
54551
|
+
bytes: cut.bytes.byteLength,
|
|
54552
|
+
slotMs: frame.slotMs
|
|
54553
|
+
}
|
|
54554
|
+
});
|
|
54555
|
+
return {
|
|
54556
|
+
ok: true,
|
|
54557
|
+
bytes: cut.bytes
|
|
54558
|
+
};
|
|
54559
|
+
};
|
|
54560
|
+
/**
|
|
54561
|
+
* The cut itself, over bytes already on this disk. Touches no camera.
|
|
54562
|
+
*
|
|
54563
|
+
* `measuredMs` is the span the fetch really delivered when one has just run;
|
|
54564
|
+
* `null` falls back to the catalog row, which is the number the operator was
|
|
54565
|
+
* already shown. Zero is refused rather than seeked to (D393/D382).
|
|
54566
|
+
*/
|
|
54567
|
+
const cutHeldStill = async (deviceId, clipKey, path, measuredMs) => {
|
|
54016
54568
|
const row = rowsByKey.get(rowKey(deviceId, clipKey));
|
|
54017
|
-
const durationMs =
|
|
54569
|
+
const durationMs = measuredMs ?? (row === void 0 ? 0 : row.endMs - row.startMs);
|
|
54018
54570
|
if (durationMs <= 0) return refuseStill("no-keyframe", "this clip has no length to take a midpoint of — nothing measured it and its catalog row spans nothing");
|
|
54019
54571
|
const cut = await cutClipStill({
|
|
54020
|
-
path
|
|
54572
|
+
path,
|
|
54021
54573
|
durationMs
|
|
54022
54574
|
}, {
|
|
54023
54575
|
logger,
|
|
@@ -54032,7 +54584,7 @@ function createClipService(deps) {
|
|
|
54032
54584
|
clipKey,
|
|
54033
54585
|
bytes: cut.bytes.byteLength,
|
|
54034
54586
|
durationMs,
|
|
54035
|
-
measured:
|
|
54587
|
+
measured: measuredMs !== null
|
|
54036
54588
|
}
|
|
54037
54589
|
});
|
|
54038
54590
|
return {
|