@camstack/addon-provider-amcrest 0.2.96 → 0.2.98

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
  });
@@ -25972,8 +26117,8 @@ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly
25972
26117
  *
25973
26118
  * An **empty array reads NOTHING** — `[]` is an empty page, never
25974
26119
  * "every camera". A request for no devices is a request, not an
25975
- * omission; same contract as `deviceManager.listFleet` and
25976
- * `pipelineAnalytics.listRecentTracks`.
26120
+ * omission; same contract as `deviceManager.listAll`'s `deviceIds`
26121
+ * and `pipelineAnalytics.listRecentTracks`.
25977
26122
  *
25978
26123
  * Absent (`undefined`) is the omission, and keeps the cluster-wide view.
25979
26124
  */
@@ -35519,12 +35664,24 @@ Object.freeze({
35519
35664
  addonId: null,
35520
35665
  access: "create"
35521
35666
  },
35667
+ "audioAnalyzer.attachDevice": {
35668
+ capName: "audio-analyzer",
35669
+ capScope: "system",
35670
+ addonId: null,
35671
+ access: "create"
35672
+ },
35522
35673
  "audioAnalyzer.classify": {
35523
35674
  capName: "audio-analyzer",
35524
35675
  capScope: "system",
35525
35676
  addonId: null,
35526
35677
  access: "view"
35527
35678
  },
35679
+ "audioAnalyzer.detachDevice": {
35680
+ capName: "audio-analyzer",
35681
+ capScope: "system",
35682
+ addonId: null,
35683
+ access: "create"
35684
+ },
35528
35685
  "audioAnalyzer.dispose": {
35529
35686
  capName: "audio-analyzer",
35530
35687
  capScope: "system",
@@ -41368,11 +41525,21 @@ Object.freeze({
41368
41525
  form: "single",
41369
41526
  optional: false
41370
41527
  }],
41528
+ "audioAnalyzer.attachDevice": [{
41529
+ name: "deviceId",
41530
+ form: "single",
41531
+ optional: false
41532
+ }],
41371
41533
  "audioAnalyzer.classify": [{
41372
41534
  name: "deviceId",
41373
41535
  form: "single",
41374
41536
  optional: true
41375
41537
  }],
41538
+ "audioAnalyzer.detachDevice": [{
41539
+ name: "deviceId",
41540
+ form: "single",
41541
+ optional: false
41542
+ }],
41376
41543
  "audioMetrics.getCurrentSnapshot": [{
41377
41544
  name: "deviceId",
41378
41545
  form: "single",
@@ -43224,6 +43391,52 @@ Object.freeze({
43224
43391
  "network-access": "ingress",
43225
43392
  "smtp-provider": "email"
43226
43393
  });
43394
+ var G711_SCALE_CORRECTION_DB = {
43395
+ PCMU: 20 * Math.log10(4),
43396
+ PCMA: 20 * Math.log10(8)
43397
+ };
43398
+ /**
43399
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
43400
+ * same intent on the ITU-T scale (D460).
43401
+ *
43402
+ * ## When this applies, and when it is the wrong thing to reach for
43403
+ *
43404
+ * An absolute-dBFS number in this repo is one of two things, and only one of
43405
+ * them converts:
43406
+ *
43407
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
43408
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
43409
+ * after. The defect was never in the number; it was that 19 of this hub's
43410
+ * 25 cameras did not obey it. Converting such a number takes something
43411
+ * correct and makes it wrong, in order to preserve a bug.
43412
+ * - **A measurement taken through the old decoder** — a value someone read
43413
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
43414
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
43415
+ * louder. That is what this function is for.
43416
+ *
43417
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
43418
+ * and it cannot be answered from the number. It is answered by the comment the
43419
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
43420
+ * mandatory.
43421
+ *
43422
+ * ## Why a function and not a typed-in number
43423
+ *
43424
+ * `-55 + 12.04` written into a source file is, six months later, completely
43425
+ * indistinguishable from a threshold somebody simply preferred. Calling this
43426
+ * keeps the derivation, the law, and the original measurement all visible at
43427
+ * the call site, so a future reader can disagree with the *premise* instead of
43428
+ * having to reverse-engineer the sum.
43429
+ *
43430
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
43431
+ * it is declared. It must never be applied to a live sample or a stored
43432
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
43433
+ * adjusting numbers the decoder already got right is the original defect with
43434
+ * an extra place to argue with (D459).
43435
+ */
43436
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
43437
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
43438
+ }
43439
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
43227
43440
  /** Schema defaults — an untouched sub-field must author exactly these. */
43228
43441
  var NC_AUDIO_DEFAULTS = {
43229
43442
  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
  });
@@ -25973,8 +26118,8 @@ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly
25973
26118
  *
25974
26119
  * An **empty array reads NOTHING** — `[]` is an empty page, never
25975
26120
  * "every camera". A request for no devices is a request, not an
25976
- * omission; same contract as `deviceManager.listFleet` and
25977
- * `pipelineAnalytics.listRecentTracks`.
26121
+ * omission; same contract as `deviceManager.listAll`'s `deviceIds`
26122
+ * and `pipelineAnalytics.listRecentTracks`.
25978
26123
  *
25979
26124
  * Absent (`undefined`) is the omission, and keeps the cluster-wide view.
25980
26125
  */
@@ -35520,12 +35665,24 @@ Object.freeze({
35520
35665
  addonId: null,
35521
35666
  access: "create"
35522
35667
  },
35668
+ "audioAnalyzer.attachDevice": {
35669
+ capName: "audio-analyzer",
35670
+ capScope: "system",
35671
+ addonId: null,
35672
+ access: "create"
35673
+ },
35523
35674
  "audioAnalyzer.classify": {
35524
35675
  capName: "audio-analyzer",
35525
35676
  capScope: "system",
35526
35677
  addonId: null,
35527
35678
  access: "view"
35528
35679
  },
35680
+ "audioAnalyzer.detachDevice": {
35681
+ capName: "audio-analyzer",
35682
+ capScope: "system",
35683
+ addonId: null,
35684
+ access: "create"
35685
+ },
35529
35686
  "audioAnalyzer.dispose": {
35530
35687
  capName: "audio-analyzer",
35531
35688
  capScope: "system",
@@ -41369,11 +41526,21 @@ Object.freeze({
41369
41526
  form: "single",
41370
41527
  optional: false
41371
41528
  }],
41529
+ "audioAnalyzer.attachDevice": [{
41530
+ name: "deviceId",
41531
+ form: "single",
41532
+ optional: false
41533
+ }],
41372
41534
  "audioAnalyzer.classify": [{
41373
41535
  name: "deviceId",
41374
41536
  form: "single",
41375
41537
  optional: true
41376
41538
  }],
41539
+ "audioAnalyzer.detachDevice": [{
41540
+ name: "deviceId",
41541
+ form: "single",
41542
+ optional: false
41543
+ }],
41377
41544
  "audioMetrics.getCurrentSnapshot": [{
41378
41545
  name: "deviceId",
41379
41546
  form: "single",
@@ -43225,6 +43392,52 @@ Object.freeze({
43225
43392
  "network-access": "ingress",
43226
43393
  "smtp-provider": "email"
43227
43394
  });
43395
+ var G711_SCALE_CORRECTION_DB = {
43396
+ PCMU: 20 * Math.log10(4),
43397
+ PCMA: 20 * Math.log10(8)
43398
+ };
43399
+ /**
43400
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
43401
+ * same intent on the ITU-T scale (D460).
43402
+ *
43403
+ * ## When this applies, and when it is the wrong thing to reach for
43404
+ *
43405
+ * An absolute-dBFS number in this repo is one of two things, and only one of
43406
+ * them converts:
43407
+ *
43408
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
43409
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
43410
+ * after. The defect was never in the number; it was that 19 of this hub's
43411
+ * 25 cameras did not obey it. Converting such a number takes something
43412
+ * correct and makes it wrong, in order to preserve a bug.
43413
+ * - **A measurement taken through the old decoder** — a value someone read
43414
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
43415
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
43416
+ * louder. That is what this function is for.
43417
+ *
43418
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
43419
+ * and it cannot be answered from the number. It is answered by the comment the
43420
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
43421
+ * mandatory.
43422
+ *
43423
+ * ## Why a function and not a typed-in number
43424
+ *
43425
+ * `-55 + 12.04` written into a source file is, six months later, completely
43426
+ * indistinguishable from a threshold somebody simply preferred. Calling this
43427
+ * keeps the derivation, the law, and the original measurement all visible at
43428
+ * the call site, so a future reader can disagree with the *premise* instead of
43429
+ * having to reverse-engineer the sum.
43430
+ *
43431
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
43432
+ * it is declared. It must never be applied to a live sample or a stored
43433
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
43434
+ * adjusting numbers the decoder already got right is the original defect with
43435
+ * an extra place to argue with (D459).
43436
+ */
43437
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
43438
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
43439
+ }
43440
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
43228
43441
  /** Schema defaults — an untouched sub-field must author exactly these. */
43229
43442
  var NC_AUDIO_DEFAULTS = {
43230
43443
  hitPercent: 60,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-amcrest",
3
- "version": "0.2.96",
3
+ "version": "0.2.98",
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",