@camstack/addon-provider-reolink 1.2.118 → 1.2.120

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 CHANGED
@@ -5371,6 +5371,86 @@ var ZodIssueCode = {
5371
5371
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
5372
5372
  var ZodFirstPartyTypeKind;
5373
5373
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5374
+ //#endregion
5375
+ //#region ../types/dist/sleep-BnujYGPe.mjs
5376
+ /**
5377
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
5378
+ * window to float samples (D455).
5379
+ *
5380
+ * ## Why a format at all
5381
+ *
5382
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
5383
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
5384
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
5385
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
5386
+ * the plane carried four times the source. The plane crosses hub-main twice on
5387
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
5388
+ *
5389
+ * So the plane carries the source BYTES too, and whoever needs floats expands
5390
+ * them where it needs them. That is the same argument D450 made for the rate,
5391
+ * one step further along the same wire.
5392
+ *
5393
+ * ## Why the expansion lives here
5394
+ *
5395
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
5396
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
5397
+ * `AudioChunkPlane` expands per subscription) and
5398
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
5399
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
5400
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
5401
+ * into their own dist (`self-contained` externals), so this travels with a
5402
+ * `camstack deploy` and needs no published server.
5403
+ *
5404
+ * A second μ-law table anywhere else is the defect this module exists to
5405
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
5406
+ * direction for the WebRTC egress — a different transform, not a copy.)
5407
+ *
5408
+ * ## Absent means f32le
5409
+ *
5410
+ * `format` is optional on the wire and its absence means `f32le` — today's
5411
+ * bytes, byte for byte. A peer that never heard of the field is served what it
5412
+ * has always been served, because the broker only emits a coded window to a
5413
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
5414
+ * That is the D448 `rawForward` negotiation, and it is what makes this
5415
+ * deployable one addon at a time across three nodes.
5416
+ */
5417
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
5418
+ var AUDIO_CHUNK_FORMATS = [
5419
+ "f32le",
5420
+ "pcmu",
5421
+ "pcma"
5422
+ ];
5423
+ /**
5424
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
5425
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
5426
+ *
5427
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
5428
+ * it buffers the coded bytes and the plane's consumers expand.
5429
+ */
5430
+ function buildUlawTable() {
5431
+ const table = new Float32Array(256);
5432
+ for (let i = 0; i < 256; i++) {
5433
+ const complemented = ~i & 255;
5434
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
5435
+ const exponent = complemented >> 4 & 7;
5436
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
5437
+ }
5438
+ return table;
5439
+ }
5440
+ /** Build the A-law decode table (ITU-T G.711). */
5441
+ function buildAlawTable() {
5442
+ const table = new Float32Array(256);
5443
+ for (let i = 0; i < 256; i++) {
5444
+ const xored = i ^ 85;
5445
+ const sign = (xored & 128) !== 0 ? 1 : -1;
5446
+ const exponent = xored >> 4 & 7;
5447
+ const mantissa = xored & 15;
5448
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
5449
+ }
5450
+ return table;
5451
+ }
5452
+ buildUlawTable();
5453
+ buildAlawTable();
5374
5454
  Object.fromEntries([
5375
5455
  {
5376
5456
  id: "overview",
@@ -6663,11 +6743,20 @@ var SubscribeFramesResultSchema = object({
6663
6743
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
6664
6744
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
6665
6745
  */
6746
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
6666
6747
  var DecodedAudioChunkSchema = object({
6667
6748
  data: _instanceof(Uint8Array),
6668
6749
  sampleRate: number().int().positive(),
6669
6750
  channels: number().int().positive(),
6670
- timestamp: number()
6751
+ timestamp: number(),
6752
+ /**
6753
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
6754
+ * byte, for any peer that never heard of this field. A coded window
6755
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
6756
+ * subscription that DECLARED it accepts one, so absence can never mean
6757
+ * "coded bytes a consumer will read as floats" (D455).
6758
+ */
6759
+ format: AudioChunkFormatSchema.optional()
6671
6760
  });
6672
6761
  /**
6673
6762
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -6679,7 +6768,18 @@ var DecodedAudioChunkSchema = object({
6679
6768
  var SubscribeAudioChunksInputSchema = object({
6680
6769
  brokerId: string(),
6681
6770
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
6682
- tag: string().optional()
6771
+ tag: string().optional(),
6772
+ /**
6773
+ * Byte formats this subscriber can READ, best first. The broker serves the
6774
+ * chunk's own format when it is in this list and expands to `f32le`
6775
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
6776
+ *
6777
+ * Absent (or without the source format) means `f32le` — the behaviour every
6778
+ * subscriber had before D455, unchanged. This is the negotiation half of
6779
+ * the source-bytes lever: it is what lets the broker and its consumers
6780
+ * deploy one at a time across three nodes.
6781
+ */
6782
+ accept: array(AudioChunkFormatSchema).readonly().optional()
6683
6783
  });
6684
6784
  /** Result of `stream-broker.subscribeAudioChunks`. */
6685
6785
  var SubscribeAudioChunksResultSchema = object({
@@ -11211,6 +11311,51 @@ var AudioAnalysisSettingsSchema = object({
11211
11311
  minConfidence: number().min(0).max(1).default(.3),
11212
11312
  allowedClasses: array(string()).default([])
11213
11313
  });
11314
+ /**
11315
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
11316
+ *
11317
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
11318
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
11319
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
11320
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
11321
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
11322
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
11323
+ * way to the one expansion that feeds the model.
11324
+ *
11325
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
11326
+ * window, the per-device node assignment, the settings read) and therefore
11327
+ * still owns the attach/detach pair. It no longer owns the bytes.
11328
+ */
11329
+ var AudioAttachDeviceInputSchema = object({
11330
+ deviceId: number(),
11331
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
11332
+ brokerId: string(),
11333
+ /**
11334
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
11335
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
11336
+ * the orchestrator's poller pinned them before the move.
11337
+ */
11338
+ ingestNodeId: string(),
11339
+ /**
11340
+ * Resolved once by the orchestrator at attach time, exactly as it was read
11341
+ * once per subscription before D461. The analyzer does NOT re-resolve per
11342
+ * window: a settings change re-attaches, which is what always happened.
11343
+ */
11344
+ settings: AudioAnalysisSettingsSchema
11345
+ });
11346
+ var AudioAttachDeviceResultSchema = object({
11347
+ /** False only when the analyzer is shutting down and refused to attach. */
11348
+ attached: boolean(),
11349
+ /**
11350
+ * True when the attachment replaced a live one for the same device. An
11351
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
11352
+ * double the broker's fanout and neither would know about the other.
11353
+ */
11354
+ replaced: boolean()
11355
+ });
11356
+ var AudioDetachDeviceResultSchema = object({
11357
+ /** False when no attachment existed — detach is idempotent. */
11358
+ detached: boolean() });
11214
11359
  var AudioClassificationResultSchema = object({
11215
11360
  labels: array(AudioClassificationLabelSchema).readonly(),
11216
11361
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -11219,7 +11364,7 @@ var AudioClassificationResultSchema = object({
11219
11364
  method(object({
11220
11365
  chunk: AudioChunkInputSchema,
11221
11366
  settings: AudioAnalysisSettingsSchema
11222
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
11367
+ }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(AudioAttachDeviceInputSchema, AudioAttachDeviceResultSchema, { kind: "mutation" }), method(object({ deviceId: number() }), AudioDetachDeviceResultSchema, { kind: "mutation" }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
11223
11368
  kind: "mutation",
11224
11369
  auth: "admin"
11225
11370
  });
@@ -21197,6 +21342,14 @@ var NativeCropResultSchema = object({
21197
21342
  * set `encodeJpeg: true`; `bytes` is then absent.
21198
21343
  */
21199
21344
  jpeg: string().optional(),
21345
+ /**
21346
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
21347
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
21348
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
21349
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
21350
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
21351
+ */
21352
+ jpegBytes: _instanceof(Uint8Array).optional(),
21200
21353
  width: number().int().positive(),
21201
21354
  height: number().int().positive(),
21202
21355
  /**
@@ -21263,7 +21416,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
21263
21416
  })]);
21264
21417
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
21265
21418
  var ParkedTrackFrameSchema = object({
21266
- jpeg: string(),
21419
+ /**
21420
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
21421
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
21422
+ * Exactly one of the two is present.
21423
+ */
21424
+ jpeg: string().optional(),
21425
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
21426
+ jpegBytes: _instanceof(Uint8Array).optional(),
21267
21427
  width: number().int().positive(),
21268
21428
  height: number().int().positive(),
21269
21429
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21850,6 +22010,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21850
22010
  bbox: NativeCropBboxSchema,
21851
22011
  maxWidth: number().int().positive().optional(),
21852
22012
  /**
22013
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
22014
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
22015
+ * wire — never assume consent: a pre-D462 caller parses the field as
22016
+ * base64 and bytes would decode to garbage rather than fail.
22017
+ */
22018
+ acceptJpegBytes: boolean().optional(),
22019
+ /**
21853
22020
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21854
22021
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21855
22022
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21917,7 +22084,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21917
22084
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21918
22085
  deviceId: number(),
21919
22086
  trackId: string(),
21920
- kind: ParkedFrameKindSchema
22087
+ kind: ParkedFrameKindSchema,
22088
+ /**
22089
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
22090
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
22091
+ * wire — never assume consent: a pre-D462 caller parses the field as
22092
+ * base64 and bytes would decode to garbage rather than fail.
22093
+ */
22094
+ acceptJpegBytes: boolean().optional()
21921
22095
  }), ParkedTrackFrameSchema.nullable()), method(object({
21922
22096
  deviceId: number(),
21923
22097
  trackId: string()
@@ -36139,12 +36313,24 @@ Object.freeze({
36139
36313
  addonId: null,
36140
36314
  access: "create"
36141
36315
  },
36316
+ "audioAnalyzer.attachDevice": {
36317
+ capName: "audio-analyzer",
36318
+ capScope: "system",
36319
+ addonId: null,
36320
+ access: "create"
36321
+ },
36142
36322
  "audioAnalyzer.classify": {
36143
36323
  capName: "audio-analyzer",
36144
36324
  capScope: "system",
36145
36325
  addonId: null,
36146
36326
  access: "view"
36147
36327
  },
36328
+ "audioAnalyzer.detachDevice": {
36329
+ capName: "audio-analyzer",
36330
+ capScope: "system",
36331
+ addonId: null,
36332
+ access: "create"
36333
+ },
36148
36334
  "audioAnalyzer.dispose": {
36149
36335
  capName: "audio-analyzer",
36150
36336
  capScope: "system",
@@ -41988,11 +42174,21 @@ Object.freeze({
41988
42174
  form: "single",
41989
42175
  optional: false
41990
42176
  }],
42177
+ "audioAnalyzer.attachDevice": [{
42178
+ name: "deviceId",
42179
+ form: "single",
42180
+ optional: false
42181
+ }],
41991
42182
  "audioAnalyzer.classify": [{
41992
42183
  name: "deviceId",
41993
42184
  form: "single",
41994
42185
  optional: true
41995
42186
  }],
42187
+ "audioAnalyzer.detachDevice": [{
42188
+ name: "deviceId",
42189
+ form: "single",
42190
+ optional: false
42191
+ }],
41996
42192
  "audioMetrics.getCurrentSnapshot": [{
41997
42193
  name: "deviceId",
41998
42194
  form: "single",
@@ -43844,6 +44040,52 @@ Object.freeze({
43844
44040
  "network-access": "ingress",
43845
44041
  "smtp-provider": "email"
43846
44042
  });
44043
+ var G711_SCALE_CORRECTION_DB = {
44044
+ PCMU: 20 * Math.log10(4),
44045
+ PCMA: 20 * Math.log10(8)
44046
+ };
44047
+ /**
44048
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
44049
+ * same intent on the ITU-T scale (D460).
44050
+ *
44051
+ * ## When this applies, and when it is the wrong thing to reach for
44052
+ *
44053
+ * An absolute-dBFS number in this repo is one of two things, and only one of
44054
+ * them converts:
44055
+ *
44056
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
44057
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
44058
+ * after. The defect was never in the number; it was that 19 of this hub's
44059
+ * 25 cameras did not obey it. Converting such a number takes something
44060
+ * correct and makes it wrong, in order to preserve a bug.
44061
+ * - **A measurement taken through the old decoder** — a value someone read
44062
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
44063
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
44064
+ * louder. That is what this function is for.
44065
+ *
44066
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
44067
+ * and it cannot be answered from the number. It is answered by the comment the
44068
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
44069
+ * mandatory.
44070
+ *
44071
+ * ## Why a function and not a typed-in number
44072
+ *
44073
+ * `-55 + 12.04` written into a source file is, six months later, completely
44074
+ * indistinguishable from a threshold somebody simply preferred. Calling this
44075
+ * keeps the derivation, the law, and the original measurement all visible at
44076
+ * the call site, so a future reader can disagree with the *premise* instead of
44077
+ * having to reverse-engineer the sum.
44078
+ *
44079
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
44080
+ * it is declared. It must never be applied to a live sample or a stored
44081
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
44082
+ * adjusting numbers the decoder already got right is the original defect with
44083
+ * an extra place to argue with (D459).
44084
+ */
44085
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
44086
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
44087
+ }
44088
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
43847
44089
  /** Schema defaults — an untouched sub-field must author exactly these. */
43848
44090
  var NC_AUDIO_DEFAULTS = {
43849
44091
  hitPercent: 60,
package/dist/addon.mjs CHANGED
@@ -5366,6 +5366,86 @@ var ZodIssueCode = {
5366
5366
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
5367
5367
  var ZodFirstPartyTypeKind;
5368
5368
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5369
+ //#endregion
5370
+ //#region ../types/dist/sleep-BnujYGPe.mjs
5371
+ /**
5372
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
5373
+ * window to float samples (D455).
5374
+ *
5375
+ * ## Why a format at all
5376
+ *
5377
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
5378
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
5379
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
5380
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
5381
+ * the plane carried four times the source. The plane crosses hub-main twice on
5382
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
5383
+ *
5384
+ * So the plane carries the source BYTES too, and whoever needs floats expands
5385
+ * them where it needs them. That is the same argument D450 made for the rate,
5386
+ * one step further along the same wire.
5387
+ *
5388
+ * ## Why the expansion lives here
5389
+ *
5390
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
5391
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
5392
+ * `AudioChunkPlane` expands per subscription) and
5393
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
5394
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
5395
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
5396
+ * into their own dist (`self-contained` externals), so this travels with a
5397
+ * `camstack deploy` and needs no published server.
5398
+ *
5399
+ * A second μ-law table anywhere else is the defect this module exists to
5400
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
5401
+ * direction for the WebRTC egress — a different transform, not a copy.)
5402
+ *
5403
+ * ## Absent means f32le
5404
+ *
5405
+ * `format` is optional on the wire and its absence means `f32le` — today's
5406
+ * bytes, byte for byte. A peer that never heard of the field is served what it
5407
+ * has always been served, because the broker only emits a coded window to a
5408
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
5409
+ * That is the D448 `rawForward` negotiation, and it is what makes this
5410
+ * deployable one addon at a time across three nodes.
5411
+ */
5412
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
5413
+ var AUDIO_CHUNK_FORMATS = [
5414
+ "f32le",
5415
+ "pcmu",
5416
+ "pcma"
5417
+ ];
5418
+ /**
5419
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
5420
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
5421
+ *
5422
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
5423
+ * it buffers the coded bytes and the plane's consumers expand.
5424
+ */
5425
+ function buildUlawTable() {
5426
+ const table = new Float32Array(256);
5427
+ for (let i = 0; i < 256; i++) {
5428
+ const complemented = ~i & 255;
5429
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
5430
+ const exponent = complemented >> 4 & 7;
5431
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
5432
+ }
5433
+ return table;
5434
+ }
5435
+ /** Build the A-law decode table (ITU-T G.711). */
5436
+ function buildAlawTable() {
5437
+ const table = new Float32Array(256);
5438
+ for (let i = 0; i < 256; i++) {
5439
+ const xored = i ^ 85;
5440
+ const sign = (xored & 128) !== 0 ? 1 : -1;
5441
+ const exponent = xored >> 4 & 7;
5442
+ const mantissa = xored & 15;
5443
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
5444
+ }
5445
+ return table;
5446
+ }
5447
+ buildUlawTable();
5448
+ buildAlawTable();
5369
5449
  Object.fromEntries([
5370
5450
  {
5371
5451
  id: "overview",
@@ -6658,11 +6738,20 @@ var SubscribeFramesResultSchema = object({
6658
6738
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
6659
6739
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
6660
6740
  */
6741
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
6661
6742
  var DecodedAudioChunkSchema = object({
6662
6743
  data: _instanceof(Uint8Array),
6663
6744
  sampleRate: number().int().positive(),
6664
6745
  channels: number().int().positive(),
6665
- timestamp: number()
6746
+ timestamp: number(),
6747
+ /**
6748
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
6749
+ * byte, for any peer that never heard of this field. A coded window
6750
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
6751
+ * subscription that DECLARED it accepts one, so absence can never mean
6752
+ * "coded bytes a consumer will read as floats" (D455).
6753
+ */
6754
+ format: AudioChunkFormatSchema.optional()
6666
6755
  });
6667
6756
  /**
6668
6757
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -6674,7 +6763,18 @@ var DecodedAudioChunkSchema = object({
6674
6763
  var SubscribeAudioChunksInputSchema = object({
6675
6764
  brokerId: string(),
6676
6765
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
6677
- tag: string().optional()
6766
+ tag: string().optional(),
6767
+ /**
6768
+ * Byte formats this subscriber can READ, best first. The broker serves the
6769
+ * chunk's own format when it is in this list and expands to `f32le`
6770
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
6771
+ *
6772
+ * Absent (or without the source format) means `f32le` — the behaviour every
6773
+ * subscriber had before D455, unchanged. This is the negotiation half of
6774
+ * the source-bytes lever: it is what lets the broker and its consumers
6775
+ * deploy one at a time across three nodes.
6776
+ */
6777
+ accept: array(AudioChunkFormatSchema).readonly().optional()
6678
6778
  });
6679
6779
  /** Result of `stream-broker.subscribeAudioChunks`. */
6680
6780
  var SubscribeAudioChunksResultSchema = object({
@@ -11206,6 +11306,51 @@ var AudioAnalysisSettingsSchema = object({
11206
11306
  minConfidence: number().min(0).max(1).default(.3),
11207
11307
  allowedClasses: array(string()).default([])
11208
11308
  });
11309
+ /**
11310
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
11311
+ *
11312
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
11313
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
11314
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
11315
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
11316
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
11317
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
11318
+ * way to the one expansion that feeds the model.
11319
+ *
11320
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
11321
+ * window, the per-device node assignment, the settings read) and therefore
11322
+ * still owns the attach/detach pair. It no longer owns the bytes.
11323
+ */
11324
+ var AudioAttachDeviceInputSchema = object({
11325
+ deviceId: number(),
11326
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
11327
+ brokerId: string(),
11328
+ /**
11329
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
11330
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
11331
+ * the orchestrator's poller pinned them before the move.
11332
+ */
11333
+ ingestNodeId: string(),
11334
+ /**
11335
+ * Resolved once by the orchestrator at attach time, exactly as it was read
11336
+ * once per subscription before D461. The analyzer does NOT re-resolve per
11337
+ * window: a settings change re-attaches, which is what always happened.
11338
+ */
11339
+ settings: AudioAnalysisSettingsSchema
11340
+ });
11341
+ var AudioAttachDeviceResultSchema = object({
11342
+ /** False only when the analyzer is shutting down and refused to attach. */
11343
+ attached: boolean(),
11344
+ /**
11345
+ * True when the attachment replaced a live one for the same device. An
11346
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
11347
+ * double the broker's fanout and neither would know about the other.
11348
+ */
11349
+ replaced: boolean()
11350
+ });
11351
+ var AudioDetachDeviceResultSchema = object({
11352
+ /** False when no attachment existed — detach is idempotent. */
11353
+ detached: boolean() });
11209
11354
  var AudioClassificationResultSchema = object({
11210
11355
  labels: array(AudioClassificationLabelSchema).readonly(),
11211
11356
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -11214,7 +11359,7 @@ var AudioClassificationResultSchema = object({
11214
11359
  method(object({
11215
11360
  chunk: AudioChunkInputSchema,
11216
11361
  settings: AudioAnalysisSettingsSchema
11217
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
11362
+ }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(AudioAttachDeviceInputSchema, AudioAttachDeviceResultSchema, { kind: "mutation" }), method(object({ deviceId: number() }), AudioDetachDeviceResultSchema, { kind: "mutation" }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
11218
11363
  kind: "mutation",
11219
11364
  auth: "admin"
11220
11365
  });
@@ -21192,6 +21337,14 @@ var NativeCropResultSchema = object({
21192
21337
  * set `encodeJpeg: true`; `bytes` is then absent.
21193
21338
  */
21194
21339
  jpeg: string().optional(),
21340
+ /**
21341
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
21342
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
21343
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
21344
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
21345
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
21346
+ */
21347
+ jpegBytes: _instanceof(Uint8Array).optional(),
21195
21348
  width: number().int().positive(),
21196
21349
  height: number().int().positive(),
21197
21350
  /**
@@ -21258,7 +21411,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
21258
21411
  })]);
21259
21412
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
21260
21413
  var ParkedTrackFrameSchema = object({
21261
- jpeg: string(),
21414
+ /**
21415
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
21416
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
21417
+ * Exactly one of the two is present.
21418
+ */
21419
+ jpeg: string().optional(),
21420
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
21421
+ jpegBytes: _instanceof(Uint8Array).optional(),
21262
21422
  width: number().int().positive(),
21263
21423
  height: number().int().positive(),
21264
21424
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21845,6 +22005,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21845
22005
  bbox: NativeCropBboxSchema,
21846
22006
  maxWidth: number().int().positive().optional(),
21847
22007
  /**
22008
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
22009
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
22010
+ * wire — never assume consent: a pre-D462 caller parses the field as
22011
+ * base64 and bytes would decode to garbage rather than fail.
22012
+ */
22013
+ acceptJpegBytes: boolean().optional(),
22014
+ /**
21848
22015
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21849
22016
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21850
22017
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21912,7 +22079,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21912
22079
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21913
22080
  deviceId: number(),
21914
22081
  trackId: string(),
21915
- kind: ParkedFrameKindSchema
22082
+ kind: ParkedFrameKindSchema,
22083
+ /**
22084
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
22085
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
22086
+ * wire — never assume consent: a pre-D462 caller parses the field as
22087
+ * base64 and bytes would decode to garbage rather than fail.
22088
+ */
22089
+ acceptJpegBytes: boolean().optional()
21916
22090
  }), ParkedTrackFrameSchema.nullable()), method(object({
21917
22091
  deviceId: number(),
21918
22092
  trackId: string()
@@ -36134,12 +36308,24 @@ Object.freeze({
36134
36308
  addonId: null,
36135
36309
  access: "create"
36136
36310
  },
36311
+ "audioAnalyzer.attachDevice": {
36312
+ capName: "audio-analyzer",
36313
+ capScope: "system",
36314
+ addonId: null,
36315
+ access: "create"
36316
+ },
36137
36317
  "audioAnalyzer.classify": {
36138
36318
  capName: "audio-analyzer",
36139
36319
  capScope: "system",
36140
36320
  addonId: null,
36141
36321
  access: "view"
36142
36322
  },
36323
+ "audioAnalyzer.detachDevice": {
36324
+ capName: "audio-analyzer",
36325
+ capScope: "system",
36326
+ addonId: null,
36327
+ access: "create"
36328
+ },
36143
36329
  "audioAnalyzer.dispose": {
36144
36330
  capName: "audio-analyzer",
36145
36331
  capScope: "system",
@@ -41983,11 +42169,21 @@ Object.freeze({
41983
42169
  form: "single",
41984
42170
  optional: false
41985
42171
  }],
42172
+ "audioAnalyzer.attachDevice": [{
42173
+ name: "deviceId",
42174
+ form: "single",
42175
+ optional: false
42176
+ }],
41986
42177
  "audioAnalyzer.classify": [{
41987
42178
  name: "deviceId",
41988
42179
  form: "single",
41989
42180
  optional: true
41990
42181
  }],
42182
+ "audioAnalyzer.detachDevice": [{
42183
+ name: "deviceId",
42184
+ form: "single",
42185
+ optional: false
42186
+ }],
41991
42187
  "audioMetrics.getCurrentSnapshot": [{
41992
42188
  name: "deviceId",
41993
42189
  form: "single",
@@ -43839,6 +44035,52 @@ Object.freeze({
43839
44035
  "network-access": "ingress",
43840
44036
  "smtp-provider": "email"
43841
44037
  });
44038
+ var G711_SCALE_CORRECTION_DB = {
44039
+ PCMU: 20 * Math.log10(4),
44040
+ PCMA: 20 * Math.log10(8)
44041
+ };
44042
+ /**
44043
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
44044
+ * same intent on the ITU-T scale (D460).
44045
+ *
44046
+ * ## When this applies, and when it is the wrong thing to reach for
44047
+ *
44048
+ * An absolute-dBFS number in this repo is one of two things, and only one of
44049
+ * them converts:
44050
+ *
44051
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
44052
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
44053
+ * after. The defect was never in the number; it was that 19 of this hub's
44054
+ * 25 cameras did not obey it. Converting such a number takes something
44055
+ * correct and makes it wrong, in order to preserve a bug.
44056
+ * - **A measurement taken through the old decoder** — a value someone read
44057
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
44058
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
44059
+ * louder. That is what this function is for.
44060
+ *
44061
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
44062
+ * and it cannot be answered from the number. It is answered by the comment the
44063
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
44064
+ * mandatory.
44065
+ *
44066
+ * ## Why a function and not a typed-in number
44067
+ *
44068
+ * `-55 + 12.04` written into a source file is, six months later, completely
44069
+ * indistinguishable from a threshold somebody simply preferred. Calling this
44070
+ * keeps the derivation, the law, and the original measurement all visible at
44071
+ * the call site, so a future reader can disagree with the *premise* instead of
44072
+ * having to reverse-engineer the sum.
44073
+ *
44074
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
44075
+ * it is declared. It must never be applied to a live sample or a stored
44076
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
44077
+ * adjusting numbers the decoder already got right is the original defect with
44078
+ * an extra place to argue with (D459).
44079
+ */
44080
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
44081
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
44082
+ }
44083
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
43842
44084
  /** Schema defaults — an untouched sub-field must author exactly these. */
43843
44085
  var NC_AUDIO_DEFAULTS = {
43844
44086
  hitPercent: 60,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-reolink",
3
- "version": "1.2.118",
3
+ "version": "1.2.120",
4
4
  "description": "Reolink camera device provider addon for CamStack — native Baichuan protocol",
5
5
  "keywords": [
6
6
  "camstack",