@camstack/addon-provider-rtsp 1.2.94 → 1.2.96

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
@@ -5369,6 +5369,86 @@ var ZodIssueCode = {
5369
5369
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
5370
5370
  var ZodFirstPartyTypeKind;
5371
5371
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5372
+ //#endregion
5373
+ //#region ../types/dist/sleep-BnujYGPe.mjs
5374
+ /**
5375
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
5376
+ * window to float samples (D455).
5377
+ *
5378
+ * ## Why a format at all
5379
+ *
5380
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
5381
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
5382
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
5383
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
5384
+ * the plane carried four times the source. The plane crosses hub-main twice on
5385
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
5386
+ *
5387
+ * So the plane carries the source BYTES too, and whoever needs floats expands
5388
+ * them where it needs them. That is the same argument D450 made for the rate,
5389
+ * one step further along the same wire.
5390
+ *
5391
+ * ## Why the expansion lives here
5392
+ *
5393
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
5394
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
5395
+ * `AudioChunkPlane` expands per subscription) and
5396
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
5397
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
5398
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
5399
+ * into their own dist (`self-contained` externals), so this travels with a
5400
+ * `camstack deploy` and needs no published server.
5401
+ *
5402
+ * A second μ-law table anywhere else is the defect this module exists to
5403
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
5404
+ * direction for the WebRTC egress — a different transform, not a copy.)
5405
+ *
5406
+ * ## Absent means f32le
5407
+ *
5408
+ * `format` is optional on the wire and its absence means `f32le` — today's
5409
+ * bytes, byte for byte. A peer that never heard of the field is served what it
5410
+ * has always been served, because the broker only emits a coded window to a
5411
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
5412
+ * That is the D448 `rawForward` negotiation, and it is what makes this
5413
+ * deployable one addon at a time across three nodes.
5414
+ */
5415
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
5416
+ var AUDIO_CHUNK_FORMATS = [
5417
+ "f32le",
5418
+ "pcmu",
5419
+ "pcma"
5420
+ ];
5421
+ /**
5422
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
5423
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
5424
+ *
5425
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
5426
+ * it buffers the coded bytes and the plane's consumers expand.
5427
+ */
5428
+ function buildUlawTable() {
5429
+ const table = new Float32Array(256);
5430
+ for (let i = 0; i < 256; i++) {
5431
+ const complemented = ~i & 255;
5432
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
5433
+ const exponent = complemented >> 4 & 7;
5434
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
5435
+ }
5436
+ return table;
5437
+ }
5438
+ /** Build the A-law decode table (ITU-T G.711). */
5439
+ function buildAlawTable() {
5440
+ const table = new Float32Array(256);
5441
+ for (let i = 0; i < 256; i++) {
5442
+ const xored = i ^ 85;
5443
+ const sign = (xored & 128) !== 0 ? 1 : -1;
5444
+ const exponent = xored >> 4 & 7;
5445
+ const mantissa = xored & 15;
5446
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
5447
+ }
5448
+ return table;
5449
+ }
5450
+ buildUlawTable();
5451
+ buildAlawTable();
5372
5452
  Object.fromEntries([
5373
5453
  {
5374
5454
  id: "overview",
@@ -6661,11 +6741,20 @@ var SubscribeFramesResultSchema = object({
6661
6741
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
6662
6742
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
6663
6743
  */
6744
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
6664
6745
  var DecodedAudioChunkSchema = object({
6665
6746
  data: _instanceof(Uint8Array),
6666
6747
  sampleRate: number().int().positive(),
6667
6748
  channels: number().int().positive(),
6668
- timestamp: number()
6749
+ timestamp: number(),
6750
+ /**
6751
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
6752
+ * byte, for any peer that never heard of this field. A coded window
6753
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
6754
+ * subscription that DECLARED it accepts one, so absence can never mean
6755
+ * "coded bytes a consumer will read as floats" (D455).
6756
+ */
6757
+ format: AudioChunkFormatSchema.optional()
6669
6758
  });
6670
6759
  /**
6671
6760
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -6677,7 +6766,18 @@ var DecodedAudioChunkSchema = object({
6677
6766
  var SubscribeAudioChunksInputSchema = object({
6678
6767
  brokerId: string(),
6679
6768
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
6680
- tag: string().optional()
6769
+ tag: string().optional(),
6770
+ /**
6771
+ * Byte formats this subscriber can READ, best first. The broker serves the
6772
+ * chunk's own format when it is in this list and expands to `f32le`
6773
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
6774
+ *
6775
+ * Absent (or without the source format) means `f32le` — the behaviour every
6776
+ * subscriber had before D455, unchanged. This is the negotiation half of
6777
+ * the source-bytes lever: it is what lets the broker and its consumers
6778
+ * deploy one at a time across three nodes.
6779
+ */
6780
+ accept: array(AudioChunkFormatSchema).readonly().optional()
6681
6781
  });
6682
6782
  /** Result of `stream-broker.subscribeAudioChunks`. */
6683
6783
  var SubscribeAudioChunksResultSchema = object({
@@ -10697,6 +10797,51 @@ var AudioAnalysisSettingsSchema = object({
10697
10797
  minConfidence: number().min(0).max(1).default(.3),
10698
10798
  allowedClasses: array(string()).default([])
10699
10799
  });
10800
+ /**
10801
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
10802
+ *
10803
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
10804
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
10805
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
10806
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
10807
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
10808
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
10809
+ * way to the one expansion that feeds the model.
10810
+ *
10811
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
10812
+ * window, the per-device node assignment, the settings read) and therefore
10813
+ * still owns the attach/detach pair. It no longer owns the bytes.
10814
+ */
10815
+ var AudioAttachDeviceInputSchema = object({
10816
+ deviceId: number(),
10817
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
10818
+ brokerId: string(),
10819
+ /**
10820
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
10821
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
10822
+ * the orchestrator's poller pinned them before the move.
10823
+ */
10824
+ ingestNodeId: string(),
10825
+ /**
10826
+ * Resolved once by the orchestrator at attach time, exactly as it was read
10827
+ * once per subscription before D461. The analyzer does NOT re-resolve per
10828
+ * window: a settings change re-attaches, which is what always happened.
10829
+ */
10830
+ settings: AudioAnalysisSettingsSchema
10831
+ });
10832
+ var AudioAttachDeviceResultSchema = object({
10833
+ /** False only when the analyzer is shutting down and refused to attach. */
10834
+ attached: boolean(),
10835
+ /**
10836
+ * True when the attachment replaced a live one for the same device. An
10837
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
10838
+ * double the broker's fanout and neither would know about the other.
10839
+ */
10840
+ replaced: boolean()
10841
+ });
10842
+ var AudioDetachDeviceResultSchema = object({
10843
+ /** False when no attachment existed — detach is idempotent. */
10844
+ detached: boolean() });
10700
10845
  var AudioClassificationResultSchema = object({
10701
10846
  labels: array(AudioClassificationLabelSchema).readonly(),
10702
10847
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -10705,7 +10850,7 @@ var AudioClassificationResultSchema = object({
10705
10850
  method(object({
10706
10851
  chunk: AudioChunkInputSchema,
10707
10852
  settings: AudioAnalysisSettingsSchema
10708
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
10853
+ }), 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() }), {
10709
10854
  kind: "mutation",
10710
10855
  auth: "admin"
10711
10856
  });
@@ -26041,8 +26186,8 @@ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly
26041
26186
  *
26042
26187
  * An **empty array reads NOTHING** — `[]` is an empty page, never
26043
26188
  * "every camera". A request for no devices is a request, not an
26044
- * omission; same contract as `deviceManager.listFleet` and
26045
- * `pipelineAnalytics.listRecentTracks`.
26189
+ * omission; same contract as `deviceManager.listAll`'s `deviceIds`
26190
+ * and `pipelineAnalytics.listRecentTracks`.
26046
26191
  *
26047
26192
  * Absent (`undefined`) is the omission, and keeps the cluster-wide view.
26048
26193
  */
@@ -35142,12 +35287,24 @@ Object.freeze({
35142
35287
  addonId: null,
35143
35288
  access: "create"
35144
35289
  },
35290
+ "audioAnalyzer.attachDevice": {
35291
+ capName: "audio-analyzer",
35292
+ capScope: "system",
35293
+ addonId: null,
35294
+ access: "create"
35295
+ },
35145
35296
  "audioAnalyzer.classify": {
35146
35297
  capName: "audio-analyzer",
35147
35298
  capScope: "system",
35148
35299
  addonId: null,
35149
35300
  access: "view"
35150
35301
  },
35302
+ "audioAnalyzer.detachDevice": {
35303
+ capName: "audio-analyzer",
35304
+ capScope: "system",
35305
+ addonId: null,
35306
+ access: "create"
35307
+ },
35151
35308
  "audioAnalyzer.dispose": {
35152
35309
  capName: "audio-analyzer",
35153
35310
  capScope: "system",
@@ -40991,11 +41148,21 @@ Object.freeze({
40991
41148
  form: "single",
40992
41149
  optional: false
40993
41150
  }],
41151
+ "audioAnalyzer.attachDevice": [{
41152
+ name: "deviceId",
41153
+ form: "single",
41154
+ optional: false
41155
+ }],
40994
41156
  "audioAnalyzer.classify": [{
40995
41157
  name: "deviceId",
40996
41158
  form: "single",
40997
41159
  optional: true
40998
41160
  }],
41161
+ "audioAnalyzer.detachDevice": [{
41162
+ name: "deviceId",
41163
+ form: "single",
41164
+ optional: false
41165
+ }],
40999
41166
  "audioMetrics.getCurrentSnapshot": [{
41000
41167
  name: "deviceId",
41001
41168
  form: "single",
@@ -42847,6 +43014,52 @@ Object.freeze({
42847
43014
  "network-access": "ingress",
42848
43015
  "smtp-provider": "email"
42849
43016
  });
43017
+ var G711_SCALE_CORRECTION_DB = {
43018
+ PCMU: 20 * Math.log10(4),
43019
+ PCMA: 20 * Math.log10(8)
43020
+ };
43021
+ /**
43022
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
43023
+ * same intent on the ITU-T scale (D460).
43024
+ *
43025
+ * ## When this applies, and when it is the wrong thing to reach for
43026
+ *
43027
+ * An absolute-dBFS number in this repo is one of two things, and only one of
43028
+ * them converts:
43029
+ *
43030
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
43031
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
43032
+ * after. The defect was never in the number; it was that 19 of this hub's
43033
+ * 25 cameras did not obey it. Converting such a number takes something
43034
+ * correct and makes it wrong, in order to preserve a bug.
43035
+ * - **A measurement taken through the old decoder** — a value someone read
43036
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
43037
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
43038
+ * louder. That is what this function is for.
43039
+ *
43040
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
43041
+ * and it cannot be answered from the number. It is answered by the comment the
43042
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
43043
+ * mandatory.
43044
+ *
43045
+ * ## Why a function and not a typed-in number
43046
+ *
43047
+ * `-55 + 12.04` written into a source file is, six months later, completely
43048
+ * indistinguishable from a threshold somebody simply preferred. Calling this
43049
+ * keeps the derivation, the law, and the original measurement all visible at
43050
+ * the call site, so a future reader can disagree with the *premise* instead of
43051
+ * having to reverse-engineer the sum.
43052
+ *
43053
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
43054
+ * it is declared. It must never be applied to a live sample or a stored
43055
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
43056
+ * adjusting numbers the decoder already got right is the original defect with
43057
+ * an extra place to argue with (D459).
43058
+ */
43059
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
43060
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
43061
+ }
43062
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
42850
43063
  /** Schema defaults — an untouched sub-field must author exactly these. */
42851
43064
  var NC_AUDIO_DEFAULTS = {
42852
43065
  hitPercent: 60,
package/dist/addon.mjs CHANGED
@@ -5345,6 +5345,86 @@ var ZodIssueCode = {
5345
5345
  /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
5346
5346
  var ZodFirstPartyTypeKind;
5347
5347
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5348
+ //#endregion
5349
+ //#region ../types/dist/sleep-BnujYGPe.mjs
5350
+ /**
5351
+ * The audio chunk plane's byte format, and the ONE expansion from a coded
5352
+ * window to float samples (D455).
5353
+ *
5354
+ * ## Why a format at all
5355
+ *
5356
+ * D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
5357
+ * RATE, and the one consumer that needs 16 kHz resamples next to the model.
5358
+ * It left the FORMAT alone — the broker still turned each G.711 byte into a
5359
+ * 4-byte f32le sample before the bytes entered the transport, so every leg of
5360
+ * the plane carried four times the source. The plane crosses hub-main twice on
5361
+ * the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
5362
+ *
5363
+ * So the plane carries the source BYTES too, and whoever needs floats expands
5364
+ * them where it needs them. That is the same argument D450 made for the rate,
5365
+ * one step further along the same wire.
5366
+ *
5367
+ * ## Why the expansion lives here
5368
+ *
5369
+ * Two packages need it and they must never disagree: `addon-pipeline`'s broker
5370
+ * (which still has to serve a subscriber that did NOT ask for coded bytes —
5371
+ * `AudioChunkPlane` expands per subscription) and
5372
+ * `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
5373
+ * f32le window to the analyzer cap, whose `AudioChunkInput` contract is
5374
+ * unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
5375
+ * into their own dist (`self-contained` externals), so this travels with a
5376
+ * `camstack deploy` and needs no published server.
5377
+ *
5378
+ * A second μ-law table anywhere else is the defect this module exists to
5379
+ * prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
5380
+ * direction for the WebRTC egress — a different transform, not a copy.)
5381
+ *
5382
+ * ## Absent means f32le
5383
+ *
5384
+ * `format` is optional on the wire and its absence means `f32le` — today's
5385
+ * bytes, byte for byte. A peer that never heard of the field is served what it
5386
+ * has always been served, because the broker only emits a coded window to a
5387
+ * subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
5388
+ * That is the D448 `rawForward` negotiation, and it is what makes this
5389
+ * deployable one addon at a time across three nodes.
5390
+ */
5391
+ /** Every byte format the audio chunk plane can carry. `f32le` is the default. */
5392
+ var AUDIO_CHUNK_FORMATS = [
5393
+ "f32le",
5394
+ "pcmu",
5395
+ "pcma"
5396
+ ];
5397
+ /**
5398
+ * Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
5399
+ * to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
5400
+ *
5401
+ * Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
5402
+ * it buffers the coded bytes and the plane's consumers expand.
5403
+ */
5404
+ function buildUlawTable() {
5405
+ const table = new Float32Array(256);
5406
+ for (let i = 0; i < 256; i++) {
5407
+ const complemented = ~i & 255;
5408
+ const sign = (complemented & 128) !== 0 ? -1 : 1;
5409
+ const exponent = complemented >> 4 & 7;
5410
+ table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
5411
+ }
5412
+ return table;
5413
+ }
5414
+ /** Build the A-law decode table (ITU-T G.711). */
5415
+ function buildAlawTable() {
5416
+ const table = new Float32Array(256);
5417
+ for (let i = 0; i < 256; i++) {
5418
+ const xored = i ^ 85;
5419
+ const sign = (xored & 128) !== 0 ? 1 : -1;
5420
+ const exponent = xored >> 4 & 7;
5421
+ const mantissa = xored & 15;
5422
+ table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
5423
+ }
5424
+ return table;
5425
+ }
5426
+ buildUlawTable();
5427
+ buildAlawTable();
5348
5428
  Object.fromEntries([
5349
5429
  {
5350
5430
  id: "overview",
@@ -6637,11 +6717,20 @@ var SubscribeFramesResultSchema = object({
6637
6717
  * (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
6638
6718
  * / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
6639
6719
  */
6720
+ var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
6640
6721
  var DecodedAudioChunkSchema = object({
6641
6722
  data: _instanceof(Uint8Array),
6642
6723
  sampleRate: number().int().positive(),
6643
6724
  channels: number().int().positive(),
6644
- timestamp: number()
6725
+ timestamp: number(),
6726
+ /**
6727
+ * Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
6728
+ * byte, for any peer that never heard of this field. A coded window
6729
+ * (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
6730
+ * subscription that DECLARED it accepts one, so absence can never mean
6731
+ * "coded bytes a consumer will read as floats" (D455).
6732
+ */
6733
+ format: AudioChunkFormatSchema.optional()
6645
6734
  });
6646
6735
  /**
6647
6736
  * Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
@@ -6653,7 +6742,18 @@ var DecodedAudioChunkSchema = object({
6653
6742
  var SubscribeAudioChunksInputSchema = object({
6654
6743
  brokerId: string(),
6655
6744
  /** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
6656
- tag: string().optional()
6745
+ tag: string().optional(),
6746
+ /**
6747
+ * Byte formats this subscriber can READ, best first. The broker serves the
6748
+ * chunk's own format when it is in this list and expands to `f32le`
6749
+ * otherwise, so a subscriber is never handed bytes it cannot interpret.
6750
+ *
6751
+ * Absent (or without the source format) means `f32le` — the behaviour every
6752
+ * subscriber had before D455, unchanged. This is the negotiation half of
6753
+ * the source-bytes lever: it is what lets the broker and its consumers
6754
+ * deploy one at a time across three nodes.
6755
+ */
6756
+ accept: array(AudioChunkFormatSchema).readonly().optional()
6657
6757
  });
6658
6758
  /** Result of `stream-broker.subscribeAudioChunks`. */
6659
6759
  var SubscribeAudioChunksResultSchema = object({
@@ -10673,6 +10773,51 @@ var AudioAnalysisSettingsSchema = object({
10673
10773
  minConfidence: number().min(0).max(1).default(.3),
10674
10774
  allowedClasses: array(string()).default([])
10675
10775
  });
10776
+ /**
10777
+ * `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
10778
+ *
10779
+ * Until D461 the orchestrator drained the broker's chunk plane, accumulated
10780
+ * ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
10781
+ * nor consumed the audio: the PCM crossed hub-main twice for a process that
10782
+ * only buffered it. `attachDevice` inverts the direction — the analyzer opens
10783
+ * its own `subscribeAudioChunks` against the broker and the subscriber IS the
10784
+ * decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
10785
+ * way to the one expansion that feeds the model.
10786
+ *
10787
+ * The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
10788
+ * window, the per-device node assignment, the settings read) and therefore
10789
+ * still owns the attach/detach pair. It no longer owns the bytes.
10790
+ */
10791
+ var AudioAttachDeviceInputSchema = object({
10792
+ deviceId: number(),
10793
+ /** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
10794
+ brokerId: string(),
10795
+ /**
10796
+ * `clusterRoles.ingestNode` — the node whose broker owns the source dial.
10797
+ * Every `streamBroker` call the attachment makes is pinned to it, exactly as
10798
+ * the orchestrator's poller pinned them before the move.
10799
+ */
10800
+ ingestNodeId: string(),
10801
+ /**
10802
+ * Resolved once by the orchestrator at attach time, exactly as it was read
10803
+ * once per subscription before D461. The analyzer does NOT re-resolve per
10804
+ * window: a settings change re-attaches, which is what always happened.
10805
+ */
10806
+ settings: AudioAnalysisSettingsSchema
10807
+ });
10808
+ var AudioAttachDeviceResultSchema = object({
10809
+ /** False only when the analyzer is shutting down and refused to attach. */
10810
+ attached: boolean(),
10811
+ /**
10812
+ * True when the attachment replaced a live one for the same device. An
10813
+ * attach is idempotent by REPLACEMENT — two pollers on one camera would
10814
+ * double the broker's fanout and neither would know about the other.
10815
+ */
10816
+ replaced: boolean()
10817
+ });
10818
+ var AudioDetachDeviceResultSchema = object({
10819
+ /** False when no attachment existed — detach is idempotent. */
10820
+ detached: boolean() });
10676
10821
  var AudioClassificationResultSchema = object({
10677
10822
  labels: array(AudioClassificationLabelSchema).readonly(),
10678
10823
  rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
@@ -10681,7 +10826,7 @@ var AudioClassificationResultSchema = object({
10681
10826
  method(object({
10682
10827
  chunk: AudioChunkInputSchema,
10683
10828
  settings: AudioAnalysisSettingsSchema
10684
- }), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
10829
+ }), 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() }), {
10685
10830
  kind: "mutation",
10686
10831
  auth: "admin"
10687
10832
  });
@@ -26017,8 +26162,8 @@ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly
26017
26162
  *
26018
26163
  * An **empty array reads NOTHING** — `[]` is an empty page, never
26019
26164
  * "every camera". A request for no devices is a request, not an
26020
- * omission; same contract as `deviceManager.listFleet` and
26021
- * `pipelineAnalytics.listRecentTracks`.
26165
+ * omission; same contract as `deviceManager.listAll`'s `deviceIds`
26166
+ * and `pipelineAnalytics.listRecentTracks`.
26022
26167
  *
26023
26168
  * Absent (`undefined`) is the omission, and keeps the cluster-wide view.
26024
26169
  */
@@ -35118,12 +35263,24 @@ Object.freeze({
35118
35263
  addonId: null,
35119
35264
  access: "create"
35120
35265
  },
35266
+ "audioAnalyzer.attachDevice": {
35267
+ capName: "audio-analyzer",
35268
+ capScope: "system",
35269
+ addonId: null,
35270
+ access: "create"
35271
+ },
35121
35272
  "audioAnalyzer.classify": {
35122
35273
  capName: "audio-analyzer",
35123
35274
  capScope: "system",
35124
35275
  addonId: null,
35125
35276
  access: "view"
35126
35277
  },
35278
+ "audioAnalyzer.detachDevice": {
35279
+ capName: "audio-analyzer",
35280
+ capScope: "system",
35281
+ addonId: null,
35282
+ access: "create"
35283
+ },
35127
35284
  "audioAnalyzer.dispose": {
35128
35285
  capName: "audio-analyzer",
35129
35286
  capScope: "system",
@@ -40967,11 +41124,21 @@ Object.freeze({
40967
41124
  form: "single",
40968
41125
  optional: false
40969
41126
  }],
41127
+ "audioAnalyzer.attachDevice": [{
41128
+ name: "deviceId",
41129
+ form: "single",
41130
+ optional: false
41131
+ }],
40970
41132
  "audioAnalyzer.classify": [{
40971
41133
  name: "deviceId",
40972
41134
  form: "single",
40973
41135
  optional: true
40974
41136
  }],
41137
+ "audioAnalyzer.detachDevice": [{
41138
+ name: "deviceId",
41139
+ form: "single",
41140
+ optional: false
41141
+ }],
40975
41142
  "audioMetrics.getCurrentSnapshot": [{
40976
41143
  name: "deviceId",
40977
41144
  form: "single",
@@ -42823,6 +42990,52 @@ Object.freeze({
42823
42990
  "network-access": "ingress",
42824
42991
  "smtp-provider": "email"
42825
42992
  });
42993
+ var G711_SCALE_CORRECTION_DB = {
42994
+ PCMU: 20 * Math.log10(4),
42995
+ PCMA: 20 * Math.log10(8)
42996
+ };
42997
+ /**
42998
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
42999
+ * same intent on the ITU-T scale (D460).
43000
+ *
43001
+ * ## When this applies, and when it is the wrong thing to reach for
43002
+ *
43003
+ * An absolute-dBFS number in this repo is one of two things, and only one of
43004
+ * them converts:
43005
+ *
43006
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
43007
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
43008
+ * after. The defect was never in the number; it was that 19 of this hub's
43009
+ * 25 cameras did not obey it. Converting such a number takes something
43010
+ * correct and makes it wrong, in order to preserve a bug.
43011
+ * - **A measurement taken through the old decoder** — a value someone read
43012
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
43013
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
43014
+ * louder. That is what this function is for.
43015
+ *
43016
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
43017
+ * and it cannot be answered from the number. It is answered by the comment the
43018
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
43019
+ * mandatory.
43020
+ *
43021
+ * ## Why a function and not a typed-in number
43022
+ *
43023
+ * `-55 + 12.04` written into a source file is, six months later, completely
43024
+ * indistinguishable from a threshold somebody simply preferred. Calling this
43025
+ * keeps the derivation, the law, and the original measurement all visible at
43026
+ * the call site, so a future reader can disagree with the *premise* instead of
43027
+ * having to reverse-engineer the sum.
43028
+ *
43029
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
43030
+ * it is declared. It must never be applied to a live sample or a stored
43031
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
43032
+ * adjusting numbers the decoder already got right is the original defect with
43033
+ * an extra place to argue with (D459).
43034
+ */
43035
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
43036
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
43037
+ }
43038
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
42826
43039
  /** Schema defaults — an untouched sub-field must author exactly these. */
42827
43040
  var NC_AUDIO_DEFAULTS = {
42828
43041
  hitPercent: 60,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-rtsp",
3
- "version": "1.2.94",
3
+ "version": "1.2.96",
4
4
  "description": "Generic RTSP camera device provider addon for CamStack",
5
5
  "keywords": [
6
6
  "camstack",