@camstack/addon-provider-reolink 1.2.118 → 1.2.119
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
|
@@ -5371,6 +5371,86 @@ var ZodIssueCode = {
|
|
|
5371
5371
|
/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
|
|
5372
5372
|
var ZodFirstPartyTypeKind;
|
|
5373
5373
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5374
|
+
//#endregion
|
|
5375
|
+
//#region ../types/dist/sleep-BnujYGPe.mjs
|
|
5376
|
+
/**
|
|
5377
|
+
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5378
|
+
* window to float samples (D455).
|
|
5379
|
+
*
|
|
5380
|
+
* ## Why a format at all
|
|
5381
|
+
*
|
|
5382
|
+
* D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
|
|
5383
|
+
* RATE, and the one consumer that needs 16 kHz resamples next to the model.
|
|
5384
|
+
* It left the FORMAT alone — the broker still turned each G.711 byte into a
|
|
5385
|
+
* 4-byte f32le sample before the bytes entered the transport, so every leg of
|
|
5386
|
+
* the plane carried four times the source. The plane crosses hub-main twice on
|
|
5387
|
+
* the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
|
|
5388
|
+
*
|
|
5389
|
+
* So the plane carries the source BYTES too, and whoever needs floats expands
|
|
5390
|
+
* them where it needs them. That is the same argument D450 made for the rate,
|
|
5391
|
+
* one step further along the same wire.
|
|
5392
|
+
*
|
|
5393
|
+
* ## Why the expansion lives here
|
|
5394
|
+
*
|
|
5395
|
+
* Two packages need it and they must never disagree: `addon-pipeline`'s broker
|
|
5396
|
+
* (which still has to serve a subscriber that did NOT ask for coded bytes —
|
|
5397
|
+
* `AudioChunkPlane` expands per subscription) and
|
|
5398
|
+
* `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
|
|
5399
|
+
* f32le window to the analyzer cap, whose `AudioChunkInput` contract is
|
|
5400
|
+
* unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
|
|
5401
|
+
* into their own dist (`self-contained` externals), so this travels with a
|
|
5402
|
+
* `camstack deploy` and needs no published server.
|
|
5403
|
+
*
|
|
5404
|
+
* A second μ-law table anywhere else is the defect this module exists to
|
|
5405
|
+
* prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
|
|
5406
|
+
* direction for the WebRTC egress — a different transform, not a copy.)
|
|
5407
|
+
*
|
|
5408
|
+
* ## Absent means f32le
|
|
5409
|
+
*
|
|
5410
|
+
* `format` is optional on the wire and its absence means `f32le` — today's
|
|
5411
|
+
* bytes, byte for byte. A peer that never heard of the field is served what it
|
|
5412
|
+
* has always been served, because the broker only emits a coded window to a
|
|
5413
|
+
* subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
|
|
5414
|
+
* That is the D448 `rawForward` negotiation, and it is what makes this
|
|
5415
|
+
* deployable one addon at a time across three nodes.
|
|
5416
|
+
*/
|
|
5417
|
+
/** Every byte format the audio chunk plane can carry. `f32le` is the default. */
|
|
5418
|
+
var AUDIO_CHUNK_FORMATS = [
|
|
5419
|
+
"f32le",
|
|
5420
|
+
"pcmu",
|
|
5421
|
+
"pcma"
|
|
5422
|
+
];
|
|
5423
|
+
/**
|
|
5424
|
+
* Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
|
|
5425
|
+
* to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
|
|
5426
|
+
*
|
|
5427
|
+
* Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
|
|
5428
|
+
* it buffers the coded bytes and the plane's consumers expand.
|
|
5429
|
+
*/
|
|
5430
|
+
function buildUlawTable() {
|
|
5431
|
+
const table = new Float32Array(256);
|
|
5432
|
+
for (let i = 0; i < 256; i++) {
|
|
5433
|
+
const complemented = ~i & 255;
|
|
5434
|
+
const sign = (complemented & 128) !== 0 ? -1 : 1;
|
|
5435
|
+
const exponent = complemented >> 4 & 7;
|
|
5436
|
+
table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
|
|
5437
|
+
}
|
|
5438
|
+
return table;
|
|
5439
|
+
}
|
|
5440
|
+
/** Build the A-law decode table (ITU-T G.711). */
|
|
5441
|
+
function buildAlawTable() {
|
|
5442
|
+
const table = new Float32Array(256);
|
|
5443
|
+
for (let i = 0; i < 256; i++) {
|
|
5444
|
+
const xored = i ^ 85;
|
|
5445
|
+
const sign = (xored & 128) !== 0 ? 1 : -1;
|
|
5446
|
+
const exponent = xored >> 4 & 7;
|
|
5447
|
+
const mantissa = xored & 15;
|
|
5448
|
+
table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
|
|
5449
|
+
}
|
|
5450
|
+
return table;
|
|
5451
|
+
}
|
|
5452
|
+
buildUlawTable();
|
|
5453
|
+
buildAlawTable();
|
|
5374
5454
|
Object.fromEntries([
|
|
5375
5455
|
{
|
|
5376
5456
|
id: "overview",
|
|
@@ -6663,11 +6743,20 @@ var SubscribeFramesResultSchema = object({
|
|
|
6663
6743
|
* (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
|
|
6664
6744
|
* / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
|
|
6665
6745
|
*/
|
|
6746
|
+
var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
|
|
6666
6747
|
var DecodedAudioChunkSchema = object({
|
|
6667
6748
|
data: _instanceof(Uint8Array),
|
|
6668
6749
|
sampleRate: number().int().positive(),
|
|
6669
6750
|
channels: number().int().positive(),
|
|
6670
|
-
timestamp: number()
|
|
6751
|
+
timestamp: number(),
|
|
6752
|
+
/**
|
|
6753
|
+
* Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
|
|
6754
|
+
* byte, for any peer that never heard of this field. A coded window
|
|
6755
|
+
* (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
|
|
6756
|
+
* subscription that DECLARED it accepts one, so absence can never mean
|
|
6757
|
+
* "coded bytes a consumer will read as floats" (D455).
|
|
6758
|
+
*/
|
|
6759
|
+
format: AudioChunkFormatSchema.optional()
|
|
6671
6760
|
});
|
|
6672
6761
|
/**
|
|
6673
6762
|
* Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
|
|
@@ -6679,7 +6768,18 @@ var DecodedAudioChunkSchema = object({
|
|
|
6679
6768
|
var SubscribeAudioChunksInputSchema = object({
|
|
6680
6769
|
brokerId: string(),
|
|
6681
6770
|
/** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
|
|
6682
|
-
tag: string().optional()
|
|
6771
|
+
tag: string().optional(),
|
|
6772
|
+
/**
|
|
6773
|
+
* Byte formats this subscriber can READ, best first. The broker serves the
|
|
6774
|
+
* chunk's own format when it is in this list and expands to `f32le`
|
|
6775
|
+
* otherwise, so a subscriber is never handed bytes it cannot interpret.
|
|
6776
|
+
*
|
|
6777
|
+
* Absent (or without the source format) means `f32le` — the behaviour every
|
|
6778
|
+
* subscriber had before D455, unchanged. This is the negotiation half of
|
|
6779
|
+
* the source-bytes lever: it is what lets the broker and its consumers
|
|
6780
|
+
* deploy one at a time across three nodes.
|
|
6781
|
+
*/
|
|
6782
|
+
accept: array(AudioChunkFormatSchema).readonly().optional()
|
|
6683
6783
|
});
|
|
6684
6784
|
/** Result of `stream-broker.subscribeAudioChunks`. */
|
|
6685
6785
|
var SubscribeAudioChunksResultSchema = object({
|
|
@@ -11211,6 +11311,51 @@ var AudioAnalysisSettingsSchema = object({
|
|
|
11211
11311
|
minConfidence: number().min(0).max(1).default(.3),
|
|
11212
11312
|
allowedClasses: array(string()).default([])
|
|
11213
11313
|
});
|
|
11314
|
+
/**
|
|
11315
|
+
* `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
|
|
11316
|
+
*
|
|
11317
|
+
* Until D461 the orchestrator drained the broker's chunk plane, accumulated
|
|
11318
|
+
* ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
|
|
11319
|
+
* nor consumed the audio: the PCM crossed hub-main twice for a process that
|
|
11320
|
+
* only buffered it. `attachDevice` inverts the direction — the analyzer opens
|
|
11321
|
+
* its own `subscribeAudioChunks` against the broker and the subscriber IS the
|
|
11322
|
+
* decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
|
|
11323
|
+
* way to the one expansion that feeds the model.
|
|
11324
|
+
*
|
|
11325
|
+
* The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
|
|
11326
|
+
* window, the per-device node assignment, the settings read) and therefore
|
|
11327
|
+
* still owns the attach/detach pair. It no longer owns the bytes.
|
|
11328
|
+
*/
|
|
11329
|
+
var AudioAttachDeviceInputSchema = object({
|
|
11330
|
+
deviceId: number(),
|
|
11331
|
+
/** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
|
|
11332
|
+
brokerId: string(),
|
|
11333
|
+
/**
|
|
11334
|
+
* `clusterRoles.ingestNode` — the node whose broker owns the source dial.
|
|
11335
|
+
* Every `streamBroker` call the attachment makes is pinned to it, exactly as
|
|
11336
|
+
* the orchestrator's poller pinned them before the move.
|
|
11337
|
+
*/
|
|
11338
|
+
ingestNodeId: string(),
|
|
11339
|
+
/**
|
|
11340
|
+
* Resolved once by the orchestrator at attach time, exactly as it was read
|
|
11341
|
+
* once per subscription before D461. The analyzer does NOT re-resolve per
|
|
11342
|
+
* window: a settings change re-attaches, which is what always happened.
|
|
11343
|
+
*/
|
|
11344
|
+
settings: AudioAnalysisSettingsSchema
|
|
11345
|
+
});
|
|
11346
|
+
var AudioAttachDeviceResultSchema = object({
|
|
11347
|
+
/** False only when the analyzer is shutting down and refused to attach. */
|
|
11348
|
+
attached: boolean(),
|
|
11349
|
+
/**
|
|
11350
|
+
* True when the attachment replaced a live one for the same device. An
|
|
11351
|
+
* attach is idempotent by REPLACEMENT — two pollers on one camera would
|
|
11352
|
+
* double the broker's fanout and neither would know about the other.
|
|
11353
|
+
*/
|
|
11354
|
+
replaced: boolean()
|
|
11355
|
+
});
|
|
11356
|
+
var AudioDetachDeviceResultSchema = object({
|
|
11357
|
+
/** False when no attachment existed — detach is idempotent. */
|
|
11358
|
+
detached: boolean() });
|
|
11214
11359
|
var AudioClassificationResultSchema = object({
|
|
11215
11360
|
labels: array(AudioClassificationLabelSchema).readonly(),
|
|
11216
11361
|
rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
|
|
@@ -11219,7 +11364,7 @@ var AudioClassificationResultSchema = object({
|
|
|
11219
11364
|
method(object({
|
|
11220
11365
|
chunk: AudioChunkInputSchema,
|
|
11221
11366
|
settings: AudioAnalysisSettingsSchema
|
|
11222
|
-
}), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
|
|
11367
|
+
}), 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() }), {
|
|
11223
11368
|
kind: "mutation",
|
|
11224
11369
|
auth: "admin"
|
|
11225
11370
|
});
|
|
@@ -36139,12 +36284,24 @@ Object.freeze({
|
|
|
36139
36284
|
addonId: null,
|
|
36140
36285
|
access: "create"
|
|
36141
36286
|
},
|
|
36287
|
+
"audioAnalyzer.attachDevice": {
|
|
36288
|
+
capName: "audio-analyzer",
|
|
36289
|
+
capScope: "system",
|
|
36290
|
+
addonId: null,
|
|
36291
|
+
access: "create"
|
|
36292
|
+
},
|
|
36142
36293
|
"audioAnalyzer.classify": {
|
|
36143
36294
|
capName: "audio-analyzer",
|
|
36144
36295
|
capScope: "system",
|
|
36145
36296
|
addonId: null,
|
|
36146
36297
|
access: "view"
|
|
36147
36298
|
},
|
|
36299
|
+
"audioAnalyzer.detachDevice": {
|
|
36300
|
+
capName: "audio-analyzer",
|
|
36301
|
+
capScope: "system",
|
|
36302
|
+
addonId: null,
|
|
36303
|
+
access: "create"
|
|
36304
|
+
},
|
|
36148
36305
|
"audioAnalyzer.dispose": {
|
|
36149
36306
|
capName: "audio-analyzer",
|
|
36150
36307
|
capScope: "system",
|
|
@@ -41988,11 +42145,21 @@ Object.freeze({
|
|
|
41988
42145
|
form: "single",
|
|
41989
42146
|
optional: false
|
|
41990
42147
|
}],
|
|
42148
|
+
"audioAnalyzer.attachDevice": [{
|
|
42149
|
+
name: "deviceId",
|
|
42150
|
+
form: "single",
|
|
42151
|
+
optional: false
|
|
42152
|
+
}],
|
|
41991
42153
|
"audioAnalyzer.classify": [{
|
|
41992
42154
|
name: "deviceId",
|
|
41993
42155
|
form: "single",
|
|
41994
42156
|
optional: true
|
|
41995
42157
|
}],
|
|
42158
|
+
"audioAnalyzer.detachDevice": [{
|
|
42159
|
+
name: "deviceId",
|
|
42160
|
+
form: "single",
|
|
42161
|
+
optional: false
|
|
42162
|
+
}],
|
|
41996
42163
|
"audioMetrics.getCurrentSnapshot": [{
|
|
41997
42164
|
name: "deviceId",
|
|
41998
42165
|
form: "single",
|
|
@@ -43844,6 +44011,52 @@ Object.freeze({
|
|
|
43844
44011
|
"network-access": "ingress",
|
|
43845
44012
|
"smtp-provider": "email"
|
|
43846
44013
|
});
|
|
44014
|
+
var G711_SCALE_CORRECTION_DB = {
|
|
44015
|
+
PCMU: 20 * Math.log10(4),
|
|
44016
|
+
PCMA: 20 * Math.log10(8)
|
|
44017
|
+
};
|
|
44018
|
+
/**
|
|
44019
|
+
* Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
|
|
44020
|
+
* same intent on the ITU-T scale (D460).
|
|
44021
|
+
*
|
|
44022
|
+
* ## When this applies, and when it is the wrong thing to reach for
|
|
44023
|
+
*
|
|
44024
|
+
* An absolute-dBFS number in this repo is one of two things, and only one of
|
|
44025
|
+
* them converts:
|
|
44026
|
+
*
|
|
44027
|
+
* - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
|
|
44028
|
+
* is loud". It was true on the ITU-T scale before the epoch and it is true
|
|
44029
|
+
* after. The defect was never in the number; it was that 19 of this hub's
|
|
44030
|
+
* 25 cameras did not obey it. Converting such a number takes something
|
|
44031
|
+
* correct and makes it wrong, in order to preserve a bug.
|
|
44032
|
+
* - **A measurement taken through the old decoder** — a value someone read
|
|
44033
|
+
* off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
|
|
44034
|
+
* describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
|
|
44035
|
+
* louder. That is what this function is for.
|
|
44036
|
+
*
|
|
44037
|
+
* Telling the two apart is a question about PROVENANCE, not about arithmetic,
|
|
44038
|
+
* and it cannot be answered from the number. It is answered by the comment the
|
|
44039
|
+
* author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
|
|
44040
|
+
* mandatory.
|
|
44041
|
+
*
|
|
44042
|
+
* ## Why a function and not a typed-in number
|
|
44043
|
+
*
|
|
44044
|
+
* `-55 + 12.04` written into a source file is, six months later, completely
|
|
44045
|
+
* indistinguishable from a threshold somebody simply preferred. Calling this
|
|
44046
|
+
* keeps the derivation, the law, and the original measurement all visible at
|
|
44047
|
+
* the call site, so a future reader can disagree with the *premise* instead of
|
|
44048
|
+
* having to reverse-engineer the sum.
|
|
44049
|
+
*
|
|
44050
|
+
* **This is not a runtime gain.** It converts an authored CONSTANT once, where
|
|
44051
|
+
* it is declared. It must never be applied to a live sample or a stored
|
|
44052
|
+
* `AudioEvent.dbfs`: the decoder is correct now, and a second authority
|
|
44053
|
+
* adjusting numbers the decoder already got right is the original defect with
|
|
44054
|
+
* an extra place to argue with (D459).
|
|
44055
|
+
*/
|
|
44056
|
+
function ituDbfsFromPreEpoch(law, authoredDbfs) {
|
|
44057
|
+
return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
|
|
44058
|
+
}
|
|
44059
|
+
Math.round(ituDbfsFromPreEpoch("PCMU", -55));
|
|
43847
44060
|
/** Schema defaults — an untouched sub-field must author exactly these. */
|
|
43848
44061
|
var NC_AUDIO_DEFAULTS = {
|
|
43849
44062
|
hitPercent: 60,
|
package/dist/addon.mjs
CHANGED
|
@@ -5366,6 +5366,86 @@ var ZodIssueCode = {
|
|
|
5366
5366
|
/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
|
|
5367
5367
|
var ZodFirstPartyTypeKind;
|
|
5368
5368
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5369
|
+
//#endregion
|
|
5370
|
+
//#region ../types/dist/sleep-BnujYGPe.mjs
|
|
5371
|
+
/**
|
|
5372
|
+
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5373
|
+
* window to float samples (D455).
|
|
5374
|
+
*
|
|
5375
|
+
* ## Why a format at all
|
|
5376
|
+
*
|
|
5377
|
+
* D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
|
|
5378
|
+
* RATE, and the one consumer that needs 16 kHz resamples next to the model.
|
|
5379
|
+
* It left the FORMAT alone — the broker still turned each G.711 byte into a
|
|
5380
|
+
* 4-byte f32le sample before the bytes entered the transport, so every leg of
|
|
5381
|
+
* the plane carried four times the source. The plane crosses hub-main twice on
|
|
5382
|
+
* the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
|
|
5383
|
+
*
|
|
5384
|
+
* So the plane carries the source BYTES too, and whoever needs floats expands
|
|
5385
|
+
* them where it needs them. That is the same argument D450 made for the rate,
|
|
5386
|
+
* one step further along the same wire.
|
|
5387
|
+
*
|
|
5388
|
+
* ## Why the expansion lives here
|
|
5389
|
+
*
|
|
5390
|
+
* Two packages need it and they must never disagree: `addon-pipeline`'s broker
|
|
5391
|
+
* (which still has to serve a subscriber that did NOT ask for coded bytes —
|
|
5392
|
+
* `AudioChunkPlane` expands per subscription) and
|
|
5393
|
+
* `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
|
|
5394
|
+
* f32le window to the analyzer cap, whose `AudioChunkInput` contract is
|
|
5395
|
+
* unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
|
|
5396
|
+
* into their own dist (`self-contained` externals), so this travels with a
|
|
5397
|
+
* `camstack deploy` and needs no published server.
|
|
5398
|
+
*
|
|
5399
|
+
* A second μ-law table anywhere else is the defect this module exists to
|
|
5400
|
+
* prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
|
|
5401
|
+
* direction for the WebRTC egress — a different transform, not a copy.)
|
|
5402
|
+
*
|
|
5403
|
+
* ## Absent means f32le
|
|
5404
|
+
*
|
|
5405
|
+
* `format` is optional on the wire and its absence means `f32le` — today's
|
|
5406
|
+
* bytes, byte for byte. A peer that never heard of the field is served what it
|
|
5407
|
+
* has always been served, because the broker only emits a coded window to a
|
|
5408
|
+
* subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
|
|
5409
|
+
* That is the D448 `rawForward` negotiation, and it is what makes this
|
|
5410
|
+
* deployable one addon at a time across three nodes.
|
|
5411
|
+
*/
|
|
5412
|
+
/** Every byte format the audio chunk plane can carry. `f32le` is the default. */
|
|
5413
|
+
var AUDIO_CHUNK_FORMATS = [
|
|
5414
|
+
"f32le",
|
|
5415
|
+
"pcmu",
|
|
5416
|
+
"pcma"
|
|
5417
|
+
];
|
|
5418
|
+
/**
|
|
5419
|
+
* Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
|
|
5420
|
+
* to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
|
|
5421
|
+
*
|
|
5422
|
+
* Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
|
|
5423
|
+
* it buffers the coded bytes and the plane's consumers expand.
|
|
5424
|
+
*/
|
|
5425
|
+
function buildUlawTable() {
|
|
5426
|
+
const table = new Float32Array(256);
|
|
5427
|
+
for (let i = 0; i < 256; i++) {
|
|
5428
|
+
const complemented = ~i & 255;
|
|
5429
|
+
const sign = (complemented & 128) !== 0 ? -1 : 1;
|
|
5430
|
+
const exponent = complemented >> 4 & 7;
|
|
5431
|
+
table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
|
|
5432
|
+
}
|
|
5433
|
+
return table;
|
|
5434
|
+
}
|
|
5435
|
+
/** Build the A-law decode table (ITU-T G.711). */
|
|
5436
|
+
function buildAlawTable() {
|
|
5437
|
+
const table = new Float32Array(256);
|
|
5438
|
+
for (let i = 0; i < 256; i++) {
|
|
5439
|
+
const xored = i ^ 85;
|
|
5440
|
+
const sign = (xored & 128) !== 0 ? 1 : -1;
|
|
5441
|
+
const exponent = xored >> 4 & 7;
|
|
5442
|
+
const mantissa = xored & 15;
|
|
5443
|
+
table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
|
|
5444
|
+
}
|
|
5445
|
+
return table;
|
|
5446
|
+
}
|
|
5447
|
+
buildUlawTable();
|
|
5448
|
+
buildAlawTable();
|
|
5369
5449
|
Object.fromEntries([
|
|
5370
5450
|
{
|
|
5371
5451
|
id: "overview",
|
|
@@ -6658,11 +6738,20 @@ var SubscribeFramesResultSchema = object({
|
|
|
6658
6738
|
* (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
|
|
6659
6739
|
* / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
|
|
6660
6740
|
*/
|
|
6741
|
+
var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
|
|
6661
6742
|
var DecodedAudioChunkSchema = object({
|
|
6662
6743
|
data: _instanceof(Uint8Array),
|
|
6663
6744
|
sampleRate: number().int().positive(),
|
|
6664
6745
|
channels: number().int().positive(),
|
|
6665
|
-
timestamp: number()
|
|
6746
|
+
timestamp: number(),
|
|
6747
|
+
/**
|
|
6748
|
+
* Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
|
|
6749
|
+
* byte, for any peer that never heard of this field. A coded window
|
|
6750
|
+
* (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
|
|
6751
|
+
* subscription that DECLARED it accepts one, so absence can never mean
|
|
6752
|
+
* "coded bytes a consumer will read as floats" (D455).
|
|
6753
|
+
*/
|
|
6754
|
+
format: AudioChunkFormatSchema.optional()
|
|
6666
6755
|
});
|
|
6667
6756
|
/**
|
|
6668
6757
|
* Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
|
|
@@ -6674,7 +6763,18 @@ var DecodedAudioChunkSchema = object({
|
|
|
6674
6763
|
var SubscribeAudioChunksInputSchema = object({
|
|
6675
6764
|
brokerId: string(),
|
|
6676
6765
|
/** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
|
|
6677
|
-
tag: string().optional()
|
|
6766
|
+
tag: string().optional(),
|
|
6767
|
+
/**
|
|
6768
|
+
* Byte formats this subscriber can READ, best first. The broker serves the
|
|
6769
|
+
* chunk's own format when it is in this list and expands to `f32le`
|
|
6770
|
+
* otherwise, so a subscriber is never handed bytes it cannot interpret.
|
|
6771
|
+
*
|
|
6772
|
+
* Absent (or without the source format) means `f32le` — the behaviour every
|
|
6773
|
+
* subscriber had before D455, unchanged. This is the negotiation half of
|
|
6774
|
+
* the source-bytes lever: it is what lets the broker and its consumers
|
|
6775
|
+
* deploy one at a time across three nodes.
|
|
6776
|
+
*/
|
|
6777
|
+
accept: array(AudioChunkFormatSchema).readonly().optional()
|
|
6678
6778
|
});
|
|
6679
6779
|
/** Result of `stream-broker.subscribeAudioChunks`. */
|
|
6680
6780
|
var SubscribeAudioChunksResultSchema = object({
|
|
@@ -11206,6 +11306,51 @@ var AudioAnalysisSettingsSchema = object({
|
|
|
11206
11306
|
minConfidence: number().min(0).max(1).default(.3),
|
|
11207
11307
|
allowedClasses: array(string()).default([])
|
|
11208
11308
|
});
|
|
11309
|
+
/**
|
|
11310
|
+
* `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
|
|
11311
|
+
*
|
|
11312
|
+
* Until D461 the orchestrator drained the broker's chunk plane, accumulated
|
|
11313
|
+
* ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
|
|
11314
|
+
* nor consumed the audio: the PCM crossed hub-main twice for a process that
|
|
11315
|
+
* only buffered it. `attachDevice` inverts the direction — the analyzer opens
|
|
11316
|
+
* its own `subscribeAudioChunks` against the broker and the subscriber IS the
|
|
11317
|
+
* decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
|
|
11318
|
+
* way to the one expansion that feeds the model.
|
|
11319
|
+
*
|
|
11320
|
+
* The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
|
|
11321
|
+
* window, the per-device node assignment, the settings read) and therefore
|
|
11322
|
+
* still owns the attach/detach pair. It no longer owns the bytes.
|
|
11323
|
+
*/
|
|
11324
|
+
var AudioAttachDeviceInputSchema = object({
|
|
11325
|
+
deviceId: number(),
|
|
11326
|
+
/** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
|
|
11327
|
+
brokerId: string(),
|
|
11328
|
+
/**
|
|
11329
|
+
* `clusterRoles.ingestNode` — the node whose broker owns the source dial.
|
|
11330
|
+
* Every `streamBroker` call the attachment makes is pinned to it, exactly as
|
|
11331
|
+
* the orchestrator's poller pinned them before the move.
|
|
11332
|
+
*/
|
|
11333
|
+
ingestNodeId: string(),
|
|
11334
|
+
/**
|
|
11335
|
+
* Resolved once by the orchestrator at attach time, exactly as it was read
|
|
11336
|
+
* once per subscription before D461. The analyzer does NOT re-resolve per
|
|
11337
|
+
* window: a settings change re-attaches, which is what always happened.
|
|
11338
|
+
*/
|
|
11339
|
+
settings: AudioAnalysisSettingsSchema
|
|
11340
|
+
});
|
|
11341
|
+
var AudioAttachDeviceResultSchema = object({
|
|
11342
|
+
/** False only when the analyzer is shutting down and refused to attach. */
|
|
11343
|
+
attached: boolean(),
|
|
11344
|
+
/**
|
|
11345
|
+
* True when the attachment replaced a live one for the same device. An
|
|
11346
|
+
* attach is idempotent by REPLACEMENT — two pollers on one camera would
|
|
11347
|
+
* double the broker's fanout and neither would know about the other.
|
|
11348
|
+
*/
|
|
11349
|
+
replaced: boolean()
|
|
11350
|
+
});
|
|
11351
|
+
var AudioDetachDeviceResultSchema = object({
|
|
11352
|
+
/** False when no attachment existed — detach is idempotent. */
|
|
11353
|
+
detached: boolean() });
|
|
11209
11354
|
var AudioClassificationResultSchema = object({
|
|
11210
11355
|
labels: array(AudioClassificationLabelSchema).readonly(),
|
|
11211
11356
|
rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
|
|
@@ -11214,7 +11359,7 @@ var AudioClassificationResultSchema = object({
|
|
|
11214
11359
|
method(object({
|
|
11215
11360
|
chunk: AudioChunkInputSchema,
|
|
11216
11361
|
settings: AudioAnalysisSettingsSchema
|
|
11217
|
-
}), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
|
|
11362
|
+
}), 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() }), {
|
|
11218
11363
|
kind: "mutation",
|
|
11219
11364
|
auth: "admin"
|
|
11220
11365
|
});
|
|
@@ -36134,12 +36279,24 @@ Object.freeze({
|
|
|
36134
36279
|
addonId: null,
|
|
36135
36280
|
access: "create"
|
|
36136
36281
|
},
|
|
36282
|
+
"audioAnalyzer.attachDevice": {
|
|
36283
|
+
capName: "audio-analyzer",
|
|
36284
|
+
capScope: "system",
|
|
36285
|
+
addonId: null,
|
|
36286
|
+
access: "create"
|
|
36287
|
+
},
|
|
36137
36288
|
"audioAnalyzer.classify": {
|
|
36138
36289
|
capName: "audio-analyzer",
|
|
36139
36290
|
capScope: "system",
|
|
36140
36291
|
addonId: null,
|
|
36141
36292
|
access: "view"
|
|
36142
36293
|
},
|
|
36294
|
+
"audioAnalyzer.detachDevice": {
|
|
36295
|
+
capName: "audio-analyzer",
|
|
36296
|
+
capScope: "system",
|
|
36297
|
+
addonId: null,
|
|
36298
|
+
access: "create"
|
|
36299
|
+
},
|
|
36143
36300
|
"audioAnalyzer.dispose": {
|
|
36144
36301
|
capName: "audio-analyzer",
|
|
36145
36302
|
capScope: "system",
|
|
@@ -41983,11 +42140,21 @@ Object.freeze({
|
|
|
41983
42140
|
form: "single",
|
|
41984
42141
|
optional: false
|
|
41985
42142
|
}],
|
|
42143
|
+
"audioAnalyzer.attachDevice": [{
|
|
42144
|
+
name: "deviceId",
|
|
42145
|
+
form: "single",
|
|
42146
|
+
optional: false
|
|
42147
|
+
}],
|
|
41986
42148
|
"audioAnalyzer.classify": [{
|
|
41987
42149
|
name: "deviceId",
|
|
41988
42150
|
form: "single",
|
|
41989
42151
|
optional: true
|
|
41990
42152
|
}],
|
|
42153
|
+
"audioAnalyzer.detachDevice": [{
|
|
42154
|
+
name: "deviceId",
|
|
42155
|
+
form: "single",
|
|
42156
|
+
optional: false
|
|
42157
|
+
}],
|
|
41991
42158
|
"audioMetrics.getCurrentSnapshot": [{
|
|
41992
42159
|
name: "deviceId",
|
|
41993
42160
|
form: "single",
|
|
@@ -43839,6 +44006,52 @@ Object.freeze({
|
|
|
43839
44006
|
"network-access": "ingress",
|
|
43840
44007
|
"smtp-provider": "email"
|
|
43841
44008
|
});
|
|
44009
|
+
var G711_SCALE_CORRECTION_DB = {
|
|
44010
|
+
PCMU: 20 * Math.log10(4),
|
|
44011
|
+
PCMA: 20 * Math.log10(8)
|
|
44012
|
+
};
|
|
44013
|
+
/**
|
|
44014
|
+
* Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
|
|
44015
|
+
* same intent on the ITU-T scale (D460).
|
|
44016
|
+
*
|
|
44017
|
+
* ## When this applies, and when it is the wrong thing to reach for
|
|
44018
|
+
*
|
|
44019
|
+
* An absolute-dBFS number in this repo is one of two things, and only one of
|
|
44020
|
+
* them converts:
|
|
44021
|
+
*
|
|
44022
|
+
* - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
|
|
44023
|
+
* is loud". It was true on the ITU-T scale before the epoch and it is true
|
|
44024
|
+
* after. The defect was never in the number; it was that 19 of this hub's
|
|
44025
|
+
* 25 cameras did not obey it. Converting such a number takes something
|
|
44026
|
+
* correct and makes it wrong, in order to preserve a bug.
|
|
44027
|
+
* - **A measurement taken through the old decoder** — a value someone read
|
|
44028
|
+
* off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
|
|
44029
|
+
* describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
|
|
44030
|
+
* louder. That is what this function is for.
|
|
44031
|
+
*
|
|
44032
|
+
* Telling the two apart is a question about PROVENANCE, not about arithmetic,
|
|
44033
|
+
* and it cannot be answered from the number. It is answered by the comment the
|
|
44034
|
+
* author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
|
|
44035
|
+
* mandatory.
|
|
44036
|
+
*
|
|
44037
|
+
* ## Why a function and not a typed-in number
|
|
44038
|
+
*
|
|
44039
|
+
* `-55 + 12.04` written into a source file is, six months later, completely
|
|
44040
|
+
* indistinguishable from a threshold somebody simply preferred. Calling this
|
|
44041
|
+
* keeps the derivation, the law, and the original measurement all visible at
|
|
44042
|
+
* the call site, so a future reader can disagree with the *premise* instead of
|
|
44043
|
+
* having to reverse-engineer the sum.
|
|
44044
|
+
*
|
|
44045
|
+
* **This is not a runtime gain.** It converts an authored CONSTANT once, where
|
|
44046
|
+
* it is declared. It must never be applied to a live sample or a stored
|
|
44047
|
+
* `AudioEvent.dbfs`: the decoder is correct now, and a second authority
|
|
44048
|
+
* adjusting numbers the decoder already got right is the original defect with
|
|
44049
|
+
* an extra place to argue with (D459).
|
|
44050
|
+
*/
|
|
44051
|
+
function ituDbfsFromPreEpoch(law, authoredDbfs) {
|
|
44052
|
+
return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
|
|
44053
|
+
}
|
|
44054
|
+
Math.round(ituDbfsFromPreEpoch("PCMU", -55));
|
|
43842
44055
|
/** Schema defaults — an untouched sub-field must author exactly these. */
|
|
43843
44056
|
var NC_AUDIO_DEFAULTS = {
|
|
43844
44057
|
hitPercent: 60,
|