@camstack/addon-provider-hikvision 1.2.103 → 1.2.105

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
@@ -5352,6 +5352,86 @@ var ZodIssueCode = {
5352
5352
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
5353
5353
  var ZodFirstPartyTypeKind;
5354
5354
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5355
+ //#endregion
5356
+ //#region ../types/dist/sleep-BnujYGPe.mjs
5357
+ /**
5358
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
5359
+ * window to float samples (D455).
5360
+ *
5361
+ * ## Why a format at all
5362
+ *
5363
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
5364
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
5365
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
5366
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
5367
+ * the plane carried four times the source. The plane crosses hub-main twice on
5368
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
5369
+ *
5370
+ * So the plane carries the source BYTES too, and whoever needs floats expands
5371
+ * them where it needs them. That is the same argument D450 made for the rate,
5372
+ * one step further along the same wire.
5373
+ *
5374
+ * ## Why the expansion lives here
5375
+ *
5376
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
5377
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
5378
+ * `AudioChunkPlane` expands per subscription) and
5379
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
5380
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
5381
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
5382
+ * into their own dist (`self-contained` externals), so this travels with a
5383
+ * `camstack deploy` and needs no published server.
5384
+ *
5385
+ * A second μ-law table anywhere else is the defect this module exists to
5386
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
5387
+ * direction for the WebRTC egress — a different transform, not a copy.)
5388
+ *
5389
+ * ## Absent means f32le
5390
+ *
5391
+ * `format` is optional on the wire and its absence means `f32le` — today's
5392
+ * bytes, byte for byte. A peer that never heard of the field is served what it
5393
+ * has always been served, because the broker only emits a coded window to a
5394
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
5395
+ * That is the D448 `rawForward` negotiation, and it is what makes this
5396
+ * deployable one addon at a time across three nodes.
5397
+ */
5398
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
5399
+ var AUDIO_CHUNK_FORMATS = [
5400
+ "f32le",
5401
+ "pcmu",
5402
+ "pcma"
5403
+ ];
5404
+ /**
5405
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
5406
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
5407
+ *
5408
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
5409
+ * it buffers the coded bytes and the plane's consumers expand.
5410
+ */
5411
+ function buildUlawTable() {
5412
+ const table = new Float32Array(256);
5413
+ for (let i = 0; i < 256; i++) {
5414
+ const complemented = ~i & 255;
5415
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
5416
+ const exponent = complemented >> 4 & 7;
5417
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
5418
+ }
5419
+ return table;
5420
+ }
5421
+ /** Build the A-law decode table (ITU-T G.711). */
5422
+ function buildAlawTable() {
5423
+ const table = new Float32Array(256);
5424
+ for (let i = 0; i < 256; i++) {
5425
+ const xored = i ^ 85;
5426
+ const sign = (xored & 128) !== 0 ? 1 : -1;
5427
+ const exponent = xored >> 4 & 7;
5428
+ const mantissa = xored & 15;
5429
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
5430
+ }
5431
+ return table;
5432
+ }
5433
+ buildUlawTable();
5434
+ buildAlawTable();
5355
5435
  Object.fromEntries([
5356
5436
  {
5357
5437
  id: "overview",
@@ -6644,11 +6724,20 @@ var SubscribeFramesResultSchema = object({
6644
6724
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
6645
6725
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
6646
6726
  */
6727
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
6647
6728
  var DecodedAudioChunkSchema = object({
6648
6729
  data: _instanceof(Uint8Array),
6649
6730
  sampleRate: number().int().positive(),
6650
6731
  channels: number().int().positive(),
6651
- timestamp: number()
6732
+ timestamp: number(),
6733
+ /**
6734
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
6735
+ * byte, for any peer that never heard of this field. A coded window
6736
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
6737
+ * subscription that DECLARED it accepts one, so absence can never mean
6738
+ * "coded bytes a consumer will read as floats" (D455).
6739
+ */
6740
+ format: AudioChunkFormatSchema.optional()
6652
6741
  });
6653
6742
  /**
6654
6743
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -6660,7 +6749,18 @@ var DecodedAudioChunkSchema = object({
6660
6749
  var SubscribeAudioChunksInputSchema = object({
6661
6750
  brokerId: string(),
6662
6751
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
6663
- tag: string().optional()
6752
+ tag: string().optional(),
6753
+ /**
6754
+ * Byte formats this subscriber can READ, best first. The broker serves the
6755
+ * chunk's own format when it is in this list and expands to `f32le`
6756
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
6757
+ *
6758
+ * Absent (or without the source format) means `f32le` — the behaviour every
6759
+ * subscriber had before D455, unchanged. This is the negotiation half of
6760
+ * the source-bytes lever: it is what lets the broker and its consumers
6761
+ * deploy one at a time across three nodes.
6762
+ */
6763
+ accept: array(AudioChunkFormatSchema).readonly().optional()
6664
6764
  });
6665
6765
  /** Result of `stream-broker.subscribeAudioChunks`. */
6666
6766
  var SubscribeAudioChunksResultSchema = object({
@@ -10917,6 +11017,51 @@ var AudioAnalysisSettingsSchema = object({
10917
11017
  minConfidence: number().min(0).max(1).default(.3),
10918
11018
  allowedClasses: array(string()).default([])
10919
11019
  });
11020
+ /**
11021
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
11022
+ *
11023
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
11024
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
11025
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
11026
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
11027
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
11028
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
11029
+ * way to the one expansion that feeds the model.
11030
+ *
11031
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
11032
+ * window, the per-device node assignment, the settings read) and therefore
11033
+ * still owns the attach/detach pair. It no longer owns the bytes.
11034
+ */
11035
+ var AudioAttachDeviceInputSchema = object({
11036
+ deviceId: number(),
11037
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
11038
+ brokerId: string(),
11039
+ /**
11040
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
11041
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
11042
+ * the orchestrator's poller pinned them before the move.
11043
+ */
11044
+ ingestNodeId: string(),
11045
+ /**
11046
+ * Resolved once by the orchestrator at attach time, exactly as it was read
11047
+ * once per subscription before D461. The analyzer does NOT re-resolve per
11048
+ * window: a settings change re-attaches, which is what always happened.
11049
+ */
11050
+ settings: AudioAnalysisSettingsSchema
11051
+ });
11052
+ var AudioAttachDeviceResultSchema = object({
11053
+ /** False only when the analyzer is shutting down and refused to attach. */
11054
+ attached: boolean(),
11055
+ /**
11056
+ * True when the attachment replaced a live one for the same device. An
11057
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
11058
+ * double the broker's fanout and neither would know about the other.
11059
+ */
11060
+ replaced: boolean()
11061
+ });
11062
+ var AudioDetachDeviceResultSchema = object({
11063
+ /** False when no attachment existed — detach is idempotent. */
11064
+ detached: boolean() });
10920
11065
  var AudioClassificationResultSchema = object({
10921
11066
  labels: array(AudioClassificationLabelSchema).readonly(),
10922
11067
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -10925,7 +11070,7 @@ var AudioClassificationResultSchema = object({
10925
11070
  method(object({
10926
11071
  chunk: AudioChunkInputSchema,
10927
11072
  settings: AudioAnalysisSettingsSchema
10928
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
11073
+ }), 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() }), {
10929
11074
  kind: "mutation",
10930
11075
  auth: "admin"
10931
11076
  });
@@ -20860,6 +21005,14 @@ var NativeCropResultSchema = object({
20860
21005
  * set `encodeJpeg: true`; `bytes` is then absent.
20861
21006
  */
20862
21007
  jpeg: string().optional(),
21008
+ /**
21009
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
21010
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
21011
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
21012
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
21013
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
21014
+ */
21015
+ jpegBytes: _instanceof(Uint8Array).optional(),
20863
21016
  width: number().int().positive(),
20864
21017
  height: number().int().positive(),
20865
21018
  /**
@@ -20926,7 +21079,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
20926
21079
  })]);
20927
21080
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
20928
21081
  var ParkedTrackFrameSchema = object({
20929
- jpeg: string(),
21082
+ /**
21083
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
21084
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
21085
+ * Exactly one of the two is present.
21086
+ */
21087
+ jpeg: string().optional(),
21088
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
21089
+ jpegBytes: _instanceof(Uint8Array).optional(),
20930
21090
  width: number().int().positive(),
20931
21091
  height: number().int().positive(),
20932
21092
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21513,6 +21673,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21513
21673
  bbox: NativeCropBboxSchema,
21514
21674
  maxWidth: number().int().positive().optional(),
21515
21675
  /**
21676
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21677
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21678
+ * wire — never assume consent: a pre-D462 caller parses the field as
21679
+ * base64 and bytes would decode to garbage rather than fail.
21680
+ */
21681
+ acceptJpegBytes: boolean().optional(),
21682
+ /**
21516
21683
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21517
21684
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21518
21685
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21580,7 +21747,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21580
21747
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21581
21748
  deviceId: number(),
21582
21749
  trackId: string(),
21583
- kind: ParkedFrameKindSchema
21750
+ kind: ParkedFrameKindSchema,
21751
+ /**
21752
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21753
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21754
+ * wire — never assume consent: a pre-D462 caller parses the field as
21755
+ * base64 and bytes would decode to garbage rather than fail.
21756
+ */
21757
+ acceptJpegBytes: boolean().optional()
21584
21758
  }), ParkedTrackFrameSchema.nullable()), method(object({
21585
21759
  deviceId: number(),
21586
21760
  trackId: string()
@@ -35883,12 +36057,24 @@ Object.freeze({
35883
36057
  addonId: null,
35884
36058
  access: "create"
35885
36059
  },
36060
+ "audioAnalyzer.attachDevice": {
36061
+ capName: "audio-analyzer",
36062
+ capScope: "system",
36063
+ addonId: null,
36064
+ access: "create"
36065
+ },
35886
36066
  "audioAnalyzer.classify": {
35887
36067
  capName: "audio-analyzer",
35888
36068
  capScope: "system",
35889
36069
  addonId: null,
35890
36070
  access: "view"
35891
36071
  },
36072
+ "audioAnalyzer.detachDevice": {
36073
+ capName: "audio-analyzer",
36074
+ capScope: "system",
36075
+ addonId: null,
36076
+ access: "create"
36077
+ },
35892
36078
  "audioAnalyzer.dispose": {
35893
36079
  capName: "audio-analyzer",
35894
36080
  capScope: "system",
@@ -41732,11 +41918,21 @@ Object.freeze({
41732
41918
  form: "single",
41733
41919
  optional: false
41734
41920
  }],
41921
+ "audioAnalyzer.attachDevice": [{
41922
+ name: "deviceId",
41923
+ form: "single",
41924
+ optional: false
41925
+ }],
41735
41926
  "audioAnalyzer.classify": [{
41736
41927
  name: "deviceId",
41737
41928
  form: "single",
41738
41929
  optional: true
41739
41930
  }],
41931
+ "audioAnalyzer.detachDevice": [{
41932
+ name: "deviceId",
41933
+ form: "single",
41934
+ optional: false
41935
+ }],
41740
41936
  "audioMetrics.getCurrentSnapshot": [{
41741
41937
  name: "deviceId",
41742
41938
  form: "single",
@@ -43588,6 +43784,52 @@ Object.freeze({
43588
43784
  "network-access": "ingress",
43589
43785
  "smtp-provider": "email"
43590
43786
  });
43787
+ var G711_SCALE_CORRECTION_DB = {
43788
+ PCMU: 20 * Math.log10(4),
43789
+ PCMA: 20 * Math.log10(8)
43790
+ };
43791
+ /**
43792
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
43793
+ * same intent on the ITU-T scale (D460).
43794
+ *
43795
+ * ## When this applies, and when it is the wrong thing to reach for
43796
+ *
43797
+ * An absolute-dBFS number in this repo is one of two things, and only one of
43798
+ * them converts:
43799
+ *
43800
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
43801
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
43802
+ * after. The defect was never in the number; it was that 19 of this hub's
43803
+ * 25 cameras did not obey it. Converting such a number takes something
43804
+ * correct and makes it wrong, in order to preserve a bug.
43805
+ * - **A measurement taken through the old decoder** — a value someone read
43806
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
43807
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
43808
+ * louder. That is what this function is for.
43809
+ *
43810
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
43811
+ * and it cannot be answered from the number. It is answered by the comment the
43812
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
43813
+ * mandatory.
43814
+ *
43815
+ * ## Why a function and not a typed-in number
43816
+ *
43817
+ * `-55 + 12.04` written into a source file is, six months later, completely
43818
+ * indistinguishable from a threshold somebody simply preferred. Calling this
43819
+ * keeps the derivation, the law, and the original measurement all visible at
43820
+ * the call site, so a future reader can disagree with the *premise* instead of
43821
+ * having to reverse-engineer the sum.
43822
+ *
43823
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
43824
+ * it is declared. It must never be applied to a live sample or a stored
43825
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
43826
+ * adjusting numbers the decoder already got right is the original defect with
43827
+ * an extra place to argue with (D459).
43828
+ */
43829
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
43830
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
43831
+ }
43832
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
43591
43833
  /** Schema defaults — an untouched sub-field must author exactly these. */
43592
43834
  var NC_AUDIO_DEFAULTS = {
43593
43835
  hitPercent: 60,
package/dist/addon.mjs CHANGED
@@ -5353,6 +5353,86 @@ var ZodIssueCode = {
5353
5353
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
5354
5354
  var ZodFirstPartyTypeKind;
5355
5355
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5356
+ //#endregion
5357
+ //#region ../types/dist/sleep-BnujYGPe.mjs
5358
+ /**
5359
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
5360
+ * window to float samples (D455).
5361
+ *
5362
+ * ## Why a format at all
5363
+ *
5364
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
5365
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
5366
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
5367
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
5368
+ * the plane carried four times the source. The plane crosses hub-main twice on
5369
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
5370
+ *
5371
+ * So the plane carries the source BYTES too, and whoever needs floats expands
5372
+ * them where it needs them. That is the same argument D450 made for the rate,
5373
+ * one step further along the same wire.
5374
+ *
5375
+ * ## Why the expansion lives here
5376
+ *
5377
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
5378
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
5379
+ * `AudioChunkPlane` expands per subscription) and
5380
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
5381
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
5382
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
5383
+ * into their own dist (`self-contained` externals), so this travels with a
5384
+ * `camstack deploy` and needs no published server.
5385
+ *
5386
+ * A second μ-law table anywhere else is the defect this module exists to
5387
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
5388
+ * direction for the WebRTC egress — a different transform, not a copy.)
5389
+ *
5390
+ * ## Absent means f32le
5391
+ *
5392
+ * `format` is optional on the wire and its absence means `f32le` — today's
5393
+ * bytes, byte for byte. A peer that never heard of the field is served what it
5394
+ * has always been served, because the broker only emits a coded window to a
5395
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
5396
+ * That is the D448 `rawForward` negotiation, and it is what makes this
5397
+ * deployable one addon at a time across three nodes.
5398
+ */
5399
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
5400
+ var AUDIO_CHUNK_FORMATS = [
5401
+ "f32le",
5402
+ "pcmu",
5403
+ "pcma"
5404
+ ];
5405
+ /**
5406
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
5407
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
5408
+ *
5409
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
5410
+ * it buffers the coded bytes and the plane's consumers expand.
5411
+ */
5412
+ function buildUlawTable() {
5413
+ const table = new Float32Array(256);
5414
+ for (let i = 0; i < 256; i++) {
5415
+ const complemented = ~i & 255;
5416
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
5417
+ const exponent = complemented >> 4 & 7;
5418
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
5419
+ }
5420
+ return table;
5421
+ }
5422
+ /** Build the A-law decode table (ITU-T G.711). */
5423
+ function buildAlawTable() {
5424
+ const table = new Float32Array(256);
5425
+ for (let i = 0; i < 256; i++) {
5426
+ const xored = i ^ 85;
5427
+ const sign = (xored & 128) !== 0 ? 1 : -1;
5428
+ const exponent = xored >> 4 & 7;
5429
+ const mantissa = xored & 15;
5430
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
5431
+ }
5432
+ return table;
5433
+ }
5434
+ buildUlawTable();
5435
+ buildAlawTable();
5356
5436
  Object.fromEntries([
5357
5437
  {
5358
5438
  id: "overview",
@@ -6645,11 +6725,20 @@ var SubscribeFramesResultSchema = object({
6645
6725
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
6646
6726
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
6647
6727
  */
6728
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
6648
6729
  var DecodedAudioChunkSchema = object({
6649
6730
  data: _instanceof(Uint8Array),
6650
6731
  sampleRate: number().int().positive(),
6651
6732
  channels: number().int().positive(),
6652
- timestamp: number()
6733
+ timestamp: number(),
6734
+ /**
6735
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
6736
+ * byte, for any peer that never heard of this field. A coded window
6737
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
6738
+ * subscription that DECLARED it accepts one, so absence can never mean
6739
+ * "coded bytes a consumer will read as floats" (D455).
6740
+ */
6741
+ format: AudioChunkFormatSchema.optional()
6653
6742
  });
6654
6743
  /**
6655
6744
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -6661,7 +6750,18 @@ var DecodedAudioChunkSchema = object({
6661
6750
  var SubscribeAudioChunksInputSchema = object({
6662
6751
  brokerId: string(),
6663
6752
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
6664
- tag: string().optional()
6753
+ tag: string().optional(),
6754
+ /**
6755
+ * Byte formats this subscriber can READ, best first. The broker serves the
6756
+ * chunk's own format when it is in this list and expands to `f32le`
6757
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
6758
+ *
6759
+ * Absent (or without the source format) means `f32le` — the behaviour every
6760
+ * subscriber had before D455, unchanged. This is the negotiation half of
6761
+ * the source-bytes lever: it is what lets the broker and its consumers
6762
+ * deploy one at a time across three nodes.
6763
+ */
6764
+ accept: array(AudioChunkFormatSchema).readonly().optional()
6665
6765
  });
6666
6766
  /** Result of `stream-broker.subscribeAudioChunks`. */
6667
6767
  var SubscribeAudioChunksResultSchema = object({
@@ -10918,6 +11018,51 @@ var AudioAnalysisSettingsSchema = object({
10918
11018
  minConfidence: number().min(0).max(1).default(.3),
10919
11019
  allowedClasses: array(string()).default([])
10920
11020
  });
11021
+ /**
11022
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
11023
+ *
11024
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
11025
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
11026
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
11027
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
11028
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
11029
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
11030
+ * way to the one expansion that feeds the model.
11031
+ *
11032
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
11033
+ * window, the per-device node assignment, the settings read) and therefore
11034
+ * still owns the attach/detach pair. It no longer owns the bytes.
11035
+ */
11036
+ var AudioAttachDeviceInputSchema = object({
11037
+ deviceId: number(),
11038
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
11039
+ brokerId: string(),
11040
+ /**
11041
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
11042
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
11043
+ * the orchestrator's poller pinned them before the move.
11044
+ */
11045
+ ingestNodeId: string(),
11046
+ /**
11047
+ * Resolved once by the orchestrator at attach time, exactly as it was read
11048
+ * once per subscription before D461. The analyzer does NOT re-resolve per
11049
+ * window: a settings change re-attaches, which is what always happened.
11050
+ */
11051
+ settings: AudioAnalysisSettingsSchema
11052
+ });
11053
+ var AudioAttachDeviceResultSchema = object({
11054
+ /** False only when the analyzer is shutting down and refused to attach. */
11055
+ attached: boolean(),
11056
+ /**
11057
+ * True when the attachment replaced a live one for the same device. An
11058
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
11059
+ * double the broker's fanout and neither would know about the other.
11060
+ */
11061
+ replaced: boolean()
11062
+ });
11063
+ var AudioDetachDeviceResultSchema = object({
11064
+ /** False when no attachment existed — detach is idempotent. */
11065
+ detached: boolean() });
10921
11066
  var AudioClassificationResultSchema = object({
10922
11067
  labels: array(AudioClassificationLabelSchema).readonly(),
10923
11068
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -10926,7 +11071,7 @@ var AudioClassificationResultSchema = object({
10926
11071
  method(object({
10927
11072
  chunk: AudioChunkInputSchema,
10928
11073
  settings: AudioAnalysisSettingsSchema
10929
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
11074
+ }), 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() }), {
10930
11075
  kind: "mutation",
10931
11076
  auth: "admin"
10932
11077
  });
@@ -20861,6 +21006,14 @@ var NativeCropResultSchema = object({
20861
21006
  * set `encodeJpeg: true`; `bytes` is then absent.
20862
21007
  */
20863
21008
  jpeg: string().optional(),
21009
+ /**
21010
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
21011
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
21012
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
21013
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
21014
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
21015
+ */
21016
+ jpegBytes: _instanceof(Uint8Array).optional(),
20864
21017
  width: number().int().positive(),
20865
21018
  height: number().int().positive(),
20866
21019
  /**
@@ -20927,7 +21080,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
20927
21080
  })]);
20928
21081
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
20929
21082
  var ParkedTrackFrameSchema = object({
20930
- jpeg: string(),
21083
+ /**
21084
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
21085
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
21086
+ * Exactly one of the two is present.
21087
+ */
21088
+ jpeg: string().optional(),
21089
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
21090
+ jpegBytes: _instanceof(Uint8Array).optional(),
20931
21091
  width: number().int().positive(),
20932
21092
  height: number().int().positive(),
20933
21093
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21514,6 +21674,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21514
21674
  bbox: NativeCropBboxSchema,
21515
21675
  maxWidth: number().int().positive().optional(),
21516
21676
  /**
21677
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21678
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21679
+ * wire — never assume consent: a pre-D462 caller parses the field as
21680
+ * base64 and bytes would decode to garbage rather than fail.
21681
+ */
21682
+ acceptJpegBytes: boolean().optional(),
21683
+ /**
21517
21684
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21518
21685
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21519
21686
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21581,7 +21748,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21581
21748
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21582
21749
  deviceId: number(),
21583
21750
  trackId: string(),
21584
- kind: ParkedFrameKindSchema
21751
+ kind: ParkedFrameKindSchema,
21752
+ /**
21753
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21754
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21755
+ * wire — never assume consent: a pre-D462 caller parses the field as
21756
+ * base64 and bytes would decode to garbage rather than fail.
21757
+ */
21758
+ acceptJpegBytes: boolean().optional()
21585
21759
  }), ParkedTrackFrameSchema.nullable()), method(object({
21586
21760
  deviceId: number(),
21587
21761
  trackId: string()
@@ -35884,12 +36058,24 @@ Object.freeze({
35884
36058
  addonId: null,
35885
36059
  access: "create"
35886
36060
  },
36061
+ "audioAnalyzer.attachDevice": {
36062
+ capName: "audio-analyzer",
36063
+ capScope: "system",
36064
+ addonId: null,
36065
+ access: "create"
36066
+ },
35887
36067
  "audioAnalyzer.classify": {
35888
36068
  capName: "audio-analyzer",
35889
36069
  capScope: "system",
35890
36070
  addonId: null,
35891
36071
  access: "view"
35892
36072
  },
36073
+ "audioAnalyzer.detachDevice": {
36074
+ capName: "audio-analyzer",
36075
+ capScope: "system",
36076
+ addonId: null,
36077
+ access: "create"
36078
+ },
35893
36079
  "audioAnalyzer.dispose": {
35894
36080
  capName: "audio-analyzer",
35895
36081
  capScope: "system",
@@ -41733,11 +41919,21 @@ Object.freeze({
41733
41919
  form: "single",
41734
41920
  optional: false
41735
41921
  }],
41922
+ "audioAnalyzer.attachDevice": [{
41923
+ name: "deviceId",
41924
+ form: "single",
41925
+ optional: false
41926
+ }],
41736
41927
  "audioAnalyzer.classify": [{
41737
41928
  name: "deviceId",
41738
41929
  form: "single",
41739
41930
  optional: true
41740
41931
  }],
41932
+ "audioAnalyzer.detachDevice": [{
41933
+ name: "deviceId",
41934
+ form: "single",
41935
+ optional: false
41936
+ }],
41741
41937
  "audioMetrics.getCurrentSnapshot": [{
41742
41938
  name: "deviceId",
41743
41939
  form: "single",
@@ -43589,6 +43785,52 @@ Object.freeze({
43589
43785
  "network-access": "ingress",
43590
43786
  "smtp-provider": "email"
43591
43787
  });
43788
+ var G711_SCALE_CORRECTION_DB = {
43789
+ PCMU: 20 * Math.log10(4),
43790
+ PCMA: 20 * Math.log10(8)
43791
+ };
43792
+ /**
43793
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
43794
+ * same intent on the ITU-T scale (D460).
43795
+ *
43796
+ * ## When this applies, and when it is the wrong thing to reach for
43797
+ *
43798
+ * An absolute-dBFS number in this repo is one of two things, and only one of
43799
+ * them converts:
43800
+ *
43801
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
43802
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
43803
+ * after. The defect was never in the number; it was that 19 of this hub's
43804
+ * 25 cameras did not obey it. Converting such a number takes something
43805
+ * correct and makes it wrong, in order to preserve a bug.
43806
+ * - **A measurement taken through the old decoder** — a value someone read
43807
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
43808
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
43809
+ * louder. That is what this function is for.
43810
+ *
43811
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
43812
+ * and it cannot be answered from the number. It is answered by the comment the
43813
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
43814
+ * mandatory.
43815
+ *
43816
+ * ## Why a function and not a typed-in number
43817
+ *
43818
+ * `-55 + 12.04` written into a source file is, six months later, completely
43819
+ * indistinguishable from a threshold somebody simply preferred. Calling this
43820
+ * keeps the derivation, the law, and the original measurement all visible at
43821
+ * the call site, so a future reader can disagree with the *premise* instead of
43822
+ * having to reverse-engineer the sum.
43823
+ *
43824
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
43825
+ * it is declared. It must never be applied to a live sample or a stored
43826
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
43827
+ * adjusting numbers the decoder already got right is the original defect with
43828
+ * an extra place to argue with (D459).
43829
+ */
43830
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
43831
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
43832
+ }
43833
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
43592
43834
  /** Schema defaults — an untouched sub-field must author exactly these. */
43593
43835
  var NC_AUDIO_DEFAULTS = {
43594
43836
  hitPercent: 60,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-hikvision",
3
- "version": "1.2.103",
3
+ "version": "1.2.105",
4
4
  "description": "Hikvision camera device provider addon for CamStack — ISAPI over HTTP(S) with digest auth (snapshot, alarm stream, RTSP discovery)",
5
5
  "keywords": [
6
6
  "camstack",