@camstack/addon-provider-amcrest 0.2.97 → 0.2.99

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({
@@ -10636,6 +10736,51 @@ var AudioAnalysisSettingsSchema = object({
10636
10736
  minConfidence: number().min(0).max(1).default(.3),
10637
10737
  allowedClasses: array(string()).default([])
10638
10738
  });
10739
+ /**
10740
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
10741
+ *
10742
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
10743
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
10744
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
10745
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
10746
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
10747
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
10748
+ * way to the one expansion that feeds the model.
10749
+ *
10750
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
10751
+ * window, the per-device node assignment, the settings read) and therefore
10752
+ * still owns the attach/detach pair. It no longer owns the bytes.
10753
+ */
10754
+ var AudioAttachDeviceInputSchema = object({
10755
+ deviceId: number(),
10756
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
10757
+ brokerId: string(),
10758
+ /**
10759
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
10760
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
10761
+ * the orchestrator's poller pinned them before the move.
10762
+ */
10763
+ ingestNodeId: string(),
10764
+ /**
10765
+ * Resolved once by the orchestrator at attach time, exactly as it was read
10766
+ * once per subscription before D461. The analyzer does NOT re-resolve per
10767
+ * window: a settings change re-attaches, which is what always happened.
10768
+ */
10769
+ settings: AudioAnalysisSettingsSchema
10770
+ });
10771
+ var AudioAttachDeviceResultSchema = object({
10772
+ /** False only when the analyzer is shutting down and refused to attach. */
10773
+ attached: boolean(),
10774
+ /**
10775
+ * True when the attachment replaced a live one for the same device. An
10776
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
10777
+ * double the broker's fanout and neither would know about the other.
10778
+ */
10779
+ replaced: boolean()
10780
+ });
10781
+ var AudioDetachDeviceResultSchema = object({
10782
+ /** False when no attachment existed — detach is idempotent. */
10783
+ detached: boolean() });
10639
10784
  var AudioClassificationResultSchema = object({
10640
10785
  labels: array(AudioClassificationLabelSchema).readonly(),
10641
10786
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -10644,7 +10789,7 @@ var AudioClassificationResultSchema = object({
10644
10789
  method(object({
10645
10790
  chunk: AudioChunkInputSchema,
10646
10791
  settings: AudioAnalysisSettingsSchema
10647
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
10792
+ }), 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() }), {
10648
10793
  kind: "mutation",
10649
10794
  auth: "admin"
10650
10795
  });
@@ -20548,6 +20693,14 @@ var NativeCropResultSchema = object({
20548
20693
  * set `encodeJpeg: true`; `bytes` is then absent.
20549
20694
  */
20550
20695
  jpeg: string().optional(),
20696
+ /**
20697
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
20698
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
20699
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
20700
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
20701
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
20702
+ */
20703
+ jpegBytes: _instanceof(Uint8Array).optional(),
20551
20704
  width: number().int().positive(),
20552
20705
  height: number().int().positive(),
20553
20706
  /**
@@ -20614,7 +20767,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
20614
20767
  })]);
20615
20768
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
20616
20769
  var ParkedTrackFrameSchema = object({
20617
- jpeg: string(),
20770
+ /**
20771
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
20772
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
20773
+ * Exactly one of the two is present.
20774
+ */
20775
+ jpeg: string().optional(),
20776
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
20777
+ jpegBytes: _instanceof(Uint8Array).optional(),
20618
20778
  width: number().int().positive(),
20619
20779
  height: number().int().positive(),
20620
20780
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21201,6 +21361,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21201
21361
  bbox: NativeCropBboxSchema,
21202
21362
  maxWidth: number().int().positive().optional(),
21203
21363
  /**
21364
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21365
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21366
+ * wire — never assume consent: a pre-D462 caller parses the field as
21367
+ * base64 and bytes would decode to garbage rather than fail.
21368
+ */
21369
+ acceptJpegBytes: boolean().optional(),
21370
+ /**
21204
21371
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21205
21372
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21206
21373
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21268,7 +21435,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21268
21435
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21269
21436
  deviceId: number(),
21270
21437
  trackId: string(),
21271
- kind: ParkedFrameKindSchema
21438
+ kind: ParkedFrameKindSchema,
21439
+ /**
21440
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21441
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21442
+ * wire — never assume consent: a pre-D462 caller parses the field as
21443
+ * base64 and bytes would decode to garbage rather than fail.
21444
+ */
21445
+ acceptJpegBytes: boolean().optional()
21272
21446
  }), ParkedTrackFrameSchema.nullable()), method(object({
21273
21447
  deviceId: number(),
21274
21448
  trackId: string()
@@ -35519,12 +35693,24 @@ Object.freeze({
35519
35693
  addonId: null,
35520
35694
  access: "create"
35521
35695
  },
35696
+ "audioAnalyzer.attachDevice": {
35697
+ capName: "audio-analyzer",
35698
+ capScope: "system",
35699
+ addonId: null,
35700
+ access: "create"
35701
+ },
35522
35702
  "audioAnalyzer.classify": {
35523
35703
  capName: "audio-analyzer",
35524
35704
  capScope: "system",
35525
35705
  addonId: null,
35526
35706
  access: "view"
35527
35707
  },
35708
+ "audioAnalyzer.detachDevice": {
35709
+ capName: "audio-analyzer",
35710
+ capScope: "system",
35711
+ addonId: null,
35712
+ access: "create"
35713
+ },
35528
35714
  "audioAnalyzer.dispose": {
35529
35715
  capName: "audio-analyzer",
35530
35716
  capScope: "system",
@@ -41368,11 +41554,21 @@ Object.freeze({
41368
41554
  form: "single",
41369
41555
  optional: false
41370
41556
  }],
41557
+ "audioAnalyzer.attachDevice": [{
41558
+ name: "deviceId",
41559
+ form: "single",
41560
+ optional: false
41561
+ }],
41371
41562
  "audioAnalyzer.classify": [{
41372
41563
  name: "deviceId",
41373
41564
  form: "single",
41374
41565
  optional: true
41375
41566
  }],
41567
+ "audioAnalyzer.detachDevice": [{
41568
+ name: "deviceId",
41569
+ form: "single",
41570
+ optional: false
41571
+ }],
41376
41572
  "audioMetrics.getCurrentSnapshot": [{
41377
41573
  name: "deviceId",
41378
41574
  form: "single",
@@ -43224,6 +43420,52 @@ Object.freeze({
43224
43420
  "network-access": "ingress",
43225
43421
  "smtp-provider": "email"
43226
43422
  });
43423
+ var G711_SCALE_CORRECTION_DB = {
43424
+ PCMU: 20 * Math.log10(4),
43425
+ PCMA: 20 * Math.log10(8)
43426
+ };
43427
+ /**
43428
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
43429
+ * same intent on the ITU-T scale (D460).
43430
+ *
43431
+ * ## When this applies, and when it is the wrong thing to reach for
43432
+ *
43433
+ * An absolute-dBFS number in this repo is one of two things, and only one of
43434
+ * them converts:
43435
+ *
43436
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
43437
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
43438
+ * after. The defect was never in the number; it was that 19 of this hub's
43439
+ * 25 cameras did not obey it. Converting such a number takes something
43440
+ * correct and makes it wrong, in order to preserve a bug.
43441
+ * - **A measurement taken through the old decoder** — a value someone read
43442
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
43443
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
43444
+ * louder. That is what this function is for.
43445
+ *
43446
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
43447
+ * and it cannot be answered from the number. It is answered by the comment the
43448
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
43449
+ * mandatory.
43450
+ *
43451
+ * ## Why a function and not a typed-in number
43452
+ *
43453
+ * `-55 + 12.04` written into a source file is, six months later, completely
43454
+ * indistinguishable from a threshold somebody simply preferred. Calling this
43455
+ * keeps the derivation, the law, and the original measurement all visible at
43456
+ * the call site, so a future reader can disagree with the *premise* instead of
43457
+ * having to reverse-engineer the sum.
43458
+ *
43459
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
43460
+ * it is declared. It must never be applied to a live sample or a stored
43461
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
43462
+ * adjusting numbers the decoder already got right is the original defect with
43463
+ * an extra place to argue with (D459).
43464
+ */
43465
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
43466
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
43467
+ }
43468
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
43227
43469
  /** Schema defaults — an untouched sub-field must author exactly these. */
43228
43470
  var NC_AUDIO_DEFAULTS = {
43229
43471
  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({
@@ -10637,6 +10737,51 @@ var AudioAnalysisSettingsSchema = object({
10637
10737
  minConfidence: number().min(0).max(1).default(.3),
10638
10738
  allowedClasses: array(string()).default([])
10639
10739
  });
10740
+ /**
10741
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
10742
+ *
10743
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
10744
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
10745
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
10746
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
10747
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
10748
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
10749
+ * way to the one expansion that feeds the model.
10750
+ *
10751
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
10752
+ * window, the per-device node assignment, the settings read) and therefore
10753
+ * still owns the attach/detach pair. It no longer owns the bytes.
10754
+ */
10755
+ var AudioAttachDeviceInputSchema = object({
10756
+ deviceId: number(),
10757
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
10758
+ brokerId: string(),
10759
+ /**
10760
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
10761
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
10762
+ * the orchestrator's poller pinned them before the move.
10763
+ */
10764
+ ingestNodeId: string(),
10765
+ /**
10766
+ * Resolved once by the orchestrator at attach time, exactly as it was read
10767
+ * once per subscription before D461. The analyzer does NOT re-resolve per
10768
+ * window: a settings change re-attaches, which is what always happened.
10769
+ */
10770
+ settings: AudioAnalysisSettingsSchema
10771
+ });
10772
+ var AudioAttachDeviceResultSchema = object({
10773
+ /** False only when the analyzer is shutting down and refused to attach. */
10774
+ attached: boolean(),
10775
+ /**
10776
+ * True when the attachment replaced a live one for the same device. An
10777
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
10778
+ * double the broker's fanout and neither would know about the other.
10779
+ */
10780
+ replaced: boolean()
10781
+ });
10782
+ var AudioDetachDeviceResultSchema = object({
10783
+ /** False when no attachment existed — detach is idempotent. */
10784
+ detached: boolean() });
10640
10785
  var AudioClassificationResultSchema = object({
10641
10786
  labels: array(AudioClassificationLabelSchema).readonly(),
10642
10787
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -10645,7 +10790,7 @@ var AudioClassificationResultSchema = object({
10645
10790
  method(object({
10646
10791
  chunk: AudioChunkInputSchema,
10647
10792
  settings: AudioAnalysisSettingsSchema
10648
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
10793
+ }), 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() }), {
10649
10794
  kind: "mutation",
10650
10795
  auth: "admin"
10651
10796
  });
@@ -20549,6 +20694,14 @@ var NativeCropResultSchema = object({
20549
20694
  * set `encodeJpeg: true`; `bytes` is then absent.
20550
20695
  */
20551
20696
  jpeg: string().optional(),
20697
+ /**
20698
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
20699
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
20700
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
20701
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
20702
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
20703
+ */
20704
+ jpegBytes: _instanceof(Uint8Array).optional(),
20552
20705
  width: number().int().positive(),
20553
20706
  height: number().int().positive(),
20554
20707
  /**
@@ -20615,7 +20768,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
20615
20768
  })]);
20616
20769
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
20617
20770
  var ParkedTrackFrameSchema = object({
20618
- jpeg: string(),
20771
+ /**
20772
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
20773
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
20774
+ * Exactly one of the two is present.
20775
+ */
20776
+ jpeg: string().optional(),
20777
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
20778
+ jpegBytes: _instanceof(Uint8Array).optional(),
20619
20779
  width: number().int().positive(),
20620
20780
  height: number().int().positive(),
20621
20781
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21202,6 +21362,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21202
21362
  bbox: NativeCropBboxSchema,
21203
21363
  maxWidth: number().int().positive().optional(),
21204
21364
  /**
21365
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21366
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21367
+ * wire — never assume consent: a pre-D462 caller parses the field as
21368
+ * base64 and bytes would decode to garbage rather than fail.
21369
+ */
21370
+ acceptJpegBytes: boolean().optional(),
21371
+ /**
21205
21372
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21206
21373
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21207
21374
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21269,7 +21436,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21269
21436
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21270
21437
  deviceId: number(),
21271
21438
  trackId: string(),
21272
- kind: ParkedFrameKindSchema
21439
+ kind: ParkedFrameKindSchema,
21440
+ /**
21441
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21442
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21443
+ * wire — never assume consent: a pre-D462 caller parses the field as
21444
+ * base64 and bytes would decode to garbage rather than fail.
21445
+ */
21446
+ acceptJpegBytes: boolean().optional()
21273
21447
  }), ParkedTrackFrameSchema.nullable()), method(object({
21274
21448
  deviceId: number(),
21275
21449
  trackId: string()
@@ -35520,12 +35694,24 @@ Object.freeze({
35520
35694
  addonId: null,
35521
35695
  access: "create"
35522
35696
  },
35697
+ "audioAnalyzer.attachDevice": {
35698
+ capName: "audio-analyzer",
35699
+ capScope: "system",
35700
+ addonId: null,
35701
+ access: "create"
35702
+ },
35523
35703
  "audioAnalyzer.classify": {
35524
35704
  capName: "audio-analyzer",
35525
35705
  capScope: "system",
35526
35706
  addonId: null,
35527
35707
  access: "view"
35528
35708
  },
35709
+ "audioAnalyzer.detachDevice": {
35710
+ capName: "audio-analyzer",
35711
+ capScope: "system",
35712
+ addonId: null,
35713
+ access: "create"
35714
+ },
35529
35715
  "audioAnalyzer.dispose": {
35530
35716
  capName: "audio-analyzer",
35531
35717
  capScope: "system",
@@ -41369,11 +41555,21 @@ Object.freeze({
41369
41555
  form: "single",
41370
41556
  optional: false
41371
41557
  }],
41558
+ "audioAnalyzer.attachDevice": [{
41559
+ name: "deviceId",
41560
+ form: "single",
41561
+ optional: false
41562
+ }],
41372
41563
  "audioAnalyzer.classify": [{
41373
41564
  name: "deviceId",
41374
41565
  form: "single",
41375
41566
  optional: true
41376
41567
  }],
41568
+ "audioAnalyzer.detachDevice": [{
41569
+ name: "deviceId",
41570
+ form: "single",
41571
+ optional: false
41572
+ }],
41377
41573
  "audioMetrics.getCurrentSnapshot": [{
41378
41574
  name: "deviceId",
41379
41575
  form: "single",
@@ -43225,6 +43421,52 @@ Object.freeze({
43225
43421
  "network-access": "ingress",
43226
43422
  "smtp-provider": "email"
43227
43423
  });
43424
+ var G711_SCALE_CORRECTION_DB = {
43425
+ PCMU: 20 * Math.log10(4),
43426
+ PCMA: 20 * Math.log10(8)
43427
+ };
43428
+ /**
43429
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
43430
+ * same intent on the ITU-T scale (D460).
43431
+ *
43432
+ * ## When this applies, and when it is the wrong thing to reach for
43433
+ *
43434
+ * An absolute-dBFS number in this repo is one of two things, and only one of
43435
+ * them converts:
43436
+ *
43437
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
43438
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
43439
+ * after. The defect was never in the number; it was that 19 of this hub's
43440
+ * 25 cameras did not obey it. Converting such a number takes something
43441
+ * correct and makes it wrong, in order to preserve a bug.
43442
+ * - **A measurement taken through the old decoder** — a value someone read
43443
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
43444
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
43445
+ * louder. That is what this function is for.
43446
+ *
43447
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
43448
+ * and it cannot be answered from the number. It is answered by the comment the
43449
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
43450
+ * mandatory.
43451
+ *
43452
+ * ## Why a function and not a typed-in number
43453
+ *
43454
+ * `-55 + 12.04` written into a source file is, six months later, completely
43455
+ * indistinguishable from a threshold somebody simply preferred. Calling this
43456
+ * keeps the derivation, the law, and the original measurement all visible at
43457
+ * the call site, so a future reader can disagree with the *premise* instead of
43458
+ * having to reverse-engineer the sum.
43459
+ *
43460
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
43461
+ * it is declared. It must never be applied to a live sample or a stored
43462
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
43463
+ * adjusting numbers the decoder already got right is the original defect with
43464
+ * an extra place to argue with (D459).
43465
+ */
43466
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
43467
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
43468
+ }
43469
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
43228
43470
  /** Schema defaults — an untouched sub-field must author exactly these. */
43229
43471
  var NC_AUDIO_DEFAULTS = {
43230
43472
  hitPercent: 60,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-amcrest",
3
- "version": "0.2.97",
3
+ "version": "0.2.99",
4
4
  "description": "Amcrest/Dahua camera device provider addon for CamStack — Dahua CGI over HTTP(S) with digest auth (snapshot, RTSP catalog, PTZ, image/day-night config)",
5
5
  "keywords": [
6
6
  "camstack",