@camstack/addon-export-hap 1.2.105 → 1.2.107

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.
@@ -5430,6 +5430,86 @@ var ZodIssueCode = {
5430
5430
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
5431
5431
  var ZodFirstPartyTypeKind;
5432
5432
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5433
+ //#endregion
5434
+ //#region ../types/dist/sleep-BnujYGPe.mjs
5435
+ /**
5436
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
5437
+ * window to float samples (D455).
5438
+ *
5439
+ * ## Why a format at all
5440
+ *
5441
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
5442
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
5443
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
5444
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
5445
+ * the plane carried four times the source. The plane crosses hub-main twice on
5446
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
5447
+ *
5448
+ * So the plane carries the source BYTES too, and whoever needs floats expands
5449
+ * them where it needs them. That is the same argument D450 made for the rate,
5450
+ * one step further along the same wire.
5451
+ *
5452
+ * ## Why the expansion lives here
5453
+ *
5454
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
5455
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
5456
+ * `AudioChunkPlane` expands per subscription) and
5457
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
5458
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
5459
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
5460
+ * into their own dist (`self-contained` externals), so this travels with a
5461
+ * `camstack deploy` and needs no published server.
5462
+ *
5463
+ * A second μ-law table anywhere else is the defect this module exists to
5464
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
5465
+ * direction for the WebRTC egress — a different transform, not a copy.)
5466
+ *
5467
+ * ## Absent means f32le
5468
+ *
5469
+ * `format` is optional on the wire and its absence means `f32le` — today's
5470
+ * bytes, byte for byte. A peer that never heard of the field is served what it
5471
+ * has always been served, because the broker only emits a coded window to a
5472
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
5473
+ * That is the D448 `rawForward` negotiation, and it is what makes this
5474
+ * deployable one addon at a time across three nodes.
5475
+ */
5476
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
5477
+ var AUDIO_CHUNK_FORMATS = [
5478
+ "f32le",
5479
+ "pcmu",
5480
+ "pcma"
5481
+ ];
5482
+ /**
5483
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
5484
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
5485
+ *
5486
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
5487
+ * it buffers the coded bytes and the plane's consumers expand.
5488
+ */
5489
+ function buildUlawTable() {
5490
+ const table = new Float32Array(256);
5491
+ for (let i = 0; i < 256; i++) {
5492
+ const complemented = ~i & 255;
5493
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
5494
+ const exponent = complemented >> 4 & 7;
5495
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
5496
+ }
5497
+ return table;
5498
+ }
5499
+ /** Build the A-law decode table (ITU-T G.711). */
5500
+ function buildAlawTable() {
5501
+ const table = new Float32Array(256);
5502
+ for (let i = 0; i < 256; i++) {
5503
+ const xored = i ^ 85;
5504
+ const sign = (xored & 128) !== 0 ? 1 : -1;
5505
+ const exponent = xored >> 4 & 7;
5506
+ const mantissa = xored & 15;
5507
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
5508
+ }
5509
+ return table;
5510
+ }
5511
+ buildUlawTable();
5512
+ buildAlawTable();
5433
5513
  Object.fromEntries([
5434
5514
  {
5435
5515
  id: "overview",
@@ -6722,11 +6802,20 @@ var SubscribeFramesResultSchema = object({
6722
6802
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
6723
6803
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
6724
6804
  */
6805
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
6725
6806
  var DecodedAudioChunkSchema = object({
6726
6807
  data: _instanceof(Uint8Array),
6727
6808
  sampleRate: number().int().positive(),
6728
6809
  channels: number().int().positive(),
6729
- timestamp: number()
6810
+ timestamp: number(),
6811
+ /**
6812
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
6813
+ * byte, for any peer that never heard of this field. A coded window
6814
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
6815
+ * subscription that DECLARED it accepts one, so absence can never mean
6816
+ * "coded bytes a consumer will read as floats" (D455).
6817
+ */
6818
+ format: AudioChunkFormatSchema.optional()
6730
6819
  });
6731
6820
  /**
6732
6821
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -6738,7 +6827,18 @@ var DecodedAudioChunkSchema = object({
6738
6827
  var SubscribeAudioChunksInputSchema = object({
6739
6828
  brokerId: string(),
6740
6829
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
6741
- tag: string().optional()
6830
+ tag: string().optional(),
6831
+ /**
6832
+ * Byte formats this subscriber can READ, best first. The broker serves the
6833
+ * chunk's own format when it is in this list and expands to `f32le`
6834
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
6835
+ *
6836
+ * Absent (or without the source format) means `f32le` — the behaviour every
6837
+ * subscriber had before D455, unchanged. This is the negotiation half of
6838
+ * the source-bytes lever: it is what lets the broker and its consumers
6839
+ * deploy one at a time across three nodes.
6840
+ */
6841
+ accept: array(AudioChunkFormatSchema).readonly().optional()
6742
6842
  });
6743
6843
  /** Result of `stream-broker.subscribeAudioChunks`. */
6744
6844
  var SubscribeAudioChunksResultSchema = object({
@@ -11361,6 +11461,51 @@ var AudioAnalysisSettingsSchema = object({
11361
11461
  minConfidence: number().min(0).max(1).default(.3),
11362
11462
  allowedClasses: array(string()).default([])
11363
11463
  });
11464
+ /**
11465
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
11466
+ *
11467
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
11468
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
11469
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
11470
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
11471
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
11472
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
11473
+ * way to the one expansion that feeds the model.
11474
+ *
11475
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
11476
+ * window, the per-device node assignment, the settings read) and therefore
11477
+ * still owns the attach/detach pair. It no longer owns the bytes.
11478
+ */
11479
+ var AudioAttachDeviceInputSchema = object({
11480
+ deviceId: number(),
11481
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
11482
+ brokerId: string(),
11483
+ /**
11484
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
11485
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
11486
+ * the orchestrator's poller pinned them before the move.
11487
+ */
11488
+ ingestNodeId: string(),
11489
+ /**
11490
+ * Resolved once by the orchestrator at attach time, exactly as it was read
11491
+ * once per subscription before D461. The analyzer does NOT re-resolve per
11492
+ * window: a settings change re-attaches, which is what always happened.
11493
+ */
11494
+ settings: AudioAnalysisSettingsSchema
11495
+ });
11496
+ var AudioAttachDeviceResultSchema = object({
11497
+ /** False only when the analyzer is shutting down and refused to attach. */
11498
+ attached: boolean(),
11499
+ /**
11500
+ * True when the attachment replaced a live one for the same device. An
11501
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
11502
+ * double the broker's fanout and neither would know about the other.
11503
+ */
11504
+ replaced: boolean()
11505
+ });
11506
+ var AudioDetachDeviceResultSchema = object({
11507
+ /** False when no attachment existed — detach is idempotent. */
11508
+ detached: boolean() });
11364
11509
  var AudioClassificationResultSchema = object({
11365
11510
  labels: array(AudioClassificationLabelSchema).readonly(),
11366
11511
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -11369,7 +11514,7 @@ var AudioClassificationResultSchema = object({
11369
11514
  method(object({
11370
11515
  chunk: AudioChunkInputSchema,
11371
11516
  settings: AudioAnalysisSettingsSchema
11372
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
11517
+ }), 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() }), {
11373
11518
  kind: "mutation",
11374
11519
  auth: "admin"
11375
11520
  });
@@ -25596,8 +25741,8 @@ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly
25596
25741
  *
25597
25742
  * An **empty array reads NOTHING** — `[]` is an empty page, never
25598
25743
  * "every camera". A request for no devices is a request, not an
25599
- * omission; same contract as `deviceManager.listFleet` and
25600
- * `pipelineAnalytics.listRecentTracks`.
25744
+ * omission; same contract as `deviceManager.listAll`'s `deviceIds`
25745
+ * and `pipelineAnalytics.listRecentTracks`.
25601
25746
  *
25602
25747
  * Absent (`undefined`) is the omission, and keeps the cluster-wide view.
25603
25748
  */
@@ -31418,12 +31563,24 @@ Object.freeze({
31418
31563
  addonId: null,
31419
31564
  access: "create"
31420
31565
  },
31566
+ "audioAnalyzer.attachDevice": {
31567
+ capName: "audio-analyzer",
31568
+ capScope: "system",
31569
+ addonId: null,
31570
+ access: "create"
31571
+ },
31421
31572
  "audioAnalyzer.classify": {
31422
31573
  capName: "audio-analyzer",
31423
31574
  capScope: "system",
31424
31575
  addonId: null,
31425
31576
  access: "view"
31426
31577
  },
31578
+ "audioAnalyzer.detachDevice": {
31579
+ capName: "audio-analyzer",
31580
+ capScope: "system",
31581
+ addonId: null,
31582
+ access: "create"
31583
+ },
31427
31584
  "audioAnalyzer.dispose": {
31428
31585
  capName: "audio-analyzer",
31429
31586
  capScope: "system",
@@ -37267,11 +37424,21 @@ Object.freeze({
37267
37424
  form: "single",
37268
37425
  optional: false
37269
37426
  }],
37427
+ "audioAnalyzer.attachDevice": [{
37428
+ name: "deviceId",
37429
+ form: "single",
37430
+ optional: false
37431
+ }],
37270
37432
  "audioAnalyzer.classify": [{
37271
37433
  name: "deviceId",
37272
37434
  form: "single",
37273
37435
  optional: true
37274
37436
  }],
37437
+ "audioAnalyzer.detachDevice": [{
37438
+ name: "deviceId",
37439
+ form: "single",
37440
+ optional: false
37441
+ }],
37275
37442
  "audioMetrics.getCurrentSnapshot": [{
37276
37443
  name: "deviceId",
37277
37444
  form: "single",
@@ -39123,6 +39290,52 @@ Object.freeze({
39123
39290
  "network-access": "ingress",
39124
39291
  "smtp-provider": "email"
39125
39292
  });
39293
+ var G711_SCALE_CORRECTION_DB = {
39294
+ PCMU: 20 * Math.log10(4),
39295
+ PCMA: 20 * Math.log10(8)
39296
+ };
39297
+ /**
39298
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
39299
+ * same intent on the ITU-T scale (D460).
39300
+ *
39301
+ * ## When this applies, and when it is the wrong thing to reach for
39302
+ *
39303
+ * An absolute-dBFS number in this repo is one of two things, and only one of
39304
+ * them converts:
39305
+ *
39306
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
39307
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
39308
+ * after. The defect was never in the number; it was that 19 of this hub's
39309
+ * 25 cameras did not obey it. Converting such a number takes something
39310
+ * correct and makes it wrong, in order to preserve a bug.
39311
+ * - **A measurement taken through the old decoder** — a value someone read
39312
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
39313
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
39314
+ * louder. That is what this function is for.
39315
+ *
39316
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
39317
+ * and it cannot be answered from the number. It is answered by the comment the
39318
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
39319
+ * mandatory.
39320
+ *
39321
+ * ## Why a function and not a typed-in number
39322
+ *
39323
+ * `-55 + 12.04` written into a source file is, six months later, completely
39324
+ * indistinguishable from a threshold somebody simply preferred. Calling this
39325
+ * keeps the derivation, the law, and the original measurement all visible at
39326
+ * the call site, so a future reader can disagree with the *premise* instead of
39327
+ * having to reverse-engineer the sum.
39328
+ *
39329
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
39330
+ * it is declared. It must never be applied to a live sample or a stored
39331
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
39332
+ * adjusting numbers the decoder already got right is the original defect with
39333
+ * an extra place to argue with (D459).
39334
+ */
39335
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
39336
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
39337
+ }
39338
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
39126
39339
  /** Schema defaults — an untouched sub-field must author exactly these. */
39127
39340
  var NC_AUDIO_DEFAULTS = {
39128
39341
  hitPercent: 60,
@@ -5418,6 +5418,86 @@ var ZodIssueCode = {
5418
5418
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
5419
5419
  var ZodFirstPartyTypeKind;
5420
5420
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5421
+ //#endregion
5422
+ //#region ../types/dist/sleep-BnujYGPe.mjs
5423
+ /**
5424
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
5425
+ * window to float samples (D455).
5426
+ *
5427
+ * ## Why a format at all
5428
+ *
5429
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
5430
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
5431
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
5432
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
5433
+ * the plane carried four times the source. The plane crosses hub-main twice on
5434
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
5435
+ *
5436
+ * So the plane carries the source BYTES too, and whoever needs floats expands
5437
+ * them where it needs them. That is the same argument D450 made for the rate,
5438
+ * one step further along the same wire.
5439
+ *
5440
+ * ## Why the expansion lives here
5441
+ *
5442
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
5443
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
5444
+ * `AudioChunkPlane` expands per subscription) and
5445
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
5446
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
5447
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
5448
+ * into their own dist (`self-contained` externals), so this travels with a
5449
+ * `camstack deploy` and needs no published server.
5450
+ *
5451
+ * A second μ-law table anywhere else is the defect this module exists to
5452
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
5453
+ * direction for the WebRTC egress — a different transform, not a copy.)
5454
+ *
5455
+ * ## Absent means f32le
5456
+ *
5457
+ * `format` is optional on the wire and its absence means `f32le` — today's
5458
+ * bytes, byte for byte. A peer that never heard of the field is served what it
5459
+ * has always been served, because the broker only emits a coded window to a
5460
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
5461
+ * That is the D448 `rawForward` negotiation, and it is what makes this
5462
+ * deployable one addon at a time across three nodes.
5463
+ */
5464
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
5465
+ var AUDIO_CHUNK_FORMATS = [
5466
+ "f32le",
5467
+ "pcmu",
5468
+ "pcma"
5469
+ ];
5470
+ /**
5471
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
5472
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
5473
+ *
5474
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
5475
+ * it buffers the coded bytes and the plane's consumers expand.
5476
+ */
5477
+ function buildUlawTable() {
5478
+ const table = new Float32Array(256);
5479
+ for (let i = 0; i < 256; i++) {
5480
+ const complemented = ~i & 255;
5481
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
5482
+ const exponent = complemented >> 4 & 7;
5483
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
5484
+ }
5485
+ return table;
5486
+ }
5487
+ /** Build the A-law decode table (ITU-T G.711). */
5488
+ function buildAlawTable() {
5489
+ const table = new Float32Array(256);
5490
+ for (let i = 0; i < 256; i++) {
5491
+ const xored = i ^ 85;
5492
+ const sign = (xored & 128) !== 0 ? 1 : -1;
5493
+ const exponent = xored >> 4 & 7;
5494
+ const mantissa = xored & 15;
5495
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
5496
+ }
5497
+ return table;
5498
+ }
5499
+ buildUlawTable();
5500
+ buildAlawTable();
5421
5501
  Object.fromEntries([
5422
5502
  {
5423
5503
  id: "overview",
@@ -6710,11 +6790,20 @@ var SubscribeFramesResultSchema = object({
6710
6790
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
6711
6791
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
6712
6792
  */
6793
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
6713
6794
  var DecodedAudioChunkSchema = object({
6714
6795
  data: _instanceof(Uint8Array),
6715
6796
  sampleRate: number().int().positive(),
6716
6797
  channels: number().int().positive(),
6717
- timestamp: number()
6798
+ timestamp: number(),
6799
+ /**
6800
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
6801
+ * byte, for any peer that never heard of this field. A coded window
6802
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
6803
+ * subscription that DECLARED it accepts one, so absence can never mean
6804
+ * "coded bytes a consumer will read as floats" (D455).
6805
+ */
6806
+ format: AudioChunkFormatSchema.optional()
6718
6807
  });
6719
6808
  /**
6720
6809
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -6726,7 +6815,18 @@ var DecodedAudioChunkSchema = object({
6726
6815
  var SubscribeAudioChunksInputSchema = object({
6727
6816
  brokerId: string(),
6728
6817
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
6729
- tag: string().optional()
6818
+ tag: string().optional(),
6819
+ /**
6820
+ * Byte formats this subscriber can READ, best first. The broker serves the
6821
+ * chunk's own format when it is in this list and expands to `f32le`
6822
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
6823
+ *
6824
+ * Absent (or without the source format) means `f32le` — the behaviour every
6825
+ * subscriber had before D455, unchanged. This is the negotiation half of
6826
+ * the source-bytes lever: it is what lets the broker and its consumers
6827
+ * deploy one at a time across three nodes.
6828
+ */
6829
+ accept: array(AudioChunkFormatSchema).readonly().optional()
6730
6830
  });
6731
6831
  /** Result of `stream-broker.subscribeAudioChunks`. */
6732
6832
  var SubscribeAudioChunksResultSchema = object({
@@ -11349,6 +11449,51 @@ var AudioAnalysisSettingsSchema = object({
11349
11449
  minConfidence: number().min(0).max(1).default(.3),
11350
11450
  allowedClasses: array(string()).default([])
11351
11451
  });
11452
+ /**
11453
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
11454
+ *
11455
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
11456
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
11457
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
11458
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
11459
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
11460
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
11461
+ * way to the one expansion that feeds the model.
11462
+ *
11463
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
11464
+ * window, the per-device node assignment, the settings read) and therefore
11465
+ * still owns the attach/detach pair. It no longer owns the bytes.
11466
+ */
11467
+ var AudioAttachDeviceInputSchema = object({
11468
+ deviceId: number(),
11469
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
11470
+ brokerId: string(),
11471
+ /**
11472
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
11473
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
11474
+ * the orchestrator's poller pinned them before the move.
11475
+ */
11476
+ ingestNodeId: string(),
11477
+ /**
11478
+ * Resolved once by the orchestrator at attach time, exactly as it was read
11479
+ * once per subscription before D461. The analyzer does NOT re-resolve per
11480
+ * window: a settings change re-attaches, which is what always happened.
11481
+ */
11482
+ settings: AudioAnalysisSettingsSchema
11483
+ });
11484
+ var AudioAttachDeviceResultSchema = object({
11485
+ /** False only when the analyzer is shutting down and refused to attach. */
11486
+ attached: boolean(),
11487
+ /**
11488
+ * True when the attachment replaced a live one for the same device. An
11489
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
11490
+ * double the broker's fanout and neither would know about the other.
11491
+ */
11492
+ replaced: boolean()
11493
+ });
11494
+ var AudioDetachDeviceResultSchema = object({
11495
+ /** False when no attachment existed — detach is idempotent. */
11496
+ detached: boolean() });
11352
11497
  var AudioClassificationResultSchema = object({
11353
11498
  labels: array(AudioClassificationLabelSchema).readonly(),
11354
11499
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -11357,7 +11502,7 @@ var AudioClassificationResultSchema = object({
11357
11502
  method(object({
11358
11503
  chunk: AudioChunkInputSchema,
11359
11504
  settings: AudioAnalysisSettingsSchema
11360
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
11505
+ }), 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() }), {
11361
11506
  kind: "mutation",
11362
11507
  auth: "admin"
11363
11508
  });
@@ -25584,8 +25729,8 @@ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly
25584
25729
  *
25585
25730
  * An **empty array reads NOTHING** — `[]` is an empty page, never
25586
25731
  * "every camera". A request for no devices is a request, not an
25587
- * omission; same contract as `deviceManager.listFleet` and
25588
- * `pipelineAnalytics.listRecentTracks`.
25732
+ * omission; same contract as `deviceManager.listAll`'s `deviceIds`
25733
+ * and `pipelineAnalytics.listRecentTracks`.
25589
25734
  *
25590
25735
  * Absent (`undefined`) is the omission, and keeps the cluster-wide view.
25591
25736
  */
@@ -31406,12 +31551,24 @@ Object.freeze({
31406
31551
  addonId: null,
31407
31552
  access: "create"
31408
31553
  },
31554
+ "audioAnalyzer.attachDevice": {
31555
+ capName: "audio-analyzer",
31556
+ capScope: "system",
31557
+ addonId: null,
31558
+ access: "create"
31559
+ },
31409
31560
  "audioAnalyzer.classify": {
31410
31561
  capName: "audio-analyzer",
31411
31562
  capScope: "system",
31412
31563
  addonId: null,
31413
31564
  access: "view"
31414
31565
  },
31566
+ "audioAnalyzer.detachDevice": {
31567
+ capName: "audio-analyzer",
31568
+ capScope: "system",
31569
+ addonId: null,
31570
+ access: "create"
31571
+ },
31415
31572
  "audioAnalyzer.dispose": {
31416
31573
  capName: "audio-analyzer",
31417
31574
  capScope: "system",
@@ -37255,11 +37412,21 @@ Object.freeze({
37255
37412
  form: "single",
37256
37413
  optional: false
37257
37414
  }],
37415
+ "audioAnalyzer.attachDevice": [{
37416
+ name: "deviceId",
37417
+ form: "single",
37418
+ optional: false
37419
+ }],
37258
37420
  "audioAnalyzer.classify": [{
37259
37421
  name: "deviceId",
37260
37422
  form: "single",
37261
37423
  optional: true
37262
37424
  }],
37425
+ "audioAnalyzer.detachDevice": [{
37426
+ name: "deviceId",
37427
+ form: "single",
37428
+ optional: false
37429
+ }],
37263
37430
  "audioMetrics.getCurrentSnapshot": [{
37264
37431
  name: "deviceId",
37265
37432
  form: "single",
@@ -39111,6 +39278,52 @@ Object.freeze({
39111
39278
  "network-access": "ingress",
39112
39279
  "smtp-provider": "email"
39113
39280
  });
39281
+ var G711_SCALE_CORRECTION_DB = {
39282
+ PCMU: 20 * Math.log10(4),
39283
+ PCMA: 20 * Math.log10(8)
39284
+ };
39285
+ /**
39286
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
39287
+ * same intent on the ITU-T scale (D460).
39288
+ *
39289
+ * ## When this applies, and when it is the wrong thing to reach for
39290
+ *
39291
+ * An absolute-dBFS number in this repo is one of two things, and only one of
39292
+ * them converts:
39293
+ *
39294
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
39295
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
39296
+ * after. The defect was never in the number; it was that 19 of this hub's
39297
+ * 25 cameras did not obey it. Converting such a number takes something
39298
+ * correct and makes it wrong, in order to preserve a bug.
39299
+ * - **A measurement taken through the old decoder** — a value someone read
39300
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
39301
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
39302
+ * louder. That is what this function is for.
39303
+ *
39304
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
39305
+ * and it cannot be answered from the number. It is answered by the comment the
39306
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
39307
+ * mandatory.
39308
+ *
39309
+ * ## Why a function and not a typed-in number
39310
+ *
39311
+ * `-55 + 12.04` written into a source file is, six months later, completely
39312
+ * indistinguishable from a threshold somebody simply preferred. Calling this
39313
+ * keeps the derivation, the law, and the original measurement all visible at
39314
+ * the call site, so a future reader can disagree with the *premise* instead of
39315
+ * having to reverse-engineer the sum.
39316
+ *
39317
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
39318
+ * it is declared. It must never be applied to a live sample or a stored
39319
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
39320
+ * adjusting numbers the decoder already got right is the original defect with
39321
+ * an extra place to argue with (D459).
39322
+ */
39323
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
39324
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
39325
+ }
39326
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
39114
39327
  /** Schema defaults — an untouched sub-field must author exactly these. */
39115
39328
  var NC_AUDIO_DEFAULTS = {
39116
39329
  hitPercent: 60,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-export-hap",
3
- "version": "1.2.105",
3
+ "version": "1.2.107",
4
4
  "description": "HomeKit (HAP) exporter for CamStack devices. Publishes each exposed device as its own HomeKit accessory: cameras and doorbells with SRTP streaming, HomeKit Secure Video, motion, two-way audio, PTZ and battery; switches, lights, locks and sensors through a capability→service table.",
5
5
  "keywords": [
6
6
  "camstack",