@camstack/addon-provider-onvif 1.2.94 → 1.2.95

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
@@ -5348,6 +5348,86 @@ var ZodIssueCode = {
5348
5348
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
5349
5349
  var ZodFirstPartyTypeKind;
5350
5350
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5351
+ //#endregion
5352
+ //#region ../types/dist/sleep-BnujYGPe.mjs
5353
+ /**
5354
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
5355
+ * window to float samples (D455).
5356
+ *
5357
+ * ## Why a format at all
5358
+ *
5359
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
5360
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
5361
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
5362
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
5363
+ * the plane carried four times the source. The plane crosses hub-main twice on
5364
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
5365
+ *
5366
+ * So the plane carries the source BYTES too, and whoever needs floats expands
5367
+ * them where it needs them. That is the same argument D450 made for the rate,
5368
+ * one step further along the same wire.
5369
+ *
5370
+ * ## Why the expansion lives here
5371
+ *
5372
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
5373
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
5374
+ * `AudioChunkPlane` expands per subscription) and
5375
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
5376
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
5377
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
5378
+ * into their own dist (`self-contained` externals), so this travels with a
5379
+ * `camstack deploy` and needs no published server.
5380
+ *
5381
+ * A second μ-law table anywhere else is the defect this module exists to
5382
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
5383
+ * direction for the WebRTC egress — a different transform, not a copy.)
5384
+ *
5385
+ * ## Absent means f32le
5386
+ *
5387
+ * `format` is optional on the wire and its absence means `f32le` — today's
5388
+ * bytes, byte for byte. A peer that never heard of the field is served what it
5389
+ * has always been served, because the broker only emits a coded window to a
5390
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
5391
+ * That is the D448 `rawForward` negotiation, and it is what makes this
5392
+ * deployable one addon at a time across three nodes.
5393
+ */
5394
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
5395
+ var AUDIO_CHUNK_FORMATS = [
5396
+ "f32le",
5397
+ "pcmu",
5398
+ "pcma"
5399
+ ];
5400
+ /**
5401
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
5402
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
5403
+ *
5404
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
5405
+ * it buffers the coded bytes and the plane's consumers expand.
5406
+ */
5407
+ function buildUlawTable() {
5408
+ const table = new Float32Array(256);
5409
+ for (let i = 0; i < 256; i++) {
5410
+ const complemented = ~i & 255;
5411
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
5412
+ const exponent = complemented >> 4 & 7;
5413
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
5414
+ }
5415
+ return table;
5416
+ }
5417
+ /** Build the A-law decode table (ITU-T G.711). */
5418
+ function buildAlawTable() {
5419
+ const table = new Float32Array(256);
5420
+ for (let i = 0; i < 256; i++) {
5421
+ const xored = i ^ 85;
5422
+ const sign = (xored & 128) !== 0 ? 1 : -1;
5423
+ const exponent = xored >> 4 & 7;
5424
+ const mantissa = xored & 15;
5425
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
5426
+ }
5427
+ return table;
5428
+ }
5429
+ buildUlawTable();
5430
+ buildAlawTable();
5351
5431
  Object.fromEntries([
5352
5432
  {
5353
5433
  id: "overview",
@@ -6640,11 +6720,20 @@ var SubscribeFramesResultSchema = object({
6640
6720
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
6641
6721
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
6642
6722
  */
6723
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
6643
6724
  var DecodedAudioChunkSchema = object({
6644
6725
  data: _instanceof(Uint8Array),
6645
6726
  sampleRate: number().int().positive(),
6646
6727
  channels: number().int().positive(),
6647
- timestamp: number()
6728
+ timestamp: number(),
6729
+ /**
6730
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
6731
+ * byte, for any peer that never heard of this field. A coded window
6732
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
6733
+ * subscription that DECLARED it accepts one, so absence can never mean
6734
+ * "coded bytes a consumer will read as floats" (D455).
6735
+ */
6736
+ format: AudioChunkFormatSchema.optional()
6648
6737
  });
6649
6738
  /**
6650
6739
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -6656,7 +6745,18 @@ var DecodedAudioChunkSchema = object({
6656
6745
  var SubscribeAudioChunksInputSchema = object({
6657
6746
  brokerId: string(),
6658
6747
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
6659
- tag: string().optional()
6748
+ tag: string().optional(),
6749
+ /**
6750
+ * Byte formats this subscriber can READ, best first. The broker serves the
6751
+ * chunk's own format when it is in this list and expands to `f32le`
6752
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
6753
+ *
6754
+ * Absent (or without the source format) means `f32le` — the behaviour every
6755
+ * subscriber had before D455, unchanged. This is the negotiation half of
6756
+ * the source-bytes lever: it is what lets the broker and its consumers
6757
+ * deploy one at a time across three nodes.
6758
+ */
6759
+ accept: array(AudioChunkFormatSchema).readonly().optional()
6660
6760
  });
6661
6761
  /** Result of `stream-broker.subscribeAudioChunks`. */
6662
6762
  var SubscribeAudioChunksResultSchema = object({
@@ -10640,6 +10740,51 @@ var AudioAnalysisSettingsSchema = object({
10640
10740
  minConfidence: number().min(0).max(1).default(.3),
10641
10741
  allowedClasses: array(string()).default([])
10642
10742
  });
10743
+ /**
10744
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
10745
+ *
10746
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
10747
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
10748
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
10749
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
10750
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
10751
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
10752
+ * way to the one expansion that feeds the model.
10753
+ *
10754
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
10755
+ * window, the per-device node assignment, the settings read) and therefore
10756
+ * still owns the attach/detach pair. It no longer owns the bytes.
10757
+ */
10758
+ var AudioAttachDeviceInputSchema = object({
10759
+ deviceId: number(),
10760
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
10761
+ brokerId: string(),
10762
+ /**
10763
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
10764
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
10765
+ * the orchestrator's poller pinned them before the move.
10766
+ */
10767
+ ingestNodeId: string(),
10768
+ /**
10769
+ * Resolved once by the orchestrator at attach time, exactly as it was read
10770
+ * once per subscription before D461. The analyzer does NOT re-resolve per
10771
+ * window: a settings change re-attaches, which is what always happened.
10772
+ */
10773
+ settings: AudioAnalysisSettingsSchema
10774
+ });
10775
+ var AudioAttachDeviceResultSchema = object({
10776
+ /** False only when the analyzer is shutting down and refused to attach. */
10777
+ attached: boolean(),
10778
+ /**
10779
+ * True when the attachment replaced a live one for the same device. An
10780
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
10781
+ * double the broker's fanout and neither would know about the other.
10782
+ */
10783
+ replaced: boolean()
10784
+ });
10785
+ var AudioDetachDeviceResultSchema = object({
10786
+ /** False when no attachment existed — detach is idempotent. */
10787
+ detached: boolean() });
10643
10788
  var AudioClassificationResultSchema = object({
10644
10789
  labels: array(AudioClassificationLabelSchema).readonly(),
10645
10790
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -10648,7 +10793,7 @@ var AudioClassificationResultSchema = object({
10648
10793
  method(object({
10649
10794
  chunk: AudioChunkInputSchema,
10650
10795
  settings: AudioAnalysisSettingsSchema
10651
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
10796
+ }), 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() }), {
10652
10797
  kind: "mutation",
10653
10798
  auth: "admin"
10654
10799
  });
@@ -31596,12 +31741,24 @@ Object.freeze({
31596
31741
  addonId: null,
31597
31742
  access: "create"
31598
31743
  },
31744
+ "audioAnalyzer.attachDevice": {
31745
+ capName: "audio-analyzer",
31746
+ capScope: "system",
31747
+ addonId: null,
31748
+ access: "create"
31749
+ },
31599
31750
  "audioAnalyzer.classify": {
31600
31751
  capName: "audio-analyzer",
31601
31752
  capScope: "system",
31602
31753
  addonId: null,
31603
31754
  access: "view"
31604
31755
  },
31756
+ "audioAnalyzer.detachDevice": {
31757
+ capName: "audio-analyzer",
31758
+ capScope: "system",
31759
+ addonId: null,
31760
+ access: "create"
31761
+ },
31605
31762
  "audioAnalyzer.dispose": {
31606
31763
  capName: "audio-analyzer",
31607
31764
  capScope: "system",
@@ -37445,11 +37602,21 @@ Object.freeze({
37445
37602
  form: "single",
37446
37603
  optional: false
37447
37604
  }],
37605
+ "audioAnalyzer.attachDevice": [{
37606
+ name: "deviceId",
37607
+ form: "single",
37608
+ optional: false
37609
+ }],
37448
37610
  "audioAnalyzer.classify": [{
37449
37611
  name: "deviceId",
37450
37612
  form: "single",
37451
37613
  optional: true
37452
37614
  }],
37615
+ "audioAnalyzer.detachDevice": [{
37616
+ name: "deviceId",
37617
+ form: "single",
37618
+ optional: false
37619
+ }],
37453
37620
  "audioMetrics.getCurrentSnapshot": [{
37454
37621
  name: "deviceId",
37455
37622
  form: "single",
@@ -39301,6 +39468,52 @@ Object.freeze({
39301
39468
  "network-access": "ingress",
39302
39469
  "smtp-provider": "email"
39303
39470
  });
39471
+ var G711_SCALE_CORRECTION_DB = {
39472
+ PCMU: 20 * Math.log10(4),
39473
+ PCMA: 20 * Math.log10(8)
39474
+ };
39475
+ /**
39476
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
39477
+ * same intent on the ITU-T scale (D460).
39478
+ *
39479
+ * ## When this applies, and when it is the wrong thing to reach for
39480
+ *
39481
+ * An absolute-dBFS number in this repo is one of two things, and only one of
39482
+ * them converts:
39483
+ *
39484
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
39485
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
39486
+ * after. The defect was never in the number; it was that 19 of this hub's
39487
+ * 25 cameras did not obey it. Converting such a number takes something
39488
+ * correct and makes it wrong, in order to preserve a bug.
39489
+ * - **A measurement taken through the old decoder** — a value someone read
39490
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
39491
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
39492
+ * louder. That is what this function is for.
39493
+ *
39494
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
39495
+ * and it cannot be answered from the number. It is answered by the comment the
39496
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
39497
+ * mandatory.
39498
+ *
39499
+ * ## Why a function and not a typed-in number
39500
+ *
39501
+ * `-55 + 12.04` written into a source file is, six months later, completely
39502
+ * indistinguishable from a threshold somebody simply preferred. Calling this
39503
+ * keeps the derivation, the law, and the original measurement all visible at
39504
+ * the call site, so a future reader can disagree with the *premise* instead of
39505
+ * having to reverse-engineer the sum.
39506
+ *
39507
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
39508
+ * it is declared. It must never be applied to a live sample or a stored
39509
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
39510
+ * adjusting numbers the decoder already got right is the original defect with
39511
+ * an extra place to argue with (D459).
39512
+ */
39513
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
39514
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
39515
+ }
39516
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
39304
39517
  /** Schema defaults — an untouched sub-field must author exactly these. */
39305
39518
  var NC_AUDIO_DEFAULTS = {
39306
39519
  hitPercent: 60,
package/dist/addon.mjs CHANGED
@@ -5349,6 +5349,86 @@ var ZodIssueCode = {
5349
5349
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
5350
5350
  var ZodFirstPartyTypeKind;
5351
5351
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5352
+ //#endregion
5353
+ //#region ../types/dist/sleep-BnujYGPe.mjs
5354
+ /**
5355
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
5356
+ * window to float samples (D455).
5357
+ *
5358
+ * ## Why a format at all
5359
+ *
5360
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
5361
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
5362
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
5363
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
5364
+ * the plane carried four times the source. The plane crosses hub-main twice on
5365
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
5366
+ *
5367
+ * So the plane carries the source BYTES too, and whoever needs floats expands
5368
+ * them where it needs them. That is the same argument D450 made for the rate,
5369
+ * one step further along the same wire.
5370
+ *
5371
+ * ## Why the expansion lives here
5372
+ *
5373
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
5374
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
5375
+ * `AudioChunkPlane` expands per subscription) and
5376
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
5377
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
5378
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
5379
+ * into their own dist (`self-contained` externals), so this travels with a
5380
+ * `camstack deploy` and needs no published server.
5381
+ *
5382
+ * A second μ-law table anywhere else is the defect this module exists to
5383
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
5384
+ * direction for the WebRTC egress — a different transform, not a copy.)
5385
+ *
5386
+ * ## Absent means f32le
5387
+ *
5388
+ * `format` is optional on the wire and its absence means `f32le` — today's
5389
+ * bytes, byte for byte. A peer that never heard of the field is served what it
5390
+ * has always been served, because the broker only emits a coded window to a
5391
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
5392
+ * That is the D448 `rawForward` negotiation, and it is what makes this
5393
+ * deployable one addon at a time across three nodes.
5394
+ */
5395
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
5396
+ var AUDIO_CHUNK_FORMATS = [
5397
+ "f32le",
5398
+ "pcmu",
5399
+ "pcma"
5400
+ ];
5401
+ /**
5402
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
5403
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
5404
+ *
5405
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
5406
+ * it buffers the coded bytes and the plane's consumers expand.
5407
+ */
5408
+ function buildUlawTable() {
5409
+ const table = new Float32Array(256);
5410
+ for (let i = 0; i < 256; i++) {
5411
+ const complemented = ~i & 255;
5412
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
5413
+ const exponent = complemented >> 4 & 7;
5414
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
5415
+ }
5416
+ return table;
5417
+ }
5418
+ /** Build the A-law decode table (ITU-T G.711). */
5419
+ function buildAlawTable() {
5420
+ const table = new Float32Array(256);
5421
+ for (let i = 0; i < 256; i++) {
5422
+ const xored = i ^ 85;
5423
+ const sign = (xored & 128) !== 0 ? 1 : -1;
5424
+ const exponent = xored >> 4 & 7;
5425
+ const mantissa = xored & 15;
5426
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
5427
+ }
5428
+ return table;
5429
+ }
5430
+ buildUlawTable();
5431
+ buildAlawTable();
5352
5432
  Object.fromEntries([
5353
5433
  {
5354
5434
  id: "overview",
@@ -6641,11 +6721,20 @@ var SubscribeFramesResultSchema = object({
6641
6721
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
6642
6722
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
6643
6723
  */
6724
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
6644
6725
  var DecodedAudioChunkSchema = object({
6645
6726
  data: _instanceof(Uint8Array),
6646
6727
  sampleRate: number().int().positive(),
6647
6728
  channels: number().int().positive(),
6648
- timestamp: number()
6729
+ timestamp: number(),
6730
+ /**
6731
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
6732
+ * byte, for any peer that never heard of this field. A coded window
6733
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
6734
+ * subscription that DECLARED it accepts one, so absence can never mean
6735
+ * "coded bytes a consumer will read as floats" (D455).
6736
+ */
6737
+ format: AudioChunkFormatSchema.optional()
6649
6738
  });
6650
6739
  /**
6651
6740
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -6657,7 +6746,18 @@ var DecodedAudioChunkSchema = object({
6657
6746
  var SubscribeAudioChunksInputSchema = object({
6658
6747
  brokerId: string(),
6659
6748
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
6660
- tag: string().optional()
6749
+ tag: string().optional(),
6750
+ /**
6751
+ * Byte formats this subscriber can READ, best first. The broker serves the
6752
+ * chunk's own format when it is in this list and expands to `f32le`
6753
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
6754
+ *
6755
+ * Absent (or without the source format) means `f32le` — the behaviour every
6756
+ * subscriber had before D455, unchanged. This is the negotiation half of
6757
+ * the source-bytes lever: it is what lets the broker and its consumers
6758
+ * deploy one at a time across three nodes.
6759
+ */
6760
+ accept: array(AudioChunkFormatSchema).readonly().optional()
6661
6761
  });
6662
6762
  /** Result of `stream-broker.subscribeAudioChunks`. */
6663
6763
  var SubscribeAudioChunksResultSchema = object({
@@ -10641,6 +10741,51 @@ var AudioAnalysisSettingsSchema = object({
10641
10741
  minConfidence: number().min(0).max(1).default(.3),
10642
10742
  allowedClasses: array(string()).default([])
10643
10743
  });
10744
+ /**
10745
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
10746
+ *
10747
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
10748
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
10749
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
10750
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
10751
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
10752
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
10753
+ * way to the one expansion that feeds the model.
10754
+ *
10755
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
10756
+ * window, the per-device node assignment, the settings read) and therefore
10757
+ * still owns the attach/detach pair. It no longer owns the bytes.
10758
+ */
10759
+ var AudioAttachDeviceInputSchema = object({
10760
+ deviceId: number(),
10761
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
10762
+ brokerId: string(),
10763
+ /**
10764
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
10765
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
10766
+ * the orchestrator's poller pinned them before the move.
10767
+ */
10768
+ ingestNodeId: string(),
10769
+ /**
10770
+ * Resolved once by the orchestrator at attach time, exactly as it was read
10771
+ * once per subscription before D461. The analyzer does NOT re-resolve per
10772
+ * window: a settings change re-attaches, which is what always happened.
10773
+ */
10774
+ settings: AudioAnalysisSettingsSchema
10775
+ });
10776
+ var AudioAttachDeviceResultSchema = object({
10777
+ /** False only when the analyzer is shutting down and refused to attach. */
10778
+ attached: boolean(),
10779
+ /**
10780
+ * True when the attachment replaced a live one for the same device. An
10781
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
10782
+ * double the broker's fanout and neither would know about the other.
10783
+ */
10784
+ replaced: boolean()
10785
+ });
10786
+ var AudioDetachDeviceResultSchema = object({
10787
+ /** False when no attachment existed — detach is idempotent. */
10788
+ detached: boolean() });
10644
10789
  var AudioClassificationResultSchema = object({
10645
10790
  labels: array(AudioClassificationLabelSchema).readonly(),
10646
10791
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -10649,7 +10794,7 @@ var AudioClassificationResultSchema = object({
10649
10794
  method(object({
10650
10795
  chunk: AudioChunkInputSchema,
10651
10796
  settings: AudioAnalysisSettingsSchema
10652
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
10797
+ }), 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() }), {
10653
10798
  kind: "mutation",
10654
10799
  auth: "admin"
10655
10800
  });
@@ -31597,12 +31742,24 @@ Object.freeze({
31597
31742
  addonId: null,
31598
31743
  access: "create"
31599
31744
  },
31745
+ "audioAnalyzer.attachDevice": {
31746
+ capName: "audio-analyzer",
31747
+ capScope: "system",
31748
+ addonId: null,
31749
+ access: "create"
31750
+ },
31600
31751
  "audioAnalyzer.classify": {
31601
31752
  capName: "audio-analyzer",
31602
31753
  capScope: "system",
31603
31754
  addonId: null,
31604
31755
  access: "view"
31605
31756
  },
31757
+ "audioAnalyzer.detachDevice": {
31758
+ capName: "audio-analyzer",
31759
+ capScope: "system",
31760
+ addonId: null,
31761
+ access: "create"
31762
+ },
31606
31763
  "audioAnalyzer.dispose": {
31607
31764
  capName: "audio-analyzer",
31608
31765
  capScope: "system",
@@ -37446,11 +37603,21 @@ Object.freeze({
37446
37603
  form: "single",
37447
37604
  optional: false
37448
37605
  }],
37606
+ "audioAnalyzer.attachDevice": [{
37607
+ name: "deviceId",
37608
+ form: "single",
37609
+ optional: false
37610
+ }],
37449
37611
  "audioAnalyzer.classify": [{
37450
37612
  name: "deviceId",
37451
37613
  form: "single",
37452
37614
  optional: true
37453
37615
  }],
37616
+ "audioAnalyzer.detachDevice": [{
37617
+ name: "deviceId",
37618
+ form: "single",
37619
+ optional: false
37620
+ }],
37454
37621
  "audioMetrics.getCurrentSnapshot": [{
37455
37622
  name: "deviceId",
37456
37623
  form: "single",
@@ -39302,6 +39469,52 @@ Object.freeze({
39302
39469
  "network-access": "ingress",
39303
39470
  "smtp-provider": "email"
39304
39471
  });
39472
+ var G711_SCALE_CORRECTION_DB = {
39473
+ PCMU: 20 * Math.log10(4),
39474
+ PCMA: 20 * Math.log10(8)
39475
+ };
39476
+ /**
39477
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
39478
+ * same intent on the ITU-T scale (D460).
39479
+ *
39480
+ * ## When this applies, and when it is the wrong thing to reach for
39481
+ *
39482
+ * An absolute-dBFS number in this repo is one of two things, and only one of
39483
+ * them converts:
39484
+ *
39485
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
39486
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
39487
+ * after. The defect was never in the number; it was that 19 of this hub's
39488
+ * 25 cameras did not obey it. Converting such a number takes something
39489
+ * correct and makes it wrong, in order to preserve a bug.
39490
+ * - **A measurement taken through the old decoder** — a value someone read
39491
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
39492
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
39493
+ * louder. That is what this function is for.
39494
+ *
39495
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
39496
+ * and it cannot be answered from the number. It is answered by the comment the
39497
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
39498
+ * mandatory.
39499
+ *
39500
+ * ## Why a function and not a typed-in number
39501
+ *
39502
+ * `-55 + 12.04` written into a source file is, six months later, completely
39503
+ * indistinguishable from a threshold somebody simply preferred. Calling this
39504
+ * keeps the derivation, the law, and the original measurement all visible at
39505
+ * the call site, so a future reader can disagree with the *premise* instead of
39506
+ * having to reverse-engineer the sum.
39507
+ *
39508
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
39509
+ * it is declared. It must never be applied to a live sample or a stored
39510
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
39511
+ * adjusting numbers the decoder already got right is the original defect with
39512
+ * an extra place to argue with (D459).
39513
+ */
39514
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
39515
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
39516
+ }
39517
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
39305
39518
  /** Schema defaults — an untouched sub-field must author exactly these. */
39306
39519
  var NC_AUDIO_DEFAULTS = {
39307
39520
  hitPercent: 60,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-onvif",
3
- "version": "1.2.94",
3
+ "version": "1.2.95",
4
4
  "description": "ONVIF camera device provider addon for CamStack",
5
5
  "keywords": [
6
6
  "camstack",