@camstack/addon-provider-dreame 0.2.96 → 0.2.97
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/addon.js +216 -3
- package/dist/addon.mjs +216 -3
- package/package.json +1 -1
package/dist/addon.js
CHANGED
|
@@ -58018,6 +58018,86 @@ var ZodIssueCode = {
|
|
|
58018
58018
|
/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
|
|
58019
58019
|
var ZodFirstPartyTypeKind;
|
|
58020
58020
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
58021
|
+
//#endregion
|
|
58022
|
+
//#region ../types/dist/sleep-BnujYGPe.mjs
|
|
58023
|
+
/**
|
|
58024
|
+
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
58025
|
+
* window to float samples (D455).
|
|
58026
|
+
*
|
|
58027
|
+
* ## Why a format at all
|
|
58028
|
+
*
|
|
58029
|
+
* D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
|
|
58030
|
+
* RATE, and the one consumer that needs 16 kHz resamples next to the model.
|
|
58031
|
+
* It left the FORMAT alone — the broker still turned each G.711 byte into a
|
|
58032
|
+
* 4-byte f32le sample before the bytes entered the transport, so every leg of
|
|
58033
|
+
* the plane carried four times the source. The plane crosses hub-main twice on
|
|
58034
|
+
* the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
|
|
58035
|
+
*
|
|
58036
|
+
* So the plane carries the source BYTES too, and whoever needs floats expands
|
|
58037
|
+
* them where it needs them. That is the same argument D450 made for the rate,
|
|
58038
|
+
* one step further along the same wire.
|
|
58039
|
+
*
|
|
58040
|
+
* ## Why the expansion lives here
|
|
58041
|
+
*
|
|
58042
|
+
* Two packages need it and they must never disagree: `addon-pipeline`'s broker
|
|
58043
|
+
* (which still has to serve a subscriber that did NOT ask for coded bytes —
|
|
58044
|
+
* `AudioChunkPlane` expands per subscription) and
|
|
58045
|
+
* `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
|
|
58046
|
+
* f32le window to the analyzer cap, whose `AudioChunkInput` contract is
|
|
58047
|
+
* unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
|
|
58048
|
+
* into their own dist (`self-contained` externals), so this travels with a
|
|
58049
|
+
* `camstack deploy` and needs no published server.
|
|
58050
|
+
*
|
|
58051
|
+
* A second μ-law table anywhere else is the defect this module exists to
|
|
58052
|
+
* prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
|
|
58053
|
+
* direction for the WebRTC egress — a different transform, not a copy.)
|
|
58054
|
+
*
|
|
58055
|
+
* ## Absent means f32le
|
|
58056
|
+
*
|
|
58057
|
+
* `format` is optional on the wire and its absence means `f32le` — today's
|
|
58058
|
+
* bytes, byte for byte. A peer that never heard of the field is served what it
|
|
58059
|
+
* has always been served, because the broker only emits a coded window to a
|
|
58060
|
+
* subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
|
|
58061
|
+
* That is the D448 `rawForward` negotiation, and it is what makes this
|
|
58062
|
+
* deployable one addon at a time across three nodes.
|
|
58063
|
+
*/
|
|
58064
|
+
/** Every byte format the audio chunk plane can carry. `f32le` is the default. */
|
|
58065
|
+
var AUDIO_CHUNK_FORMATS = [
|
|
58066
|
+
"f32le",
|
|
58067
|
+
"pcmu",
|
|
58068
|
+
"pcma"
|
|
58069
|
+
];
|
|
58070
|
+
/**
|
|
58071
|
+
* Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
|
|
58072
|
+
* to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
|
|
58073
|
+
*
|
|
58074
|
+
* Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
|
|
58075
|
+
* it buffers the coded bytes and the plane's consumers expand.
|
|
58076
|
+
*/
|
|
58077
|
+
function buildUlawTable() {
|
|
58078
|
+
const table = new Float32Array(256);
|
|
58079
|
+
for (let i = 0; i < 256; i++) {
|
|
58080
|
+
const complemented = ~i & 255;
|
|
58081
|
+
const sign = (complemented & 128) !== 0 ? -1 : 1;
|
|
58082
|
+
const exponent = complemented >> 4 & 7;
|
|
58083
|
+
table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
|
|
58084
|
+
}
|
|
58085
|
+
return table;
|
|
58086
|
+
}
|
|
58087
|
+
/** Build the A-law decode table (ITU-T G.711). */
|
|
58088
|
+
function buildAlawTable() {
|
|
58089
|
+
const table = new Float32Array(256);
|
|
58090
|
+
for (let i = 0; i < 256; i++) {
|
|
58091
|
+
const xored = i ^ 85;
|
|
58092
|
+
const sign = (xored & 128) !== 0 ? 1 : -1;
|
|
58093
|
+
const exponent = xored >> 4 & 7;
|
|
58094
|
+
const mantissa = xored & 15;
|
|
58095
|
+
table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
|
|
58096
|
+
}
|
|
58097
|
+
return table;
|
|
58098
|
+
}
|
|
58099
|
+
buildUlawTable();
|
|
58100
|
+
buildAlawTable();
|
|
58021
58101
|
Object.fromEntries([
|
|
58022
58102
|
{
|
|
58023
58103
|
id: "overview",
|
|
@@ -59310,11 +59390,20 @@ var SubscribeFramesResultSchema = object({
|
|
|
59310
59390
|
* (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
|
|
59311
59391
|
* / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
|
|
59312
59392
|
*/
|
|
59393
|
+
var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
|
|
59313
59394
|
var DecodedAudioChunkSchema = object({
|
|
59314
59395
|
data: _instanceof(Uint8Array),
|
|
59315
59396
|
sampleRate: number().int().positive(),
|
|
59316
59397
|
channels: number().int().positive(),
|
|
59317
|
-
timestamp: number()
|
|
59398
|
+
timestamp: number(),
|
|
59399
|
+
/**
|
|
59400
|
+
* Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
|
|
59401
|
+
* byte, for any peer that never heard of this field. A coded window
|
|
59402
|
+
* (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
|
|
59403
|
+
* subscription that DECLARED it accepts one, so absence can never mean
|
|
59404
|
+
* "coded bytes a consumer will read as floats" (D455).
|
|
59405
|
+
*/
|
|
59406
|
+
format: AudioChunkFormatSchema.optional()
|
|
59318
59407
|
});
|
|
59319
59408
|
/**
|
|
59320
59409
|
* Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
|
|
@@ -59326,7 +59415,18 @@ var DecodedAudioChunkSchema = object({
|
|
|
59326
59415
|
var SubscribeAudioChunksInputSchema = object({
|
|
59327
59416
|
brokerId: string(),
|
|
59328
59417
|
/** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
|
|
59329
|
-
tag: string().optional()
|
|
59418
|
+
tag: string().optional(),
|
|
59419
|
+
/**
|
|
59420
|
+
* Byte formats this subscriber can READ, best first. The broker serves the
|
|
59421
|
+
* chunk's own format when it is in this list and expands to `f32le`
|
|
59422
|
+
* otherwise, so a subscriber is never handed bytes it cannot interpret.
|
|
59423
|
+
*
|
|
59424
|
+
* Absent (or without the source format) means `f32le` — the behaviour every
|
|
59425
|
+
* subscriber had before D455, unchanged. This is the negotiation half of
|
|
59426
|
+
* the source-bytes lever: it is what lets the broker and its consumers
|
|
59427
|
+
* deploy one at a time across three nodes.
|
|
59428
|
+
*/
|
|
59429
|
+
accept: array(AudioChunkFormatSchema).readonly().optional()
|
|
59330
59430
|
});
|
|
59331
59431
|
/** Result of `stream-broker.subscribeAudioChunks`. */
|
|
59332
59432
|
var SubscribeAudioChunksResultSchema = object({
|
|
@@ -63314,6 +63414,51 @@ var AudioAnalysisSettingsSchema = object({
|
|
|
63314
63414
|
minConfidence: number().min(0).max(1).default(.3),
|
|
63315
63415
|
allowedClasses: array(string()).default([])
|
|
63316
63416
|
});
|
|
63417
|
+
/**
|
|
63418
|
+
* `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
|
|
63419
|
+
*
|
|
63420
|
+
* Until D461 the orchestrator drained the broker's chunk plane, accumulated
|
|
63421
|
+
* ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
|
|
63422
|
+
* nor consumed the audio: the PCM crossed hub-main twice for a process that
|
|
63423
|
+
* only buffered it. `attachDevice` inverts the direction — the analyzer opens
|
|
63424
|
+
* its own `subscribeAudioChunks` against the broker and the subscriber IS the
|
|
63425
|
+
* decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
|
|
63426
|
+
* way to the one expansion that feeds the model.
|
|
63427
|
+
*
|
|
63428
|
+
* The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
|
|
63429
|
+
* window, the per-device node assignment, the settings read) and therefore
|
|
63430
|
+
* still owns the attach/detach pair. It no longer owns the bytes.
|
|
63431
|
+
*/
|
|
63432
|
+
var AudioAttachDeviceInputSchema = object({
|
|
63433
|
+
deviceId: number(),
|
|
63434
|
+
/** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
|
|
63435
|
+
brokerId: string(),
|
|
63436
|
+
/**
|
|
63437
|
+
* `clusterRoles.ingestNode` — the node whose broker owns the source dial.
|
|
63438
|
+
* Every `streamBroker` call the attachment makes is pinned to it, exactly as
|
|
63439
|
+
* the orchestrator's poller pinned them before the move.
|
|
63440
|
+
*/
|
|
63441
|
+
ingestNodeId: string(),
|
|
63442
|
+
/**
|
|
63443
|
+
* Resolved once by the orchestrator at attach time, exactly as it was read
|
|
63444
|
+
* once per subscription before D461. The analyzer does NOT re-resolve per
|
|
63445
|
+
* window: a settings change re-attaches, which is what always happened.
|
|
63446
|
+
*/
|
|
63447
|
+
settings: AudioAnalysisSettingsSchema
|
|
63448
|
+
});
|
|
63449
|
+
var AudioAttachDeviceResultSchema = object({
|
|
63450
|
+
/** False only when the analyzer is shutting down and refused to attach. */
|
|
63451
|
+
attached: boolean(),
|
|
63452
|
+
/**
|
|
63453
|
+
* True when the attachment replaced a live one for the same device. An
|
|
63454
|
+
* attach is idempotent by REPLACEMENT — two pollers on one camera would
|
|
63455
|
+
* double the broker's fanout and neither would know about the other.
|
|
63456
|
+
*/
|
|
63457
|
+
replaced: boolean()
|
|
63458
|
+
});
|
|
63459
|
+
var AudioDetachDeviceResultSchema = object({
|
|
63460
|
+
/** False when no attachment existed — detach is idempotent. */
|
|
63461
|
+
detached: boolean() });
|
|
63317
63462
|
var AudioClassificationResultSchema = object({
|
|
63318
63463
|
labels: array(AudioClassificationLabelSchema).readonly(),
|
|
63319
63464
|
rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
|
|
@@ -63322,7 +63467,7 @@ var AudioClassificationResultSchema = object({
|
|
|
63322
63467
|
method(object({
|
|
63323
63468
|
chunk: AudioChunkInputSchema,
|
|
63324
63469
|
settings: AudioAnalysisSettingsSchema
|
|
63325
|
-
}), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
|
|
63470
|
+
}), 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() }), {
|
|
63326
63471
|
kind: "mutation",
|
|
63327
63472
|
auth: "admin"
|
|
63328
63473
|
});
|
|
@@ -87771,12 +87916,24 @@ Object.freeze({
|
|
|
87771
87916
|
addonId: null,
|
|
87772
87917
|
access: "create"
|
|
87773
87918
|
},
|
|
87919
|
+
"audioAnalyzer.attachDevice": {
|
|
87920
|
+
capName: "audio-analyzer",
|
|
87921
|
+
capScope: "system",
|
|
87922
|
+
addonId: null,
|
|
87923
|
+
access: "create"
|
|
87924
|
+
},
|
|
87774
87925
|
"audioAnalyzer.classify": {
|
|
87775
87926
|
capName: "audio-analyzer",
|
|
87776
87927
|
capScope: "system",
|
|
87777
87928
|
addonId: null,
|
|
87778
87929
|
access: "view"
|
|
87779
87930
|
},
|
|
87931
|
+
"audioAnalyzer.detachDevice": {
|
|
87932
|
+
capName: "audio-analyzer",
|
|
87933
|
+
capScope: "system",
|
|
87934
|
+
addonId: null,
|
|
87935
|
+
access: "create"
|
|
87936
|
+
},
|
|
87780
87937
|
"audioAnalyzer.dispose": {
|
|
87781
87938
|
capName: "audio-analyzer",
|
|
87782
87939
|
capScope: "system",
|
|
@@ -93620,11 +93777,21 @@ Object.freeze({
|
|
|
93620
93777
|
form: "single",
|
|
93621
93778
|
optional: false
|
|
93622
93779
|
}],
|
|
93780
|
+
"audioAnalyzer.attachDevice": [{
|
|
93781
|
+
name: "deviceId",
|
|
93782
|
+
form: "single",
|
|
93783
|
+
optional: false
|
|
93784
|
+
}],
|
|
93623
93785
|
"audioAnalyzer.classify": [{
|
|
93624
93786
|
name: "deviceId",
|
|
93625
93787
|
form: "single",
|
|
93626
93788
|
optional: true
|
|
93627
93789
|
}],
|
|
93790
|
+
"audioAnalyzer.detachDevice": [{
|
|
93791
|
+
name: "deviceId",
|
|
93792
|
+
form: "single",
|
|
93793
|
+
optional: false
|
|
93794
|
+
}],
|
|
93628
93795
|
"audioMetrics.getCurrentSnapshot": [{
|
|
93629
93796
|
name: "deviceId",
|
|
93630
93797
|
form: "single",
|
|
@@ -95476,6 +95643,52 @@ Object.freeze({
|
|
|
95476
95643
|
"network-access": "ingress",
|
|
95477
95644
|
"smtp-provider": "email"
|
|
95478
95645
|
});
|
|
95646
|
+
var G711_SCALE_CORRECTION_DB = {
|
|
95647
|
+
PCMU: 20 * Math.log10(4),
|
|
95648
|
+
PCMA: 20 * Math.log10(8)
|
|
95649
|
+
};
|
|
95650
|
+
/**
|
|
95651
|
+
* Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
|
|
95652
|
+
* same intent on the ITU-T scale (D460).
|
|
95653
|
+
*
|
|
95654
|
+
* ## When this applies, and when it is the wrong thing to reach for
|
|
95655
|
+
*
|
|
95656
|
+
* An absolute-dBFS number in this repo is one of two things, and only one of
|
|
95657
|
+
* them converts:
|
|
95658
|
+
*
|
|
95659
|
+
* - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
|
|
95660
|
+
* is loud". It was true on the ITU-T scale before the epoch and it is true
|
|
95661
|
+
* after. The defect was never in the number; it was that 19 of this hub's
|
|
95662
|
+
* 25 cameras did not obey it. Converting such a number takes something
|
|
95663
|
+
* correct and makes it wrong, in order to preserve a bug.
|
|
95664
|
+
* - **A measurement taken through the old decoder** — a value someone read
|
|
95665
|
+
* off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
|
|
95666
|
+
* describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
|
|
95667
|
+
* louder. That is what this function is for.
|
|
95668
|
+
*
|
|
95669
|
+
* Telling the two apart is a question about PROVENANCE, not about arithmetic,
|
|
95670
|
+
* and it cannot be answered from the number. It is answered by the comment the
|
|
95671
|
+
* author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
|
|
95672
|
+
* mandatory.
|
|
95673
|
+
*
|
|
95674
|
+
* ## Why a function and not a typed-in number
|
|
95675
|
+
*
|
|
95676
|
+
* `-55 + 12.04` written into a source file is, six months later, completely
|
|
95677
|
+
* indistinguishable from a threshold somebody simply preferred. Calling this
|
|
95678
|
+
* keeps the derivation, the law, and the original measurement all visible at
|
|
95679
|
+
* the call site, so a future reader can disagree with the *premise* instead of
|
|
95680
|
+
* having to reverse-engineer the sum.
|
|
95681
|
+
*
|
|
95682
|
+
* **This is not a runtime gain.** It converts an authored CONSTANT once, where
|
|
95683
|
+
* it is declared. It must never be applied to a live sample or a stored
|
|
95684
|
+
* `AudioEvent.dbfs`: the decoder is correct now, and a second authority
|
|
95685
|
+
* adjusting numbers the decoder already got right is the original defect with
|
|
95686
|
+
* an extra place to argue with (D459).
|
|
95687
|
+
*/
|
|
95688
|
+
function ituDbfsFromPreEpoch(law, authoredDbfs) {
|
|
95689
|
+
return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
|
|
95690
|
+
}
|
|
95691
|
+
Math.round(ituDbfsFromPreEpoch("PCMU", -55));
|
|
95479
95692
|
/** Schema defaults — an untouched sub-field must author exactly these. */
|
|
95480
95693
|
var NC_AUDIO_DEFAULTS = {
|
|
95481
95694
|
hitPercent: 60,
|
package/dist/addon.mjs
CHANGED
|
@@ -58015,6 +58015,86 @@ var ZodIssueCode = {
|
|
|
58015
58015
|
/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
|
|
58016
58016
|
var ZodFirstPartyTypeKind;
|
|
58017
58017
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
58018
|
+
//#endregion
|
|
58019
|
+
//#region ../types/dist/sleep-BnujYGPe.mjs
|
|
58020
|
+
/**
|
|
58021
|
+
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
58022
|
+
* window to float samples (D455).
|
|
58023
|
+
*
|
|
58024
|
+
* ## Why a format at all
|
|
58025
|
+
*
|
|
58026
|
+
* D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
|
|
58027
|
+
* RATE, and the one consumer that needs 16 kHz resamples next to the model.
|
|
58028
|
+
* It left the FORMAT alone — the broker still turned each G.711 byte into a
|
|
58029
|
+
* 4-byte f32le sample before the bytes entered the transport, so every leg of
|
|
58030
|
+
* the plane carried four times the source. The plane crosses hub-main twice on
|
|
58031
|
+
* the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
|
|
58032
|
+
*
|
|
58033
|
+
* So the plane carries the source BYTES too, and whoever needs floats expands
|
|
58034
|
+
* them where it needs them. That is the same argument D450 made for the rate,
|
|
58035
|
+
* one step further along the same wire.
|
|
58036
|
+
*
|
|
58037
|
+
* ## Why the expansion lives here
|
|
58038
|
+
*
|
|
58039
|
+
* Two packages need it and they must never disagree: `addon-pipeline`'s broker
|
|
58040
|
+
* (which still has to serve a subscriber that did NOT ask for coded bytes —
|
|
58041
|
+
* `AudioChunkPlane` expands per subscription) and
|
|
58042
|
+
* `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
|
|
58043
|
+
* f32le window to the analyzer cap, whose `AudioChunkInput` contract is
|
|
58044
|
+
* unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
|
|
58045
|
+
* into their own dist (`self-contained` externals), so this travels with a
|
|
58046
|
+
* `camstack deploy` and needs no published server.
|
|
58047
|
+
*
|
|
58048
|
+
* A second μ-law table anywhere else is the defect this module exists to
|
|
58049
|
+
* prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
|
|
58050
|
+
* direction for the WebRTC egress — a different transform, not a copy.)
|
|
58051
|
+
*
|
|
58052
|
+
* ## Absent means f32le
|
|
58053
|
+
*
|
|
58054
|
+
* `format` is optional on the wire and its absence means `f32le` — today's
|
|
58055
|
+
* bytes, byte for byte. A peer that never heard of the field is served what it
|
|
58056
|
+
* has always been served, because the broker only emits a coded window to a
|
|
58057
|
+
* subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
|
|
58058
|
+
* That is the D448 `rawForward` negotiation, and it is what makes this
|
|
58059
|
+
* deployable one addon at a time across three nodes.
|
|
58060
|
+
*/
|
|
58061
|
+
/** Every byte format the audio chunk plane can carry. `f32le` is the default. */
|
|
58062
|
+
var AUDIO_CHUNK_FORMATS = [
|
|
58063
|
+
"f32le",
|
|
58064
|
+
"pcmu",
|
|
58065
|
+
"pcma"
|
|
58066
|
+
];
|
|
58067
|
+
/**
|
|
58068
|
+
* Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
|
|
58069
|
+
* to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
|
|
58070
|
+
*
|
|
58071
|
+
* Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
|
|
58072
|
+
* it buffers the coded bytes and the plane's consumers expand.
|
|
58073
|
+
*/
|
|
58074
|
+
function buildUlawTable() {
|
|
58075
|
+
const table = new Float32Array(256);
|
|
58076
|
+
for (let i = 0; i < 256; i++) {
|
|
58077
|
+
const complemented = ~i & 255;
|
|
58078
|
+
const sign = (complemented & 128) !== 0 ? -1 : 1;
|
|
58079
|
+
const exponent = complemented >> 4 & 7;
|
|
58080
|
+
table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
|
|
58081
|
+
}
|
|
58082
|
+
return table;
|
|
58083
|
+
}
|
|
58084
|
+
/** Build the A-law decode table (ITU-T G.711). */
|
|
58085
|
+
function buildAlawTable() {
|
|
58086
|
+
const table = new Float32Array(256);
|
|
58087
|
+
for (let i = 0; i < 256; i++) {
|
|
58088
|
+
const xored = i ^ 85;
|
|
58089
|
+
const sign = (xored & 128) !== 0 ? 1 : -1;
|
|
58090
|
+
const exponent = xored >> 4 & 7;
|
|
58091
|
+
const mantissa = xored & 15;
|
|
58092
|
+
table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
|
|
58093
|
+
}
|
|
58094
|
+
return table;
|
|
58095
|
+
}
|
|
58096
|
+
buildUlawTable();
|
|
58097
|
+
buildAlawTable();
|
|
58018
58098
|
Object.fromEntries([
|
|
58019
58099
|
{
|
|
58020
58100
|
id: "overview",
|
|
@@ -59307,11 +59387,20 @@ var SubscribeFramesResultSchema = object({
|
|
|
59307
59387
|
* (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
|
|
59308
59388
|
* / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
|
|
59309
59389
|
*/
|
|
59390
|
+
var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
|
|
59310
59391
|
var DecodedAudioChunkSchema = object({
|
|
59311
59392
|
data: _instanceof(Uint8Array),
|
|
59312
59393
|
sampleRate: number().int().positive(),
|
|
59313
59394
|
channels: number().int().positive(),
|
|
59314
|
-
timestamp: number()
|
|
59395
|
+
timestamp: number(),
|
|
59396
|
+
/**
|
|
59397
|
+
* Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
|
|
59398
|
+
* byte, for any peer that never heard of this field. A coded window
|
|
59399
|
+
* (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
|
|
59400
|
+
* subscription that DECLARED it accepts one, so absence can never mean
|
|
59401
|
+
* "coded bytes a consumer will read as floats" (D455).
|
|
59402
|
+
*/
|
|
59403
|
+
format: AudioChunkFormatSchema.optional()
|
|
59315
59404
|
});
|
|
59316
59405
|
/**
|
|
59317
59406
|
* Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
|
|
@@ -59323,7 +59412,18 @@ var DecodedAudioChunkSchema = object({
|
|
|
59323
59412
|
var SubscribeAudioChunksInputSchema = object({
|
|
59324
59413
|
brokerId: string(),
|
|
59325
59414
|
/** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
|
|
59326
|
-
tag: string().optional()
|
|
59415
|
+
tag: string().optional(),
|
|
59416
|
+
/**
|
|
59417
|
+
* Byte formats this subscriber can READ, best first. The broker serves the
|
|
59418
|
+
* chunk's own format when it is in this list and expands to `f32le`
|
|
59419
|
+
* otherwise, so a subscriber is never handed bytes it cannot interpret.
|
|
59420
|
+
*
|
|
59421
|
+
* Absent (or without the source format) means `f32le` — the behaviour every
|
|
59422
|
+
* subscriber had before D455, unchanged. This is the negotiation half of
|
|
59423
|
+
* the source-bytes lever: it is what lets the broker and its consumers
|
|
59424
|
+
* deploy one at a time across three nodes.
|
|
59425
|
+
*/
|
|
59426
|
+
accept: array(AudioChunkFormatSchema).readonly().optional()
|
|
59327
59427
|
});
|
|
59328
59428
|
/** Result of `stream-broker.subscribeAudioChunks`. */
|
|
59329
59429
|
var SubscribeAudioChunksResultSchema = object({
|
|
@@ -63311,6 +63411,51 @@ var AudioAnalysisSettingsSchema = object({
|
|
|
63311
63411
|
minConfidence: number().min(0).max(1).default(.3),
|
|
63312
63412
|
allowedClasses: array(string()).default([])
|
|
63313
63413
|
});
|
|
63414
|
+
/**
|
|
63415
|
+
* `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
|
|
63416
|
+
*
|
|
63417
|
+
* Until D461 the orchestrator drained the broker's chunk plane, accumulated
|
|
63418
|
+
* ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
|
|
63419
|
+
* nor consumed the audio: the PCM crossed hub-main twice for a process that
|
|
63420
|
+
* only buffered it. `attachDevice` inverts the direction — the analyzer opens
|
|
63421
|
+
* its own `subscribeAudioChunks` against the broker and the subscriber IS the
|
|
63422
|
+
* decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
|
|
63423
|
+
* way to the one expansion that feeds the model.
|
|
63424
|
+
*
|
|
63425
|
+
* The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
|
|
63426
|
+
* window, the per-device node assignment, the settings read) and therefore
|
|
63427
|
+
* still owns the attach/detach pair. It no longer owns the bytes.
|
|
63428
|
+
*/
|
|
63429
|
+
var AudioAttachDeviceInputSchema = object({
|
|
63430
|
+
deviceId: number(),
|
|
63431
|
+
/** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
|
|
63432
|
+
brokerId: string(),
|
|
63433
|
+
/**
|
|
63434
|
+
* `clusterRoles.ingestNode` — the node whose broker owns the source dial.
|
|
63435
|
+
* Every `streamBroker` call the attachment makes is pinned to it, exactly as
|
|
63436
|
+
* the orchestrator's poller pinned them before the move.
|
|
63437
|
+
*/
|
|
63438
|
+
ingestNodeId: string(),
|
|
63439
|
+
/**
|
|
63440
|
+
* Resolved once by the orchestrator at attach time, exactly as it was read
|
|
63441
|
+
* once per subscription before D461. The analyzer does NOT re-resolve per
|
|
63442
|
+
* window: a settings change re-attaches, which is what always happened.
|
|
63443
|
+
*/
|
|
63444
|
+
settings: AudioAnalysisSettingsSchema
|
|
63445
|
+
});
|
|
63446
|
+
var AudioAttachDeviceResultSchema = object({
|
|
63447
|
+
/** False only when the analyzer is shutting down and refused to attach. */
|
|
63448
|
+
attached: boolean(),
|
|
63449
|
+
/**
|
|
63450
|
+
* True when the attachment replaced a live one for the same device. An
|
|
63451
|
+
* attach is idempotent by REPLACEMENT — two pollers on one camera would
|
|
63452
|
+
* double the broker's fanout and neither would know about the other.
|
|
63453
|
+
*/
|
|
63454
|
+
replaced: boolean()
|
|
63455
|
+
});
|
|
63456
|
+
var AudioDetachDeviceResultSchema = object({
|
|
63457
|
+
/** False when no attachment existed — detach is idempotent. */
|
|
63458
|
+
detached: boolean() });
|
|
63314
63459
|
var AudioClassificationResultSchema = object({
|
|
63315
63460
|
labels: array(AudioClassificationLabelSchema).readonly(),
|
|
63316
63461
|
rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
|
|
@@ -63319,7 +63464,7 @@ var AudioClassificationResultSchema = object({
|
|
|
63319
63464
|
method(object({
|
|
63320
63465
|
chunk: AudioChunkInputSchema,
|
|
63321
63466
|
settings: AudioAnalysisSettingsSchema
|
|
63322
|
-
}), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
|
|
63467
|
+
}), 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() }), {
|
|
63323
63468
|
kind: "mutation",
|
|
63324
63469
|
auth: "admin"
|
|
63325
63470
|
});
|
|
@@ -87768,12 +87913,24 @@ Object.freeze({
|
|
|
87768
87913
|
addonId: null,
|
|
87769
87914
|
access: "create"
|
|
87770
87915
|
},
|
|
87916
|
+
"audioAnalyzer.attachDevice": {
|
|
87917
|
+
capName: "audio-analyzer",
|
|
87918
|
+
capScope: "system",
|
|
87919
|
+
addonId: null,
|
|
87920
|
+
access: "create"
|
|
87921
|
+
},
|
|
87771
87922
|
"audioAnalyzer.classify": {
|
|
87772
87923
|
capName: "audio-analyzer",
|
|
87773
87924
|
capScope: "system",
|
|
87774
87925
|
addonId: null,
|
|
87775
87926
|
access: "view"
|
|
87776
87927
|
},
|
|
87928
|
+
"audioAnalyzer.detachDevice": {
|
|
87929
|
+
capName: "audio-analyzer",
|
|
87930
|
+
capScope: "system",
|
|
87931
|
+
addonId: null,
|
|
87932
|
+
access: "create"
|
|
87933
|
+
},
|
|
87777
87934
|
"audioAnalyzer.dispose": {
|
|
87778
87935
|
capName: "audio-analyzer",
|
|
87779
87936
|
capScope: "system",
|
|
@@ -93617,11 +93774,21 @@ Object.freeze({
|
|
|
93617
93774
|
form: "single",
|
|
93618
93775
|
optional: false
|
|
93619
93776
|
}],
|
|
93777
|
+
"audioAnalyzer.attachDevice": [{
|
|
93778
|
+
name: "deviceId",
|
|
93779
|
+
form: "single",
|
|
93780
|
+
optional: false
|
|
93781
|
+
}],
|
|
93620
93782
|
"audioAnalyzer.classify": [{
|
|
93621
93783
|
name: "deviceId",
|
|
93622
93784
|
form: "single",
|
|
93623
93785
|
optional: true
|
|
93624
93786
|
}],
|
|
93787
|
+
"audioAnalyzer.detachDevice": [{
|
|
93788
|
+
name: "deviceId",
|
|
93789
|
+
form: "single",
|
|
93790
|
+
optional: false
|
|
93791
|
+
}],
|
|
93625
93792
|
"audioMetrics.getCurrentSnapshot": [{
|
|
93626
93793
|
name: "deviceId",
|
|
93627
93794
|
form: "single",
|
|
@@ -95473,6 +95640,52 @@ Object.freeze({
|
|
|
95473
95640
|
"network-access": "ingress",
|
|
95474
95641
|
"smtp-provider": "email"
|
|
95475
95642
|
});
|
|
95643
|
+
var G711_SCALE_CORRECTION_DB = {
|
|
95644
|
+
PCMU: 20 * Math.log10(4),
|
|
95645
|
+
PCMA: 20 * Math.log10(8)
|
|
95646
|
+
};
|
|
95647
|
+
/**
|
|
95648
|
+
* Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
|
|
95649
|
+
* same intent on the ITU-T scale (D460).
|
|
95650
|
+
*
|
|
95651
|
+
* ## When this applies, and when it is the wrong thing to reach for
|
|
95652
|
+
*
|
|
95653
|
+
* An absolute-dBFS number in this repo is one of two things, and only one of
|
|
95654
|
+
* them converts:
|
|
95655
|
+
*
|
|
95656
|
+
* - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
|
|
95657
|
+
* is loud". It was true on the ITU-T scale before the epoch and it is true
|
|
95658
|
+
* after. The defect was never in the number; it was that 19 of this hub's
|
|
95659
|
+
* 25 cameras did not obey it. Converting such a number takes something
|
|
95660
|
+
* correct and makes it wrong, in order to preserve a bug.
|
|
95661
|
+
* - **A measurement taken through the old decoder** — a value someone read
|
|
95662
|
+
* off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
|
|
95663
|
+
* describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
|
|
95664
|
+
* louder. That is what this function is for.
|
|
95665
|
+
*
|
|
95666
|
+
* Telling the two apart is a question about PROVENANCE, not about arithmetic,
|
|
95667
|
+
* and it cannot be answered from the number. It is answered by the comment the
|
|
95668
|
+
* author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
|
|
95669
|
+
* mandatory.
|
|
95670
|
+
*
|
|
95671
|
+
* ## Why a function and not a typed-in number
|
|
95672
|
+
*
|
|
95673
|
+
* `-55 + 12.04` written into a source file is, six months later, completely
|
|
95674
|
+
* indistinguishable from a threshold somebody simply preferred. Calling this
|
|
95675
|
+
* keeps the derivation, the law, and the original measurement all visible at
|
|
95676
|
+
* the call site, so a future reader can disagree with the *premise* instead of
|
|
95677
|
+
* having to reverse-engineer the sum.
|
|
95678
|
+
*
|
|
95679
|
+
* **This is not a runtime gain.** It converts an authored CONSTANT once, where
|
|
95680
|
+
* it is declared. It must never be applied to a live sample or a stored
|
|
95681
|
+
* `AudioEvent.dbfs`: the decoder is correct now, and a second authority
|
|
95682
|
+
* adjusting numbers the decoder already got right is the original defect with
|
|
95683
|
+
* an extra place to argue with (D459).
|
|
95684
|
+
*/
|
|
95685
|
+
function ituDbfsFromPreEpoch(law, authoredDbfs) {
|
|
95686
|
+
return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
|
|
95687
|
+
}
|
|
95688
|
+
Math.round(ituDbfsFromPreEpoch("PCMU", -55));
|
|
95476
95689
|
/** Schema defaults — an untouched sub-field must author exactly these. */
|
|
95477
95690
|
var NC_AUDIO_DEFAULTS = {
|
|
95478
95691
|
hitPercent: 60,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/addon-provider-dreame",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.97",
|
|
4
4
|
"description": "Dreame robot-vacuum / lawn-mower device-provider addon for CamStack — wraps the @apocaliss92/nodedreame Dreamehome cloud client",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"camstack",
|