@camstack/addon-provider-rtsp 1.2.95 → 1.2.97

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
  });
@@ -20609,6 +20754,14 @@ var NativeCropResultSchema = object({
20609
20754
  * set `encodeJpeg: true`; `bytes` is then absent.
20610
20755
  */
20611
20756
  jpeg: string().optional(),
20757
+ /**
20758
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
20759
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
20760
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
20761
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
20762
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
20763
+ */
20764
+ jpegBytes: _instanceof(Uint8Array).optional(),
20612
20765
  width: number().int().positive(),
20613
20766
  height: number().int().positive(),
20614
20767
  /**
@@ -20675,7 +20828,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
20675
20828
  })]);
20676
20829
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
20677
20830
  var ParkedTrackFrameSchema = object({
20678
- jpeg: string(),
20831
+ /**
20832
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
20833
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
20834
+ * Exactly one of the two is present.
20835
+ */
20836
+ jpeg: string().optional(),
20837
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
20838
+ jpegBytes: _instanceof(Uint8Array).optional(),
20679
20839
  width: number().int().positive(),
20680
20840
  height: number().int().positive(),
20681
20841
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21262,6 +21422,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21262
21422
  bbox: NativeCropBboxSchema,
21263
21423
  maxWidth: number().int().positive().optional(),
21264
21424
  /**
21425
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21426
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21427
+ * wire — never assume consent: a pre-D462 caller parses the field as
21428
+ * base64 and bytes would decode to garbage rather than fail.
21429
+ */
21430
+ acceptJpegBytes: boolean().optional(),
21431
+ /**
21265
21432
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21266
21433
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21267
21434
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21329,7 +21496,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21329
21496
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21330
21497
  deviceId: number(),
21331
21498
  trackId: string(),
21332
- kind: ParkedFrameKindSchema
21499
+ kind: ParkedFrameKindSchema,
21500
+ /**
21501
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21502
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21503
+ * wire — never assume consent: a pre-D462 caller parses the field as
21504
+ * base64 and bytes would decode to garbage rather than fail.
21505
+ */
21506
+ acceptJpegBytes: boolean().optional()
21333
21507
  }), ParkedTrackFrameSchema.nullable()), method(object({
21334
21508
  deviceId: number(),
21335
21509
  trackId: string()
@@ -35142,12 +35316,24 @@ Object.freeze({
35142
35316
  addonId: null,
35143
35317
  access: "create"
35144
35318
  },
35319
+ "audioAnalyzer.attachDevice": {
35320
+ capName: "audio-analyzer",
35321
+ capScope: "system",
35322
+ addonId: null,
35323
+ access: "create"
35324
+ },
35145
35325
  "audioAnalyzer.classify": {
35146
35326
  capName: "audio-analyzer",
35147
35327
  capScope: "system",
35148
35328
  addonId: null,
35149
35329
  access: "view"
35150
35330
  },
35331
+ "audioAnalyzer.detachDevice": {
35332
+ capName: "audio-analyzer",
35333
+ capScope: "system",
35334
+ addonId: null,
35335
+ access: "create"
35336
+ },
35151
35337
  "audioAnalyzer.dispose": {
35152
35338
  capName: "audio-analyzer",
35153
35339
  capScope: "system",
@@ -40991,11 +41177,21 @@ Object.freeze({
40991
41177
  form: "single",
40992
41178
  optional: false
40993
41179
  }],
41180
+ "audioAnalyzer.attachDevice": [{
41181
+ name: "deviceId",
41182
+ form: "single",
41183
+ optional: false
41184
+ }],
40994
41185
  "audioAnalyzer.classify": [{
40995
41186
  name: "deviceId",
40996
41187
  form: "single",
40997
41188
  optional: true
40998
41189
  }],
41190
+ "audioAnalyzer.detachDevice": [{
41191
+ name: "deviceId",
41192
+ form: "single",
41193
+ optional: false
41194
+ }],
40999
41195
  "audioMetrics.getCurrentSnapshot": [{
41000
41196
  name: "deviceId",
41001
41197
  form: "single",
@@ -42847,6 +43043,52 @@ Object.freeze({
42847
43043
  "network-access": "ingress",
42848
43044
  "smtp-provider": "email"
42849
43045
  });
43046
+ var G711_SCALE_CORRECTION_DB = {
43047
+ PCMU: 20 * Math.log10(4),
43048
+ PCMA: 20 * Math.log10(8)
43049
+ };
43050
+ /**
43051
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
43052
+ * same intent on the ITU-T scale (D460).
43053
+ *
43054
+ * ## When this applies, and when it is the wrong thing to reach for
43055
+ *
43056
+ * An absolute-dBFS number in this repo is one of two things, and only one of
43057
+ * them converts:
43058
+ *
43059
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
43060
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
43061
+ * after. The defect was never in the number; it was that 19 of this hub's
43062
+ * 25 cameras did not obey it. Converting such a number takes something
43063
+ * correct and makes it wrong, in order to preserve a bug.
43064
+ * - **A measurement taken through the old decoder** — a value someone read
43065
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
43066
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
43067
+ * louder. That is what this function is for.
43068
+ *
43069
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
43070
+ * and it cannot be answered from the number. It is answered by the comment the
43071
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
43072
+ * mandatory.
43073
+ *
43074
+ * ## Why a function and not a typed-in number
43075
+ *
43076
+ * `-55 + 12.04` written into a source file is, six months later, completely
43077
+ * indistinguishable from a threshold somebody simply preferred. Calling this
43078
+ * keeps the derivation, the law, and the original measurement all visible at
43079
+ * the call site, so a future reader can disagree with the *premise* instead of
43080
+ * having to reverse-engineer the sum.
43081
+ *
43082
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
43083
+ * it is declared. It must never be applied to a live sample or a stored
43084
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
43085
+ * adjusting numbers the decoder already got right is the original defect with
43086
+ * an extra place to argue with (D459).
43087
+ */
43088
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
43089
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
43090
+ }
43091
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
42850
43092
  /** Schema defaults — an untouched sub-field must author exactly these. */
42851
43093
  var NC_AUDIO_DEFAULTS = {
42852
43094
  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
  });
@@ -20585,6 +20730,14 @@ var NativeCropResultSchema = object({
20585
20730
  * set `encodeJpeg: true`; `bytes` is then absent.
20586
20731
  */
20587
20732
  jpeg: string().optional(),
20733
+ /**
20734
+ * The SAME compressed JPEG as `jpeg`, as bytes (D462). Present instead of
20735
+ * `jpeg` when the request set `acceptJpegBytes`; a request that did not gets
20736
+ * `jpeg` exactly as before. MsgPack and the mesh leg both carry binary —
20737
+ * `bytes` above has crossed this boundary as a `Uint8Array` all along — so
20738
+ * base64 was buying nothing but a multi-megabyte string in the relay's heap.
20739
+ */
20740
+ jpegBytes: _instanceof(Uint8Array).optional(),
20588
20741
  width: number().int().positive(),
20589
20742
  height: number().int().positive(),
20590
20743
  /**
@@ -20651,7 +20804,14 @@ var ParkTrackFrameResultSchema = discriminatedUnion("parked", [object({
20651
20804
  })]);
20652
20805
  /** A retrieved parcel — the runner's own JPEG, base64 for the wire. */
20653
20806
  var ParkedTrackFrameSchema = object({
20654
- jpeg: string(),
20807
+ /**
20808
+ * Base64 JPEG — the pre-D462 wire. OPTIONAL since D462: a request that set
20809
+ * `acceptJpegBytes` is answered in `jpegBytes` and this is then absent.
20810
+ * Exactly one of the two is present.
20811
+ */
20812
+ jpeg: string().optional(),
20813
+ /** The same JPEG as bytes, for a caller that declared it reads them (D462). */
20814
+ jpegBytes: _instanceof(Uint8Array).optional(),
20655
20815
  width: number().int().positive(),
20656
20816
  height: number().int().positive(),
20657
20817
  /** The frame instant the parcel shows (the caller's clock, echoed back). */
@@ -21238,6 +21398,13 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21238
21398
  bbox: NativeCropBboxSchema,
21239
21399
  maxWidth: number().int().positive().optional(),
21240
21400
  /**
21401
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21402
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21403
+ * wire — never assume consent: a pre-D462 caller parses the field as
21404
+ * base64 and bytes would decode to garbage rather than fail.
21405
+ */
21406
+ acceptJpegBytes: boolean().optional(),
21407
+ /**
21241
21408
  * When `true`, the runner encodes the resolved crop to JPEG ON THE
21242
21409
  * OWNING NODE and returns it in `jpeg` (base64) INSTEAD of raw `bytes`.
21243
21410
  * Callers set this for CROSS-NODE fetches (`handle.nodeId` is a remote
@@ -21305,7 +21472,14 @@ method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mu
21305
21472
  }), ParkTrackFrameResultSchema, { kind: "mutation" }), method(object({
21306
21473
  deviceId: number(),
21307
21474
  trackId: string(),
21308
- kind: ParkedFrameKindSchema
21475
+ kind: ParkedFrameKindSchema,
21476
+ /**
21477
+ * The caller reads a `Uint8Array` (D462). When set, a JPEG answer comes
21478
+ * back in `jpegBytes` instead of base64 `jpeg`. Absent means the old
21479
+ * wire — never assume consent: a pre-D462 caller parses the field as
21480
+ * base64 and bytes would decode to garbage rather than fail.
21481
+ */
21482
+ acceptJpegBytes: boolean().optional()
21309
21483
  }), ParkedTrackFrameSchema.nullable()), method(object({
21310
21484
  deviceId: number(),
21311
21485
  trackId: string()
@@ -35118,12 +35292,24 @@ Object.freeze({
35118
35292
  addonId: null,
35119
35293
  access: "create"
35120
35294
  },
35295
+ "audioAnalyzer.attachDevice": {
35296
+ capName: "audio-analyzer",
35297
+ capScope: "system",
35298
+ addonId: null,
35299
+ access: "create"
35300
+ },
35121
35301
  "audioAnalyzer.classify": {
35122
35302
  capName: "audio-analyzer",
35123
35303
  capScope: "system",
35124
35304
  addonId: null,
35125
35305
  access: "view"
35126
35306
  },
35307
+ "audioAnalyzer.detachDevice": {
35308
+ capName: "audio-analyzer",
35309
+ capScope: "system",
35310
+ addonId: null,
35311
+ access: "create"
35312
+ },
35127
35313
  "audioAnalyzer.dispose": {
35128
35314
  capName: "audio-analyzer",
35129
35315
  capScope: "system",
@@ -40967,11 +41153,21 @@ Object.freeze({
40967
41153
  form: "single",
40968
41154
  optional: false
40969
41155
  }],
41156
+ "audioAnalyzer.attachDevice": [{
41157
+ name: "deviceId",
41158
+ form: "single",
41159
+ optional: false
41160
+ }],
40970
41161
  "audioAnalyzer.classify": [{
40971
41162
  name: "deviceId",
40972
41163
  form: "single",
40973
41164
  optional: true
40974
41165
  }],
41166
+ "audioAnalyzer.detachDevice": [{
41167
+ name: "deviceId",
41168
+ form: "single",
41169
+ optional: false
41170
+ }],
40975
41171
  "audioMetrics.getCurrentSnapshot": [{
40976
41172
  name: "deviceId",
40977
41173
  form: "single",
@@ -42823,6 +43019,52 @@ Object.freeze({
42823
43019
  "network-access": "ingress",
42824
43020
  "smtp-provider": "email"
42825
43021
  });
43022
+ var G711_SCALE_CORRECTION_DB = {
43023
+ PCMU: 20 * Math.log10(4),
43024
+ PCMA: 20 * Math.log10(8)
43025
+ };
43026
+ /**
43027
+ * Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
43028
+ * same intent on the ITU-T scale (D460).
43029
+ *
43030
+ * ## When this applies, and when it is the wrong thing to reach for
43031
+ *
43032
+ * An absolute-dBFS number in this repo is one of two things, and only one of
43033
+ * them converts:
43034
+ *
43035
+ * - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
43036
+ * is loud". It was true on the ITU-T scale before the epoch and it is true
43037
+ * after. The defect was never in the number; it was that 19 of this hub's
43038
+ * 25 cameras did not obey it. Converting such a number takes something
43039
+ * correct and makes it wrong, in order to preserve a bug.
43040
+ * - **A measurement taken through the old decoder** — a value someone read
43041
+ * off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
43042
+ * describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
43043
+ * louder. That is what this function is for.
43044
+ *
43045
+ * Telling the two apart is a question about PROVENANCE, not about arithmetic,
43046
+ * and it cannot be answered from the number. It is answered by the comment the
43047
+ * author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
43048
+ * mandatory.
43049
+ *
43050
+ * ## Why a function and not a typed-in number
43051
+ *
43052
+ * `-55 + 12.04` written into a source file is, six months later, completely
43053
+ * indistinguishable from a threshold somebody simply preferred. Calling this
43054
+ * keeps the derivation, the law, and the original measurement all visible at
43055
+ * the call site, so a future reader can disagree with the *premise* instead of
43056
+ * having to reverse-engineer the sum.
43057
+ *
43058
+ * **This is not a runtime gain.** It converts an authored CONSTANT once, where
43059
+ * it is declared. It must never be applied to a live sample or a stored
43060
+ * `AudioEvent.dbfs`: the decoder is correct now, and a second authority
43061
+ * adjusting numbers the decoder already got right is the original defect with
43062
+ * an extra place to argue with (D459).
43063
+ */
43064
+ function ituDbfsFromPreEpoch(law, authoredDbfs) {
43065
+ return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
43066
+ }
43067
+ Math.round(ituDbfsFromPreEpoch("PCMU", -55));
42826
43068
  /** Schema defaults — an untouched sub-field must author exactly these. */
42827
43069
  var NC_AUDIO_DEFAULTS = {
42828
43070
  hitPercent: 60,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-rtsp",
3
- "version": "1.2.95",
3
+ "version": "1.2.97",
4
4
  "description": "Generic RTSP camera device provider addon for CamStack",
5
5
  "keywords": [
6
6
  "camstack",