@camstack/addon-provider-hikvision 1.2.102 → 1.2.104
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 +218 -5
- package/dist/addon.mjs +218 -5
- package/package.json +1 -1
package/dist/addon.js
CHANGED
|
@@ -5352,6 +5352,86 @@ var ZodIssueCode = {
|
|
|
5352
5352
|
/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
|
|
5353
5353
|
var ZodFirstPartyTypeKind;
|
|
5354
5354
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5355
|
+
//#endregion
|
|
5356
|
+
//#region ../types/dist/sleep-BnujYGPe.mjs
|
|
5357
|
+
/**
|
|
5358
|
+
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5359
|
+
* window to float samples (D455).
|
|
5360
|
+
*
|
|
5361
|
+
* ## Why a format at all
|
|
5362
|
+
*
|
|
5363
|
+
* D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
|
|
5364
|
+
* RATE, and the one consumer that needs 16 kHz resamples next to the model.
|
|
5365
|
+
* It left the FORMAT alone — the broker still turned each G.711 byte into a
|
|
5366
|
+
* 4-byte f32le sample before the bytes entered the transport, so every leg of
|
|
5367
|
+
* the plane carried four times the source. The plane crosses hub-main twice on
|
|
5368
|
+
* the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
|
|
5369
|
+
*
|
|
5370
|
+
* So the plane carries the source BYTES too, and whoever needs floats expands
|
|
5371
|
+
* them where it needs them. That is the same argument D450 made for the rate,
|
|
5372
|
+
* one step further along the same wire.
|
|
5373
|
+
*
|
|
5374
|
+
* ## Why the expansion lives here
|
|
5375
|
+
*
|
|
5376
|
+
* Two packages need it and they must never disagree: `addon-pipeline`'s broker
|
|
5377
|
+
* (which still has to serve a subscriber that did NOT ask for coded bytes —
|
|
5378
|
+
* `AudioChunkPlane` expands per subscription) and
|
|
5379
|
+
* `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
|
|
5380
|
+
* f32le window to the analyzer cap, whose `AudioChunkInput` contract is
|
|
5381
|
+
* unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
|
|
5382
|
+
* into their own dist (`self-contained` externals), so this travels with a
|
|
5383
|
+
* `camstack deploy` and needs no published server.
|
|
5384
|
+
*
|
|
5385
|
+
* A second μ-law table anywhere else is the defect this module exists to
|
|
5386
|
+
* prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
|
|
5387
|
+
* direction for the WebRTC egress — a different transform, not a copy.)
|
|
5388
|
+
*
|
|
5389
|
+
* ## Absent means f32le
|
|
5390
|
+
*
|
|
5391
|
+
* `format` is optional on the wire and its absence means `f32le` — today's
|
|
5392
|
+
* bytes, byte for byte. A peer that never heard of the field is served what it
|
|
5393
|
+
* has always been served, because the broker only emits a coded window to a
|
|
5394
|
+
* subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
|
|
5395
|
+
* That is the D448 `rawForward` negotiation, and it is what makes this
|
|
5396
|
+
* deployable one addon at a time across three nodes.
|
|
5397
|
+
*/
|
|
5398
|
+
/** Every byte format the audio chunk plane can carry. `f32le` is the default. */
|
|
5399
|
+
var AUDIO_CHUNK_FORMATS = [
|
|
5400
|
+
"f32le",
|
|
5401
|
+
"pcmu",
|
|
5402
|
+
"pcma"
|
|
5403
|
+
];
|
|
5404
|
+
/**
|
|
5405
|
+
* Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
|
|
5406
|
+
* to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
|
|
5407
|
+
*
|
|
5408
|
+
* Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
|
|
5409
|
+
* it buffers the coded bytes and the plane's consumers expand.
|
|
5410
|
+
*/
|
|
5411
|
+
function buildUlawTable() {
|
|
5412
|
+
const table = new Float32Array(256);
|
|
5413
|
+
for (let i = 0; i < 256; i++) {
|
|
5414
|
+
const complemented = ~i & 255;
|
|
5415
|
+
const sign = (complemented & 128) !== 0 ? -1 : 1;
|
|
5416
|
+
const exponent = complemented >> 4 & 7;
|
|
5417
|
+
table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
|
|
5418
|
+
}
|
|
5419
|
+
return table;
|
|
5420
|
+
}
|
|
5421
|
+
/** Build the A-law decode table (ITU-T G.711). */
|
|
5422
|
+
function buildAlawTable() {
|
|
5423
|
+
const table = new Float32Array(256);
|
|
5424
|
+
for (let i = 0; i < 256; i++) {
|
|
5425
|
+
const xored = i ^ 85;
|
|
5426
|
+
const sign = (xored & 128) !== 0 ? 1 : -1;
|
|
5427
|
+
const exponent = xored >> 4 & 7;
|
|
5428
|
+
const mantissa = xored & 15;
|
|
5429
|
+
table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
|
|
5430
|
+
}
|
|
5431
|
+
return table;
|
|
5432
|
+
}
|
|
5433
|
+
buildUlawTable();
|
|
5434
|
+
buildAlawTable();
|
|
5355
5435
|
Object.fromEntries([
|
|
5356
5436
|
{
|
|
5357
5437
|
id: "overview",
|
|
@@ -6644,11 +6724,20 @@ var SubscribeFramesResultSchema = object({
|
|
|
6644
6724
|
* (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
|
|
6645
6725
|
* / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
|
|
6646
6726
|
*/
|
|
6727
|
+
var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
|
|
6647
6728
|
var DecodedAudioChunkSchema = object({
|
|
6648
6729
|
data: _instanceof(Uint8Array),
|
|
6649
6730
|
sampleRate: number().int().positive(),
|
|
6650
6731
|
channels: number().int().positive(),
|
|
6651
|
-
timestamp: number()
|
|
6732
|
+
timestamp: number(),
|
|
6733
|
+
/**
|
|
6734
|
+
* Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
|
|
6735
|
+
* byte, for any peer that never heard of this field. A coded window
|
|
6736
|
+
* (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
|
|
6737
|
+
* subscription that DECLARED it accepts one, so absence can never mean
|
|
6738
|
+
* "coded bytes a consumer will read as floats" (D455).
|
|
6739
|
+
*/
|
|
6740
|
+
format: AudioChunkFormatSchema.optional()
|
|
6652
6741
|
});
|
|
6653
6742
|
/**
|
|
6654
6743
|
* Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
|
|
@@ -6660,7 +6749,18 @@ var DecodedAudioChunkSchema = object({
|
|
|
6660
6749
|
var SubscribeAudioChunksInputSchema = object({
|
|
6661
6750
|
brokerId: string(),
|
|
6662
6751
|
/** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
|
|
6663
|
-
tag: string().optional()
|
|
6752
|
+
tag: string().optional(),
|
|
6753
|
+
/**
|
|
6754
|
+
* Byte formats this subscriber can READ, best first. The broker serves the
|
|
6755
|
+
* chunk's own format when it is in this list and expands to `f32le`
|
|
6756
|
+
* otherwise, so a subscriber is never handed bytes it cannot interpret.
|
|
6757
|
+
*
|
|
6758
|
+
* Absent (or without the source format) means `f32le` — the behaviour every
|
|
6759
|
+
* subscriber had before D455, unchanged. This is the negotiation half of
|
|
6760
|
+
* the source-bytes lever: it is what lets the broker and its consumers
|
|
6761
|
+
* deploy one at a time across three nodes.
|
|
6762
|
+
*/
|
|
6763
|
+
accept: array(AudioChunkFormatSchema).readonly().optional()
|
|
6664
6764
|
});
|
|
6665
6765
|
/** Result of `stream-broker.subscribeAudioChunks`. */
|
|
6666
6766
|
var SubscribeAudioChunksResultSchema = object({
|
|
@@ -10917,6 +11017,51 @@ var AudioAnalysisSettingsSchema = object({
|
|
|
10917
11017
|
minConfidence: number().min(0).max(1).default(.3),
|
|
10918
11018
|
allowedClasses: array(string()).default([])
|
|
10919
11019
|
});
|
|
11020
|
+
/**
|
|
11021
|
+
* `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
|
|
11022
|
+
*
|
|
11023
|
+
* Until D461 the orchestrator drained the broker's chunk plane, accumulated
|
|
11024
|
+
* ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
|
|
11025
|
+
* nor consumed the audio: the PCM crossed hub-main twice for a process that
|
|
11026
|
+
* only buffered it. `attachDevice` inverts the direction — the analyzer opens
|
|
11027
|
+
* its own `subscribeAudioChunks` against the broker and the subscriber IS the
|
|
11028
|
+
* decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
|
|
11029
|
+
* way to the one expansion that feeds the model.
|
|
11030
|
+
*
|
|
11031
|
+
* The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
|
|
11032
|
+
* window, the per-device node assignment, the settings read) and therefore
|
|
11033
|
+
* still owns the attach/detach pair. It no longer owns the bytes.
|
|
11034
|
+
*/
|
|
11035
|
+
var AudioAttachDeviceInputSchema = object({
|
|
11036
|
+
deviceId: number(),
|
|
11037
|
+
/** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
|
|
11038
|
+
brokerId: string(),
|
|
11039
|
+
/**
|
|
11040
|
+
* `clusterRoles.ingestNode` — the node whose broker owns the source dial.
|
|
11041
|
+
* Every `streamBroker` call the attachment makes is pinned to it, exactly as
|
|
11042
|
+
* the orchestrator's poller pinned them before the move.
|
|
11043
|
+
*/
|
|
11044
|
+
ingestNodeId: string(),
|
|
11045
|
+
/**
|
|
11046
|
+
* Resolved once by the orchestrator at attach time, exactly as it was read
|
|
11047
|
+
* once per subscription before D461. The analyzer does NOT re-resolve per
|
|
11048
|
+
* window: a settings change re-attaches, which is what always happened.
|
|
11049
|
+
*/
|
|
11050
|
+
settings: AudioAnalysisSettingsSchema
|
|
11051
|
+
});
|
|
11052
|
+
var AudioAttachDeviceResultSchema = object({
|
|
11053
|
+
/** False only when the analyzer is shutting down and refused to attach. */
|
|
11054
|
+
attached: boolean(),
|
|
11055
|
+
/**
|
|
11056
|
+
* True when the attachment replaced a live one for the same device. An
|
|
11057
|
+
* attach is idempotent by REPLACEMENT — two pollers on one camera would
|
|
11058
|
+
* double the broker's fanout and neither would know about the other.
|
|
11059
|
+
*/
|
|
11060
|
+
replaced: boolean()
|
|
11061
|
+
});
|
|
11062
|
+
var AudioDetachDeviceResultSchema = object({
|
|
11063
|
+
/** False when no attachment existed — detach is idempotent. */
|
|
11064
|
+
detached: boolean() });
|
|
10920
11065
|
var AudioClassificationResultSchema = object({
|
|
10921
11066
|
labels: array(AudioClassificationLabelSchema).readonly(),
|
|
10922
11067
|
rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
|
|
@@ -10925,7 +11070,7 @@ var AudioClassificationResultSchema = object({
|
|
|
10925
11070
|
method(object({
|
|
10926
11071
|
chunk: AudioChunkInputSchema,
|
|
10927
11072
|
settings: AudioAnalysisSettingsSchema
|
|
10928
|
-
}), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
|
|
11073
|
+
}), 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() }), {
|
|
10929
11074
|
kind: "mutation",
|
|
10930
11075
|
auth: "admin"
|
|
10931
11076
|
});
|
|
@@ -26284,8 +26429,8 @@ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly
|
|
|
26284
26429
|
*
|
|
26285
26430
|
* An **empty array reads NOTHING** — `[]` is an empty page, never
|
|
26286
26431
|
* "every camera". A request for no devices is a request, not an
|
|
26287
|
-
* omission; same contract as `deviceManager.
|
|
26288
|
-
* `pipelineAnalytics.listRecentTracks`.
|
|
26432
|
+
* omission; same contract as `deviceManager.listAll`'s `deviceIds`
|
|
26433
|
+
* and `pipelineAnalytics.listRecentTracks`.
|
|
26289
26434
|
*
|
|
26290
26435
|
* Absent (`undefined`) is the omission, and keeps the cluster-wide view.
|
|
26291
26436
|
*/
|
|
@@ -35883,12 +36028,24 @@ Object.freeze({
|
|
|
35883
36028
|
addonId: null,
|
|
35884
36029
|
access: "create"
|
|
35885
36030
|
},
|
|
36031
|
+
"audioAnalyzer.attachDevice": {
|
|
36032
|
+
capName: "audio-analyzer",
|
|
36033
|
+
capScope: "system",
|
|
36034
|
+
addonId: null,
|
|
36035
|
+
access: "create"
|
|
36036
|
+
},
|
|
35886
36037
|
"audioAnalyzer.classify": {
|
|
35887
36038
|
capName: "audio-analyzer",
|
|
35888
36039
|
capScope: "system",
|
|
35889
36040
|
addonId: null,
|
|
35890
36041
|
access: "view"
|
|
35891
36042
|
},
|
|
36043
|
+
"audioAnalyzer.detachDevice": {
|
|
36044
|
+
capName: "audio-analyzer",
|
|
36045
|
+
capScope: "system",
|
|
36046
|
+
addonId: null,
|
|
36047
|
+
access: "create"
|
|
36048
|
+
},
|
|
35892
36049
|
"audioAnalyzer.dispose": {
|
|
35893
36050
|
capName: "audio-analyzer",
|
|
35894
36051
|
capScope: "system",
|
|
@@ -41732,11 +41889,21 @@ Object.freeze({
|
|
|
41732
41889
|
form: "single",
|
|
41733
41890
|
optional: false
|
|
41734
41891
|
}],
|
|
41892
|
+
"audioAnalyzer.attachDevice": [{
|
|
41893
|
+
name: "deviceId",
|
|
41894
|
+
form: "single",
|
|
41895
|
+
optional: false
|
|
41896
|
+
}],
|
|
41735
41897
|
"audioAnalyzer.classify": [{
|
|
41736
41898
|
name: "deviceId",
|
|
41737
41899
|
form: "single",
|
|
41738
41900
|
optional: true
|
|
41739
41901
|
}],
|
|
41902
|
+
"audioAnalyzer.detachDevice": [{
|
|
41903
|
+
name: "deviceId",
|
|
41904
|
+
form: "single",
|
|
41905
|
+
optional: false
|
|
41906
|
+
}],
|
|
41740
41907
|
"audioMetrics.getCurrentSnapshot": [{
|
|
41741
41908
|
name: "deviceId",
|
|
41742
41909
|
form: "single",
|
|
@@ -43588,6 +43755,52 @@ Object.freeze({
|
|
|
43588
43755
|
"network-access": "ingress",
|
|
43589
43756
|
"smtp-provider": "email"
|
|
43590
43757
|
});
|
|
43758
|
+
var G711_SCALE_CORRECTION_DB = {
|
|
43759
|
+
PCMU: 20 * Math.log10(4),
|
|
43760
|
+
PCMA: 20 * Math.log10(8)
|
|
43761
|
+
};
|
|
43762
|
+
/**
|
|
43763
|
+
* Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
|
|
43764
|
+
* same intent on the ITU-T scale (D460).
|
|
43765
|
+
*
|
|
43766
|
+
* ## When this applies, and when it is the wrong thing to reach for
|
|
43767
|
+
*
|
|
43768
|
+
* An absolute-dBFS number in this repo is one of two things, and only one of
|
|
43769
|
+
* them converts:
|
|
43770
|
+
*
|
|
43771
|
+
* - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
|
|
43772
|
+
* is loud". It was true on the ITU-T scale before the epoch and it is true
|
|
43773
|
+
* after. The defect was never in the number; it was that 19 of this hub's
|
|
43774
|
+
* 25 cameras did not obey it. Converting such a number takes something
|
|
43775
|
+
* correct and makes it wrong, in order to preserve a bug.
|
|
43776
|
+
* - **A measurement taken through the old decoder** — a value someone read
|
|
43777
|
+
* off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
|
|
43778
|
+
* describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
|
|
43779
|
+
* louder. That is what this function is for.
|
|
43780
|
+
*
|
|
43781
|
+
* Telling the two apart is a question about PROVENANCE, not about arithmetic,
|
|
43782
|
+
* and it cannot be answered from the number. It is answered by the comment the
|
|
43783
|
+
* author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
|
|
43784
|
+
* mandatory.
|
|
43785
|
+
*
|
|
43786
|
+
* ## Why a function and not a typed-in number
|
|
43787
|
+
*
|
|
43788
|
+
* `-55 + 12.04` written into a source file is, six months later, completely
|
|
43789
|
+
* indistinguishable from a threshold somebody simply preferred. Calling this
|
|
43790
|
+
* keeps the derivation, the law, and the original measurement all visible at
|
|
43791
|
+
* the call site, so a future reader can disagree with the *premise* instead of
|
|
43792
|
+
* having to reverse-engineer the sum.
|
|
43793
|
+
*
|
|
43794
|
+
* **This is not a runtime gain.** It converts an authored CONSTANT once, where
|
|
43795
|
+
* it is declared. It must never be applied to a live sample or a stored
|
|
43796
|
+
* `AudioEvent.dbfs`: the decoder is correct now, and a second authority
|
|
43797
|
+
* adjusting numbers the decoder already got right is the original defect with
|
|
43798
|
+
* an extra place to argue with (D459).
|
|
43799
|
+
*/
|
|
43800
|
+
function ituDbfsFromPreEpoch(law, authoredDbfs) {
|
|
43801
|
+
return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
|
|
43802
|
+
}
|
|
43803
|
+
Math.round(ituDbfsFromPreEpoch("PCMU", -55));
|
|
43591
43804
|
/** Schema defaults — an untouched sub-field must author exactly these. */
|
|
43592
43805
|
var NC_AUDIO_DEFAULTS = {
|
|
43593
43806
|
hitPercent: 60,
|
package/dist/addon.mjs
CHANGED
|
@@ -5353,6 +5353,86 @@ var ZodIssueCode = {
|
|
|
5353
5353
|
/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
|
|
5354
5354
|
var ZodFirstPartyTypeKind;
|
|
5355
5355
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5356
|
+
//#endregion
|
|
5357
|
+
//#region ../types/dist/sleep-BnujYGPe.mjs
|
|
5358
|
+
/**
|
|
5359
|
+
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5360
|
+
* window to float samples (D455).
|
|
5361
|
+
*
|
|
5362
|
+
* ## Why a format at all
|
|
5363
|
+
*
|
|
5364
|
+
* D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
|
|
5365
|
+
* RATE, and the one consumer that needs 16 kHz resamples next to the model.
|
|
5366
|
+
* It left the FORMAT alone — the broker still turned each G.711 byte into a
|
|
5367
|
+
* 4-byte f32le sample before the bytes entered the transport, so every leg of
|
|
5368
|
+
* the plane carried four times the source. The plane crosses hub-main twice on
|
|
5369
|
+
* the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
|
|
5370
|
+
*
|
|
5371
|
+
* So the plane carries the source BYTES too, and whoever needs floats expands
|
|
5372
|
+
* them where it needs them. That is the same argument D450 made for the rate,
|
|
5373
|
+
* one step further along the same wire.
|
|
5374
|
+
*
|
|
5375
|
+
* ## Why the expansion lives here
|
|
5376
|
+
*
|
|
5377
|
+
* Two packages need it and they must never disagree: `addon-pipeline`'s broker
|
|
5378
|
+
* (which still has to serve a subscriber that did NOT ask for coded bytes —
|
|
5379
|
+
* `AudioChunkPlane` expands per subscription) and
|
|
5380
|
+
* `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
|
|
5381
|
+
* f32le window to the analyzer cap, whose `AudioChunkInput` contract is
|
|
5382
|
+
* unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
|
|
5383
|
+
* into their own dist (`self-contained` externals), so this travels with a
|
|
5384
|
+
* `camstack deploy` and needs no published server.
|
|
5385
|
+
*
|
|
5386
|
+
* A second μ-law table anywhere else is the defect this module exists to
|
|
5387
|
+
* prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
|
|
5388
|
+
* direction for the WebRTC egress — a different transform, not a copy.)
|
|
5389
|
+
*
|
|
5390
|
+
* ## Absent means f32le
|
|
5391
|
+
*
|
|
5392
|
+
* `format` is optional on the wire and its absence means `f32le` — today's
|
|
5393
|
+
* bytes, byte for byte. A peer that never heard of the field is served what it
|
|
5394
|
+
* has always been served, because the broker only emits a coded window to a
|
|
5395
|
+
* subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
|
|
5396
|
+
* That is the D448 `rawForward` negotiation, and it is what makes this
|
|
5397
|
+
* deployable one addon at a time across three nodes.
|
|
5398
|
+
*/
|
|
5399
|
+
/** Every byte format the audio chunk plane can carry. `f32le` is the default. */
|
|
5400
|
+
var AUDIO_CHUNK_FORMATS = [
|
|
5401
|
+
"f32le",
|
|
5402
|
+
"pcmu",
|
|
5403
|
+
"pcma"
|
|
5404
|
+
];
|
|
5405
|
+
/**
|
|
5406
|
+
* Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
|
|
5407
|
+
* to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
|
|
5408
|
+
*
|
|
5409
|
+
* Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
|
|
5410
|
+
* it buffers the coded bytes and the plane's consumers expand.
|
|
5411
|
+
*/
|
|
5412
|
+
function buildUlawTable() {
|
|
5413
|
+
const table = new Float32Array(256);
|
|
5414
|
+
for (let i = 0; i < 256; i++) {
|
|
5415
|
+
const complemented = ~i & 255;
|
|
5416
|
+
const sign = (complemented & 128) !== 0 ? -1 : 1;
|
|
5417
|
+
const exponent = complemented >> 4 & 7;
|
|
5418
|
+
table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
|
|
5419
|
+
}
|
|
5420
|
+
return table;
|
|
5421
|
+
}
|
|
5422
|
+
/** Build the A-law decode table (ITU-T G.711). */
|
|
5423
|
+
function buildAlawTable() {
|
|
5424
|
+
const table = new Float32Array(256);
|
|
5425
|
+
for (let i = 0; i < 256; i++) {
|
|
5426
|
+
const xored = i ^ 85;
|
|
5427
|
+
const sign = (xored & 128) !== 0 ? 1 : -1;
|
|
5428
|
+
const exponent = xored >> 4 & 7;
|
|
5429
|
+
const mantissa = xored & 15;
|
|
5430
|
+
table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
|
|
5431
|
+
}
|
|
5432
|
+
return table;
|
|
5433
|
+
}
|
|
5434
|
+
buildUlawTable();
|
|
5435
|
+
buildAlawTable();
|
|
5356
5436
|
Object.fromEntries([
|
|
5357
5437
|
{
|
|
5358
5438
|
id: "overview",
|
|
@@ -6645,11 +6725,20 @@ var SubscribeFramesResultSchema = object({
|
|
|
6645
6725
|
* (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
|
|
6646
6726
|
* / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
|
|
6647
6727
|
*/
|
|
6728
|
+
var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
|
|
6648
6729
|
var DecodedAudioChunkSchema = object({
|
|
6649
6730
|
data: _instanceof(Uint8Array),
|
|
6650
6731
|
sampleRate: number().int().positive(),
|
|
6651
6732
|
channels: number().int().positive(),
|
|
6652
|
-
timestamp: number()
|
|
6733
|
+
timestamp: number(),
|
|
6734
|
+
/**
|
|
6735
|
+
* Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
|
|
6736
|
+
* byte, for any peer that never heard of this field. A coded window
|
|
6737
|
+
* (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
|
|
6738
|
+
* subscription that DECLARED it accepts one, so absence can never mean
|
|
6739
|
+
* "coded bytes a consumer will read as floats" (D455).
|
|
6740
|
+
*/
|
|
6741
|
+
format: AudioChunkFormatSchema.optional()
|
|
6653
6742
|
});
|
|
6654
6743
|
/**
|
|
6655
6744
|
* Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
|
|
@@ -6661,7 +6750,18 @@ var DecodedAudioChunkSchema = object({
|
|
|
6661
6750
|
var SubscribeAudioChunksInputSchema = object({
|
|
6662
6751
|
brokerId: string(),
|
|
6663
6752
|
/** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
|
|
6664
|
-
tag: string().optional()
|
|
6753
|
+
tag: string().optional(),
|
|
6754
|
+
/**
|
|
6755
|
+
* Byte formats this subscriber can READ, best first. The broker serves the
|
|
6756
|
+
* chunk's own format when it is in this list and expands to `f32le`
|
|
6757
|
+
* otherwise, so a subscriber is never handed bytes it cannot interpret.
|
|
6758
|
+
*
|
|
6759
|
+
* Absent (or without the source format) means `f32le` — the behaviour every
|
|
6760
|
+
* subscriber had before D455, unchanged. This is the negotiation half of
|
|
6761
|
+
* the source-bytes lever: it is what lets the broker and its consumers
|
|
6762
|
+
* deploy one at a time across three nodes.
|
|
6763
|
+
*/
|
|
6764
|
+
accept: array(AudioChunkFormatSchema).readonly().optional()
|
|
6665
6765
|
});
|
|
6666
6766
|
/** Result of `stream-broker.subscribeAudioChunks`. */
|
|
6667
6767
|
var SubscribeAudioChunksResultSchema = object({
|
|
@@ -10918,6 +11018,51 @@ var AudioAnalysisSettingsSchema = object({
|
|
|
10918
11018
|
minConfidence: number().min(0).max(1).default(.3),
|
|
10919
11019
|
allowedClasses: array(string()).default([])
|
|
10920
11020
|
});
|
|
11021
|
+
/**
|
|
11022
|
+
* `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
|
|
11023
|
+
*
|
|
11024
|
+
* Until D461 the orchestrator drained the broker's chunk plane, accumulated
|
|
11025
|
+
* ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
|
|
11026
|
+
* nor consumed the audio: the PCM crossed hub-main twice for a process that
|
|
11027
|
+
* only buffered it. `attachDevice` inverts the direction — the analyzer opens
|
|
11028
|
+
* its own `subscribeAudioChunks` against the broker and the subscriber IS the
|
|
11029
|
+
* decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
|
|
11030
|
+
* way to the one expansion that feeds the model.
|
|
11031
|
+
*
|
|
11032
|
+
* The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
|
|
11033
|
+
* window, the per-device node assignment, the settings read) and therefore
|
|
11034
|
+
* still owns the attach/detach pair. It no longer owns the bytes.
|
|
11035
|
+
*/
|
|
11036
|
+
var AudioAttachDeviceInputSchema = object({
|
|
11037
|
+
deviceId: number(),
|
|
11038
|
+
/** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
|
|
11039
|
+
brokerId: string(),
|
|
11040
|
+
/**
|
|
11041
|
+
* `clusterRoles.ingestNode` — the node whose broker owns the source dial.
|
|
11042
|
+
* Every `streamBroker` call the attachment makes is pinned to it, exactly as
|
|
11043
|
+
* the orchestrator's poller pinned them before the move.
|
|
11044
|
+
*/
|
|
11045
|
+
ingestNodeId: string(),
|
|
11046
|
+
/**
|
|
11047
|
+
* Resolved once by the orchestrator at attach time, exactly as it was read
|
|
11048
|
+
* once per subscription before D461. The analyzer does NOT re-resolve per
|
|
11049
|
+
* window: a settings change re-attaches, which is what always happened.
|
|
11050
|
+
*/
|
|
11051
|
+
settings: AudioAnalysisSettingsSchema
|
|
11052
|
+
});
|
|
11053
|
+
var AudioAttachDeviceResultSchema = object({
|
|
11054
|
+
/** False only when the analyzer is shutting down and refused to attach. */
|
|
11055
|
+
attached: boolean(),
|
|
11056
|
+
/**
|
|
11057
|
+
* True when the attachment replaced a live one for the same device. An
|
|
11058
|
+
* attach is idempotent by REPLACEMENT — two pollers on one camera would
|
|
11059
|
+
* double the broker's fanout and neither would know about the other.
|
|
11060
|
+
*/
|
|
11061
|
+
replaced: boolean()
|
|
11062
|
+
});
|
|
11063
|
+
var AudioDetachDeviceResultSchema = object({
|
|
11064
|
+
/** False when no attachment existed — detach is idempotent. */
|
|
11065
|
+
detached: boolean() });
|
|
10921
11066
|
var AudioClassificationResultSchema = object({
|
|
10922
11067
|
labels: array(AudioClassificationLabelSchema).readonly(),
|
|
10923
11068
|
rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
|
|
@@ -10926,7 +11071,7 @@ var AudioClassificationResultSchema = object({
|
|
|
10926
11071
|
method(object({
|
|
10927
11072
|
chunk: AudioChunkInputSchema,
|
|
10928
11073
|
settings: AudioAnalysisSettingsSchema
|
|
10929
|
-
}), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
|
|
11074
|
+
}), 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() }), {
|
|
10930
11075
|
kind: "mutation",
|
|
10931
11076
|
auth: "admin"
|
|
10932
11077
|
});
|
|
@@ -26285,8 +26430,8 @@ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly
|
|
|
26285
26430
|
*
|
|
26286
26431
|
* An **empty array reads NOTHING** — `[]` is an empty page, never
|
|
26287
26432
|
* "every camera". A request for no devices is a request, not an
|
|
26288
|
-
* omission; same contract as `deviceManager.
|
|
26289
|
-
* `pipelineAnalytics.listRecentTracks`.
|
|
26433
|
+
* omission; same contract as `deviceManager.listAll`'s `deviceIds`
|
|
26434
|
+
* and `pipelineAnalytics.listRecentTracks`.
|
|
26290
26435
|
*
|
|
26291
26436
|
* Absent (`undefined`) is the omission, and keeps the cluster-wide view.
|
|
26292
26437
|
*/
|
|
@@ -35884,12 +36029,24 @@ Object.freeze({
|
|
|
35884
36029
|
addonId: null,
|
|
35885
36030
|
access: "create"
|
|
35886
36031
|
},
|
|
36032
|
+
"audioAnalyzer.attachDevice": {
|
|
36033
|
+
capName: "audio-analyzer",
|
|
36034
|
+
capScope: "system",
|
|
36035
|
+
addonId: null,
|
|
36036
|
+
access: "create"
|
|
36037
|
+
},
|
|
35887
36038
|
"audioAnalyzer.classify": {
|
|
35888
36039
|
capName: "audio-analyzer",
|
|
35889
36040
|
capScope: "system",
|
|
35890
36041
|
addonId: null,
|
|
35891
36042
|
access: "view"
|
|
35892
36043
|
},
|
|
36044
|
+
"audioAnalyzer.detachDevice": {
|
|
36045
|
+
capName: "audio-analyzer",
|
|
36046
|
+
capScope: "system",
|
|
36047
|
+
addonId: null,
|
|
36048
|
+
access: "create"
|
|
36049
|
+
},
|
|
35893
36050
|
"audioAnalyzer.dispose": {
|
|
35894
36051
|
capName: "audio-analyzer",
|
|
35895
36052
|
capScope: "system",
|
|
@@ -41733,11 +41890,21 @@ Object.freeze({
|
|
|
41733
41890
|
form: "single",
|
|
41734
41891
|
optional: false
|
|
41735
41892
|
}],
|
|
41893
|
+
"audioAnalyzer.attachDevice": [{
|
|
41894
|
+
name: "deviceId",
|
|
41895
|
+
form: "single",
|
|
41896
|
+
optional: false
|
|
41897
|
+
}],
|
|
41736
41898
|
"audioAnalyzer.classify": [{
|
|
41737
41899
|
name: "deviceId",
|
|
41738
41900
|
form: "single",
|
|
41739
41901
|
optional: true
|
|
41740
41902
|
}],
|
|
41903
|
+
"audioAnalyzer.detachDevice": [{
|
|
41904
|
+
name: "deviceId",
|
|
41905
|
+
form: "single",
|
|
41906
|
+
optional: false
|
|
41907
|
+
}],
|
|
41741
41908
|
"audioMetrics.getCurrentSnapshot": [{
|
|
41742
41909
|
name: "deviceId",
|
|
41743
41910
|
form: "single",
|
|
@@ -43589,6 +43756,52 @@ Object.freeze({
|
|
|
43589
43756
|
"network-access": "ingress",
|
|
43590
43757
|
"smtp-provider": "email"
|
|
43591
43758
|
});
|
|
43759
|
+
var G711_SCALE_CORRECTION_DB = {
|
|
43760
|
+
PCMU: 20 * Math.log10(4),
|
|
43761
|
+
PCMA: 20 * Math.log10(8)
|
|
43762
|
+
};
|
|
43763
|
+
/**
|
|
43764
|
+
* Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
|
|
43765
|
+
* same intent on the ITU-T scale (D460).
|
|
43766
|
+
*
|
|
43767
|
+
* ## When this applies, and when it is the wrong thing to reach for
|
|
43768
|
+
*
|
|
43769
|
+
* An absolute-dBFS number in this repo is one of two things, and only one of
|
|
43770
|
+
* them converts:
|
|
43771
|
+
*
|
|
43772
|
+
* - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
|
|
43773
|
+
* is loud". It was true on the ITU-T scale before the epoch and it is true
|
|
43774
|
+
* after. The defect was never in the number; it was that 19 of this hub's
|
|
43775
|
+
* 25 cameras did not obey it. Converting such a number takes something
|
|
43776
|
+
* correct and makes it wrong, in order to preserve a bug.
|
|
43777
|
+
* - **A measurement taken through the old decoder** — a value someone read
|
|
43778
|
+
* off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
|
|
43779
|
+
* describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
|
|
43780
|
+
* louder. That is what this function is for.
|
|
43781
|
+
*
|
|
43782
|
+
* Telling the two apart is a question about PROVENANCE, not about arithmetic,
|
|
43783
|
+
* and it cannot be answered from the number. It is answered by the comment the
|
|
43784
|
+
* author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
|
|
43785
|
+
* mandatory.
|
|
43786
|
+
*
|
|
43787
|
+
* ## Why a function and not a typed-in number
|
|
43788
|
+
*
|
|
43789
|
+
* `-55 + 12.04` written into a source file is, six months later, completely
|
|
43790
|
+
* indistinguishable from a threshold somebody simply preferred. Calling this
|
|
43791
|
+
* keeps the derivation, the law, and the original measurement all visible at
|
|
43792
|
+
* the call site, so a future reader can disagree with the *premise* instead of
|
|
43793
|
+
* having to reverse-engineer the sum.
|
|
43794
|
+
*
|
|
43795
|
+
* **This is not a runtime gain.** It converts an authored CONSTANT once, where
|
|
43796
|
+
* it is declared. It must never be applied to a live sample or a stored
|
|
43797
|
+
* `AudioEvent.dbfs`: the decoder is correct now, and a second authority
|
|
43798
|
+
* adjusting numbers the decoder already got right is the original defect with
|
|
43799
|
+
* an extra place to argue with (D459).
|
|
43800
|
+
*/
|
|
43801
|
+
function ituDbfsFromPreEpoch(law, authoredDbfs) {
|
|
43802
|
+
return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
|
|
43803
|
+
}
|
|
43804
|
+
Math.round(ituDbfsFromPreEpoch("PCMU", -55));
|
|
43592
43805
|
/** Schema defaults — an untouched sub-field must author exactly these. */
|
|
43593
43806
|
var NC_AUDIO_DEFAULTS = {
|
|
43594
43807
|
hitPercent: 60,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/addon-provider-hikvision",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.104",
|
|
4
4
|
"description": "Hikvision camera device provider addon for CamStack — ISAPI over HTTP(S) with digest auth (snapshot, alarm stream, RTSP discovery)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"camstack",
|