@camstack/addon-provider-unifi 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
|
@@ -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({
|
|
@@ -10641,6 +10741,51 @@ var AudioAnalysisSettingsSchema = object({
|
|
|
10641
10741
|
minConfidence: number().min(0).max(1).default(.3),
|
|
10642
10742
|
allowedClasses: array(string()).default([])
|
|
10643
10743
|
});
|
|
10744
|
+
/**
|
|
10745
|
+
* `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
|
|
10746
|
+
*
|
|
10747
|
+
* Until D461 the orchestrator drained the broker's chunk plane, accumulated
|
|
10748
|
+
* ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
|
|
10749
|
+
* nor consumed the audio: the PCM crossed hub-main twice for a process that
|
|
10750
|
+
* only buffered it. `attachDevice` inverts the direction — the analyzer opens
|
|
10751
|
+
* its own `subscribeAudioChunks` against the broker and the subscriber IS the
|
|
10752
|
+
* decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
|
|
10753
|
+
* way to the one expansion that feeds the model.
|
|
10754
|
+
*
|
|
10755
|
+
* The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
|
|
10756
|
+
* window, the per-device node assignment, the settings read) and therefore
|
|
10757
|
+
* still owns the attach/detach pair. It no longer owns the bytes.
|
|
10758
|
+
*/
|
|
10759
|
+
var AudioAttachDeviceInputSchema = object({
|
|
10760
|
+
deviceId: number(),
|
|
10761
|
+
/** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
|
|
10762
|
+
brokerId: string(),
|
|
10763
|
+
/**
|
|
10764
|
+
* `clusterRoles.ingestNode` — the node whose broker owns the source dial.
|
|
10765
|
+
* Every `streamBroker` call the attachment makes is pinned to it, exactly as
|
|
10766
|
+
* the orchestrator's poller pinned them before the move.
|
|
10767
|
+
*/
|
|
10768
|
+
ingestNodeId: string(),
|
|
10769
|
+
/**
|
|
10770
|
+
* Resolved once by the orchestrator at attach time, exactly as it was read
|
|
10771
|
+
* once per subscription before D461. The analyzer does NOT re-resolve per
|
|
10772
|
+
* window: a settings change re-attaches, which is what always happened.
|
|
10773
|
+
*/
|
|
10774
|
+
settings: AudioAnalysisSettingsSchema
|
|
10775
|
+
});
|
|
10776
|
+
var AudioAttachDeviceResultSchema = object({
|
|
10777
|
+
/** False only when the analyzer is shutting down and refused to attach. */
|
|
10778
|
+
attached: boolean(),
|
|
10779
|
+
/**
|
|
10780
|
+
* True when the attachment replaced a live one for the same device. An
|
|
10781
|
+
* attach is idempotent by REPLACEMENT — two pollers on one camera would
|
|
10782
|
+
* double the broker's fanout and neither would know about the other.
|
|
10783
|
+
*/
|
|
10784
|
+
replaced: boolean()
|
|
10785
|
+
});
|
|
10786
|
+
var AudioDetachDeviceResultSchema = object({
|
|
10787
|
+
/** False when no attachment existed — detach is idempotent. */
|
|
10788
|
+
detached: boolean() });
|
|
10644
10789
|
var AudioClassificationResultSchema = object({
|
|
10645
10790
|
labels: array(AudioClassificationLabelSchema).readonly(),
|
|
10646
10791
|
rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
|
|
@@ -10649,7 +10794,7 @@ var AudioClassificationResultSchema = object({
|
|
|
10649
10794
|
method(object({
|
|
10650
10795
|
chunk: AudioChunkInputSchema,
|
|
10651
10796
|
settings: AudioAnalysisSettingsSchema
|
|
10652
|
-
}), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
|
|
10797
|
+
}), 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() }), {
|
|
10653
10798
|
kind: "mutation",
|
|
10654
10799
|
auth: "admin"
|
|
10655
10800
|
});
|
|
@@ -34925,12 +35070,24 @@ Object.freeze({
|
|
|
34925
35070
|
addonId: null,
|
|
34926
35071
|
access: "create"
|
|
34927
35072
|
},
|
|
35073
|
+
"audioAnalyzer.attachDevice": {
|
|
35074
|
+
capName: "audio-analyzer",
|
|
35075
|
+
capScope: "system",
|
|
35076
|
+
addonId: null,
|
|
35077
|
+
access: "create"
|
|
35078
|
+
},
|
|
34928
35079
|
"audioAnalyzer.classify": {
|
|
34929
35080
|
capName: "audio-analyzer",
|
|
34930
35081
|
capScope: "system",
|
|
34931
35082
|
addonId: null,
|
|
34932
35083
|
access: "view"
|
|
34933
35084
|
},
|
|
35085
|
+
"audioAnalyzer.detachDevice": {
|
|
35086
|
+
capName: "audio-analyzer",
|
|
35087
|
+
capScope: "system",
|
|
35088
|
+
addonId: null,
|
|
35089
|
+
access: "create"
|
|
35090
|
+
},
|
|
34934
35091
|
"audioAnalyzer.dispose": {
|
|
34935
35092
|
capName: "audio-analyzer",
|
|
34936
35093
|
capScope: "system",
|
|
@@ -40774,11 +40931,21 @@ Object.freeze({
|
|
|
40774
40931
|
form: "single",
|
|
40775
40932
|
optional: false
|
|
40776
40933
|
}],
|
|
40934
|
+
"audioAnalyzer.attachDevice": [{
|
|
40935
|
+
name: "deviceId",
|
|
40936
|
+
form: "single",
|
|
40937
|
+
optional: false
|
|
40938
|
+
}],
|
|
40777
40939
|
"audioAnalyzer.classify": [{
|
|
40778
40940
|
name: "deviceId",
|
|
40779
40941
|
form: "single",
|
|
40780
40942
|
optional: true
|
|
40781
40943
|
}],
|
|
40944
|
+
"audioAnalyzer.detachDevice": [{
|
|
40945
|
+
name: "deviceId",
|
|
40946
|
+
form: "single",
|
|
40947
|
+
optional: false
|
|
40948
|
+
}],
|
|
40782
40949
|
"audioMetrics.getCurrentSnapshot": [{
|
|
40783
40950
|
name: "deviceId",
|
|
40784
40951
|
form: "single",
|
|
@@ -42630,6 +42797,52 @@ Object.freeze({
|
|
|
42630
42797
|
"network-access": "ingress",
|
|
42631
42798
|
"smtp-provider": "email"
|
|
42632
42799
|
});
|
|
42800
|
+
var G711_SCALE_CORRECTION_DB = {
|
|
42801
|
+
PCMU: 20 * Math.log10(4),
|
|
42802
|
+
PCMA: 20 * Math.log10(8)
|
|
42803
|
+
};
|
|
42804
|
+
/**
|
|
42805
|
+
* Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
|
|
42806
|
+
* same intent on the ITU-T scale (D460).
|
|
42807
|
+
*
|
|
42808
|
+
* ## When this applies, and when it is the wrong thing to reach for
|
|
42809
|
+
*
|
|
42810
|
+
* An absolute-dBFS number in this repo is one of two things, and only one of
|
|
42811
|
+
* them converts:
|
|
42812
|
+
*
|
|
42813
|
+
* - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
|
|
42814
|
+
* is loud". It was true on the ITU-T scale before the epoch and it is true
|
|
42815
|
+
* after. The defect was never in the number; it was that 19 of this hub's
|
|
42816
|
+
* 25 cameras did not obey it. Converting such a number takes something
|
|
42817
|
+
* correct and makes it wrong, in order to preserve a bug.
|
|
42818
|
+
* - **A measurement taken through the old decoder** — a value someone read
|
|
42819
|
+
* off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
|
|
42820
|
+
* describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
|
|
42821
|
+
* louder. That is what this function is for.
|
|
42822
|
+
*
|
|
42823
|
+
* Telling the two apart is a question about PROVENANCE, not about arithmetic,
|
|
42824
|
+
* and it cannot be answered from the number. It is answered by the comment the
|
|
42825
|
+
* author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
|
|
42826
|
+
* mandatory.
|
|
42827
|
+
*
|
|
42828
|
+
* ## Why a function and not a typed-in number
|
|
42829
|
+
*
|
|
42830
|
+
* `-55 + 12.04` written into a source file is, six months later, completely
|
|
42831
|
+
* indistinguishable from a threshold somebody simply preferred. Calling this
|
|
42832
|
+
* keeps the derivation, the law, and the original measurement all visible at
|
|
42833
|
+
* the call site, so a future reader can disagree with the *premise* instead of
|
|
42834
|
+
* having to reverse-engineer the sum.
|
|
42835
|
+
*
|
|
42836
|
+
* **This is not a runtime gain.** It converts an authored CONSTANT once, where
|
|
42837
|
+
* it is declared. It must never be applied to a live sample or a stored
|
|
42838
|
+
* `AudioEvent.dbfs`: the decoder is correct now, and a second authority
|
|
42839
|
+
* adjusting numbers the decoder already got right is the original defect with
|
|
42840
|
+
* an extra place to argue with (D459).
|
|
42841
|
+
*/
|
|
42842
|
+
function ituDbfsFromPreEpoch(law, authoredDbfs) {
|
|
42843
|
+
return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
|
|
42844
|
+
}
|
|
42845
|
+
Math.round(ituDbfsFromPreEpoch("PCMU", -55));
|
|
42633
42846
|
/** Schema defaults — an untouched sub-field must author exactly these. */
|
|
42634
42847
|
var NC_AUDIO_DEFAULTS = {
|
|
42635
42848
|
hitPercent: 60,
|
package/dist/addon.mjs
CHANGED
|
@@ -5344,6 +5344,86 @@ var ZodIssueCode = {
|
|
|
5344
5344
|
/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
|
|
5345
5345
|
var ZodFirstPartyTypeKind;
|
|
5346
5346
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5347
|
+
//#endregion
|
|
5348
|
+
//#region ../types/dist/sleep-BnujYGPe.mjs
|
|
5349
|
+
/**
|
|
5350
|
+
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5351
|
+
* window to float samples (D455).
|
|
5352
|
+
*
|
|
5353
|
+
* ## Why a format at all
|
|
5354
|
+
*
|
|
5355
|
+
* D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
|
|
5356
|
+
* RATE, and the one consumer that needs 16 kHz resamples next to the model.
|
|
5357
|
+
* It left the FORMAT alone — the broker still turned each G.711 byte into a
|
|
5358
|
+
* 4-byte f32le sample before the bytes entered the transport, so every leg of
|
|
5359
|
+
* the plane carried four times the source. The plane crosses hub-main twice on
|
|
5360
|
+
* the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
|
|
5361
|
+
*
|
|
5362
|
+
* So the plane carries the source BYTES too, and whoever needs floats expands
|
|
5363
|
+
* them where it needs them. That is the same argument D450 made for the rate,
|
|
5364
|
+
* one step further along the same wire.
|
|
5365
|
+
*
|
|
5366
|
+
* ## Why the expansion lives here
|
|
5367
|
+
*
|
|
5368
|
+
* Two packages need it and they must never disagree: `addon-pipeline`'s broker
|
|
5369
|
+
* (which still has to serve a subscriber that did NOT ask for coded bytes —
|
|
5370
|
+
* `AudioChunkPlane` expands per subscription) and
|
|
5371
|
+
* `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
|
|
5372
|
+
* f32le window to the analyzer cap, whose `AudioChunkInput` contract is
|
|
5373
|
+
* unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
|
|
5374
|
+
* into their own dist (`self-contained` externals), so this travels with a
|
|
5375
|
+
* `camstack deploy` and needs no published server.
|
|
5376
|
+
*
|
|
5377
|
+
* A second μ-law table anywhere else is the defect this module exists to
|
|
5378
|
+
* prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
|
|
5379
|
+
* direction for the WebRTC egress — a different transform, not a copy.)
|
|
5380
|
+
*
|
|
5381
|
+
* ## Absent means f32le
|
|
5382
|
+
*
|
|
5383
|
+
* `format` is optional on the wire and its absence means `f32le` — today's
|
|
5384
|
+
* bytes, byte for byte. A peer that never heard of the field is served what it
|
|
5385
|
+
* has always been served, because the broker only emits a coded window to a
|
|
5386
|
+
* subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
|
|
5387
|
+
* That is the D448 `rawForward` negotiation, and it is what makes this
|
|
5388
|
+
* deployable one addon at a time across three nodes.
|
|
5389
|
+
*/
|
|
5390
|
+
/** Every byte format the audio chunk plane can carry. `f32le` is the default. */
|
|
5391
|
+
var AUDIO_CHUNK_FORMATS = [
|
|
5392
|
+
"f32le",
|
|
5393
|
+
"pcmu",
|
|
5394
|
+
"pcma"
|
|
5395
|
+
];
|
|
5396
|
+
/**
|
|
5397
|
+
* Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
|
|
5398
|
+
* to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
|
|
5399
|
+
*
|
|
5400
|
+
* Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
|
|
5401
|
+
* it buffers the coded bytes and the plane's consumers expand.
|
|
5402
|
+
*/
|
|
5403
|
+
function buildUlawTable() {
|
|
5404
|
+
const table = new Float32Array(256);
|
|
5405
|
+
for (let i = 0; i < 256; i++) {
|
|
5406
|
+
const complemented = ~i & 255;
|
|
5407
|
+
const sign = (complemented & 128) !== 0 ? -1 : 1;
|
|
5408
|
+
const exponent = complemented >> 4 & 7;
|
|
5409
|
+
table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
|
|
5410
|
+
}
|
|
5411
|
+
return table;
|
|
5412
|
+
}
|
|
5413
|
+
/** Build the A-law decode table (ITU-T G.711). */
|
|
5414
|
+
function buildAlawTable() {
|
|
5415
|
+
const table = new Float32Array(256);
|
|
5416
|
+
for (let i = 0; i < 256; i++) {
|
|
5417
|
+
const xored = i ^ 85;
|
|
5418
|
+
const sign = (xored & 128) !== 0 ? 1 : -1;
|
|
5419
|
+
const exponent = xored >> 4 & 7;
|
|
5420
|
+
const mantissa = xored & 15;
|
|
5421
|
+
table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
|
|
5422
|
+
}
|
|
5423
|
+
return table;
|
|
5424
|
+
}
|
|
5425
|
+
buildUlawTable();
|
|
5426
|
+
buildAlawTable();
|
|
5347
5427
|
Object.fromEntries([
|
|
5348
5428
|
{
|
|
5349
5429
|
id: "overview",
|
|
@@ -6636,11 +6716,20 @@ var SubscribeFramesResultSchema = object({
|
|
|
6636
6716
|
* (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
|
|
6637
6717
|
* / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
|
|
6638
6718
|
*/
|
|
6719
|
+
var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
|
|
6639
6720
|
var DecodedAudioChunkSchema = object({
|
|
6640
6721
|
data: _instanceof(Uint8Array),
|
|
6641
6722
|
sampleRate: number().int().positive(),
|
|
6642
6723
|
channels: number().int().positive(),
|
|
6643
|
-
timestamp: number()
|
|
6724
|
+
timestamp: number(),
|
|
6725
|
+
/**
|
|
6726
|
+
* Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
|
|
6727
|
+
* byte, for any peer that never heard of this field. A coded window
|
|
6728
|
+
* (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
|
|
6729
|
+
* subscription that DECLARED it accepts one, so absence can never mean
|
|
6730
|
+
* "coded bytes a consumer will read as floats" (D455).
|
|
6731
|
+
*/
|
|
6732
|
+
format: AudioChunkFormatSchema.optional()
|
|
6644
6733
|
});
|
|
6645
6734
|
/**
|
|
6646
6735
|
* Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
|
|
@@ -6652,7 +6741,18 @@ var DecodedAudioChunkSchema = object({
|
|
|
6652
6741
|
var SubscribeAudioChunksInputSchema = object({
|
|
6653
6742
|
brokerId: string(),
|
|
6654
6743
|
/** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
|
|
6655
|
-
tag: string().optional()
|
|
6744
|
+
tag: string().optional(),
|
|
6745
|
+
/**
|
|
6746
|
+
* Byte formats this subscriber can READ, best first. The broker serves the
|
|
6747
|
+
* chunk's own format when it is in this list and expands to `f32le`
|
|
6748
|
+
* otherwise, so a subscriber is never handed bytes it cannot interpret.
|
|
6749
|
+
*
|
|
6750
|
+
* Absent (or without the source format) means `f32le` — the behaviour every
|
|
6751
|
+
* subscriber had before D455, unchanged. This is the negotiation half of
|
|
6752
|
+
* the source-bytes lever: it is what lets the broker and its consumers
|
|
6753
|
+
* deploy one at a time across three nodes.
|
|
6754
|
+
*/
|
|
6755
|
+
accept: array(AudioChunkFormatSchema).readonly().optional()
|
|
6656
6756
|
});
|
|
6657
6757
|
/** Result of `stream-broker.subscribeAudioChunks`. */
|
|
6658
6758
|
var SubscribeAudioChunksResultSchema = object({
|
|
@@ -10640,6 +10740,51 @@ var AudioAnalysisSettingsSchema = object({
|
|
|
10640
10740
|
minConfidence: number().min(0).max(1).default(.3),
|
|
10641
10741
|
allowedClasses: array(string()).default([])
|
|
10642
10742
|
});
|
|
10743
|
+
/**
|
|
10744
|
+
* `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
|
|
10745
|
+
*
|
|
10746
|
+
* Until D461 the orchestrator drained the broker's chunk plane, accumulated
|
|
10747
|
+
* ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
|
|
10748
|
+
* nor consumed the audio: the PCM crossed hub-main twice for a process that
|
|
10749
|
+
* only buffered it. `attachDevice` inverts the direction — the analyzer opens
|
|
10750
|
+
* its own `subscribeAudioChunks` against the broker and the subscriber IS the
|
|
10751
|
+
* decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
|
|
10752
|
+
* way to the one expansion that feeds the model.
|
|
10753
|
+
*
|
|
10754
|
+
* The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
|
|
10755
|
+
* window, the per-device node assignment, the settings read) and therefore
|
|
10756
|
+
* still owns the attach/detach pair. It no longer owns the bytes.
|
|
10757
|
+
*/
|
|
10758
|
+
var AudioAttachDeviceInputSchema = object({
|
|
10759
|
+
deviceId: number(),
|
|
10760
|
+
/** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
|
|
10761
|
+
brokerId: string(),
|
|
10762
|
+
/**
|
|
10763
|
+
* `clusterRoles.ingestNode` — the node whose broker owns the source dial.
|
|
10764
|
+
* Every `streamBroker` call the attachment makes is pinned to it, exactly as
|
|
10765
|
+
* the orchestrator's poller pinned them before the move.
|
|
10766
|
+
*/
|
|
10767
|
+
ingestNodeId: string(),
|
|
10768
|
+
/**
|
|
10769
|
+
* Resolved once by the orchestrator at attach time, exactly as it was read
|
|
10770
|
+
* once per subscription before D461. The analyzer does NOT re-resolve per
|
|
10771
|
+
* window: a settings change re-attaches, which is what always happened.
|
|
10772
|
+
*/
|
|
10773
|
+
settings: AudioAnalysisSettingsSchema
|
|
10774
|
+
});
|
|
10775
|
+
var AudioAttachDeviceResultSchema = object({
|
|
10776
|
+
/** False only when the analyzer is shutting down and refused to attach. */
|
|
10777
|
+
attached: boolean(),
|
|
10778
|
+
/**
|
|
10779
|
+
* True when the attachment replaced a live one for the same device. An
|
|
10780
|
+
* attach is idempotent by REPLACEMENT — two pollers on one camera would
|
|
10781
|
+
* double the broker's fanout and neither would know about the other.
|
|
10782
|
+
*/
|
|
10783
|
+
replaced: boolean()
|
|
10784
|
+
});
|
|
10785
|
+
var AudioDetachDeviceResultSchema = object({
|
|
10786
|
+
/** False when no attachment existed — detach is idempotent. */
|
|
10787
|
+
detached: boolean() });
|
|
10643
10788
|
var AudioClassificationResultSchema = object({
|
|
10644
10789
|
labels: array(AudioClassificationLabelSchema).readonly(),
|
|
10645
10790
|
rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
|
|
@@ -10648,7 +10793,7 @@ var AudioClassificationResultSchema = object({
|
|
|
10648
10793
|
method(object({
|
|
10649
10794
|
chunk: AudioChunkInputSchema,
|
|
10650
10795
|
settings: AudioAnalysisSettingsSchema
|
|
10651
|
-
}), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
|
|
10796
|
+
}), 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() }), {
|
|
10652
10797
|
kind: "mutation",
|
|
10653
10798
|
auth: "admin"
|
|
10654
10799
|
});
|
|
@@ -34924,12 +35069,24 @@ Object.freeze({
|
|
|
34924
35069
|
addonId: null,
|
|
34925
35070
|
access: "create"
|
|
34926
35071
|
},
|
|
35072
|
+
"audioAnalyzer.attachDevice": {
|
|
35073
|
+
capName: "audio-analyzer",
|
|
35074
|
+
capScope: "system",
|
|
35075
|
+
addonId: null,
|
|
35076
|
+
access: "create"
|
|
35077
|
+
},
|
|
34927
35078
|
"audioAnalyzer.classify": {
|
|
34928
35079
|
capName: "audio-analyzer",
|
|
34929
35080
|
capScope: "system",
|
|
34930
35081
|
addonId: null,
|
|
34931
35082
|
access: "view"
|
|
34932
35083
|
},
|
|
35084
|
+
"audioAnalyzer.detachDevice": {
|
|
35085
|
+
capName: "audio-analyzer",
|
|
35086
|
+
capScope: "system",
|
|
35087
|
+
addonId: null,
|
|
35088
|
+
access: "create"
|
|
35089
|
+
},
|
|
34933
35090
|
"audioAnalyzer.dispose": {
|
|
34934
35091
|
capName: "audio-analyzer",
|
|
34935
35092
|
capScope: "system",
|
|
@@ -40773,11 +40930,21 @@ Object.freeze({
|
|
|
40773
40930
|
form: "single",
|
|
40774
40931
|
optional: false
|
|
40775
40932
|
}],
|
|
40933
|
+
"audioAnalyzer.attachDevice": [{
|
|
40934
|
+
name: "deviceId",
|
|
40935
|
+
form: "single",
|
|
40936
|
+
optional: false
|
|
40937
|
+
}],
|
|
40776
40938
|
"audioAnalyzer.classify": [{
|
|
40777
40939
|
name: "deviceId",
|
|
40778
40940
|
form: "single",
|
|
40779
40941
|
optional: true
|
|
40780
40942
|
}],
|
|
40943
|
+
"audioAnalyzer.detachDevice": [{
|
|
40944
|
+
name: "deviceId",
|
|
40945
|
+
form: "single",
|
|
40946
|
+
optional: false
|
|
40947
|
+
}],
|
|
40781
40948
|
"audioMetrics.getCurrentSnapshot": [{
|
|
40782
40949
|
name: "deviceId",
|
|
40783
40950
|
form: "single",
|
|
@@ -42629,6 +42796,52 @@ Object.freeze({
|
|
|
42629
42796
|
"network-access": "ingress",
|
|
42630
42797
|
"smtp-provider": "email"
|
|
42631
42798
|
});
|
|
42799
|
+
var G711_SCALE_CORRECTION_DB = {
|
|
42800
|
+
PCMU: 20 * Math.log10(4),
|
|
42801
|
+
PCMA: 20 * Math.log10(8)
|
|
42802
|
+
};
|
|
42803
|
+
/**
|
|
42804
|
+
* Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
|
|
42805
|
+
* same intent on the ITU-T scale (D460).
|
|
42806
|
+
*
|
|
42807
|
+
* ## When this applies, and when it is the wrong thing to reach for
|
|
42808
|
+
*
|
|
42809
|
+
* An absolute-dBFS number in this repo is one of two things, and only one of
|
|
42810
|
+
* them converts:
|
|
42811
|
+
*
|
|
42812
|
+
* - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
|
|
42813
|
+
* is loud". It was true on the ITU-T scale before the epoch and it is true
|
|
42814
|
+
* after. The defect was never in the number; it was that 19 of this hub's
|
|
42815
|
+
* 25 cameras did not obey it. Converting such a number takes something
|
|
42816
|
+
* correct and makes it wrong, in order to preserve a bug.
|
|
42817
|
+
* - **A measurement taken through the old decoder** — a value someone read
|
|
42818
|
+
* off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
|
|
42819
|
+
* describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
|
|
42820
|
+
* louder. That is what this function is for.
|
|
42821
|
+
*
|
|
42822
|
+
* Telling the two apart is a question about PROVENANCE, not about arithmetic,
|
|
42823
|
+
* and it cannot be answered from the number. It is answered by the comment the
|
|
42824
|
+
* author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
|
|
42825
|
+
* mandatory.
|
|
42826
|
+
*
|
|
42827
|
+
* ## Why a function and not a typed-in number
|
|
42828
|
+
*
|
|
42829
|
+
* `-55 + 12.04` written into a source file is, six months later, completely
|
|
42830
|
+
* indistinguishable from a threshold somebody simply preferred. Calling this
|
|
42831
|
+
* keeps the derivation, the law, and the original measurement all visible at
|
|
42832
|
+
* the call site, so a future reader can disagree with the *premise* instead of
|
|
42833
|
+
* having to reverse-engineer the sum.
|
|
42834
|
+
*
|
|
42835
|
+
* **This is not a runtime gain.** It converts an authored CONSTANT once, where
|
|
42836
|
+
* it is declared. It must never be applied to a live sample or a stored
|
|
42837
|
+
* `AudioEvent.dbfs`: the decoder is correct now, and a second authority
|
|
42838
|
+
* adjusting numbers the decoder already got right is the original defect with
|
|
42839
|
+
* an extra place to argue with (D459).
|
|
42840
|
+
*/
|
|
42841
|
+
function ituDbfsFromPreEpoch(law, authoredDbfs) {
|
|
42842
|
+
return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
|
|
42843
|
+
}
|
|
42844
|
+
Math.round(ituDbfsFromPreEpoch("PCMU", -55));
|
|
42632
42845
|
/** Schema defaults — an untouched sub-field must author exactly these. */
|
|
42633
42846
|
var NC_AUDIO_DEFAULTS = {
|
|
42634
42847
|
hitPercent: 60,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/addon-provider-unifi",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.96",
|
|
4
4
|
"description": "UniFi Network controller device-provider addon for CamStack — local-controller infra switches/APs (as containers) + network-client presence. NO cameras/Protect.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"camstack",
|