@camstack/addon-matter-broker 0.2.93 → 0.2.95
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/addon.js +218 -5
- package/dist/addon.mjs +218 -5
- package/package.json +1 -1
package/dist/addon.js
CHANGED
|
@@ -5359,6 +5359,86 @@ var ZodIssueCode = {
|
|
|
5359
5359
|
/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
|
|
5360
5360
|
var ZodFirstPartyTypeKind;
|
|
5361
5361
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5362
|
+
//#endregion
|
|
5363
|
+
//#region ../types/dist/sleep-BnujYGPe.mjs
|
|
5364
|
+
/**
|
|
5365
|
+
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5366
|
+
* window to float samples (D455).
|
|
5367
|
+
*
|
|
5368
|
+
* ## Why a format at all
|
|
5369
|
+
*
|
|
5370
|
+
* D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
|
|
5371
|
+
* RATE, and the one consumer that needs 16 kHz resamples next to the model.
|
|
5372
|
+
* It left the FORMAT alone — the broker still turned each G.711 byte into a
|
|
5373
|
+
* 4-byte f32le sample before the bytes entered the transport, so every leg of
|
|
5374
|
+
* the plane carried four times the source. The plane crosses hub-main twice on
|
|
5375
|
+
* the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
|
|
5376
|
+
*
|
|
5377
|
+
* So the plane carries the source BYTES too, and whoever needs floats expands
|
|
5378
|
+
* them where it needs them. That is the same argument D450 made for the rate,
|
|
5379
|
+
* one step further along the same wire.
|
|
5380
|
+
*
|
|
5381
|
+
* ## Why the expansion lives here
|
|
5382
|
+
*
|
|
5383
|
+
* Two packages need it and they must never disagree: `addon-pipeline`'s broker
|
|
5384
|
+
* (which still has to serve a subscriber that did NOT ask for coded bytes —
|
|
5385
|
+
* `AudioChunkPlane` expands per subscription) and
|
|
5386
|
+
* `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
|
|
5387
|
+
* f32le window to the analyzer cap, whose `AudioChunkInput` contract is
|
|
5388
|
+
* unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
|
|
5389
|
+
* into their own dist (`self-contained` externals), so this travels with a
|
|
5390
|
+
* `camstack deploy` and needs no published server.
|
|
5391
|
+
*
|
|
5392
|
+
* A second μ-law table anywhere else is the defect this module exists to
|
|
5393
|
+
* prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
|
|
5394
|
+
* direction for the WebRTC egress — a different transform, not a copy.)
|
|
5395
|
+
*
|
|
5396
|
+
* ## Absent means f32le
|
|
5397
|
+
*
|
|
5398
|
+
* `format` is optional on the wire and its absence means `f32le` — today's
|
|
5399
|
+
* bytes, byte for byte. A peer that never heard of the field is served what it
|
|
5400
|
+
* has always been served, because the broker only emits a coded window to a
|
|
5401
|
+
* subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
|
|
5402
|
+
* That is the D448 `rawForward` negotiation, and it is what makes this
|
|
5403
|
+
* deployable one addon at a time across three nodes.
|
|
5404
|
+
*/
|
|
5405
|
+
/** Every byte format the audio chunk plane can carry. `f32le` is the default. */
|
|
5406
|
+
var AUDIO_CHUNK_FORMATS = [
|
|
5407
|
+
"f32le",
|
|
5408
|
+
"pcmu",
|
|
5409
|
+
"pcma"
|
|
5410
|
+
];
|
|
5411
|
+
/**
|
|
5412
|
+
* Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
|
|
5413
|
+
* to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
|
|
5414
|
+
*
|
|
5415
|
+
* Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
|
|
5416
|
+
* it buffers the coded bytes and the plane's consumers expand.
|
|
5417
|
+
*/
|
|
5418
|
+
function buildUlawTable() {
|
|
5419
|
+
const table = new Float32Array(256);
|
|
5420
|
+
for (let i = 0; i < 256; i++) {
|
|
5421
|
+
const complemented = ~i & 255;
|
|
5422
|
+
const sign = (complemented & 128) !== 0 ? -1 : 1;
|
|
5423
|
+
const exponent = complemented >> 4 & 7;
|
|
5424
|
+
table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
|
|
5425
|
+
}
|
|
5426
|
+
return table;
|
|
5427
|
+
}
|
|
5428
|
+
/** Build the A-law decode table (ITU-T G.711). */
|
|
5429
|
+
function buildAlawTable() {
|
|
5430
|
+
const table = new Float32Array(256);
|
|
5431
|
+
for (let i = 0; i < 256; i++) {
|
|
5432
|
+
const xored = i ^ 85;
|
|
5433
|
+
const sign = (xored & 128) !== 0 ? 1 : -1;
|
|
5434
|
+
const exponent = xored >> 4 & 7;
|
|
5435
|
+
const mantissa = xored & 15;
|
|
5436
|
+
table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
|
|
5437
|
+
}
|
|
5438
|
+
return table;
|
|
5439
|
+
}
|
|
5440
|
+
buildUlawTable();
|
|
5441
|
+
buildAlawTable();
|
|
5362
5442
|
Object.fromEntries([
|
|
5363
5443
|
{
|
|
5364
5444
|
id: "overview",
|
|
@@ -6651,11 +6731,20 @@ var SubscribeFramesResultSchema = object({
|
|
|
6651
6731
|
* (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
|
|
6652
6732
|
* / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
|
|
6653
6733
|
*/
|
|
6734
|
+
var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
|
|
6654
6735
|
var DecodedAudioChunkSchema = object({
|
|
6655
6736
|
data: _instanceof(Uint8Array),
|
|
6656
6737
|
sampleRate: number().int().positive(),
|
|
6657
6738
|
channels: number().int().positive(),
|
|
6658
|
-
timestamp: number()
|
|
6739
|
+
timestamp: number(),
|
|
6740
|
+
/**
|
|
6741
|
+
* Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
|
|
6742
|
+
* byte, for any peer that never heard of this field. A coded window
|
|
6743
|
+
* (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
|
|
6744
|
+
* subscription that DECLARED it accepts one, so absence can never mean
|
|
6745
|
+
* "coded bytes a consumer will read as floats" (D455).
|
|
6746
|
+
*/
|
|
6747
|
+
format: AudioChunkFormatSchema.optional()
|
|
6659
6748
|
});
|
|
6660
6749
|
/**
|
|
6661
6750
|
* Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
|
|
@@ -6667,7 +6756,18 @@ var DecodedAudioChunkSchema = object({
|
|
|
6667
6756
|
var SubscribeAudioChunksInputSchema = object({
|
|
6668
6757
|
brokerId: string$2(),
|
|
6669
6758
|
/** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
|
|
6670
|
-
tag: string$2().optional()
|
|
6759
|
+
tag: string$2().optional(),
|
|
6760
|
+
/**
|
|
6761
|
+
* Byte formats this subscriber can READ, best first. The broker serves the
|
|
6762
|
+
* chunk's own format when it is in this list and expands to `f32le`
|
|
6763
|
+
* otherwise, so a subscriber is never handed bytes it cannot interpret.
|
|
6764
|
+
*
|
|
6765
|
+
* Absent (or without the source format) means `f32le` — the behaviour every
|
|
6766
|
+
* subscriber had before D455, unchanged. This is the negotiation half of
|
|
6767
|
+
* the source-bytes lever: it is what lets the broker and its consumers
|
|
6768
|
+
* deploy one at a time across three nodes.
|
|
6769
|
+
*/
|
|
6770
|
+
accept: array(AudioChunkFormatSchema).readonly().optional()
|
|
6671
6771
|
});
|
|
6672
6772
|
/** Result of `stream-broker.subscribeAudioChunks`. */
|
|
6673
6773
|
var SubscribeAudioChunksResultSchema = object({
|
|
@@ -10655,6 +10755,51 @@ var AudioAnalysisSettingsSchema = object({
|
|
|
10655
10755
|
minConfidence: number().min(0).max(1).default(.3),
|
|
10656
10756
|
allowedClasses: array(string$2()).default([])
|
|
10657
10757
|
});
|
|
10758
|
+
/**
|
|
10759
|
+
* `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
|
|
10760
|
+
*
|
|
10761
|
+
* Until D461 the orchestrator drained the broker's chunk plane, accumulated
|
|
10762
|
+
* ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
|
|
10763
|
+
* nor consumed the audio: the PCM crossed hub-main twice for a process that
|
|
10764
|
+
* only buffered it. `attachDevice` inverts the direction — the analyzer opens
|
|
10765
|
+
* its own `subscribeAudioChunks` against the broker and the subscriber IS the
|
|
10766
|
+
* decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
|
|
10767
|
+
* way to the one expansion that feeds the model.
|
|
10768
|
+
*
|
|
10769
|
+
* The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
|
|
10770
|
+
* window, the per-device node assignment, the settings read) and therefore
|
|
10771
|
+
* still owns the attach/detach pair. It no longer owns the bytes.
|
|
10772
|
+
*/
|
|
10773
|
+
var AudioAttachDeviceInputSchema = object({
|
|
10774
|
+
deviceId: number(),
|
|
10775
|
+
/** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
|
|
10776
|
+
brokerId: string$2(),
|
|
10777
|
+
/**
|
|
10778
|
+
* `clusterRoles.ingestNode` — the node whose broker owns the source dial.
|
|
10779
|
+
* Every `streamBroker` call the attachment makes is pinned to it, exactly as
|
|
10780
|
+
* the orchestrator's poller pinned them before the move.
|
|
10781
|
+
*/
|
|
10782
|
+
ingestNodeId: string$2(),
|
|
10783
|
+
/**
|
|
10784
|
+
* Resolved once by the orchestrator at attach time, exactly as it was read
|
|
10785
|
+
* once per subscription before D461. The analyzer does NOT re-resolve per
|
|
10786
|
+
* window: a settings change re-attaches, which is what always happened.
|
|
10787
|
+
*/
|
|
10788
|
+
settings: AudioAnalysisSettingsSchema
|
|
10789
|
+
});
|
|
10790
|
+
var AudioAttachDeviceResultSchema = object({
|
|
10791
|
+
/** False only when the analyzer is shutting down and refused to attach. */
|
|
10792
|
+
attached: boolean(),
|
|
10793
|
+
/**
|
|
10794
|
+
* True when the attachment replaced a live one for the same device. An
|
|
10795
|
+
* attach is idempotent by REPLACEMENT — two pollers on one camera would
|
|
10796
|
+
* double the broker's fanout and neither would know about the other.
|
|
10797
|
+
*/
|
|
10798
|
+
replaced: boolean()
|
|
10799
|
+
});
|
|
10800
|
+
var AudioDetachDeviceResultSchema = object({
|
|
10801
|
+
/** False when no attachment existed — detach is idempotent. */
|
|
10802
|
+
detached: boolean() });
|
|
10658
10803
|
var AudioClassificationResultSchema = object({
|
|
10659
10804
|
labels: array(AudioClassificationLabelSchema).readonly(),
|
|
10660
10805
|
rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
|
|
@@ -10663,7 +10808,7 @@ var AudioClassificationResultSchema = object({
|
|
|
10663
10808
|
method(object({
|
|
10664
10809
|
chunk: AudioChunkInputSchema,
|
|
10665
10810
|
settings: AudioAnalysisSettingsSchema
|
|
10666
|
-
}), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string$2() }), {
|
|
10811
|
+
}), 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$2() }), {
|
|
10667
10812
|
kind: "mutation",
|
|
10668
10813
|
auth: "admin"
|
|
10669
10814
|
});
|
|
@@ -25970,8 +26115,8 @@ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly
|
|
|
25970
26115
|
*
|
|
25971
26116
|
* An **empty array reads NOTHING** — `[]` is an empty page, never
|
|
25972
26117
|
* "every camera". A request for no devices is a request, not an
|
|
25973
|
-
* omission; same contract as `deviceManager.
|
|
25974
|
-
* `pipelineAnalytics.listRecentTracks`.
|
|
26118
|
+
* omission; same contract as `deviceManager.listAll`'s `deviceIds`
|
|
26119
|
+
* and `pipelineAnalytics.listRecentTracks`.
|
|
25975
26120
|
*
|
|
25976
26121
|
* Absent (`undefined`) is the omission, and keeps the cluster-wide view.
|
|
25977
26122
|
*/
|
|
@@ -35005,12 +35150,24 @@ Object.freeze({
|
|
|
35005
35150
|
addonId: null,
|
|
35006
35151
|
access: "create"
|
|
35007
35152
|
},
|
|
35153
|
+
"audioAnalyzer.attachDevice": {
|
|
35154
|
+
capName: "audio-analyzer",
|
|
35155
|
+
capScope: "system",
|
|
35156
|
+
addonId: null,
|
|
35157
|
+
access: "create"
|
|
35158
|
+
},
|
|
35008
35159
|
"audioAnalyzer.classify": {
|
|
35009
35160
|
capName: "audio-analyzer",
|
|
35010
35161
|
capScope: "system",
|
|
35011
35162
|
addonId: null,
|
|
35012
35163
|
access: "view"
|
|
35013
35164
|
},
|
|
35165
|
+
"audioAnalyzer.detachDevice": {
|
|
35166
|
+
capName: "audio-analyzer",
|
|
35167
|
+
capScope: "system",
|
|
35168
|
+
addonId: null,
|
|
35169
|
+
access: "create"
|
|
35170
|
+
},
|
|
35014
35171
|
"audioAnalyzer.dispose": {
|
|
35015
35172
|
capName: "audio-analyzer",
|
|
35016
35173
|
capScope: "system",
|
|
@@ -40854,11 +41011,21 @@ Object.freeze({
|
|
|
40854
41011
|
form: "single",
|
|
40855
41012
|
optional: false
|
|
40856
41013
|
}],
|
|
41014
|
+
"audioAnalyzer.attachDevice": [{
|
|
41015
|
+
name: "deviceId",
|
|
41016
|
+
form: "single",
|
|
41017
|
+
optional: false
|
|
41018
|
+
}],
|
|
40857
41019
|
"audioAnalyzer.classify": [{
|
|
40858
41020
|
name: "deviceId",
|
|
40859
41021
|
form: "single",
|
|
40860
41022
|
optional: true
|
|
40861
41023
|
}],
|
|
41024
|
+
"audioAnalyzer.detachDevice": [{
|
|
41025
|
+
name: "deviceId",
|
|
41026
|
+
form: "single",
|
|
41027
|
+
optional: false
|
|
41028
|
+
}],
|
|
40862
41029
|
"audioMetrics.getCurrentSnapshot": [{
|
|
40863
41030
|
name: "deviceId",
|
|
40864
41031
|
form: "single",
|
|
@@ -42710,6 +42877,52 @@ Object.freeze({
|
|
|
42710
42877
|
"network-access": "ingress",
|
|
42711
42878
|
"smtp-provider": "email"
|
|
42712
42879
|
});
|
|
42880
|
+
var G711_SCALE_CORRECTION_DB = {
|
|
42881
|
+
PCMU: 20 * Math.log10(4),
|
|
42882
|
+
PCMA: 20 * Math.log10(8)
|
|
42883
|
+
};
|
|
42884
|
+
/**
|
|
42885
|
+
* Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
|
|
42886
|
+
* same intent on the ITU-T scale (D460).
|
|
42887
|
+
*
|
|
42888
|
+
* ## When this applies, and when it is the wrong thing to reach for
|
|
42889
|
+
*
|
|
42890
|
+
* An absolute-dBFS number in this repo is one of two things, and only one of
|
|
42891
|
+
* them converts:
|
|
42892
|
+
*
|
|
42893
|
+
* - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
|
|
42894
|
+
* is loud". It was true on the ITU-T scale before the epoch and it is true
|
|
42895
|
+
* after. The defect was never in the number; it was that 19 of this hub's
|
|
42896
|
+
* 25 cameras did not obey it. Converting such a number takes something
|
|
42897
|
+
* correct and makes it wrong, in order to preserve a bug.
|
|
42898
|
+
* - **A measurement taken through the old decoder** — a value someone read
|
|
42899
|
+
* off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
|
|
42900
|
+
* describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
|
|
42901
|
+
* louder. That is what this function is for.
|
|
42902
|
+
*
|
|
42903
|
+
* Telling the two apart is a question about PROVENANCE, not about arithmetic,
|
|
42904
|
+
* and it cannot be answered from the number. It is answered by the comment the
|
|
42905
|
+
* author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
|
|
42906
|
+
* mandatory.
|
|
42907
|
+
*
|
|
42908
|
+
* ## Why a function and not a typed-in number
|
|
42909
|
+
*
|
|
42910
|
+
* `-55 + 12.04` written into a source file is, six months later, completely
|
|
42911
|
+
* indistinguishable from a threshold somebody simply preferred. Calling this
|
|
42912
|
+
* keeps the derivation, the law, and the original measurement all visible at
|
|
42913
|
+
* the call site, so a future reader can disagree with the *premise* instead of
|
|
42914
|
+
* having to reverse-engineer the sum.
|
|
42915
|
+
*
|
|
42916
|
+
* **This is not a runtime gain.** It converts an authored CONSTANT once, where
|
|
42917
|
+
* it is declared. It must never be applied to a live sample or a stored
|
|
42918
|
+
* `AudioEvent.dbfs`: the decoder is correct now, and a second authority
|
|
42919
|
+
* adjusting numbers the decoder already got right is the original defect with
|
|
42920
|
+
* an extra place to argue with (D459).
|
|
42921
|
+
*/
|
|
42922
|
+
function ituDbfsFromPreEpoch(law, authoredDbfs) {
|
|
42923
|
+
return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
|
|
42924
|
+
}
|
|
42925
|
+
Math.round(ituDbfsFromPreEpoch("PCMU", -55));
|
|
42713
42926
|
/** Schema defaults — an untouched sub-field must author exactly these. */
|
|
42714
42927
|
var NC_AUDIO_DEFAULTS = {
|
|
42715
42928
|
hitPercent: 60,
|
package/dist/addon.mjs
CHANGED
|
@@ -5357,6 +5357,86 @@ var ZodIssueCode = {
|
|
|
5357
5357
|
/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
|
|
5358
5358
|
var ZodFirstPartyTypeKind;
|
|
5359
5359
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5360
|
+
//#endregion
|
|
5361
|
+
//#region ../types/dist/sleep-BnujYGPe.mjs
|
|
5362
|
+
/**
|
|
5363
|
+
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5364
|
+
* window to float samples (D455).
|
|
5365
|
+
*
|
|
5366
|
+
* ## Why a format at all
|
|
5367
|
+
*
|
|
5368
|
+
* D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
|
|
5369
|
+
* RATE, and the one consumer that needs 16 kHz resamples next to the model.
|
|
5370
|
+
* It left the FORMAT alone — the broker still turned each G.711 byte into a
|
|
5371
|
+
* 4-byte f32le sample before the bytes entered the transport, so every leg of
|
|
5372
|
+
* the plane carried four times the source. The plane crosses hub-main twice on
|
|
5373
|
+
* the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
|
|
5374
|
+
*
|
|
5375
|
+
* So the plane carries the source BYTES too, and whoever needs floats expands
|
|
5376
|
+
* them where it needs them. That is the same argument D450 made for the rate,
|
|
5377
|
+
* one step further along the same wire.
|
|
5378
|
+
*
|
|
5379
|
+
* ## Why the expansion lives here
|
|
5380
|
+
*
|
|
5381
|
+
* Two packages need it and they must never disagree: `addon-pipeline`'s broker
|
|
5382
|
+
* (which still has to serve a subscriber that did NOT ask for coded bytes —
|
|
5383
|
+
* `AudioChunkPlane` expands per subscription) and
|
|
5384
|
+
* `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
|
|
5385
|
+
* f32le window to the analyzer cap, whose `AudioChunkInput` contract is
|
|
5386
|
+
* unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
|
|
5387
|
+
* into their own dist (`self-contained` externals), so this travels with a
|
|
5388
|
+
* `camstack deploy` and needs no published server.
|
|
5389
|
+
*
|
|
5390
|
+
* A second μ-law table anywhere else is the defect this module exists to
|
|
5391
|
+
* prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
|
|
5392
|
+
* direction for the WebRTC egress — a different transform, not a copy.)
|
|
5393
|
+
*
|
|
5394
|
+
* ## Absent means f32le
|
|
5395
|
+
*
|
|
5396
|
+
* `format` is optional on the wire and its absence means `f32le` — today's
|
|
5397
|
+
* bytes, byte for byte. A peer that never heard of the field is served what it
|
|
5398
|
+
* has always been served, because the broker only emits a coded window to a
|
|
5399
|
+
* subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
|
|
5400
|
+
* That is the D448 `rawForward` negotiation, and it is what makes this
|
|
5401
|
+
* deployable one addon at a time across three nodes.
|
|
5402
|
+
*/
|
|
5403
|
+
/** Every byte format the audio chunk plane can carry. `f32le` is the default. */
|
|
5404
|
+
var AUDIO_CHUNK_FORMATS = [
|
|
5405
|
+
"f32le",
|
|
5406
|
+
"pcmu",
|
|
5407
|
+
"pcma"
|
|
5408
|
+
];
|
|
5409
|
+
/**
|
|
5410
|
+
* Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
|
|
5411
|
+
* to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
|
|
5412
|
+
*
|
|
5413
|
+
* Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
|
|
5414
|
+
* it buffers the coded bytes and the plane's consumers expand.
|
|
5415
|
+
*/
|
|
5416
|
+
function buildUlawTable() {
|
|
5417
|
+
const table = new Float32Array(256);
|
|
5418
|
+
for (let i = 0; i < 256; i++) {
|
|
5419
|
+
const complemented = ~i & 255;
|
|
5420
|
+
const sign = (complemented & 128) !== 0 ? -1 : 1;
|
|
5421
|
+
const exponent = complemented >> 4 & 7;
|
|
5422
|
+
table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
|
|
5423
|
+
}
|
|
5424
|
+
return table;
|
|
5425
|
+
}
|
|
5426
|
+
/** Build the A-law decode table (ITU-T G.711). */
|
|
5427
|
+
function buildAlawTable() {
|
|
5428
|
+
const table = new Float32Array(256);
|
|
5429
|
+
for (let i = 0; i < 256; i++) {
|
|
5430
|
+
const xored = i ^ 85;
|
|
5431
|
+
const sign = (xored & 128) !== 0 ? 1 : -1;
|
|
5432
|
+
const exponent = xored >> 4 & 7;
|
|
5433
|
+
const mantissa = xored & 15;
|
|
5434
|
+
table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
|
|
5435
|
+
}
|
|
5436
|
+
return table;
|
|
5437
|
+
}
|
|
5438
|
+
buildUlawTable();
|
|
5439
|
+
buildAlawTable();
|
|
5360
5440
|
Object.fromEntries([
|
|
5361
5441
|
{
|
|
5362
5442
|
id: "overview",
|
|
@@ -6649,11 +6729,20 @@ var SubscribeFramesResultSchema = object({
|
|
|
6649
6729
|
* (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
|
|
6650
6730
|
* / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
|
|
6651
6731
|
*/
|
|
6732
|
+
var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
|
|
6652
6733
|
var DecodedAudioChunkSchema = object({
|
|
6653
6734
|
data: _instanceof(Uint8Array),
|
|
6654
6735
|
sampleRate: number().int().positive(),
|
|
6655
6736
|
channels: number().int().positive(),
|
|
6656
|
-
timestamp: number()
|
|
6737
|
+
timestamp: number(),
|
|
6738
|
+
/**
|
|
6739
|
+
* Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
|
|
6740
|
+
* byte, for any peer that never heard of this field. A coded window
|
|
6741
|
+
* (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
|
|
6742
|
+
* subscription that DECLARED it accepts one, so absence can never mean
|
|
6743
|
+
* "coded bytes a consumer will read as floats" (D455).
|
|
6744
|
+
*/
|
|
6745
|
+
format: AudioChunkFormatSchema.optional()
|
|
6657
6746
|
});
|
|
6658
6747
|
/**
|
|
6659
6748
|
* Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
|
|
@@ -6665,7 +6754,18 @@ var DecodedAudioChunkSchema = object({
|
|
|
6665
6754
|
var SubscribeAudioChunksInputSchema = object({
|
|
6666
6755
|
brokerId: string$2(),
|
|
6667
6756
|
/** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
|
|
6668
|
-
tag: string$2().optional()
|
|
6757
|
+
tag: string$2().optional(),
|
|
6758
|
+
/**
|
|
6759
|
+
* Byte formats this subscriber can READ, best first. The broker serves the
|
|
6760
|
+
* chunk's own format when it is in this list and expands to `f32le`
|
|
6761
|
+
* otherwise, so a subscriber is never handed bytes it cannot interpret.
|
|
6762
|
+
*
|
|
6763
|
+
* Absent (or without the source format) means `f32le` — the behaviour every
|
|
6764
|
+
* subscriber had before D455, unchanged. This is the negotiation half of
|
|
6765
|
+
* the source-bytes lever: it is what lets the broker and its consumers
|
|
6766
|
+
* deploy one at a time across three nodes.
|
|
6767
|
+
*/
|
|
6768
|
+
accept: array(AudioChunkFormatSchema).readonly().optional()
|
|
6669
6769
|
});
|
|
6670
6770
|
/** Result of `stream-broker.subscribeAudioChunks`. */
|
|
6671
6771
|
var SubscribeAudioChunksResultSchema = object({
|
|
@@ -10653,6 +10753,51 @@ var AudioAnalysisSettingsSchema = object({
|
|
|
10653
10753
|
minConfidence: number().min(0).max(1).default(.3),
|
|
10654
10754
|
allowedClasses: array(string$2()).default([])
|
|
10655
10755
|
});
|
|
10756
|
+
/**
|
|
10757
|
+
* `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
|
|
10758
|
+
*
|
|
10759
|
+
* Until D461 the orchestrator drained the broker's chunk plane, accumulated
|
|
10760
|
+
* ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
|
|
10761
|
+
* nor consumed the audio: the PCM crossed hub-main twice for a process that
|
|
10762
|
+
* only buffered it. `attachDevice` inverts the direction — the analyzer opens
|
|
10763
|
+
* its own `subscribeAudioChunks` against the broker and the subscriber IS the
|
|
10764
|
+
* decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
|
|
10765
|
+
* way to the one expansion that feeds the model.
|
|
10766
|
+
*
|
|
10767
|
+
* The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
|
|
10768
|
+
* window, the per-device node assignment, the settings read) and therefore
|
|
10769
|
+
* still owns the attach/detach pair. It no longer owns the bytes.
|
|
10770
|
+
*/
|
|
10771
|
+
var AudioAttachDeviceInputSchema = object({
|
|
10772
|
+
deviceId: number(),
|
|
10773
|
+
/** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
|
|
10774
|
+
brokerId: string$2(),
|
|
10775
|
+
/**
|
|
10776
|
+
* `clusterRoles.ingestNode` — the node whose broker owns the source dial.
|
|
10777
|
+
* Every `streamBroker` call the attachment makes is pinned to it, exactly as
|
|
10778
|
+
* the orchestrator's poller pinned them before the move.
|
|
10779
|
+
*/
|
|
10780
|
+
ingestNodeId: string$2(),
|
|
10781
|
+
/**
|
|
10782
|
+
* Resolved once by the orchestrator at attach time, exactly as it was read
|
|
10783
|
+
* once per subscription before D461. The analyzer does NOT re-resolve per
|
|
10784
|
+
* window: a settings change re-attaches, which is what always happened.
|
|
10785
|
+
*/
|
|
10786
|
+
settings: AudioAnalysisSettingsSchema
|
|
10787
|
+
});
|
|
10788
|
+
var AudioAttachDeviceResultSchema = object({
|
|
10789
|
+
/** False only when the analyzer is shutting down and refused to attach. */
|
|
10790
|
+
attached: boolean(),
|
|
10791
|
+
/**
|
|
10792
|
+
* True when the attachment replaced a live one for the same device. An
|
|
10793
|
+
* attach is idempotent by REPLACEMENT — two pollers on one camera would
|
|
10794
|
+
* double the broker's fanout and neither would know about the other.
|
|
10795
|
+
*/
|
|
10796
|
+
replaced: boolean()
|
|
10797
|
+
});
|
|
10798
|
+
var AudioDetachDeviceResultSchema = object({
|
|
10799
|
+
/** False when no attachment existed — detach is idempotent. */
|
|
10800
|
+
detached: boolean() });
|
|
10656
10801
|
var AudioClassificationResultSchema = object({
|
|
10657
10802
|
labels: array(AudioClassificationLabelSchema).readonly(),
|
|
10658
10803
|
rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
|
|
@@ -10661,7 +10806,7 @@ var AudioClassificationResultSchema = object({
|
|
|
10661
10806
|
method(object({
|
|
10662
10807
|
chunk: AudioChunkInputSchema,
|
|
10663
10808
|
settings: AudioAnalysisSettingsSchema
|
|
10664
|
-
}), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string$2() }), {
|
|
10809
|
+
}), 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$2() }), {
|
|
10665
10810
|
kind: "mutation",
|
|
10666
10811
|
auth: "admin"
|
|
10667
10812
|
});
|
|
@@ -25968,8 +26113,8 @@ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly
|
|
|
25968
26113
|
*
|
|
25969
26114
|
* An **empty array reads NOTHING** — `[]` is an empty page, never
|
|
25970
26115
|
* "every camera". A request for no devices is a request, not an
|
|
25971
|
-
* omission; same contract as `deviceManager.
|
|
25972
|
-
* `pipelineAnalytics.listRecentTracks`.
|
|
26116
|
+
* omission; same contract as `deviceManager.listAll`'s `deviceIds`
|
|
26117
|
+
* and `pipelineAnalytics.listRecentTracks`.
|
|
25973
26118
|
*
|
|
25974
26119
|
* Absent (`undefined`) is the omission, and keeps the cluster-wide view.
|
|
25975
26120
|
*/
|
|
@@ -35003,12 +35148,24 @@ Object.freeze({
|
|
|
35003
35148
|
addonId: null,
|
|
35004
35149
|
access: "create"
|
|
35005
35150
|
},
|
|
35151
|
+
"audioAnalyzer.attachDevice": {
|
|
35152
|
+
capName: "audio-analyzer",
|
|
35153
|
+
capScope: "system",
|
|
35154
|
+
addonId: null,
|
|
35155
|
+
access: "create"
|
|
35156
|
+
},
|
|
35006
35157
|
"audioAnalyzer.classify": {
|
|
35007
35158
|
capName: "audio-analyzer",
|
|
35008
35159
|
capScope: "system",
|
|
35009
35160
|
addonId: null,
|
|
35010
35161
|
access: "view"
|
|
35011
35162
|
},
|
|
35163
|
+
"audioAnalyzer.detachDevice": {
|
|
35164
|
+
capName: "audio-analyzer",
|
|
35165
|
+
capScope: "system",
|
|
35166
|
+
addonId: null,
|
|
35167
|
+
access: "create"
|
|
35168
|
+
},
|
|
35012
35169
|
"audioAnalyzer.dispose": {
|
|
35013
35170
|
capName: "audio-analyzer",
|
|
35014
35171
|
capScope: "system",
|
|
@@ -40852,11 +41009,21 @@ Object.freeze({
|
|
|
40852
41009
|
form: "single",
|
|
40853
41010
|
optional: false
|
|
40854
41011
|
}],
|
|
41012
|
+
"audioAnalyzer.attachDevice": [{
|
|
41013
|
+
name: "deviceId",
|
|
41014
|
+
form: "single",
|
|
41015
|
+
optional: false
|
|
41016
|
+
}],
|
|
40855
41017
|
"audioAnalyzer.classify": [{
|
|
40856
41018
|
name: "deviceId",
|
|
40857
41019
|
form: "single",
|
|
40858
41020
|
optional: true
|
|
40859
41021
|
}],
|
|
41022
|
+
"audioAnalyzer.detachDevice": [{
|
|
41023
|
+
name: "deviceId",
|
|
41024
|
+
form: "single",
|
|
41025
|
+
optional: false
|
|
41026
|
+
}],
|
|
40860
41027
|
"audioMetrics.getCurrentSnapshot": [{
|
|
40861
41028
|
name: "deviceId",
|
|
40862
41029
|
form: "single",
|
|
@@ -42708,6 +42875,52 @@ Object.freeze({
|
|
|
42708
42875
|
"network-access": "ingress",
|
|
42709
42876
|
"smtp-provider": "email"
|
|
42710
42877
|
});
|
|
42878
|
+
var G711_SCALE_CORRECTION_DB = {
|
|
42879
|
+
PCMU: 20 * Math.log10(4),
|
|
42880
|
+
PCMA: 20 * Math.log10(8)
|
|
42881
|
+
};
|
|
42882
|
+
/**
|
|
42883
|
+
* Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
|
|
42884
|
+
* same intent on the ITU-T scale (D460).
|
|
42885
|
+
*
|
|
42886
|
+
* ## When this applies, and when it is the wrong thing to reach for
|
|
42887
|
+
*
|
|
42888
|
+
* An absolute-dBFS number in this repo is one of two things, and only one of
|
|
42889
|
+
* them converts:
|
|
42890
|
+
*
|
|
42891
|
+
* - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
|
|
42892
|
+
* is loud". It was true on the ITU-T scale before the epoch and it is true
|
|
42893
|
+
* after. The defect was never in the number; it was that 19 of this hub's
|
|
42894
|
+
* 25 cameras did not obey it. Converting such a number takes something
|
|
42895
|
+
* correct and makes it wrong, in order to preserve a bug.
|
|
42896
|
+
* - **A measurement taken through the old decoder** — a value someone read
|
|
42897
|
+
* off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
|
|
42898
|
+
* describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
|
|
42899
|
+
* louder. That is what this function is for.
|
|
42900
|
+
*
|
|
42901
|
+
* Telling the two apart is a question about PROVENANCE, not about arithmetic,
|
|
42902
|
+
* and it cannot be answered from the number. It is answered by the comment the
|
|
42903
|
+
* author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
|
|
42904
|
+
* mandatory.
|
|
42905
|
+
*
|
|
42906
|
+
* ## Why a function and not a typed-in number
|
|
42907
|
+
*
|
|
42908
|
+
* `-55 + 12.04` written into a source file is, six months later, completely
|
|
42909
|
+
* indistinguishable from a threshold somebody simply preferred. Calling this
|
|
42910
|
+
* keeps the derivation, the law, and the original measurement all visible at
|
|
42911
|
+
* the call site, so a future reader can disagree with the *premise* instead of
|
|
42912
|
+
* having to reverse-engineer the sum.
|
|
42913
|
+
*
|
|
42914
|
+
* **This is not a runtime gain.** It converts an authored CONSTANT once, where
|
|
42915
|
+
* it is declared. It must never be applied to a live sample or a stored
|
|
42916
|
+
* `AudioEvent.dbfs`: the decoder is correct now, and a second authority
|
|
42917
|
+
* adjusting numbers the decoder already got right is the original defect with
|
|
42918
|
+
* an extra place to argue with (D459).
|
|
42919
|
+
*/
|
|
42920
|
+
function ituDbfsFromPreEpoch(law, authoredDbfs) {
|
|
42921
|
+
return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
|
|
42922
|
+
}
|
|
42923
|
+
Math.round(ituDbfsFromPreEpoch("PCMU", -55));
|
|
42711
42924
|
/** Schema defaults — an untouched sub-field must author exactly these. */
|
|
42712
42925
|
var NC_AUDIO_DEFAULTS = {
|
|
42713
42926
|
hitPercent: 60,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/addon-matter-broker",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.95",
|
|
4
4
|
"description": "Matter broker addon for CamStack — owns a Matter fabric (commissioning + the long-lived controller) via the matter.js controller and brokers commissioned Matter nodes into CamStack",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"camstack",
|