@camstack/addon-provider-wyze 0.2.99 → 0.2.100
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
|
@@ -5377,6 +5377,86 @@ var ZodIssueCode = {
|
|
|
5377
5377
|
/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
|
|
5378
5378
|
var ZodFirstPartyTypeKind;
|
|
5379
5379
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5380
|
+
//#endregion
|
|
5381
|
+
//#region ../types/dist/sleep-BnujYGPe.mjs
|
|
5382
|
+
/**
|
|
5383
|
+
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5384
|
+
* window to float samples (D455).
|
|
5385
|
+
*
|
|
5386
|
+
* ## Why a format at all
|
|
5387
|
+
*
|
|
5388
|
+
* D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
|
|
5389
|
+
* RATE, and the one consumer that needs 16 kHz resamples next to the model.
|
|
5390
|
+
* It left the FORMAT alone — the broker still turned each G.711 byte into a
|
|
5391
|
+
* 4-byte f32le sample before the bytes entered the transport, so every leg of
|
|
5392
|
+
* the plane carried four times the source. The plane crosses hub-main twice on
|
|
5393
|
+
* the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
|
|
5394
|
+
*
|
|
5395
|
+
* So the plane carries the source BYTES too, and whoever needs floats expands
|
|
5396
|
+
* them where it needs them. That is the same argument D450 made for the rate,
|
|
5397
|
+
* one step further along the same wire.
|
|
5398
|
+
*
|
|
5399
|
+
* ## Why the expansion lives here
|
|
5400
|
+
*
|
|
5401
|
+
* Two packages need it and they must never disagree: `addon-pipeline`'s broker
|
|
5402
|
+
* (which still has to serve a subscriber that did NOT ask for coded bytes —
|
|
5403
|
+
* `AudioChunkPlane` expands per subscription) and
|
|
5404
|
+
* `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
|
|
5405
|
+
* f32le window to the analyzer cap, whose `AudioChunkInput` contract is
|
|
5406
|
+
* unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
|
|
5407
|
+
* into their own dist (`self-contained` externals), so this travels with a
|
|
5408
|
+
* `camstack deploy` and needs no published server.
|
|
5409
|
+
*
|
|
5410
|
+
* A second μ-law table anywhere else is the defect this module exists to
|
|
5411
|
+
* prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
|
|
5412
|
+
* direction for the WebRTC egress — a different transform, not a copy.)
|
|
5413
|
+
*
|
|
5414
|
+
* ## Absent means f32le
|
|
5415
|
+
*
|
|
5416
|
+
* `format` is optional on the wire and its absence means `f32le` — today's
|
|
5417
|
+
* bytes, byte for byte. A peer that never heard of the field is served what it
|
|
5418
|
+
* has always been served, because the broker only emits a coded window to a
|
|
5419
|
+
* subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
|
|
5420
|
+
* That is the D448 `rawForward` negotiation, and it is what makes this
|
|
5421
|
+
* deployable one addon at a time across three nodes.
|
|
5422
|
+
*/
|
|
5423
|
+
/** Every byte format the audio chunk plane can carry. `f32le` is the default. */
|
|
5424
|
+
var AUDIO_CHUNK_FORMATS = [
|
|
5425
|
+
"f32le",
|
|
5426
|
+
"pcmu",
|
|
5427
|
+
"pcma"
|
|
5428
|
+
];
|
|
5429
|
+
/**
|
|
5430
|
+
* Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
|
|
5431
|
+
* to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
|
|
5432
|
+
*
|
|
5433
|
+
* Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
|
|
5434
|
+
* it buffers the coded bytes and the plane's consumers expand.
|
|
5435
|
+
*/
|
|
5436
|
+
function buildUlawTable() {
|
|
5437
|
+
const table = new Float32Array(256);
|
|
5438
|
+
for (let i = 0; i < 256; i++) {
|
|
5439
|
+
const complemented = ~i & 255;
|
|
5440
|
+
const sign = (complemented & 128) !== 0 ? -1 : 1;
|
|
5441
|
+
const exponent = complemented >> 4 & 7;
|
|
5442
|
+
table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
|
|
5443
|
+
}
|
|
5444
|
+
return table;
|
|
5445
|
+
}
|
|
5446
|
+
/** Build the A-law decode table (ITU-T G.711). */
|
|
5447
|
+
function buildAlawTable() {
|
|
5448
|
+
const table = new Float32Array(256);
|
|
5449
|
+
for (let i = 0; i < 256; i++) {
|
|
5450
|
+
const xored = i ^ 85;
|
|
5451
|
+
const sign = (xored & 128) !== 0 ? 1 : -1;
|
|
5452
|
+
const exponent = xored >> 4 & 7;
|
|
5453
|
+
const mantissa = xored & 15;
|
|
5454
|
+
table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
|
|
5455
|
+
}
|
|
5456
|
+
return table;
|
|
5457
|
+
}
|
|
5458
|
+
buildUlawTable();
|
|
5459
|
+
buildAlawTable();
|
|
5380
5460
|
Object.fromEntries([
|
|
5381
5461
|
{
|
|
5382
5462
|
id: "overview",
|
|
@@ -6669,11 +6749,20 @@ var SubscribeFramesResultSchema = object({
|
|
|
6669
6749
|
* (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
|
|
6670
6750
|
* / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
|
|
6671
6751
|
*/
|
|
6752
|
+
var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
|
|
6672
6753
|
var DecodedAudioChunkSchema = object({
|
|
6673
6754
|
data: _instanceof(Uint8Array),
|
|
6674
6755
|
sampleRate: number().int().positive(),
|
|
6675
6756
|
channels: number().int().positive(),
|
|
6676
|
-
timestamp: number()
|
|
6757
|
+
timestamp: number(),
|
|
6758
|
+
/**
|
|
6759
|
+
* Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
|
|
6760
|
+
* byte, for any peer that never heard of this field. A coded window
|
|
6761
|
+
* (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
|
|
6762
|
+
* subscription that DECLARED it accepts one, so absence can never mean
|
|
6763
|
+
* "coded bytes a consumer will read as floats" (D455).
|
|
6764
|
+
*/
|
|
6765
|
+
format: AudioChunkFormatSchema.optional()
|
|
6677
6766
|
});
|
|
6678
6767
|
/**
|
|
6679
6768
|
* Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
|
|
@@ -6685,7 +6774,18 @@ var DecodedAudioChunkSchema = object({
|
|
|
6685
6774
|
var SubscribeAudioChunksInputSchema = object({
|
|
6686
6775
|
brokerId: string(),
|
|
6687
6776
|
/** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
|
|
6688
|
-
tag: string().optional()
|
|
6777
|
+
tag: string().optional(),
|
|
6778
|
+
/**
|
|
6779
|
+
* Byte formats this subscriber can READ, best first. The broker serves the
|
|
6780
|
+
* chunk's own format when it is in this list and expands to `f32le`
|
|
6781
|
+
* otherwise, so a subscriber is never handed bytes it cannot interpret.
|
|
6782
|
+
*
|
|
6783
|
+
* Absent (or without the source format) means `f32le` — the behaviour every
|
|
6784
|
+
* subscriber had before D455, unchanged. This is the negotiation half of
|
|
6785
|
+
* the source-bytes lever: it is what lets the broker and its consumers
|
|
6786
|
+
* deploy one at a time across three nodes.
|
|
6787
|
+
*/
|
|
6788
|
+
accept: array(AudioChunkFormatSchema).readonly().optional()
|
|
6689
6789
|
});
|
|
6690
6790
|
/** Result of `stream-broker.subscribeAudioChunks`. */
|
|
6691
6791
|
var SubscribeAudioChunksResultSchema = object({
|
|
@@ -10673,6 +10773,51 @@ var AudioAnalysisSettingsSchema = object({
|
|
|
10673
10773
|
minConfidence: number().min(0).max(1).default(.3),
|
|
10674
10774
|
allowedClasses: array(string()).default([])
|
|
10675
10775
|
});
|
|
10776
|
+
/**
|
|
10777
|
+
* `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
|
|
10778
|
+
*
|
|
10779
|
+
* Until D461 the orchestrator drained the broker's chunk plane, accumulated
|
|
10780
|
+
* ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
|
|
10781
|
+
* nor consumed the audio: the PCM crossed hub-main twice for a process that
|
|
10782
|
+
* only buffered it. `attachDevice` inverts the direction — the analyzer opens
|
|
10783
|
+
* its own `subscribeAudioChunks` against the broker and the subscriber IS the
|
|
10784
|
+
* decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
|
|
10785
|
+
* way to the one expansion that feeds the model.
|
|
10786
|
+
*
|
|
10787
|
+
* The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
|
|
10788
|
+
* window, the per-device node assignment, the settings read) and therefore
|
|
10789
|
+
* still owns the attach/detach pair. It no longer owns the bytes.
|
|
10790
|
+
*/
|
|
10791
|
+
var AudioAttachDeviceInputSchema = object({
|
|
10792
|
+
deviceId: number(),
|
|
10793
|
+
/** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
|
|
10794
|
+
brokerId: string(),
|
|
10795
|
+
/**
|
|
10796
|
+
* `clusterRoles.ingestNode` — the node whose broker owns the source dial.
|
|
10797
|
+
* Every `streamBroker` call the attachment makes is pinned to it, exactly as
|
|
10798
|
+
* the orchestrator's poller pinned them before the move.
|
|
10799
|
+
*/
|
|
10800
|
+
ingestNodeId: string(),
|
|
10801
|
+
/**
|
|
10802
|
+
* Resolved once by the orchestrator at attach time, exactly as it was read
|
|
10803
|
+
* once per subscription before D461. The analyzer does NOT re-resolve per
|
|
10804
|
+
* window: a settings change re-attaches, which is what always happened.
|
|
10805
|
+
*/
|
|
10806
|
+
settings: AudioAnalysisSettingsSchema
|
|
10807
|
+
});
|
|
10808
|
+
var AudioAttachDeviceResultSchema = object({
|
|
10809
|
+
/** False only when the analyzer is shutting down and refused to attach. */
|
|
10810
|
+
attached: boolean(),
|
|
10811
|
+
/**
|
|
10812
|
+
* True when the attachment replaced a live one for the same device. An
|
|
10813
|
+
* attach is idempotent by REPLACEMENT — two pollers on one camera would
|
|
10814
|
+
* double the broker's fanout and neither would know about the other.
|
|
10815
|
+
*/
|
|
10816
|
+
replaced: boolean()
|
|
10817
|
+
});
|
|
10818
|
+
var AudioDetachDeviceResultSchema = object({
|
|
10819
|
+
/** False when no attachment existed — detach is idempotent. */
|
|
10820
|
+
detached: boolean() });
|
|
10676
10821
|
var AudioClassificationResultSchema = object({
|
|
10677
10822
|
labels: array(AudioClassificationLabelSchema).readonly(),
|
|
10678
10823
|
rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
|
|
@@ -10681,7 +10826,7 @@ var AudioClassificationResultSchema = object({
|
|
|
10681
10826
|
method(object({
|
|
10682
10827
|
chunk: AudioChunkInputSchema,
|
|
10683
10828
|
settings: AudioAnalysisSettingsSchema
|
|
10684
|
-
}), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
|
|
10829
|
+
}), 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() }), {
|
|
10685
10830
|
kind: "mutation",
|
|
10686
10831
|
auth: "admin"
|
|
10687
10832
|
});
|
|
@@ -35069,12 +35214,24 @@ Object.freeze({
|
|
|
35069
35214
|
addonId: null,
|
|
35070
35215
|
access: "create"
|
|
35071
35216
|
},
|
|
35217
|
+
"audioAnalyzer.attachDevice": {
|
|
35218
|
+
capName: "audio-analyzer",
|
|
35219
|
+
capScope: "system",
|
|
35220
|
+
addonId: null,
|
|
35221
|
+
access: "create"
|
|
35222
|
+
},
|
|
35072
35223
|
"audioAnalyzer.classify": {
|
|
35073
35224
|
capName: "audio-analyzer",
|
|
35074
35225
|
capScope: "system",
|
|
35075
35226
|
addonId: null,
|
|
35076
35227
|
access: "view"
|
|
35077
35228
|
},
|
|
35229
|
+
"audioAnalyzer.detachDevice": {
|
|
35230
|
+
capName: "audio-analyzer",
|
|
35231
|
+
capScope: "system",
|
|
35232
|
+
addonId: null,
|
|
35233
|
+
access: "create"
|
|
35234
|
+
},
|
|
35078
35235
|
"audioAnalyzer.dispose": {
|
|
35079
35236
|
capName: "audio-analyzer",
|
|
35080
35237
|
capScope: "system",
|
|
@@ -40918,11 +41075,21 @@ Object.freeze({
|
|
|
40918
41075
|
form: "single",
|
|
40919
41076
|
optional: false
|
|
40920
41077
|
}],
|
|
41078
|
+
"audioAnalyzer.attachDevice": [{
|
|
41079
|
+
name: "deviceId",
|
|
41080
|
+
form: "single",
|
|
41081
|
+
optional: false
|
|
41082
|
+
}],
|
|
40921
41083
|
"audioAnalyzer.classify": [{
|
|
40922
41084
|
name: "deviceId",
|
|
40923
41085
|
form: "single",
|
|
40924
41086
|
optional: true
|
|
40925
41087
|
}],
|
|
41088
|
+
"audioAnalyzer.detachDevice": [{
|
|
41089
|
+
name: "deviceId",
|
|
41090
|
+
form: "single",
|
|
41091
|
+
optional: false
|
|
41092
|
+
}],
|
|
40926
41093
|
"audioMetrics.getCurrentSnapshot": [{
|
|
40927
41094
|
name: "deviceId",
|
|
40928
41095
|
form: "single",
|
|
@@ -42774,6 +42941,52 @@ Object.freeze({
|
|
|
42774
42941
|
"network-access": "ingress",
|
|
42775
42942
|
"smtp-provider": "email"
|
|
42776
42943
|
});
|
|
42944
|
+
var G711_SCALE_CORRECTION_DB = {
|
|
42945
|
+
PCMU: 20 * Math.log10(4),
|
|
42946
|
+
PCMA: 20 * Math.log10(8)
|
|
42947
|
+
};
|
|
42948
|
+
/**
|
|
42949
|
+
* Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
|
|
42950
|
+
* same intent on the ITU-T scale (D460).
|
|
42951
|
+
*
|
|
42952
|
+
* ## When this applies, and when it is the wrong thing to reach for
|
|
42953
|
+
*
|
|
42954
|
+
* An absolute-dBFS number in this repo is one of two things, and only one of
|
|
42955
|
+
* them converts:
|
|
42956
|
+
*
|
|
42957
|
+
* - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
|
|
42958
|
+
* is loud". It was true on the ITU-T scale before the epoch and it is true
|
|
42959
|
+
* after. The defect was never in the number; it was that 19 of this hub's
|
|
42960
|
+
* 25 cameras did not obey it. Converting such a number takes something
|
|
42961
|
+
* correct and makes it wrong, in order to preserve a bug.
|
|
42962
|
+
* - **A measurement taken through the old decoder** — a value someone read
|
|
42963
|
+
* off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
|
|
42964
|
+
* describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
|
|
42965
|
+
* louder. That is what this function is for.
|
|
42966
|
+
*
|
|
42967
|
+
* Telling the two apart is a question about PROVENANCE, not about arithmetic,
|
|
42968
|
+
* and it cannot be answered from the number. It is answered by the comment the
|
|
42969
|
+
* author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
|
|
42970
|
+
* mandatory.
|
|
42971
|
+
*
|
|
42972
|
+
* ## Why a function and not a typed-in number
|
|
42973
|
+
*
|
|
42974
|
+
* `-55 + 12.04` written into a source file is, six months later, completely
|
|
42975
|
+
* indistinguishable from a threshold somebody simply preferred. Calling this
|
|
42976
|
+
* keeps the derivation, the law, and the original measurement all visible at
|
|
42977
|
+
* the call site, so a future reader can disagree with the *premise* instead of
|
|
42978
|
+
* having to reverse-engineer the sum.
|
|
42979
|
+
*
|
|
42980
|
+
* **This is not a runtime gain.** It converts an authored CONSTANT once, where
|
|
42981
|
+
* it is declared. It must never be applied to a live sample or a stored
|
|
42982
|
+
* `AudioEvent.dbfs`: the decoder is correct now, and a second authority
|
|
42983
|
+
* adjusting numbers the decoder already got right is the original defect with
|
|
42984
|
+
* an extra place to argue with (D459).
|
|
42985
|
+
*/
|
|
42986
|
+
function ituDbfsFromPreEpoch(law, authoredDbfs) {
|
|
42987
|
+
return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
|
|
42988
|
+
}
|
|
42989
|
+
Math.round(ituDbfsFromPreEpoch("PCMU", -55));
|
|
42777
42990
|
/** Schema defaults — an untouched sub-field must author exactly these. */
|
|
42778
42991
|
var NC_AUDIO_DEFAULTS = {
|
|
42779
42992
|
hitPercent: 60,
|
package/dist/addon.mjs
CHANGED
|
@@ -5356,6 +5356,86 @@ var ZodIssueCode = {
|
|
|
5356
5356
|
/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
|
|
5357
5357
|
var ZodFirstPartyTypeKind;
|
|
5358
5358
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5359
|
+
//#endregion
|
|
5360
|
+
//#region ../types/dist/sleep-BnujYGPe.mjs
|
|
5361
|
+
/**
|
|
5362
|
+
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5363
|
+
* window to float samples (D455).
|
|
5364
|
+
*
|
|
5365
|
+
* ## Why a format at all
|
|
5366
|
+
*
|
|
5367
|
+
* D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
|
|
5368
|
+
* RATE, and the one consumer that needs 16 kHz resamples next to the model.
|
|
5369
|
+
* It left the FORMAT alone — the broker still turned each G.711 byte into a
|
|
5370
|
+
* 4-byte f32le sample before the bytes entered the transport, so every leg of
|
|
5371
|
+
* the plane carried four times the source. The plane crosses hub-main twice on
|
|
5372
|
+
* the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
|
|
5373
|
+
*
|
|
5374
|
+
* So the plane carries the source BYTES too, and whoever needs floats expands
|
|
5375
|
+
* them where it needs them. That is the same argument D450 made for the rate,
|
|
5376
|
+
* one step further along the same wire.
|
|
5377
|
+
*
|
|
5378
|
+
* ## Why the expansion lives here
|
|
5379
|
+
*
|
|
5380
|
+
* Two packages need it and they must never disagree: `addon-pipeline`'s broker
|
|
5381
|
+
* (which still has to serve a subscriber that did NOT ask for coded bytes —
|
|
5382
|
+
* `AudioChunkPlane` expands per subscription) and
|
|
5383
|
+
* `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
|
|
5384
|
+
* f32le window to the analyzer cap, whose `AudioChunkInput` contract is
|
|
5385
|
+
* unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
|
|
5386
|
+
* into their own dist (`self-contained` externals), so this travels with a
|
|
5387
|
+
* `camstack deploy` and needs no published server.
|
|
5388
|
+
*
|
|
5389
|
+
* A second μ-law table anywhere else is the defect this module exists to
|
|
5390
|
+
* prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
|
|
5391
|
+
* direction for the WebRTC egress — a different transform, not a copy.)
|
|
5392
|
+
*
|
|
5393
|
+
* ## Absent means f32le
|
|
5394
|
+
*
|
|
5395
|
+
* `format` is optional on the wire and its absence means `f32le` — today's
|
|
5396
|
+
* bytes, byte for byte. A peer that never heard of the field is served what it
|
|
5397
|
+
* has always been served, because the broker only emits a coded window to a
|
|
5398
|
+
* subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
|
|
5399
|
+
* That is the D448 `rawForward` negotiation, and it is what makes this
|
|
5400
|
+
* deployable one addon at a time across three nodes.
|
|
5401
|
+
*/
|
|
5402
|
+
/** Every byte format the audio chunk plane can carry. `f32le` is the default. */
|
|
5403
|
+
var AUDIO_CHUNK_FORMATS = [
|
|
5404
|
+
"f32le",
|
|
5405
|
+
"pcmu",
|
|
5406
|
+
"pcma"
|
|
5407
|
+
];
|
|
5408
|
+
/**
|
|
5409
|
+
* Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
|
|
5410
|
+
* to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
|
|
5411
|
+
*
|
|
5412
|
+
* Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
|
|
5413
|
+
* it buffers the coded bytes and the plane's consumers expand.
|
|
5414
|
+
*/
|
|
5415
|
+
function buildUlawTable() {
|
|
5416
|
+
const table = new Float32Array(256);
|
|
5417
|
+
for (let i = 0; i < 256; i++) {
|
|
5418
|
+
const complemented = ~i & 255;
|
|
5419
|
+
const sign = (complemented & 128) !== 0 ? -1 : 1;
|
|
5420
|
+
const exponent = complemented >> 4 & 7;
|
|
5421
|
+
table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
|
|
5422
|
+
}
|
|
5423
|
+
return table;
|
|
5424
|
+
}
|
|
5425
|
+
/** Build the A-law decode table (ITU-T G.711). */
|
|
5426
|
+
function buildAlawTable() {
|
|
5427
|
+
const table = new Float32Array(256);
|
|
5428
|
+
for (let i = 0; i < 256; i++) {
|
|
5429
|
+
const xored = i ^ 85;
|
|
5430
|
+
const sign = (xored & 128) !== 0 ? 1 : -1;
|
|
5431
|
+
const exponent = xored >> 4 & 7;
|
|
5432
|
+
const mantissa = xored & 15;
|
|
5433
|
+
table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
|
|
5434
|
+
}
|
|
5435
|
+
return table;
|
|
5436
|
+
}
|
|
5437
|
+
buildUlawTable();
|
|
5438
|
+
buildAlawTable();
|
|
5359
5439
|
Object.fromEntries([
|
|
5360
5440
|
{
|
|
5361
5441
|
id: "overview",
|
|
@@ -6648,11 +6728,20 @@ var SubscribeFramesResultSchema = object({
|
|
|
6648
6728
|
* (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
|
|
6649
6729
|
* / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
|
|
6650
6730
|
*/
|
|
6731
|
+
var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
|
|
6651
6732
|
var DecodedAudioChunkSchema = object({
|
|
6652
6733
|
data: _instanceof(Uint8Array),
|
|
6653
6734
|
sampleRate: number().int().positive(),
|
|
6654
6735
|
channels: number().int().positive(),
|
|
6655
|
-
timestamp: number()
|
|
6736
|
+
timestamp: number(),
|
|
6737
|
+
/**
|
|
6738
|
+
* Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
|
|
6739
|
+
* byte, for any peer that never heard of this field. A coded window
|
|
6740
|
+
* (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
|
|
6741
|
+
* subscription that DECLARED it accepts one, so absence can never mean
|
|
6742
|
+
* "coded bytes a consumer will read as floats" (D455).
|
|
6743
|
+
*/
|
|
6744
|
+
format: AudioChunkFormatSchema.optional()
|
|
6656
6745
|
});
|
|
6657
6746
|
/**
|
|
6658
6747
|
* Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
|
|
@@ -6664,7 +6753,18 @@ var DecodedAudioChunkSchema = object({
|
|
|
6664
6753
|
var SubscribeAudioChunksInputSchema = object({
|
|
6665
6754
|
brokerId: string(),
|
|
6666
6755
|
/** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
|
|
6667
|
-
tag: string().optional()
|
|
6756
|
+
tag: string().optional(),
|
|
6757
|
+
/**
|
|
6758
|
+
* Byte formats this subscriber can READ, best first. The broker serves the
|
|
6759
|
+
* chunk's own format when it is in this list and expands to `f32le`
|
|
6760
|
+
* otherwise, so a subscriber is never handed bytes it cannot interpret.
|
|
6761
|
+
*
|
|
6762
|
+
* Absent (or without the source format) means `f32le` — the behaviour every
|
|
6763
|
+
* subscriber had before D455, unchanged. This is the negotiation half of
|
|
6764
|
+
* the source-bytes lever: it is what lets the broker and its consumers
|
|
6765
|
+
* deploy one at a time across three nodes.
|
|
6766
|
+
*/
|
|
6767
|
+
accept: array(AudioChunkFormatSchema).readonly().optional()
|
|
6668
6768
|
});
|
|
6669
6769
|
/** Result of `stream-broker.subscribeAudioChunks`. */
|
|
6670
6770
|
var SubscribeAudioChunksResultSchema = object({
|
|
@@ -10652,6 +10752,51 @@ var AudioAnalysisSettingsSchema = object({
|
|
|
10652
10752
|
minConfidence: number().min(0).max(1).default(.3),
|
|
10653
10753
|
allowedClasses: array(string()).default([])
|
|
10654
10754
|
});
|
|
10755
|
+
/**
|
|
10756
|
+
* `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
|
|
10757
|
+
*
|
|
10758
|
+
* Until D461 the orchestrator drained the broker's chunk plane, accumulated
|
|
10759
|
+
* ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
|
|
10760
|
+
* nor consumed the audio: the PCM crossed hub-main twice for a process that
|
|
10761
|
+
* only buffered it. `attachDevice` inverts the direction — the analyzer opens
|
|
10762
|
+
* its own `subscribeAudioChunks` against the broker and the subscriber IS the
|
|
10763
|
+
* decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
|
|
10764
|
+
* way to the one expansion that feeds the model.
|
|
10765
|
+
*
|
|
10766
|
+
* The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
|
|
10767
|
+
* window, the per-device node assignment, the settings read) and therefore
|
|
10768
|
+
* still owns the attach/detach pair. It no longer owns the bytes.
|
|
10769
|
+
*/
|
|
10770
|
+
var AudioAttachDeviceInputSchema = object({
|
|
10771
|
+
deviceId: number(),
|
|
10772
|
+
/** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
|
|
10773
|
+
brokerId: string(),
|
|
10774
|
+
/**
|
|
10775
|
+
* `clusterRoles.ingestNode` — the node whose broker owns the source dial.
|
|
10776
|
+
* Every `streamBroker` call the attachment makes is pinned to it, exactly as
|
|
10777
|
+
* the orchestrator's poller pinned them before the move.
|
|
10778
|
+
*/
|
|
10779
|
+
ingestNodeId: string(),
|
|
10780
|
+
/**
|
|
10781
|
+
* Resolved once by the orchestrator at attach time, exactly as it was read
|
|
10782
|
+
* once per subscription before D461. The analyzer does NOT re-resolve per
|
|
10783
|
+
* window: a settings change re-attaches, which is what always happened.
|
|
10784
|
+
*/
|
|
10785
|
+
settings: AudioAnalysisSettingsSchema
|
|
10786
|
+
});
|
|
10787
|
+
var AudioAttachDeviceResultSchema = object({
|
|
10788
|
+
/** False only when the analyzer is shutting down and refused to attach. */
|
|
10789
|
+
attached: boolean(),
|
|
10790
|
+
/**
|
|
10791
|
+
* True when the attachment replaced a live one for the same device. An
|
|
10792
|
+
* attach is idempotent by REPLACEMENT — two pollers on one camera would
|
|
10793
|
+
* double the broker's fanout and neither would know about the other.
|
|
10794
|
+
*/
|
|
10795
|
+
replaced: boolean()
|
|
10796
|
+
});
|
|
10797
|
+
var AudioDetachDeviceResultSchema = object({
|
|
10798
|
+
/** False when no attachment existed — detach is idempotent. */
|
|
10799
|
+
detached: boolean() });
|
|
10655
10800
|
var AudioClassificationResultSchema = object({
|
|
10656
10801
|
labels: array(AudioClassificationLabelSchema).readonly(),
|
|
10657
10802
|
rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
|
|
@@ -10660,7 +10805,7 @@ var AudioClassificationResultSchema = object({
|
|
|
10660
10805
|
method(object({
|
|
10661
10806
|
chunk: AudioChunkInputSchema,
|
|
10662
10807
|
settings: AudioAnalysisSettingsSchema
|
|
10663
|
-
}), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
|
|
10808
|
+
}), 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() }), {
|
|
10664
10809
|
kind: "mutation",
|
|
10665
10810
|
auth: "admin"
|
|
10666
10811
|
});
|
|
@@ -35048,12 +35193,24 @@ Object.freeze({
|
|
|
35048
35193
|
addonId: null,
|
|
35049
35194
|
access: "create"
|
|
35050
35195
|
},
|
|
35196
|
+
"audioAnalyzer.attachDevice": {
|
|
35197
|
+
capName: "audio-analyzer",
|
|
35198
|
+
capScope: "system",
|
|
35199
|
+
addonId: null,
|
|
35200
|
+
access: "create"
|
|
35201
|
+
},
|
|
35051
35202
|
"audioAnalyzer.classify": {
|
|
35052
35203
|
capName: "audio-analyzer",
|
|
35053
35204
|
capScope: "system",
|
|
35054
35205
|
addonId: null,
|
|
35055
35206
|
access: "view"
|
|
35056
35207
|
},
|
|
35208
|
+
"audioAnalyzer.detachDevice": {
|
|
35209
|
+
capName: "audio-analyzer",
|
|
35210
|
+
capScope: "system",
|
|
35211
|
+
addonId: null,
|
|
35212
|
+
access: "create"
|
|
35213
|
+
},
|
|
35057
35214
|
"audioAnalyzer.dispose": {
|
|
35058
35215
|
capName: "audio-analyzer",
|
|
35059
35216
|
capScope: "system",
|
|
@@ -40897,11 +41054,21 @@ Object.freeze({
|
|
|
40897
41054
|
form: "single",
|
|
40898
41055
|
optional: false
|
|
40899
41056
|
}],
|
|
41057
|
+
"audioAnalyzer.attachDevice": [{
|
|
41058
|
+
name: "deviceId",
|
|
41059
|
+
form: "single",
|
|
41060
|
+
optional: false
|
|
41061
|
+
}],
|
|
40900
41062
|
"audioAnalyzer.classify": [{
|
|
40901
41063
|
name: "deviceId",
|
|
40902
41064
|
form: "single",
|
|
40903
41065
|
optional: true
|
|
40904
41066
|
}],
|
|
41067
|
+
"audioAnalyzer.detachDevice": [{
|
|
41068
|
+
name: "deviceId",
|
|
41069
|
+
form: "single",
|
|
41070
|
+
optional: false
|
|
41071
|
+
}],
|
|
40905
41072
|
"audioMetrics.getCurrentSnapshot": [{
|
|
40906
41073
|
name: "deviceId",
|
|
40907
41074
|
form: "single",
|
|
@@ -42753,6 +42920,52 @@ Object.freeze({
|
|
|
42753
42920
|
"network-access": "ingress",
|
|
42754
42921
|
"smtp-provider": "email"
|
|
42755
42922
|
});
|
|
42923
|
+
var G711_SCALE_CORRECTION_DB = {
|
|
42924
|
+
PCMU: 20 * Math.log10(4),
|
|
42925
|
+
PCMA: 20 * Math.log10(8)
|
|
42926
|
+
};
|
|
42927
|
+
/**
|
|
42928
|
+
* Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
|
|
42929
|
+
* same intent on the ITU-T scale (D460).
|
|
42930
|
+
*
|
|
42931
|
+
* ## When this applies, and when it is the wrong thing to reach for
|
|
42932
|
+
*
|
|
42933
|
+
* An absolute-dBFS number in this repo is one of two things, and only one of
|
|
42934
|
+
* them converts:
|
|
42935
|
+
*
|
|
42936
|
+
* - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
|
|
42937
|
+
* is loud". It was true on the ITU-T scale before the epoch and it is true
|
|
42938
|
+
* after. The defect was never in the number; it was that 19 of this hub's
|
|
42939
|
+
* 25 cameras did not obey it. Converting such a number takes something
|
|
42940
|
+
* correct and makes it wrong, in order to preserve a bug.
|
|
42941
|
+
* - **A measurement taken through the old decoder** — a value someone read
|
|
42942
|
+
* off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
|
|
42943
|
+
* describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
|
|
42944
|
+
* louder. That is what this function is for.
|
|
42945
|
+
*
|
|
42946
|
+
* Telling the two apart is a question about PROVENANCE, not about arithmetic,
|
|
42947
|
+
* and it cannot be answered from the number. It is answered by the comment the
|
|
42948
|
+
* author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
|
|
42949
|
+
* mandatory.
|
|
42950
|
+
*
|
|
42951
|
+
* ## Why a function and not a typed-in number
|
|
42952
|
+
*
|
|
42953
|
+
* `-55 + 12.04` written into a source file is, six months later, completely
|
|
42954
|
+
* indistinguishable from a threshold somebody simply preferred. Calling this
|
|
42955
|
+
* keeps the derivation, the law, and the original measurement all visible at
|
|
42956
|
+
* the call site, so a future reader can disagree with the *premise* instead of
|
|
42957
|
+
* having to reverse-engineer the sum.
|
|
42958
|
+
*
|
|
42959
|
+
* **This is not a runtime gain.** It converts an authored CONSTANT once, where
|
|
42960
|
+
* it is declared. It must never be applied to a live sample or a stored
|
|
42961
|
+
* `AudioEvent.dbfs`: the decoder is correct now, and a second authority
|
|
42962
|
+
* adjusting numbers the decoder already got right is the original defect with
|
|
42963
|
+
* an extra place to argue with (D459).
|
|
42964
|
+
*/
|
|
42965
|
+
function ituDbfsFromPreEpoch(law, authoredDbfs) {
|
|
42966
|
+
return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
|
|
42967
|
+
}
|
|
42968
|
+
Math.round(ituDbfsFromPreEpoch("PCMU", -55));
|
|
42756
42969
|
/** Schema defaults — an untouched sub-field must author exactly these. */
|
|
42757
42970
|
var NC_AUDIO_DEFAULTS = {
|
|
42758
42971
|
hitPercent: 60,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/addon-provider-wyze",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.100",
|
|
4
4
|
"description": "Wyze camera device-provider addon for CamStack — wraps the @apocaliss92/wyze-bridge-js P2P/DTLS client, feeding the stream-broker via the pull-rfc4571 lazy-publish path (a structural twin of addon-provider-reolink)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"camstack",
|