@camstack/addon-provider-petkit 0.2.95 → 0.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 +216 -3
- package/dist/addon.mjs +216 -3
- package/package.json +1 -1
package/dist/addon.js
CHANGED
|
@@ -6447,6 +6447,86 @@ var ZodIssueCode = {
|
|
|
6447
6447
|
/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
|
|
6448
6448
|
var ZodFirstPartyTypeKind;
|
|
6449
6449
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
6450
|
+
//#endregion
|
|
6451
|
+
//#region ../types/dist/sleep-BnujYGPe.mjs
|
|
6452
|
+
/**
|
|
6453
|
+
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
6454
|
+
* window to float samples (D455).
|
|
6455
|
+
*
|
|
6456
|
+
* ## Why a format at all
|
|
6457
|
+
*
|
|
6458
|
+
* D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
|
|
6459
|
+
* RATE, and the one consumer that needs 16 kHz resamples next to the model.
|
|
6460
|
+
* It left the FORMAT alone — the broker still turned each G.711 byte into a
|
|
6461
|
+
* 4-byte f32le sample before the bytes entered the transport, so every leg of
|
|
6462
|
+
* the plane carried four times the source. The plane crosses hub-main twice on
|
|
6463
|
+
* the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
|
|
6464
|
+
*
|
|
6465
|
+
* So the plane carries the source BYTES too, and whoever needs floats expands
|
|
6466
|
+
* them where it needs them. That is the same argument D450 made for the rate,
|
|
6467
|
+
* one step further along the same wire.
|
|
6468
|
+
*
|
|
6469
|
+
* ## Why the expansion lives here
|
|
6470
|
+
*
|
|
6471
|
+
* Two packages need it and they must never disagree: `addon-pipeline`'s broker
|
|
6472
|
+
* (which still has to serve a subscriber that did NOT ask for coded bytes —
|
|
6473
|
+
* `AudioChunkPlane` expands per subscription) and
|
|
6474
|
+
* `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
|
|
6475
|
+
* f32le window to the analyzer cap, whose `AudioChunkInput` contract is
|
|
6476
|
+
* unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
|
|
6477
|
+
* into their own dist (`self-contained` externals), so this travels with a
|
|
6478
|
+
* `camstack deploy` and needs no published server.
|
|
6479
|
+
*
|
|
6480
|
+
* A second μ-law table anywhere else is the defect this module exists to
|
|
6481
|
+
* prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
|
|
6482
|
+
* direction for the WebRTC egress — a different transform, not a copy.)
|
|
6483
|
+
*
|
|
6484
|
+
* ## Absent means f32le
|
|
6485
|
+
*
|
|
6486
|
+
* `format` is optional on the wire and its absence means `f32le` — today's
|
|
6487
|
+
* bytes, byte for byte. A peer that never heard of the field is served what it
|
|
6488
|
+
* has always been served, because the broker only emits a coded window to a
|
|
6489
|
+
* subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
|
|
6490
|
+
* That is the D448 `rawForward` negotiation, and it is what makes this
|
|
6491
|
+
* deployable one addon at a time across three nodes.
|
|
6492
|
+
*/
|
|
6493
|
+
/** Every byte format the audio chunk plane can carry. `f32le` is the default. */
|
|
6494
|
+
var AUDIO_CHUNK_FORMATS = [
|
|
6495
|
+
"f32le",
|
|
6496
|
+
"pcmu",
|
|
6497
|
+
"pcma"
|
|
6498
|
+
];
|
|
6499
|
+
/**
|
|
6500
|
+
* Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
|
|
6501
|
+
* to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
|
|
6502
|
+
*
|
|
6503
|
+
* Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
|
|
6504
|
+
* it buffers the coded bytes and the plane's consumers expand.
|
|
6505
|
+
*/
|
|
6506
|
+
function buildUlawTable() {
|
|
6507
|
+
const table = new Float32Array(256);
|
|
6508
|
+
for (let i = 0; i < 256; i++) {
|
|
6509
|
+
const complemented = ~i & 255;
|
|
6510
|
+
const sign = (complemented & 128) !== 0 ? -1 : 1;
|
|
6511
|
+
const exponent = complemented >> 4 & 7;
|
|
6512
|
+
table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
|
|
6513
|
+
}
|
|
6514
|
+
return table;
|
|
6515
|
+
}
|
|
6516
|
+
/** Build the A-law decode table (ITU-T G.711). */
|
|
6517
|
+
function buildAlawTable() {
|
|
6518
|
+
const table = new Float32Array(256);
|
|
6519
|
+
for (let i = 0; i < 256; i++) {
|
|
6520
|
+
const xored = i ^ 85;
|
|
6521
|
+
const sign = (xored & 128) !== 0 ? 1 : -1;
|
|
6522
|
+
const exponent = xored >> 4 & 7;
|
|
6523
|
+
const mantissa = xored & 15;
|
|
6524
|
+
table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
|
|
6525
|
+
}
|
|
6526
|
+
return table;
|
|
6527
|
+
}
|
|
6528
|
+
buildUlawTable();
|
|
6529
|
+
buildAlawTable();
|
|
6450
6530
|
Object.fromEntries([
|
|
6451
6531
|
{
|
|
6452
6532
|
id: "overview",
|
|
@@ -7739,11 +7819,20 @@ var SubscribeFramesResultSchema = object({
|
|
|
7739
7819
|
* (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
|
|
7740
7820
|
* / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
|
|
7741
7821
|
*/
|
|
7822
|
+
var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
|
|
7742
7823
|
var DecodedAudioChunkSchema = object({
|
|
7743
7824
|
data: _instanceof(Uint8Array),
|
|
7744
7825
|
sampleRate: number().int().positive(),
|
|
7745
7826
|
channels: number().int().positive(),
|
|
7746
|
-
timestamp: number()
|
|
7827
|
+
timestamp: number(),
|
|
7828
|
+
/**
|
|
7829
|
+
* Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
|
|
7830
|
+
* byte, for any peer that never heard of this field. A coded window
|
|
7831
|
+
* (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
|
|
7832
|
+
* subscription that DECLARED it accepts one, so absence can never mean
|
|
7833
|
+
* "coded bytes a consumer will read as floats" (D455).
|
|
7834
|
+
*/
|
|
7835
|
+
format: AudioChunkFormatSchema.optional()
|
|
7747
7836
|
});
|
|
7748
7837
|
/**
|
|
7749
7838
|
* Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
|
|
@@ -7755,7 +7844,18 @@ var DecodedAudioChunkSchema = object({
|
|
|
7755
7844
|
var SubscribeAudioChunksInputSchema = object({
|
|
7756
7845
|
brokerId: string(),
|
|
7757
7846
|
/** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
|
|
7758
|
-
tag: string().optional()
|
|
7847
|
+
tag: string().optional(),
|
|
7848
|
+
/**
|
|
7849
|
+
* Byte formats this subscriber can READ, best first. The broker serves the
|
|
7850
|
+
* chunk's own format when it is in this list and expands to `f32le`
|
|
7851
|
+
* otherwise, so a subscriber is never handed bytes it cannot interpret.
|
|
7852
|
+
*
|
|
7853
|
+
* Absent (or without the source format) means `f32le` — the behaviour every
|
|
7854
|
+
* subscriber had before D455, unchanged. This is the negotiation half of
|
|
7855
|
+
* the source-bytes lever: it is what lets the broker and its consumers
|
|
7856
|
+
* deploy one at a time across three nodes.
|
|
7857
|
+
*/
|
|
7858
|
+
accept: array(AudioChunkFormatSchema).readonly().optional()
|
|
7759
7859
|
});
|
|
7760
7860
|
/** Result of `stream-broker.subscribeAudioChunks`. */
|
|
7761
7861
|
var SubscribeAudioChunksResultSchema = object({
|
|
@@ -11743,6 +11843,51 @@ var AudioAnalysisSettingsSchema = object({
|
|
|
11743
11843
|
minConfidence: number().min(0).max(1).default(.3),
|
|
11744
11844
|
allowedClasses: array(string()).default([])
|
|
11745
11845
|
});
|
|
11846
|
+
/**
|
|
11847
|
+
* `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
|
|
11848
|
+
*
|
|
11849
|
+
* Until D461 the orchestrator drained the broker's chunk plane, accumulated
|
|
11850
|
+
* ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
|
|
11851
|
+
* nor consumed the audio: the PCM crossed hub-main twice for a process that
|
|
11852
|
+
* only buffered it. `attachDevice` inverts the direction — the analyzer opens
|
|
11853
|
+
* its own `subscribeAudioChunks` against the broker and the subscriber IS the
|
|
11854
|
+
* decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
|
|
11855
|
+
* way to the one expansion that feeds the model.
|
|
11856
|
+
*
|
|
11857
|
+
* The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
|
|
11858
|
+
* window, the per-device node assignment, the settings read) and therefore
|
|
11859
|
+
* still owns the attach/detach pair. It no longer owns the bytes.
|
|
11860
|
+
*/
|
|
11861
|
+
var AudioAttachDeviceInputSchema = object({
|
|
11862
|
+
deviceId: number(),
|
|
11863
|
+
/** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
|
|
11864
|
+
brokerId: string(),
|
|
11865
|
+
/**
|
|
11866
|
+
* `clusterRoles.ingestNode` — the node whose broker owns the source dial.
|
|
11867
|
+
* Every `streamBroker` call the attachment makes is pinned to it, exactly as
|
|
11868
|
+
* the orchestrator's poller pinned them before the move.
|
|
11869
|
+
*/
|
|
11870
|
+
ingestNodeId: string(),
|
|
11871
|
+
/**
|
|
11872
|
+
* Resolved once by the orchestrator at attach time, exactly as it was read
|
|
11873
|
+
* once per subscription before D461. The analyzer does NOT re-resolve per
|
|
11874
|
+
* window: a settings change re-attaches, which is what always happened.
|
|
11875
|
+
*/
|
|
11876
|
+
settings: AudioAnalysisSettingsSchema
|
|
11877
|
+
});
|
|
11878
|
+
var AudioAttachDeviceResultSchema = object({
|
|
11879
|
+
/** False only when the analyzer is shutting down and refused to attach. */
|
|
11880
|
+
attached: boolean(),
|
|
11881
|
+
/**
|
|
11882
|
+
* True when the attachment replaced a live one for the same device. An
|
|
11883
|
+
* attach is idempotent by REPLACEMENT — two pollers on one camera would
|
|
11884
|
+
* double the broker's fanout and neither would know about the other.
|
|
11885
|
+
*/
|
|
11886
|
+
replaced: boolean()
|
|
11887
|
+
});
|
|
11888
|
+
var AudioDetachDeviceResultSchema = object({
|
|
11889
|
+
/** False when no attachment existed — detach is idempotent. */
|
|
11890
|
+
detached: boolean() });
|
|
11746
11891
|
var AudioClassificationResultSchema = object({
|
|
11747
11892
|
labels: array(AudioClassificationLabelSchema).readonly(),
|
|
11748
11893
|
rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
|
|
@@ -11751,7 +11896,7 @@ var AudioClassificationResultSchema = object({
|
|
|
11751
11896
|
method(object({
|
|
11752
11897
|
chunk: AudioChunkInputSchema,
|
|
11753
11898
|
settings: AudioAnalysisSettingsSchema
|
|
11754
|
-
}), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
|
|
11899
|
+
}), 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() }), {
|
|
11755
11900
|
kind: "mutation",
|
|
11756
11901
|
auth: "admin"
|
|
11757
11902
|
});
|
|
@@ -36035,12 +36180,24 @@ Object.freeze({
|
|
|
36035
36180
|
addonId: null,
|
|
36036
36181
|
access: "create"
|
|
36037
36182
|
},
|
|
36183
|
+
"audioAnalyzer.attachDevice": {
|
|
36184
|
+
capName: "audio-analyzer",
|
|
36185
|
+
capScope: "system",
|
|
36186
|
+
addonId: null,
|
|
36187
|
+
access: "create"
|
|
36188
|
+
},
|
|
36038
36189
|
"audioAnalyzer.classify": {
|
|
36039
36190
|
capName: "audio-analyzer",
|
|
36040
36191
|
capScope: "system",
|
|
36041
36192
|
addonId: null,
|
|
36042
36193
|
access: "view"
|
|
36043
36194
|
},
|
|
36195
|
+
"audioAnalyzer.detachDevice": {
|
|
36196
|
+
capName: "audio-analyzer",
|
|
36197
|
+
capScope: "system",
|
|
36198
|
+
addonId: null,
|
|
36199
|
+
access: "create"
|
|
36200
|
+
},
|
|
36044
36201
|
"audioAnalyzer.dispose": {
|
|
36045
36202
|
capName: "audio-analyzer",
|
|
36046
36203
|
capScope: "system",
|
|
@@ -41884,11 +42041,21 @@ Object.freeze({
|
|
|
41884
42041
|
form: "single",
|
|
41885
42042
|
optional: false
|
|
41886
42043
|
}],
|
|
42044
|
+
"audioAnalyzer.attachDevice": [{
|
|
42045
|
+
name: "deviceId",
|
|
42046
|
+
form: "single",
|
|
42047
|
+
optional: false
|
|
42048
|
+
}],
|
|
41887
42049
|
"audioAnalyzer.classify": [{
|
|
41888
42050
|
name: "deviceId",
|
|
41889
42051
|
form: "single",
|
|
41890
42052
|
optional: true
|
|
41891
42053
|
}],
|
|
42054
|
+
"audioAnalyzer.detachDevice": [{
|
|
42055
|
+
name: "deviceId",
|
|
42056
|
+
form: "single",
|
|
42057
|
+
optional: false
|
|
42058
|
+
}],
|
|
41892
42059
|
"audioMetrics.getCurrentSnapshot": [{
|
|
41893
42060
|
name: "deviceId",
|
|
41894
42061
|
form: "single",
|
|
@@ -43740,6 +43907,52 @@ Object.freeze({
|
|
|
43740
43907
|
"network-access": "ingress",
|
|
43741
43908
|
"smtp-provider": "email"
|
|
43742
43909
|
});
|
|
43910
|
+
var G711_SCALE_CORRECTION_DB = {
|
|
43911
|
+
PCMU: 20 * Math.log10(4),
|
|
43912
|
+
PCMA: 20 * Math.log10(8)
|
|
43913
|
+
};
|
|
43914
|
+
/**
|
|
43915
|
+
* Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
|
|
43916
|
+
* same intent on the ITU-T scale (D460).
|
|
43917
|
+
*
|
|
43918
|
+
* ## When this applies, and when it is the wrong thing to reach for
|
|
43919
|
+
*
|
|
43920
|
+
* An absolute-dBFS number in this repo is one of two things, and only one of
|
|
43921
|
+
* them converts:
|
|
43922
|
+
*
|
|
43923
|
+
* - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
|
|
43924
|
+
* is loud". It was true on the ITU-T scale before the epoch and it is true
|
|
43925
|
+
* after. The defect was never in the number; it was that 19 of this hub's
|
|
43926
|
+
* 25 cameras did not obey it. Converting such a number takes something
|
|
43927
|
+
* correct and makes it wrong, in order to preserve a bug.
|
|
43928
|
+
* - **A measurement taken through the old decoder** — a value someone read
|
|
43929
|
+
* off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
|
|
43930
|
+
* describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
|
|
43931
|
+
* louder. That is what this function is for.
|
|
43932
|
+
*
|
|
43933
|
+
* Telling the two apart is a question about PROVENANCE, not about arithmetic,
|
|
43934
|
+
* and it cannot be answered from the number. It is answered by the comment the
|
|
43935
|
+
* author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
|
|
43936
|
+
* mandatory.
|
|
43937
|
+
*
|
|
43938
|
+
* ## Why a function and not a typed-in number
|
|
43939
|
+
*
|
|
43940
|
+
* `-55 + 12.04` written into a source file is, six months later, completely
|
|
43941
|
+
* indistinguishable from a threshold somebody simply preferred. Calling this
|
|
43942
|
+
* keeps the derivation, the law, and the original measurement all visible at
|
|
43943
|
+
* the call site, so a future reader can disagree with the *premise* instead of
|
|
43944
|
+
* having to reverse-engineer the sum.
|
|
43945
|
+
*
|
|
43946
|
+
* **This is not a runtime gain.** It converts an authored CONSTANT once, where
|
|
43947
|
+
* it is declared. It must never be applied to a live sample or a stored
|
|
43948
|
+
* `AudioEvent.dbfs`: the decoder is correct now, and a second authority
|
|
43949
|
+
* adjusting numbers the decoder already got right is the original defect with
|
|
43950
|
+
* an extra place to argue with (D459).
|
|
43951
|
+
*/
|
|
43952
|
+
function ituDbfsFromPreEpoch(law, authoredDbfs) {
|
|
43953
|
+
return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
|
|
43954
|
+
}
|
|
43955
|
+
Math.round(ituDbfsFromPreEpoch("PCMU", -55));
|
|
43743
43956
|
/** Schema defaults — an untouched sub-field must author exactly these. */
|
|
43744
43957
|
var NC_AUDIO_DEFAULTS = {
|
|
43745
43958
|
hitPercent: 60,
|
package/dist/addon.mjs
CHANGED
|
@@ -6446,6 +6446,86 @@ var ZodIssueCode = {
|
|
|
6446
6446
|
/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
|
|
6447
6447
|
var ZodFirstPartyTypeKind;
|
|
6448
6448
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
6449
|
+
//#endregion
|
|
6450
|
+
//#region ../types/dist/sleep-BnujYGPe.mjs
|
|
6451
|
+
/**
|
|
6452
|
+
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
6453
|
+
* window to float samples (D455).
|
|
6454
|
+
*
|
|
6455
|
+
* ## Why a format at all
|
|
6456
|
+
*
|
|
6457
|
+
* D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
|
|
6458
|
+
* RATE, and the one consumer that needs 16 kHz resamples next to the model.
|
|
6459
|
+
* It left the FORMAT alone — the broker still turned each G.711 byte into a
|
|
6460
|
+
* 4-byte f32le sample before the bytes entered the transport, so every leg of
|
|
6461
|
+
* the plane carried four times the source. The plane crosses hub-main twice on
|
|
6462
|
+
* the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
|
|
6463
|
+
*
|
|
6464
|
+
* So the plane carries the source BYTES too, and whoever needs floats expands
|
|
6465
|
+
* them where it needs them. That is the same argument D450 made for the rate,
|
|
6466
|
+
* one step further along the same wire.
|
|
6467
|
+
*
|
|
6468
|
+
* ## Why the expansion lives here
|
|
6469
|
+
*
|
|
6470
|
+
* Two packages need it and they must never disagree: `addon-pipeline`'s broker
|
|
6471
|
+
* (which still has to serve a subscriber that did NOT ask for coded bytes —
|
|
6472
|
+
* `AudioChunkPlane` expands per subscription) and
|
|
6473
|
+
* `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
|
|
6474
|
+
* f32le window to the analyzer cap, whose `AudioChunkInput` contract is
|
|
6475
|
+
* unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
|
|
6476
|
+
* into their own dist (`self-contained` externals), so this travels with a
|
|
6477
|
+
* `camstack deploy` and needs no published server.
|
|
6478
|
+
*
|
|
6479
|
+
* A second μ-law table anywhere else is the defect this module exists to
|
|
6480
|
+
* prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
|
|
6481
|
+
* direction for the WebRTC egress — a different transform, not a copy.)
|
|
6482
|
+
*
|
|
6483
|
+
* ## Absent means f32le
|
|
6484
|
+
*
|
|
6485
|
+
* `format` is optional on the wire and its absence means `f32le` — today's
|
|
6486
|
+
* bytes, byte for byte. A peer that never heard of the field is served what it
|
|
6487
|
+
* has always been served, because the broker only emits a coded window to a
|
|
6488
|
+
* subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
|
|
6489
|
+
* That is the D448 `rawForward` negotiation, and it is what makes this
|
|
6490
|
+
* deployable one addon at a time across three nodes.
|
|
6491
|
+
*/
|
|
6492
|
+
/** Every byte format the audio chunk plane can carry. `f32le` is the default. */
|
|
6493
|
+
var AUDIO_CHUNK_FORMATS = [
|
|
6494
|
+
"f32le",
|
|
6495
|
+
"pcmu",
|
|
6496
|
+
"pcma"
|
|
6497
|
+
];
|
|
6498
|
+
/**
|
|
6499
|
+
* Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
|
|
6500
|
+
* to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
|
|
6501
|
+
*
|
|
6502
|
+
* Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
|
|
6503
|
+
* it buffers the coded bytes and the plane's consumers expand.
|
|
6504
|
+
*/
|
|
6505
|
+
function buildUlawTable() {
|
|
6506
|
+
const table = new Float32Array(256);
|
|
6507
|
+
for (let i = 0; i < 256; i++) {
|
|
6508
|
+
const complemented = ~i & 255;
|
|
6509
|
+
const sign = (complemented & 128) !== 0 ? -1 : 1;
|
|
6510
|
+
const exponent = complemented >> 4 & 7;
|
|
6511
|
+
table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
|
|
6512
|
+
}
|
|
6513
|
+
return table;
|
|
6514
|
+
}
|
|
6515
|
+
/** Build the A-law decode table (ITU-T G.711). */
|
|
6516
|
+
function buildAlawTable() {
|
|
6517
|
+
const table = new Float32Array(256);
|
|
6518
|
+
for (let i = 0; i < 256; i++) {
|
|
6519
|
+
const xored = i ^ 85;
|
|
6520
|
+
const sign = (xored & 128) !== 0 ? 1 : -1;
|
|
6521
|
+
const exponent = xored >> 4 & 7;
|
|
6522
|
+
const mantissa = xored & 15;
|
|
6523
|
+
table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
|
|
6524
|
+
}
|
|
6525
|
+
return table;
|
|
6526
|
+
}
|
|
6527
|
+
buildUlawTable();
|
|
6528
|
+
buildAlawTable();
|
|
6449
6529
|
Object.fromEntries([
|
|
6450
6530
|
{
|
|
6451
6531
|
id: "overview",
|
|
@@ -7738,11 +7818,20 @@ var SubscribeFramesResultSchema = object({
|
|
|
7738
7818
|
* (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
|
|
7739
7819
|
* / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
|
|
7740
7820
|
*/
|
|
7821
|
+
var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
|
|
7741
7822
|
var DecodedAudioChunkSchema = object({
|
|
7742
7823
|
data: _instanceof(Uint8Array),
|
|
7743
7824
|
sampleRate: number().int().positive(),
|
|
7744
7825
|
channels: number().int().positive(),
|
|
7745
|
-
timestamp: number()
|
|
7826
|
+
timestamp: number(),
|
|
7827
|
+
/**
|
|
7828
|
+
* Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
|
|
7829
|
+
* byte, for any peer that never heard of this field. A coded window
|
|
7830
|
+
* (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
|
|
7831
|
+
* subscription that DECLARED it accepts one, so absence can never mean
|
|
7832
|
+
* "coded bytes a consumer will read as floats" (D455).
|
|
7833
|
+
*/
|
|
7834
|
+
format: AudioChunkFormatSchema.optional()
|
|
7746
7835
|
});
|
|
7747
7836
|
/**
|
|
7748
7837
|
* Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
|
|
@@ -7754,7 +7843,18 @@ var DecodedAudioChunkSchema = object({
|
|
|
7754
7843
|
var SubscribeAudioChunksInputSchema = object({
|
|
7755
7844
|
brokerId: string(),
|
|
7756
7845
|
/** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
|
|
7757
|
-
tag: string().optional()
|
|
7846
|
+
tag: string().optional(),
|
|
7847
|
+
/**
|
|
7848
|
+
* Byte formats this subscriber can READ, best first. The broker serves the
|
|
7849
|
+
* chunk's own format when it is in this list and expands to `f32le`
|
|
7850
|
+
* otherwise, so a subscriber is never handed bytes it cannot interpret.
|
|
7851
|
+
*
|
|
7852
|
+
* Absent (or without the source format) means `f32le` — the behaviour every
|
|
7853
|
+
* subscriber had before D455, unchanged. This is the negotiation half of
|
|
7854
|
+
* the source-bytes lever: it is what lets the broker and its consumers
|
|
7855
|
+
* deploy one at a time across three nodes.
|
|
7856
|
+
*/
|
|
7857
|
+
accept: array(AudioChunkFormatSchema).readonly().optional()
|
|
7758
7858
|
});
|
|
7759
7859
|
/** Result of `stream-broker.subscribeAudioChunks`. */
|
|
7760
7860
|
var SubscribeAudioChunksResultSchema = object({
|
|
@@ -11742,6 +11842,51 @@ var AudioAnalysisSettingsSchema = object({
|
|
|
11742
11842
|
minConfidence: number().min(0).max(1).default(.3),
|
|
11743
11843
|
allowedClasses: array(string()).default([])
|
|
11744
11844
|
});
|
|
11845
|
+
/**
|
|
11846
|
+
* `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
|
|
11847
|
+
*
|
|
11848
|
+
* Until D461 the orchestrator drained the broker's chunk plane, accumulated
|
|
11849
|
+
* ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
|
|
11850
|
+
* nor consumed the audio: the PCM crossed hub-main twice for a process that
|
|
11851
|
+
* only buffered it. `attachDevice` inverts the direction — the analyzer opens
|
|
11852
|
+
* its own `subscribeAudioChunks` against the broker and the subscriber IS the
|
|
11853
|
+
* decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
|
|
11854
|
+
* way to the one expansion that feeds the model.
|
|
11855
|
+
*
|
|
11856
|
+
* The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
|
|
11857
|
+
* window, the per-device node assignment, the settings read) and therefore
|
|
11858
|
+
* still owns the attach/detach pair. It no longer owns the bytes.
|
|
11859
|
+
*/
|
|
11860
|
+
var AudioAttachDeviceInputSchema = object({
|
|
11861
|
+
deviceId: number(),
|
|
11862
|
+
/** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
|
|
11863
|
+
brokerId: string(),
|
|
11864
|
+
/**
|
|
11865
|
+
* `clusterRoles.ingestNode` — the node whose broker owns the source dial.
|
|
11866
|
+
* Every `streamBroker` call the attachment makes is pinned to it, exactly as
|
|
11867
|
+
* the orchestrator's poller pinned them before the move.
|
|
11868
|
+
*/
|
|
11869
|
+
ingestNodeId: string(),
|
|
11870
|
+
/**
|
|
11871
|
+
* Resolved once by the orchestrator at attach time, exactly as it was read
|
|
11872
|
+
* once per subscription before D461. The analyzer does NOT re-resolve per
|
|
11873
|
+
* window: a settings change re-attaches, which is what always happened.
|
|
11874
|
+
*/
|
|
11875
|
+
settings: AudioAnalysisSettingsSchema
|
|
11876
|
+
});
|
|
11877
|
+
var AudioAttachDeviceResultSchema = object({
|
|
11878
|
+
/** False only when the analyzer is shutting down and refused to attach. */
|
|
11879
|
+
attached: boolean(),
|
|
11880
|
+
/**
|
|
11881
|
+
* True when the attachment replaced a live one for the same device. An
|
|
11882
|
+
* attach is idempotent by REPLACEMENT — two pollers on one camera would
|
|
11883
|
+
* double the broker's fanout and neither would know about the other.
|
|
11884
|
+
*/
|
|
11885
|
+
replaced: boolean()
|
|
11886
|
+
});
|
|
11887
|
+
var AudioDetachDeviceResultSchema = object({
|
|
11888
|
+
/** False when no attachment existed — detach is idempotent. */
|
|
11889
|
+
detached: boolean() });
|
|
11745
11890
|
var AudioClassificationResultSchema = object({
|
|
11746
11891
|
labels: array(AudioClassificationLabelSchema).readonly(),
|
|
11747
11892
|
rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
|
|
@@ -11750,7 +11895,7 @@ var AudioClassificationResultSchema = object({
|
|
|
11750
11895
|
method(object({
|
|
11751
11896
|
chunk: AudioChunkInputSchema,
|
|
11752
11897
|
settings: AudioAnalysisSettingsSchema
|
|
11753
|
-
}), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
|
|
11898
|
+
}), 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() }), {
|
|
11754
11899
|
kind: "mutation",
|
|
11755
11900
|
auth: "admin"
|
|
11756
11901
|
});
|
|
@@ -36034,12 +36179,24 @@ Object.freeze({
|
|
|
36034
36179
|
addonId: null,
|
|
36035
36180
|
access: "create"
|
|
36036
36181
|
},
|
|
36182
|
+
"audioAnalyzer.attachDevice": {
|
|
36183
|
+
capName: "audio-analyzer",
|
|
36184
|
+
capScope: "system",
|
|
36185
|
+
addonId: null,
|
|
36186
|
+
access: "create"
|
|
36187
|
+
},
|
|
36037
36188
|
"audioAnalyzer.classify": {
|
|
36038
36189
|
capName: "audio-analyzer",
|
|
36039
36190
|
capScope: "system",
|
|
36040
36191
|
addonId: null,
|
|
36041
36192
|
access: "view"
|
|
36042
36193
|
},
|
|
36194
|
+
"audioAnalyzer.detachDevice": {
|
|
36195
|
+
capName: "audio-analyzer",
|
|
36196
|
+
capScope: "system",
|
|
36197
|
+
addonId: null,
|
|
36198
|
+
access: "create"
|
|
36199
|
+
},
|
|
36043
36200
|
"audioAnalyzer.dispose": {
|
|
36044
36201
|
capName: "audio-analyzer",
|
|
36045
36202
|
capScope: "system",
|
|
@@ -41883,11 +42040,21 @@ Object.freeze({
|
|
|
41883
42040
|
form: "single",
|
|
41884
42041
|
optional: false
|
|
41885
42042
|
}],
|
|
42043
|
+
"audioAnalyzer.attachDevice": [{
|
|
42044
|
+
name: "deviceId",
|
|
42045
|
+
form: "single",
|
|
42046
|
+
optional: false
|
|
42047
|
+
}],
|
|
41886
42048
|
"audioAnalyzer.classify": [{
|
|
41887
42049
|
name: "deviceId",
|
|
41888
42050
|
form: "single",
|
|
41889
42051
|
optional: true
|
|
41890
42052
|
}],
|
|
42053
|
+
"audioAnalyzer.detachDevice": [{
|
|
42054
|
+
name: "deviceId",
|
|
42055
|
+
form: "single",
|
|
42056
|
+
optional: false
|
|
42057
|
+
}],
|
|
41891
42058
|
"audioMetrics.getCurrentSnapshot": [{
|
|
41892
42059
|
name: "deviceId",
|
|
41893
42060
|
form: "single",
|
|
@@ -43739,6 +43906,52 @@ Object.freeze({
|
|
|
43739
43906
|
"network-access": "ingress",
|
|
43740
43907
|
"smtp-provider": "email"
|
|
43741
43908
|
});
|
|
43909
|
+
var G711_SCALE_CORRECTION_DB = {
|
|
43910
|
+
PCMU: 20 * Math.log10(4),
|
|
43911
|
+
PCMA: 20 * Math.log10(8)
|
|
43912
|
+
};
|
|
43913
|
+
/**
|
|
43914
|
+
* Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
|
|
43915
|
+
* same intent on the ITU-T scale (D460).
|
|
43916
|
+
*
|
|
43917
|
+
* ## When this applies, and when it is the wrong thing to reach for
|
|
43918
|
+
*
|
|
43919
|
+
* An absolute-dBFS number in this repo is one of two things, and only one of
|
|
43920
|
+
* them converts:
|
|
43921
|
+
*
|
|
43922
|
+
* - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
|
|
43923
|
+
* is loud". It was true on the ITU-T scale before the epoch and it is true
|
|
43924
|
+
* after. The defect was never in the number; it was that 19 of this hub's
|
|
43925
|
+
* 25 cameras did not obey it. Converting such a number takes something
|
|
43926
|
+
* correct and makes it wrong, in order to preserve a bug.
|
|
43927
|
+
* - **A measurement taken through the old decoder** — a value someone read
|
|
43928
|
+
* off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
|
|
43929
|
+
* describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
|
|
43930
|
+
* louder. That is what this function is for.
|
|
43931
|
+
*
|
|
43932
|
+
* Telling the two apart is a question about PROVENANCE, not about arithmetic,
|
|
43933
|
+
* and it cannot be answered from the number. It is answered by the comment the
|
|
43934
|
+
* author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
|
|
43935
|
+
* mandatory.
|
|
43936
|
+
*
|
|
43937
|
+
* ## Why a function and not a typed-in number
|
|
43938
|
+
*
|
|
43939
|
+
* `-55 + 12.04` written into a source file is, six months later, completely
|
|
43940
|
+
* indistinguishable from a threshold somebody simply preferred. Calling this
|
|
43941
|
+
* keeps the derivation, the law, and the original measurement all visible at
|
|
43942
|
+
* the call site, so a future reader can disagree with the *premise* instead of
|
|
43943
|
+
* having to reverse-engineer the sum.
|
|
43944
|
+
*
|
|
43945
|
+
* **This is not a runtime gain.** It converts an authored CONSTANT once, where
|
|
43946
|
+
* it is declared. It must never be applied to a live sample or a stored
|
|
43947
|
+
* `AudioEvent.dbfs`: the decoder is correct now, and a second authority
|
|
43948
|
+
* adjusting numbers the decoder already got right is the original defect with
|
|
43949
|
+
* an extra place to argue with (D459).
|
|
43950
|
+
*/
|
|
43951
|
+
function ituDbfsFromPreEpoch(law, authoredDbfs) {
|
|
43952
|
+
return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
|
|
43953
|
+
}
|
|
43954
|
+
Math.round(ituDbfsFromPreEpoch("PCMU", -55));
|
|
43742
43955
|
/** Schema defaults — an untouched sub-field must author exactly these. */
|
|
43743
43956
|
var NC_AUDIO_DEFAULTS = {
|
|
43744
43957
|
hitPercent: 60,
|
package/package.json
CHANGED