@camstack/addon-provider-tuya 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
|
@@ -6165,6 +6165,86 @@ var ZodIssueCode = {
|
|
|
6165
6165
|
/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
|
|
6166
6166
|
var ZodFirstPartyTypeKind;
|
|
6167
6167
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
6168
|
+
//#endregion
|
|
6169
|
+
//#region ../types/dist/sleep-BnujYGPe.mjs
|
|
6170
|
+
/**
|
|
6171
|
+
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
6172
|
+
* window to float samples (D455).
|
|
6173
|
+
*
|
|
6174
|
+
* ## Why a format at all
|
|
6175
|
+
*
|
|
6176
|
+
* D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
|
|
6177
|
+
* RATE, and the one consumer that needs 16 kHz resamples next to the model.
|
|
6178
|
+
* It left the FORMAT alone — the broker still turned each G.711 byte into a
|
|
6179
|
+
* 4-byte f32le sample before the bytes entered the transport, so every leg of
|
|
6180
|
+
* the plane carried four times the source. The plane crosses hub-main twice on
|
|
6181
|
+
* the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
|
|
6182
|
+
*
|
|
6183
|
+
* So the plane carries the source BYTES too, and whoever needs floats expands
|
|
6184
|
+
* them where it needs them. That is the same argument D450 made for the rate,
|
|
6185
|
+
* one step further along the same wire.
|
|
6186
|
+
*
|
|
6187
|
+
* ## Why the expansion lives here
|
|
6188
|
+
*
|
|
6189
|
+
* Two packages need it and they must never disagree: `addon-pipeline`'s broker
|
|
6190
|
+
* (which still has to serve a subscriber that did NOT ask for coded bytes —
|
|
6191
|
+
* `AudioChunkPlane` expands per subscription) and
|
|
6192
|
+
* `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
|
|
6193
|
+
* f32le window to the analyzer cap, whose `AudioChunkInput` contract is
|
|
6194
|
+
* unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
|
|
6195
|
+
* into their own dist (`self-contained` externals), so this travels with a
|
|
6196
|
+
* `camstack deploy` and needs no published server.
|
|
6197
|
+
*
|
|
6198
|
+
* A second μ-law table anywhere else is the defect this module exists to
|
|
6199
|
+
* prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
|
|
6200
|
+
* direction for the WebRTC egress — a different transform, not a copy.)
|
|
6201
|
+
*
|
|
6202
|
+
* ## Absent means f32le
|
|
6203
|
+
*
|
|
6204
|
+
* `format` is optional on the wire and its absence means `f32le` — today's
|
|
6205
|
+
* bytes, byte for byte. A peer that never heard of the field is served what it
|
|
6206
|
+
* has always been served, because the broker only emits a coded window to a
|
|
6207
|
+
* subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
|
|
6208
|
+
* That is the D448 `rawForward` negotiation, and it is what makes this
|
|
6209
|
+
* deployable one addon at a time across three nodes.
|
|
6210
|
+
*/
|
|
6211
|
+
/** Every byte format the audio chunk plane can carry. `f32le` is the default. */
|
|
6212
|
+
var AUDIO_CHUNK_FORMATS = [
|
|
6213
|
+
"f32le",
|
|
6214
|
+
"pcmu",
|
|
6215
|
+
"pcma"
|
|
6216
|
+
];
|
|
6217
|
+
/**
|
|
6218
|
+
* Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
|
|
6219
|
+
* to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
|
|
6220
|
+
*
|
|
6221
|
+
* Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
|
|
6222
|
+
* it buffers the coded bytes and the plane's consumers expand.
|
|
6223
|
+
*/
|
|
6224
|
+
function buildUlawTable() {
|
|
6225
|
+
const table = new Float32Array(256);
|
|
6226
|
+
for (let i = 0; i < 256; i++) {
|
|
6227
|
+
const complemented = ~i & 255;
|
|
6228
|
+
const sign = (complemented & 128) !== 0 ? -1 : 1;
|
|
6229
|
+
const exponent = complemented >> 4 & 7;
|
|
6230
|
+
table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
|
|
6231
|
+
}
|
|
6232
|
+
return table;
|
|
6233
|
+
}
|
|
6234
|
+
/** Build the A-law decode table (ITU-T G.711). */
|
|
6235
|
+
function buildAlawTable() {
|
|
6236
|
+
const table = new Float32Array(256);
|
|
6237
|
+
for (let i = 0; i < 256; i++) {
|
|
6238
|
+
const xored = i ^ 85;
|
|
6239
|
+
const sign = (xored & 128) !== 0 ? 1 : -1;
|
|
6240
|
+
const exponent = xored >> 4 & 7;
|
|
6241
|
+
const mantissa = xored & 15;
|
|
6242
|
+
table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
|
|
6243
|
+
}
|
|
6244
|
+
return table;
|
|
6245
|
+
}
|
|
6246
|
+
buildUlawTable();
|
|
6247
|
+
buildAlawTable();
|
|
6168
6248
|
Object.fromEntries([
|
|
6169
6249
|
{
|
|
6170
6250
|
id: "overview",
|
|
@@ -7457,11 +7537,20 @@ var SubscribeFramesResultSchema = object({
|
|
|
7457
7537
|
* (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
|
|
7458
7538
|
* / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
|
|
7459
7539
|
*/
|
|
7540
|
+
var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
|
|
7460
7541
|
var DecodedAudioChunkSchema = object({
|
|
7461
7542
|
data: _instanceof(Uint8Array),
|
|
7462
7543
|
sampleRate: number().int().positive(),
|
|
7463
7544
|
channels: number().int().positive(),
|
|
7464
|
-
timestamp: number()
|
|
7545
|
+
timestamp: number(),
|
|
7546
|
+
/**
|
|
7547
|
+
* Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
|
|
7548
|
+
* byte, for any peer that never heard of this field. A coded window
|
|
7549
|
+
* (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
|
|
7550
|
+
* subscription that DECLARED it accepts one, so absence can never mean
|
|
7551
|
+
* "coded bytes a consumer will read as floats" (D455).
|
|
7552
|
+
*/
|
|
7553
|
+
format: AudioChunkFormatSchema.optional()
|
|
7465
7554
|
});
|
|
7466
7555
|
/**
|
|
7467
7556
|
* Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
|
|
@@ -7473,7 +7562,18 @@ var DecodedAudioChunkSchema = object({
|
|
|
7473
7562
|
var SubscribeAudioChunksInputSchema = object({
|
|
7474
7563
|
brokerId: string(),
|
|
7475
7564
|
/** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
|
|
7476
|
-
tag: string().optional()
|
|
7565
|
+
tag: string().optional(),
|
|
7566
|
+
/**
|
|
7567
|
+
* Byte formats this subscriber can READ, best first. The broker serves the
|
|
7568
|
+
* chunk's own format when it is in this list and expands to `f32le`
|
|
7569
|
+
* otherwise, so a subscriber is never handed bytes it cannot interpret.
|
|
7570
|
+
*
|
|
7571
|
+
* Absent (or without the source format) means `f32le` — the behaviour every
|
|
7572
|
+
* subscriber had before D455, unchanged. This is the negotiation half of
|
|
7573
|
+
* the source-bytes lever: it is what lets the broker and its consumers
|
|
7574
|
+
* deploy one at a time across three nodes.
|
|
7575
|
+
*/
|
|
7576
|
+
accept: array(AudioChunkFormatSchema).readonly().optional()
|
|
7477
7577
|
});
|
|
7478
7578
|
/** Result of `stream-broker.subscribeAudioChunks`. */
|
|
7479
7579
|
var SubscribeAudioChunksResultSchema = object({
|
|
@@ -11461,6 +11561,51 @@ var AudioAnalysisSettingsSchema = object({
|
|
|
11461
11561
|
minConfidence: number().min(0).max(1).default(.3),
|
|
11462
11562
|
allowedClasses: array(string()).default([])
|
|
11463
11563
|
});
|
|
11564
|
+
/**
|
|
11565
|
+
* `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
|
|
11566
|
+
*
|
|
11567
|
+
* Until D461 the orchestrator drained the broker's chunk plane, accumulated
|
|
11568
|
+
* ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
|
|
11569
|
+
* nor consumed the audio: the PCM crossed hub-main twice for a process that
|
|
11570
|
+
* only buffered it. `attachDevice` inverts the direction — the analyzer opens
|
|
11571
|
+
* its own `subscribeAudioChunks` against the broker and the subscriber IS the
|
|
11572
|
+
* decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
|
|
11573
|
+
* way to the one expansion that feeds the model.
|
|
11574
|
+
*
|
|
11575
|
+
* The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
|
|
11576
|
+
* window, the per-device node assignment, the settings read) and therefore
|
|
11577
|
+
* still owns the attach/detach pair. It no longer owns the bytes.
|
|
11578
|
+
*/
|
|
11579
|
+
var AudioAttachDeviceInputSchema = object({
|
|
11580
|
+
deviceId: number(),
|
|
11581
|
+
/** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
|
|
11582
|
+
brokerId: string(),
|
|
11583
|
+
/**
|
|
11584
|
+
* `clusterRoles.ingestNode` — the node whose broker owns the source dial.
|
|
11585
|
+
* Every `streamBroker` call the attachment makes is pinned to it, exactly as
|
|
11586
|
+
* the orchestrator's poller pinned them before the move.
|
|
11587
|
+
*/
|
|
11588
|
+
ingestNodeId: string(),
|
|
11589
|
+
/**
|
|
11590
|
+
* Resolved once by the orchestrator at attach time, exactly as it was read
|
|
11591
|
+
* once per subscription before D461. The analyzer does NOT re-resolve per
|
|
11592
|
+
* window: a settings change re-attaches, which is what always happened.
|
|
11593
|
+
*/
|
|
11594
|
+
settings: AudioAnalysisSettingsSchema
|
|
11595
|
+
});
|
|
11596
|
+
var AudioAttachDeviceResultSchema = object({
|
|
11597
|
+
/** False only when the analyzer is shutting down and refused to attach. */
|
|
11598
|
+
attached: boolean(),
|
|
11599
|
+
/**
|
|
11600
|
+
* True when the attachment replaced a live one for the same device. An
|
|
11601
|
+
* attach is idempotent by REPLACEMENT — two pollers on one camera would
|
|
11602
|
+
* double the broker's fanout and neither would know about the other.
|
|
11603
|
+
*/
|
|
11604
|
+
replaced: boolean()
|
|
11605
|
+
});
|
|
11606
|
+
var AudioDetachDeviceResultSchema = object({
|
|
11607
|
+
/** False when no attachment existed — detach is idempotent. */
|
|
11608
|
+
detached: boolean() });
|
|
11464
11609
|
var AudioClassificationResultSchema = object({
|
|
11465
11610
|
labels: array(AudioClassificationLabelSchema).readonly(),
|
|
11466
11611
|
rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
|
|
@@ -11469,7 +11614,7 @@ var AudioClassificationResultSchema = object({
|
|
|
11469
11614
|
method(object({
|
|
11470
11615
|
chunk: AudioChunkInputSchema,
|
|
11471
11616
|
settings: AudioAnalysisSettingsSchema
|
|
11472
|
-
}), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
|
|
11617
|
+
}), 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() }), {
|
|
11473
11618
|
kind: "mutation",
|
|
11474
11619
|
auth: "admin"
|
|
11475
11620
|
});
|
|
@@ -35753,12 +35898,24 @@ Object.freeze({
|
|
|
35753
35898
|
addonId: null,
|
|
35754
35899
|
access: "create"
|
|
35755
35900
|
},
|
|
35901
|
+
"audioAnalyzer.attachDevice": {
|
|
35902
|
+
capName: "audio-analyzer",
|
|
35903
|
+
capScope: "system",
|
|
35904
|
+
addonId: null,
|
|
35905
|
+
access: "create"
|
|
35906
|
+
},
|
|
35756
35907
|
"audioAnalyzer.classify": {
|
|
35757
35908
|
capName: "audio-analyzer",
|
|
35758
35909
|
capScope: "system",
|
|
35759
35910
|
addonId: null,
|
|
35760
35911
|
access: "view"
|
|
35761
35912
|
},
|
|
35913
|
+
"audioAnalyzer.detachDevice": {
|
|
35914
|
+
capName: "audio-analyzer",
|
|
35915
|
+
capScope: "system",
|
|
35916
|
+
addonId: null,
|
|
35917
|
+
access: "create"
|
|
35918
|
+
},
|
|
35762
35919
|
"audioAnalyzer.dispose": {
|
|
35763
35920
|
capName: "audio-analyzer",
|
|
35764
35921
|
capScope: "system",
|
|
@@ -41602,11 +41759,21 @@ Object.freeze({
|
|
|
41602
41759
|
form: "single",
|
|
41603
41760
|
optional: false
|
|
41604
41761
|
}],
|
|
41762
|
+
"audioAnalyzer.attachDevice": [{
|
|
41763
|
+
name: "deviceId",
|
|
41764
|
+
form: "single",
|
|
41765
|
+
optional: false
|
|
41766
|
+
}],
|
|
41605
41767
|
"audioAnalyzer.classify": [{
|
|
41606
41768
|
name: "deviceId",
|
|
41607
41769
|
form: "single",
|
|
41608
41770
|
optional: true
|
|
41609
41771
|
}],
|
|
41772
|
+
"audioAnalyzer.detachDevice": [{
|
|
41773
|
+
name: "deviceId",
|
|
41774
|
+
form: "single",
|
|
41775
|
+
optional: false
|
|
41776
|
+
}],
|
|
41610
41777
|
"audioMetrics.getCurrentSnapshot": [{
|
|
41611
41778
|
name: "deviceId",
|
|
41612
41779
|
form: "single",
|
|
@@ -43458,6 +43625,52 @@ Object.freeze({
|
|
|
43458
43625
|
"network-access": "ingress",
|
|
43459
43626
|
"smtp-provider": "email"
|
|
43460
43627
|
});
|
|
43628
|
+
var G711_SCALE_CORRECTION_DB = {
|
|
43629
|
+
PCMU: 20 * Math.log10(4),
|
|
43630
|
+
PCMA: 20 * Math.log10(8)
|
|
43631
|
+
};
|
|
43632
|
+
/**
|
|
43633
|
+
* Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
|
|
43634
|
+
* same intent on the ITU-T scale (D460).
|
|
43635
|
+
*
|
|
43636
|
+
* ## When this applies, and when it is the wrong thing to reach for
|
|
43637
|
+
*
|
|
43638
|
+
* An absolute-dBFS number in this repo is one of two things, and only one of
|
|
43639
|
+
* them converts:
|
|
43640
|
+
*
|
|
43641
|
+
* - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
|
|
43642
|
+
* is loud". It was true on the ITU-T scale before the epoch and it is true
|
|
43643
|
+
* after. The defect was never in the number; it was that 19 of this hub's
|
|
43644
|
+
* 25 cameras did not obey it. Converting such a number takes something
|
|
43645
|
+
* correct and makes it wrong, in order to preserve a bug.
|
|
43646
|
+
* - **A measurement taken through the old decoder** — a value someone read
|
|
43647
|
+
* off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
|
|
43648
|
+
* describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
|
|
43649
|
+
* louder. That is what this function is for.
|
|
43650
|
+
*
|
|
43651
|
+
* Telling the two apart is a question about PROVENANCE, not about arithmetic,
|
|
43652
|
+
* and it cannot be answered from the number. It is answered by the comment the
|
|
43653
|
+
* author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
|
|
43654
|
+
* mandatory.
|
|
43655
|
+
*
|
|
43656
|
+
* ## Why a function and not a typed-in number
|
|
43657
|
+
*
|
|
43658
|
+
* `-55 + 12.04` written into a source file is, six months later, completely
|
|
43659
|
+
* indistinguishable from a threshold somebody simply preferred. Calling this
|
|
43660
|
+
* keeps the derivation, the law, and the original measurement all visible at
|
|
43661
|
+
* the call site, so a future reader can disagree with the *premise* instead of
|
|
43662
|
+
* having to reverse-engineer the sum.
|
|
43663
|
+
*
|
|
43664
|
+
* **This is not a runtime gain.** It converts an authored CONSTANT once, where
|
|
43665
|
+
* it is declared. It must never be applied to a live sample or a stored
|
|
43666
|
+
* `AudioEvent.dbfs`: the decoder is correct now, and a second authority
|
|
43667
|
+
* adjusting numbers the decoder already got right is the original defect with
|
|
43668
|
+
* an extra place to argue with (D459).
|
|
43669
|
+
*/
|
|
43670
|
+
function ituDbfsFromPreEpoch(law, authoredDbfs) {
|
|
43671
|
+
return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
|
|
43672
|
+
}
|
|
43673
|
+
Math.round(ituDbfsFromPreEpoch("PCMU", -55));
|
|
43461
43674
|
/** Schema defaults — an untouched sub-field must author exactly these. */
|
|
43462
43675
|
var NC_AUDIO_DEFAULTS = {
|
|
43463
43676
|
hitPercent: 60,
|
package/dist/addon.mjs
CHANGED
|
@@ -6164,6 +6164,86 @@ var ZodIssueCode = {
|
|
|
6164
6164
|
/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
|
|
6165
6165
|
var ZodFirstPartyTypeKind;
|
|
6166
6166
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
6167
|
+
//#endregion
|
|
6168
|
+
//#region ../types/dist/sleep-BnujYGPe.mjs
|
|
6169
|
+
/**
|
|
6170
|
+
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
6171
|
+
* window to float samples (D455).
|
|
6172
|
+
*
|
|
6173
|
+
* ## Why a format at all
|
|
6174
|
+
*
|
|
6175
|
+
* D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
|
|
6176
|
+
* RATE, and the one consumer that needs 16 kHz resamples next to the model.
|
|
6177
|
+
* It left the FORMAT alone — the broker still turned each G.711 byte into a
|
|
6178
|
+
* 4-byte f32le sample before the bytes entered the transport, so every leg of
|
|
6179
|
+
* the plane carried four times the source. The plane crosses hub-main twice on
|
|
6180
|
+
* the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
|
|
6181
|
+
*
|
|
6182
|
+
* So the plane carries the source BYTES too, and whoever needs floats expands
|
|
6183
|
+
* them where it needs them. That is the same argument D450 made for the rate,
|
|
6184
|
+
* one step further along the same wire.
|
|
6185
|
+
*
|
|
6186
|
+
* ## Why the expansion lives here
|
|
6187
|
+
*
|
|
6188
|
+
* Two packages need it and they must never disagree: `addon-pipeline`'s broker
|
|
6189
|
+
* (which still has to serve a subscriber that did NOT ask for coded bytes —
|
|
6190
|
+
* `AudioChunkPlane` expands per subscription) and
|
|
6191
|
+
* `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
|
|
6192
|
+
* f32le window to the analyzer cap, whose `AudioChunkInput` contract is
|
|
6193
|
+
* unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
|
|
6194
|
+
* into their own dist (`self-contained` externals), so this travels with a
|
|
6195
|
+
* `camstack deploy` and needs no published server.
|
|
6196
|
+
*
|
|
6197
|
+
* A second μ-law table anywhere else is the defect this module exists to
|
|
6198
|
+
* prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
|
|
6199
|
+
* direction for the WebRTC egress — a different transform, not a copy.)
|
|
6200
|
+
*
|
|
6201
|
+
* ## Absent means f32le
|
|
6202
|
+
*
|
|
6203
|
+
* `format` is optional on the wire and its absence means `f32le` — today's
|
|
6204
|
+
* bytes, byte for byte. A peer that never heard of the field is served what it
|
|
6205
|
+
* has always been served, because the broker only emits a coded window to a
|
|
6206
|
+
* subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
|
|
6207
|
+
* That is the D448 `rawForward` negotiation, and it is what makes this
|
|
6208
|
+
* deployable one addon at a time across three nodes.
|
|
6209
|
+
*/
|
|
6210
|
+
/** Every byte format the audio chunk plane can carry. `f32le` is the default. */
|
|
6211
|
+
var AUDIO_CHUNK_FORMATS = [
|
|
6212
|
+
"f32le",
|
|
6213
|
+
"pcmu",
|
|
6214
|
+
"pcma"
|
|
6215
|
+
];
|
|
6216
|
+
/**
|
|
6217
|
+
* Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
|
|
6218
|
+
* to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
|
|
6219
|
+
*
|
|
6220
|
+
* Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
|
|
6221
|
+
* it buffers the coded bytes and the plane's consumers expand.
|
|
6222
|
+
*/
|
|
6223
|
+
function buildUlawTable() {
|
|
6224
|
+
const table = new Float32Array(256);
|
|
6225
|
+
for (let i = 0; i < 256; i++) {
|
|
6226
|
+
const complemented = ~i & 255;
|
|
6227
|
+
const sign = (complemented & 128) !== 0 ? -1 : 1;
|
|
6228
|
+
const exponent = complemented >> 4 & 7;
|
|
6229
|
+
table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
|
|
6230
|
+
}
|
|
6231
|
+
return table;
|
|
6232
|
+
}
|
|
6233
|
+
/** Build the A-law decode table (ITU-T G.711). */
|
|
6234
|
+
function buildAlawTable() {
|
|
6235
|
+
const table = new Float32Array(256);
|
|
6236
|
+
for (let i = 0; i < 256; i++) {
|
|
6237
|
+
const xored = i ^ 85;
|
|
6238
|
+
const sign = (xored & 128) !== 0 ? 1 : -1;
|
|
6239
|
+
const exponent = xored >> 4 & 7;
|
|
6240
|
+
const mantissa = xored & 15;
|
|
6241
|
+
table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
|
|
6242
|
+
}
|
|
6243
|
+
return table;
|
|
6244
|
+
}
|
|
6245
|
+
buildUlawTable();
|
|
6246
|
+
buildAlawTable();
|
|
6167
6247
|
Object.fromEntries([
|
|
6168
6248
|
{
|
|
6169
6249
|
id: "overview",
|
|
@@ -7456,11 +7536,20 @@ var SubscribeFramesResultSchema = object({
|
|
|
7456
7536
|
* (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
|
|
7457
7537
|
* / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
|
|
7458
7538
|
*/
|
|
7539
|
+
var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
|
|
7459
7540
|
var DecodedAudioChunkSchema = object({
|
|
7460
7541
|
data: _instanceof(Uint8Array),
|
|
7461
7542
|
sampleRate: number().int().positive(),
|
|
7462
7543
|
channels: number().int().positive(),
|
|
7463
|
-
timestamp: number()
|
|
7544
|
+
timestamp: number(),
|
|
7545
|
+
/**
|
|
7546
|
+
* Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
|
|
7547
|
+
* byte, for any peer that never heard of this field. A coded window
|
|
7548
|
+
* (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
|
|
7549
|
+
* subscription that DECLARED it accepts one, so absence can never mean
|
|
7550
|
+
* "coded bytes a consumer will read as floats" (D455).
|
|
7551
|
+
*/
|
|
7552
|
+
format: AudioChunkFormatSchema.optional()
|
|
7464
7553
|
});
|
|
7465
7554
|
/**
|
|
7466
7555
|
* Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
|
|
@@ -7472,7 +7561,18 @@ var DecodedAudioChunkSchema = object({
|
|
|
7472
7561
|
var SubscribeAudioChunksInputSchema = object({
|
|
7473
7562
|
brokerId: string(),
|
|
7474
7563
|
/** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
|
|
7475
|
-
tag: string().optional()
|
|
7564
|
+
tag: string().optional(),
|
|
7565
|
+
/**
|
|
7566
|
+
* Byte formats this subscriber can READ, best first. The broker serves the
|
|
7567
|
+
* chunk's own format when it is in this list and expands to `f32le`
|
|
7568
|
+
* otherwise, so a subscriber is never handed bytes it cannot interpret.
|
|
7569
|
+
*
|
|
7570
|
+
* Absent (or without the source format) means `f32le` — the behaviour every
|
|
7571
|
+
* subscriber had before D455, unchanged. This is the negotiation half of
|
|
7572
|
+
* the source-bytes lever: it is what lets the broker and its consumers
|
|
7573
|
+
* deploy one at a time across three nodes.
|
|
7574
|
+
*/
|
|
7575
|
+
accept: array(AudioChunkFormatSchema).readonly().optional()
|
|
7476
7576
|
});
|
|
7477
7577
|
/** Result of `stream-broker.subscribeAudioChunks`. */
|
|
7478
7578
|
var SubscribeAudioChunksResultSchema = object({
|
|
@@ -11460,6 +11560,51 @@ var AudioAnalysisSettingsSchema = object({
|
|
|
11460
11560
|
minConfidence: number().min(0).max(1).default(.3),
|
|
11461
11561
|
allowedClasses: array(string()).default([])
|
|
11462
11562
|
});
|
|
11563
|
+
/**
|
|
11564
|
+
* `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
|
|
11565
|
+
*
|
|
11566
|
+
* Until D461 the orchestrator drained the broker's chunk plane, accumulated
|
|
11567
|
+
* ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
|
|
11568
|
+
* nor consumed the audio: the PCM crossed hub-main twice for a process that
|
|
11569
|
+
* only buffered it. `attachDevice` inverts the direction — the analyzer opens
|
|
11570
|
+
* its own `subscribeAudioChunks` against the broker and the subscriber IS the
|
|
11571
|
+
* decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
|
|
11572
|
+
* way to the one expansion that feeds the model.
|
|
11573
|
+
*
|
|
11574
|
+
* The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
|
|
11575
|
+
* window, the per-device node assignment, the settings read) and therefore
|
|
11576
|
+
* still owns the attach/detach pair. It no longer owns the bytes.
|
|
11577
|
+
*/
|
|
11578
|
+
var AudioAttachDeviceInputSchema = object({
|
|
11579
|
+
deviceId: number(),
|
|
11580
|
+
/** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
|
|
11581
|
+
brokerId: string(),
|
|
11582
|
+
/**
|
|
11583
|
+
* `clusterRoles.ingestNode` — the node whose broker owns the source dial.
|
|
11584
|
+
* Every `streamBroker` call the attachment makes is pinned to it, exactly as
|
|
11585
|
+
* the orchestrator's poller pinned them before the move.
|
|
11586
|
+
*/
|
|
11587
|
+
ingestNodeId: string(),
|
|
11588
|
+
/**
|
|
11589
|
+
* Resolved once by the orchestrator at attach time, exactly as it was read
|
|
11590
|
+
* once per subscription before D461. The analyzer does NOT re-resolve per
|
|
11591
|
+
* window: a settings change re-attaches, which is what always happened.
|
|
11592
|
+
*/
|
|
11593
|
+
settings: AudioAnalysisSettingsSchema
|
|
11594
|
+
});
|
|
11595
|
+
var AudioAttachDeviceResultSchema = object({
|
|
11596
|
+
/** False only when the analyzer is shutting down and refused to attach. */
|
|
11597
|
+
attached: boolean(),
|
|
11598
|
+
/**
|
|
11599
|
+
* True when the attachment replaced a live one for the same device. An
|
|
11600
|
+
* attach is idempotent by REPLACEMENT — two pollers on one camera would
|
|
11601
|
+
* double the broker's fanout and neither would know about the other.
|
|
11602
|
+
*/
|
|
11603
|
+
replaced: boolean()
|
|
11604
|
+
});
|
|
11605
|
+
var AudioDetachDeviceResultSchema = object({
|
|
11606
|
+
/** False when no attachment existed — detach is idempotent. */
|
|
11607
|
+
detached: boolean() });
|
|
11463
11608
|
var AudioClassificationResultSchema = object({
|
|
11464
11609
|
labels: array(AudioClassificationLabelSchema).readonly(),
|
|
11465
11610
|
rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
|
|
@@ -11468,7 +11613,7 @@ var AudioClassificationResultSchema = object({
|
|
|
11468
11613
|
method(object({
|
|
11469
11614
|
chunk: AudioChunkInputSchema,
|
|
11470
11615
|
settings: AudioAnalysisSettingsSchema
|
|
11471
|
-
}), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
|
|
11616
|
+
}), 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() }), {
|
|
11472
11617
|
kind: "mutation",
|
|
11473
11618
|
auth: "admin"
|
|
11474
11619
|
});
|
|
@@ -35752,12 +35897,24 @@ Object.freeze({
|
|
|
35752
35897
|
addonId: null,
|
|
35753
35898
|
access: "create"
|
|
35754
35899
|
},
|
|
35900
|
+
"audioAnalyzer.attachDevice": {
|
|
35901
|
+
capName: "audio-analyzer",
|
|
35902
|
+
capScope: "system",
|
|
35903
|
+
addonId: null,
|
|
35904
|
+
access: "create"
|
|
35905
|
+
},
|
|
35755
35906
|
"audioAnalyzer.classify": {
|
|
35756
35907
|
capName: "audio-analyzer",
|
|
35757
35908
|
capScope: "system",
|
|
35758
35909
|
addonId: null,
|
|
35759
35910
|
access: "view"
|
|
35760
35911
|
},
|
|
35912
|
+
"audioAnalyzer.detachDevice": {
|
|
35913
|
+
capName: "audio-analyzer",
|
|
35914
|
+
capScope: "system",
|
|
35915
|
+
addonId: null,
|
|
35916
|
+
access: "create"
|
|
35917
|
+
},
|
|
35761
35918
|
"audioAnalyzer.dispose": {
|
|
35762
35919
|
capName: "audio-analyzer",
|
|
35763
35920
|
capScope: "system",
|
|
@@ -41601,11 +41758,21 @@ Object.freeze({
|
|
|
41601
41758
|
form: "single",
|
|
41602
41759
|
optional: false
|
|
41603
41760
|
}],
|
|
41761
|
+
"audioAnalyzer.attachDevice": [{
|
|
41762
|
+
name: "deviceId",
|
|
41763
|
+
form: "single",
|
|
41764
|
+
optional: false
|
|
41765
|
+
}],
|
|
41604
41766
|
"audioAnalyzer.classify": [{
|
|
41605
41767
|
name: "deviceId",
|
|
41606
41768
|
form: "single",
|
|
41607
41769
|
optional: true
|
|
41608
41770
|
}],
|
|
41771
|
+
"audioAnalyzer.detachDevice": [{
|
|
41772
|
+
name: "deviceId",
|
|
41773
|
+
form: "single",
|
|
41774
|
+
optional: false
|
|
41775
|
+
}],
|
|
41609
41776
|
"audioMetrics.getCurrentSnapshot": [{
|
|
41610
41777
|
name: "deviceId",
|
|
41611
41778
|
form: "single",
|
|
@@ -43457,6 +43624,52 @@ Object.freeze({
|
|
|
43457
43624
|
"network-access": "ingress",
|
|
43458
43625
|
"smtp-provider": "email"
|
|
43459
43626
|
});
|
|
43627
|
+
var G711_SCALE_CORRECTION_DB = {
|
|
43628
|
+
PCMU: 20 * Math.log10(4),
|
|
43629
|
+
PCMA: 20 * Math.log10(8)
|
|
43630
|
+
};
|
|
43631
|
+
/**
|
|
43632
|
+
* Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
|
|
43633
|
+
* same intent on the ITU-T scale (D460).
|
|
43634
|
+
*
|
|
43635
|
+
* ## When this applies, and when it is the wrong thing to reach for
|
|
43636
|
+
*
|
|
43637
|
+
* An absolute-dBFS number in this repo is one of two things, and only one of
|
|
43638
|
+
* them converts:
|
|
43639
|
+
*
|
|
43640
|
+
* - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
|
|
43641
|
+
* is loud". It was true on the ITU-T scale before the epoch and it is true
|
|
43642
|
+
* after. The defect was never in the number; it was that 19 of this hub's
|
|
43643
|
+
* 25 cameras did not obey it. Converting such a number takes something
|
|
43644
|
+
* correct and makes it wrong, in order to preserve a bug.
|
|
43645
|
+
* - **A measurement taken through the old decoder** — a value someone read
|
|
43646
|
+
* off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
|
|
43647
|
+
* describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
|
|
43648
|
+
* louder. That is what this function is for.
|
|
43649
|
+
*
|
|
43650
|
+
* Telling the two apart is a question about PROVENANCE, not about arithmetic,
|
|
43651
|
+
* and it cannot be answered from the number. It is answered by the comment the
|
|
43652
|
+
* author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
|
|
43653
|
+
* mandatory.
|
|
43654
|
+
*
|
|
43655
|
+
* ## Why a function and not a typed-in number
|
|
43656
|
+
*
|
|
43657
|
+
* `-55 + 12.04` written into a source file is, six months later, completely
|
|
43658
|
+
* indistinguishable from a threshold somebody simply preferred. Calling this
|
|
43659
|
+
* keeps the derivation, the law, and the original measurement all visible at
|
|
43660
|
+
* the call site, so a future reader can disagree with the *premise* instead of
|
|
43661
|
+
* having to reverse-engineer the sum.
|
|
43662
|
+
*
|
|
43663
|
+
* **This is not a runtime gain.** It converts an authored CONSTANT once, where
|
|
43664
|
+
* it is declared. It must never be applied to a live sample or a stored
|
|
43665
|
+
* `AudioEvent.dbfs`: the decoder is correct now, and a second authority
|
|
43666
|
+
* adjusting numbers the decoder already got right is the original defect with
|
|
43667
|
+
* an extra place to argue with (D459).
|
|
43668
|
+
*/
|
|
43669
|
+
function ituDbfsFromPreEpoch(law, authoredDbfs) {
|
|
43670
|
+
return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
|
|
43671
|
+
}
|
|
43672
|
+
Math.round(ituDbfsFromPreEpoch("PCMU", -55));
|
|
43460
43673
|
/** Schema defaults — an untouched sub-field must author exactly these. */
|
|
43461
43674
|
var NC_AUDIO_DEFAULTS = {
|
|
43462
43675
|
hitPercent: 60,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/addon-provider-tuya",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.96",
|
|
4
4
|
"description": "Tuya / Smart Life device-provider addon for CamStack — account-onboarded (Tuya IoT cloud fetch of device localKeys) + LOCAL DP control via the @apocaliss92/nodetuya encrypted-LAN client, exposing switch / water-heater-family kettle entities",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"camstack",
|