@camstack/addon-provider-gree 0.2.94 → 0.2.95
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
|
@@ -5348,6 +5348,86 @@ var ZodIssueCode = {
|
|
|
5348
5348
|
/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
|
|
5349
5349
|
var ZodFirstPartyTypeKind;
|
|
5350
5350
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5351
|
+
//#endregion
|
|
5352
|
+
//#region ../types/dist/sleep-BnujYGPe.mjs
|
|
5353
|
+
/**
|
|
5354
|
+
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5355
|
+
* window to float samples (D455).
|
|
5356
|
+
*
|
|
5357
|
+
* ## Why a format at all
|
|
5358
|
+
*
|
|
5359
|
+
* D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
|
|
5360
|
+
* RATE, and the one consumer that needs 16 kHz resamples next to the model.
|
|
5361
|
+
* It left the FORMAT alone — the broker still turned each G.711 byte into a
|
|
5362
|
+
* 4-byte f32le sample before the bytes entered the transport, so every leg of
|
|
5363
|
+
* the plane carried four times the source. The plane crosses hub-main twice on
|
|
5364
|
+
* the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
|
|
5365
|
+
*
|
|
5366
|
+
* So the plane carries the source BYTES too, and whoever needs floats expands
|
|
5367
|
+
* them where it needs them. That is the same argument D450 made for the rate,
|
|
5368
|
+
* one step further along the same wire.
|
|
5369
|
+
*
|
|
5370
|
+
* ## Why the expansion lives here
|
|
5371
|
+
*
|
|
5372
|
+
* Two packages need it and they must never disagree: `addon-pipeline`'s broker
|
|
5373
|
+
* (which still has to serve a subscriber that did NOT ask for coded bytes —
|
|
5374
|
+
* `AudioChunkPlane` expands per subscription) and
|
|
5375
|
+
* `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
|
|
5376
|
+
* f32le window to the analyzer cap, whose `AudioChunkInput` contract is
|
|
5377
|
+
* unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
|
|
5378
|
+
* into their own dist (`self-contained` externals), so this travels with a
|
|
5379
|
+
* `camstack deploy` and needs no published server.
|
|
5380
|
+
*
|
|
5381
|
+
* A second μ-law table anywhere else is the defect this module exists to
|
|
5382
|
+
* prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
|
|
5383
|
+
* direction for the WebRTC egress — a different transform, not a copy.)
|
|
5384
|
+
*
|
|
5385
|
+
* ## Absent means f32le
|
|
5386
|
+
*
|
|
5387
|
+
* `format` is optional on the wire and its absence means `f32le` — today's
|
|
5388
|
+
* bytes, byte for byte. A peer that never heard of the field is served what it
|
|
5389
|
+
* has always been served, because the broker only emits a coded window to a
|
|
5390
|
+
* subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
|
|
5391
|
+
* That is the D448 `rawForward` negotiation, and it is what makes this
|
|
5392
|
+
* deployable one addon at a time across three nodes.
|
|
5393
|
+
*/
|
|
5394
|
+
/** Every byte format the audio chunk plane can carry. `f32le` is the default. */
|
|
5395
|
+
var AUDIO_CHUNK_FORMATS = [
|
|
5396
|
+
"f32le",
|
|
5397
|
+
"pcmu",
|
|
5398
|
+
"pcma"
|
|
5399
|
+
];
|
|
5400
|
+
/**
|
|
5401
|
+
* Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
|
|
5402
|
+
* to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
|
|
5403
|
+
*
|
|
5404
|
+
* Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
|
|
5405
|
+
* it buffers the coded bytes and the plane's consumers expand.
|
|
5406
|
+
*/
|
|
5407
|
+
function buildUlawTable() {
|
|
5408
|
+
const table = new Float32Array(256);
|
|
5409
|
+
for (let i = 0; i < 256; i++) {
|
|
5410
|
+
const complemented = ~i & 255;
|
|
5411
|
+
const sign = (complemented & 128) !== 0 ? -1 : 1;
|
|
5412
|
+
const exponent = complemented >> 4 & 7;
|
|
5413
|
+
table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
|
|
5414
|
+
}
|
|
5415
|
+
return table;
|
|
5416
|
+
}
|
|
5417
|
+
/** Build the A-law decode table (ITU-T G.711). */
|
|
5418
|
+
function buildAlawTable() {
|
|
5419
|
+
const table = new Float32Array(256);
|
|
5420
|
+
for (let i = 0; i < 256; i++) {
|
|
5421
|
+
const xored = i ^ 85;
|
|
5422
|
+
const sign = (xored & 128) !== 0 ? 1 : -1;
|
|
5423
|
+
const exponent = xored >> 4 & 7;
|
|
5424
|
+
const mantissa = xored & 15;
|
|
5425
|
+
table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
|
|
5426
|
+
}
|
|
5427
|
+
return table;
|
|
5428
|
+
}
|
|
5429
|
+
buildUlawTable();
|
|
5430
|
+
buildAlawTable();
|
|
5351
5431
|
Object.fromEntries([
|
|
5352
5432
|
{
|
|
5353
5433
|
id: "overview",
|
|
@@ -6640,11 +6720,20 @@ var SubscribeFramesResultSchema = object({
|
|
|
6640
6720
|
* (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
|
|
6641
6721
|
* / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
|
|
6642
6722
|
*/
|
|
6723
|
+
var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
|
|
6643
6724
|
var DecodedAudioChunkSchema = object({
|
|
6644
6725
|
data: _instanceof(Uint8Array),
|
|
6645
6726
|
sampleRate: number().int().positive(),
|
|
6646
6727
|
channels: number().int().positive(),
|
|
6647
|
-
timestamp: number()
|
|
6728
|
+
timestamp: number(),
|
|
6729
|
+
/**
|
|
6730
|
+
* Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
|
|
6731
|
+
* byte, for any peer that never heard of this field. A coded window
|
|
6732
|
+
* (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
|
|
6733
|
+
* subscription that DECLARED it accepts one, so absence can never mean
|
|
6734
|
+
* "coded bytes a consumer will read as floats" (D455).
|
|
6735
|
+
*/
|
|
6736
|
+
format: AudioChunkFormatSchema.optional()
|
|
6648
6737
|
});
|
|
6649
6738
|
/**
|
|
6650
6739
|
* Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
|
|
@@ -6656,7 +6745,18 @@ var DecodedAudioChunkSchema = object({
|
|
|
6656
6745
|
var SubscribeAudioChunksInputSchema = object({
|
|
6657
6746
|
brokerId: string(),
|
|
6658
6747
|
/** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
|
|
6659
|
-
tag: string().optional()
|
|
6748
|
+
tag: string().optional(),
|
|
6749
|
+
/**
|
|
6750
|
+
* Byte formats this subscriber can READ, best first. The broker serves the
|
|
6751
|
+
* chunk's own format when it is in this list and expands to `f32le`
|
|
6752
|
+
* otherwise, so a subscriber is never handed bytes it cannot interpret.
|
|
6753
|
+
*
|
|
6754
|
+
* Absent (or without the source format) means `f32le` — the behaviour every
|
|
6755
|
+
* subscriber had before D455, unchanged. This is the negotiation half of
|
|
6756
|
+
* the source-bytes lever: it is what lets the broker and its consumers
|
|
6757
|
+
* deploy one at a time across three nodes.
|
|
6758
|
+
*/
|
|
6759
|
+
accept: array(AudioChunkFormatSchema).readonly().optional()
|
|
6660
6760
|
});
|
|
6661
6761
|
/** Result of `stream-broker.subscribeAudioChunks`. */
|
|
6662
6762
|
var SubscribeAudioChunksResultSchema = object({
|
|
@@ -10644,6 +10744,51 @@ var AudioAnalysisSettingsSchema = object({
|
|
|
10644
10744
|
minConfidence: number().min(0).max(1).default(.3),
|
|
10645
10745
|
allowedClasses: array(string()).default([])
|
|
10646
10746
|
});
|
|
10747
|
+
/**
|
|
10748
|
+
* `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
|
|
10749
|
+
*
|
|
10750
|
+
* Until D461 the orchestrator drained the broker's chunk plane, accumulated
|
|
10751
|
+
* ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
|
|
10752
|
+
* nor consumed the audio: the PCM crossed hub-main twice for a process that
|
|
10753
|
+
* only buffered it. `attachDevice` inverts the direction — the analyzer opens
|
|
10754
|
+
* its own `subscribeAudioChunks` against the broker and the subscriber IS the
|
|
10755
|
+
* decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
|
|
10756
|
+
* way to the one expansion that feeds the model.
|
|
10757
|
+
*
|
|
10758
|
+
* The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
|
|
10759
|
+
* window, the per-device node assignment, the settings read) and therefore
|
|
10760
|
+
* still owns the attach/detach pair. It no longer owns the bytes.
|
|
10761
|
+
*/
|
|
10762
|
+
var AudioAttachDeviceInputSchema = object({
|
|
10763
|
+
deviceId: number(),
|
|
10764
|
+
/** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
|
|
10765
|
+
brokerId: string(),
|
|
10766
|
+
/**
|
|
10767
|
+
* `clusterRoles.ingestNode` — the node whose broker owns the source dial.
|
|
10768
|
+
* Every `streamBroker` call the attachment makes is pinned to it, exactly as
|
|
10769
|
+
* the orchestrator's poller pinned them before the move.
|
|
10770
|
+
*/
|
|
10771
|
+
ingestNodeId: string(),
|
|
10772
|
+
/**
|
|
10773
|
+
* Resolved once by the orchestrator at attach time, exactly as it was read
|
|
10774
|
+
* once per subscription before D461. The analyzer does NOT re-resolve per
|
|
10775
|
+
* window: a settings change re-attaches, which is what always happened.
|
|
10776
|
+
*/
|
|
10777
|
+
settings: AudioAnalysisSettingsSchema
|
|
10778
|
+
});
|
|
10779
|
+
var AudioAttachDeviceResultSchema = object({
|
|
10780
|
+
/** False only when the analyzer is shutting down and refused to attach. */
|
|
10781
|
+
attached: boolean(),
|
|
10782
|
+
/**
|
|
10783
|
+
* True when the attachment replaced a live one for the same device. An
|
|
10784
|
+
* attach is idempotent by REPLACEMENT — two pollers on one camera would
|
|
10785
|
+
* double the broker's fanout and neither would know about the other.
|
|
10786
|
+
*/
|
|
10787
|
+
replaced: boolean()
|
|
10788
|
+
});
|
|
10789
|
+
var AudioDetachDeviceResultSchema = object({
|
|
10790
|
+
/** False when no attachment existed — detach is idempotent. */
|
|
10791
|
+
detached: boolean() });
|
|
10647
10792
|
var AudioClassificationResultSchema = object({
|
|
10648
10793
|
labels: array(AudioClassificationLabelSchema).readonly(),
|
|
10649
10794
|
rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
|
|
@@ -10652,7 +10797,7 @@ var AudioClassificationResultSchema = object({
|
|
|
10652
10797
|
method(object({
|
|
10653
10798
|
chunk: AudioChunkInputSchema,
|
|
10654
10799
|
settings: AudioAnalysisSettingsSchema
|
|
10655
|
-
}), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
|
|
10800
|
+
}), 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() }), {
|
|
10656
10801
|
kind: "mutation",
|
|
10657
10802
|
auth: "admin"
|
|
10658
10803
|
});
|
|
@@ -34911,12 +35056,24 @@ Object.freeze({
|
|
|
34911
35056
|
addonId: null,
|
|
34912
35057
|
access: "create"
|
|
34913
35058
|
},
|
|
35059
|
+
"audioAnalyzer.attachDevice": {
|
|
35060
|
+
capName: "audio-analyzer",
|
|
35061
|
+
capScope: "system",
|
|
35062
|
+
addonId: null,
|
|
35063
|
+
access: "create"
|
|
35064
|
+
},
|
|
34914
35065
|
"audioAnalyzer.classify": {
|
|
34915
35066
|
capName: "audio-analyzer",
|
|
34916
35067
|
capScope: "system",
|
|
34917
35068
|
addonId: null,
|
|
34918
35069
|
access: "view"
|
|
34919
35070
|
},
|
|
35071
|
+
"audioAnalyzer.detachDevice": {
|
|
35072
|
+
capName: "audio-analyzer",
|
|
35073
|
+
capScope: "system",
|
|
35074
|
+
addonId: null,
|
|
35075
|
+
access: "create"
|
|
35076
|
+
},
|
|
34920
35077
|
"audioAnalyzer.dispose": {
|
|
34921
35078
|
capName: "audio-analyzer",
|
|
34922
35079
|
capScope: "system",
|
|
@@ -40760,11 +40917,21 @@ Object.freeze({
|
|
|
40760
40917
|
form: "single",
|
|
40761
40918
|
optional: false
|
|
40762
40919
|
}],
|
|
40920
|
+
"audioAnalyzer.attachDevice": [{
|
|
40921
|
+
name: "deviceId",
|
|
40922
|
+
form: "single",
|
|
40923
|
+
optional: false
|
|
40924
|
+
}],
|
|
40763
40925
|
"audioAnalyzer.classify": [{
|
|
40764
40926
|
name: "deviceId",
|
|
40765
40927
|
form: "single",
|
|
40766
40928
|
optional: true
|
|
40767
40929
|
}],
|
|
40930
|
+
"audioAnalyzer.detachDevice": [{
|
|
40931
|
+
name: "deviceId",
|
|
40932
|
+
form: "single",
|
|
40933
|
+
optional: false
|
|
40934
|
+
}],
|
|
40768
40935
|
"audioMetrics.getCurrentSnapshot": [{
|
|
40769
40936
|
name: "deviceId",
|
|
40770
40937
|
form: "single",
|
|
@@ -42616,6 +42783,52 @@ Object.freeze({
|
|
|
42616
42783
|
"network-access": "ingress",
|
|
42617
42784
|
"smtp-provider": "email"
|
|
42618
42785
|
});
|
|
42786
|
+
var G711_SCALE_CORRECTION_DB = {
|
|
42787
|
+
PCMU: 20 * Math.log10(4),
|
|
42788
|
+
PCMA: 20 * Math.log10(8)
|
|
42789
|
+
};
|
|
42790
|
+
/**
|
|
42791
|
+
* Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
|
|
42792
|
+
* same intent on the ITU-T scale (D460).
|
|
42793
|
+
*
|
|
42794
|
+
* ## When this applies, and when it is the wrong thing to reach for
|
|
42795
|
+
*
|
|
42796
|
+
* An absolute-dBFS number in this repo is one of two things, and only one of
|
|
42797
|
+
* them converts:
|
|
42798
|
+
*
|
|
42799
|
+
* - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
|
|
42800
|
+
* is loud". It was true on the ITU-T scale before the epoch and it is true
|
|
42801
|
+
* after. The defect was never in the number; it was that 19 of this hub's
|
|
42802
|
+
* 25 cameras did not obey it. Converting such a number takes something
|
|
42803
|
+
* correct and makes it wrong, in order to preserve a bug.
|
|
42804
|
+
* - **A measurement taken through the old decoder** — a value someone read
|
|
42805
|
+
* off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
|
|
42806
|
+
* describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
|
|
42807
|
+
* louder. That is what this function is for.
|
|
42808
|
+
*
|
|
42809
|
+
* Telling the two apart is a question about PROVENANCE, not about arithmetic,
|
|
42810
|
+
* and it cannot be answered from the number. It is answered by the comment the
|
|
42811
|
+
* author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
|
|
42812
|
+
* mandatory.
|
|
42813
|
+
*
|
|
42814
|
+
* ## Why a function and not a typed-in number
|
|
42815
|
+
*
|
|
42816
|
+
* `-55 + 12.04` written into a source file is, six months later, completely
|
|
42817
|
+
* indistinguishable from a threshold somebody simply preferred. Calling this
|
|
42818
|
+
* keeps the derivation, the law, and the original measurement all visible at
|
|
42819
|
+
* the call site, so a future reader can disagree with the *premise* instead of
|
|
42820
|
+
* having to reverse-engineer the sum.
|
|
42821
|
+
*
|
|
42822
|
+
* **This is not a runtime gain.** It converts an authored CONSTANT once, where
|
|
42823
|
+
* it is declared. It must never be applied to a live sample or a stored
|
|
42824
|
+
* `AudioEvent.dbfs`: the decoder is correct now, and a second authority
|
|
42825
|
+
* adjusting numbers the decoder already got right is the original defect with
|
|
42826
|
+
* an extra place to argue with (D459).
|
|
42827
|
+
*/
|
|
42828
|
+
function ituDbfsFromPreEpoch(law, authoredDbfs) {
|
|
42829
|
+
return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
|
|
42830
|
+
}
|
|
42831
|
+
Math.round(ituDbfsFromPreEpoch("PCMU", -55));
|
|
42619
42832
|
/** Schema defaults — an untouched sub-field must author exactly these. */
|
|
42620
42833
|
var NC_AUDIO_DEFAULTS = {
|
|
42621
42834
|
hitPercent: 60,
|
package/dist/addon.mjs
CHANGED
|
@@ -5347,6 +5347,86 @@ var ZodIssueCode = {
|
|
|
5347
5347
|
/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
|
|
5348
5348
|
var ZodFirstPartyTypeKind;
|
|
5349
5349
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5350
|
+
//#endregion
|
|
5351
|
+
//#region ../types/dist/sleep-BnujYGPe.mjs
|
|
5352
|
+
/**
|
|
5353
|
+
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5354
|
+
* window to float samples (D455).
|
|
5355
|
+
*
|
|
5356
|
+
* ## Why a format at all
|
|
5357
|
+
*
|
|
5358
|
+
* D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
|
|
5359
|
+
* RATE, and the one consumer that needs 16 kHz resamples next to the model.
|
|
5360
|
+
* It left the FORMAT alone — the broker still turned each G.711 byte into a
|
|
5361
|
+
* 4-byte f32le sample before the bytes entered the transport, so every leg of
|
|
5362
|
+
* the plane carried four times the source. The plane crosses hub-main twice on
|
|
5363
|
+
* the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
|
|
5364
|
+
*
|
|
5365
|
+
* So the plane carries the source BYTES too, and whoever needs floats expands
|
|
5366
|
+
* them where it needs them. That is the same argument D450 made for the rate,
|
|
5367
|
+
* one step further along the same wire.
|
|
5368
|
+
*
|
|
5369
|
+
* ## Why the expansion lives here
|
|
5370
|
+
*
|
|
5371
|
+
* Two packages need it and they must never disagree: `addon-pipeline`'s broker
|
|
5372
|
+
* (which still has to serve a subscriber that did NOT ask for coded bytes —
|
|
5373
|
+
* `AudioChunkPlane` expands per subscription) and
|
|
5374
|
+
* `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
|
|
5375
|
+
* f32le window to the analyzer cap, whose `AudioChunkInput` contract is
|
|
5376
|
+
* unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
|
|
5377
|
+
* into their own dist (`self-contained` externals), so this travels with a
|
|
5378
|
+
* `camstack deploy` and needs no published server.
|
|
5379
|
+
*
|
|
5380
|
+
* A second μ-law table anywhere else is the defect this module exists to
|
|
5381
|
+
* prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
|
|
5382
|
+
* direction for the WebRTC egress — a different transform, not a copy.)
|
|
5383
|
+
*
|
|
5384
|
+
* ## Absent means f32le
|
|
5385
|
+
*
|
|
5386
|
+
* `format` is optional on the wire and its absence means `f32le` — today's
|
|
5387
|
+
* bytes, byte for byte. A peer that never heard of the field is served what it
|
|
5388
|
+
* has always been served, because the broker only emits a coded window to a
|
|
5389
|
+
* subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
|
|
5390
|
+
* That is the D448 `rawForward` negotiation, and it is what makes this
|
|
5391
|
+
* deployable one addon at a time across three nodes.
|
|
5392
|
+
*/
|
|
5393
|
+
/** Every byte format the audio chunk plane can carry. `f32le` is the default. */
|
|
5394
|
+
var AUDIO_CHUNK_FORMATS = [
|
|
5395
|
+
"f32le",
|
|
5396
|
+
"pcmu",
|
|
5397
|
+
"pcma"
|
|
5398
|
+
];
|
|
5399
|
+
/**
|
|
5400
|
+
* Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
|
|
5401
|
+
* to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
|
|
5402
|
+
*
|
|
5403
|
+
* Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
|
|
5404
|
+
* it buffers the coded bytes and the plane's consumers expand.
|
|
5405
|
+
*/
|
|
5406
|
+
function buildUlawTable() {
|
|
5407
|
+
const table = new Float32Array(256);
|
|
5408
|
+
for (let i = 0; i < 256; i++) {
|
|
5409
|
+
const complemented = ~i & 255;
|
|
5410
|
+
const sign = (complemented & 128) !== 0 ? -1 : 1;
|
|
5411
|
+
const exponent = complemented >> 4 & 7;
|
|
5412
|
+
table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
|
|
5413
|
+
}
|
|
5414
|
+
return table;
|
|
5415
|
+
}
|
|
5416
|
+
/** Build the A-law decode table (ITU-T G.711). */
|
|
5417
|
+
function buildAlawTable() {
|
|
5418
|
+
const table = new Float32Array(256);
|
|
5419
|
+
for (let i = 0; i < 256; i++) {
|
|
5420
|
+
const xored = i ^ 85;
|
|
5421
|
+
const sign = (xored & 128) !== 0 ? 1 : -1;
|
|
5422
|
+
const exponent = xored >> 4 & 7;
|
|
5423
|
+
const mantissa = xored & 15;
|
|
5424
|
+
table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
|
|
5425
|
+
}
|
|
5426
|
+
return table;
|
|
5427
|
+
}
|
|
5428
|
+
buildUlawTable();
|
|
5429
|
+
buildAlawTable();
|
|
5350
5430
|
Object.fromEntries([
|
|
5351
5431
|
{
|
|
5352
5432
|
id: "overview",
|
|
@@ -6639,11 +6719,20 @@ var SubscribeFramesResultSchema = object({
|
|
|
6639
6719
|
* (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
|
|
6640
6720
|
* / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
|
|
6641
6721
|
*/
|
|
6722
|
+
var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
|
|
6642
6723
|
var DecodedAudioChunkSchema = object({
|
|
6643
6724
|
data: _instanceof(Uint8Array),
|
|
6644
6725
|
sampleRate: number().int().positive(),
|
|
6645
6726
|
channels: number().int().positive(),
|
|
6646
|
-
timestamp: number()
|
|
6727
|
+
timestamp: number(),
|
|
6728
|
+
/**
|
|
6729
|
+
* Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
|
|
6730
|
+
* byte, for any peer that never heard of this field. A coded window
|
|
6731
|
+
* (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
|
|
6732
|
+
* subscription that DECLARED it accepts one, so absence can never mean
|
|
6733
|
+
* "coded bytes a consumer will read as floats" (D455).
|
|
6734
|
+
*/
|
|
6735
|
+
format: AudioChunkFormatSchema.optional()
|
|
6647
6736
|
});
|
|
6648
6737
|
/**
|
|
6649
6738
|
* Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
|
|
@@ -6655,7 +6744,18 @@ var DecodedAudioChunkSchema = object({
|
|
|
6655
6744
|
var SubscribeAudioChunksInputSchema = object({
|
|
6656
6745
|
brokerId: string(),
|
|
6657
6746
|
/** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
|
|
6658
|
-
tag: string().optional()
|
|
6747
|
+
tag: string().optional(),
|
|
6748
|
+
/**
|
|
6749
|
+
* Byte formats this subscriber can READ, best first. The broker serves the
|
|
6750
|
+
* chunk's own format when it is in this list and expands to `f32le`
|
|
6751
|
+
* otherwise, so a subscriber is never handed bytes it cannot interpret.
|
|
6752
|
+
*
|
|
6753
|
+
* Absent (or without the source format) means `f32le` — the behaviour every
|
|
6754
|
+
* subscriber had before D455, unchanged. This is the negotiation half of
|
|
6755
|
+
* the source-bytes lever: it is what lets the broker and its consumers
|
|
6756
|
+
* deploy one at a time across three nodes.
|
|
6757
|
+
*/
|
|
6758
|
+
accept: array(AudioChunkFormatSchema).readonly().optional()
|
|
6659
6759
|
});
|
|
6660
6760
|
/** Result of `stream-broker.subscribeAudioChunks`. */
|
|
6661
6761
|
var SubscribeAudioChunksResultSchema = object({
|
|
@@ -10643,6 +10743,51 @@ var AudioAnalysisSettingsSchema = object({
|
|
|
10643
10743
|
minConfidence: number().min(0).max(1).default(.3),
|
|
10644
10744
|
allowedClasses: array(string()).default([])
|
|
10645
10745
|
});
|
|
10746
|
+
/**
|
|
10747
|
+
* `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
|
|
10748
|
+
*
|
|
10749
|
+
* Until D461 the orchestrator drained the broker's chunk plane, accumulated
|
|
10750
|
+
* ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
|
|
10751
|
+
* nor consumed the audio: the PCM crossed hub-main twice for a process that
|
|
10752
|
+
* only buffered it. `attachDevice` inverts the direction — the analyzer opens
|
|
10753
|
+
* its own `subscribeAudioChunks` against the broker and the subscriber IS the
|
|
10754
|
+
* decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
|
|
10755
|
+
* way to the one expansion that feeds the model.
|
|
10756
|
+
*
|
|
10757
|
+
* The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
|
|
10758
|
+
* window, the per-device node assignment, the settings read) and therefore
|
|
10759
|
+
* still owns the attach/detach pair. It no longer owns the bytes.
|
|
10760
|
+
*/
|
|
10761
|
+
var AudioAttachDeviceInputSchema = object({
|
|
10762
|
+
deviceId: number(),
|
|
10763
|
+
/** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
|
|
10764
|
+
brokerId: string(),
|
|
10765
|
+
/**
|
|
10766
|
+
* `clusterRoles.ingestNode` — the node whose broker owns the source dial.
|
|
10767
|
+
* Every `streamBroker` call the attachment makes is pinned to it, exactly as
|
|
10768
|
+
* the orchestrator's poller pinned them before the move.
|
|
10769
|
+
*/
|
|
10770
|
+
ingestNodeId: string(),
|
|
10771
|
+
/**
|
|
10772
|
+
* Resolved once by the orchestrator at attach time, exactly as it was read
|
|
10773
|
+
* once per subscription before D461. The analyzer does NOT re-resolve per
|
|
10774
|
+
* window: a settings change re-attaches, which is what always happened.
|
|
10775
|
+
*/
|
|
10776
|
+
settings: AudioAnalysisSettingsSchema
|
|
10777
|
+
});
|
|
10778
|
+
var AudioAttachDeviceResultSchema = object({
|
|
10779
|
+
/** False only when the analyzer is shutting down and refused to attach. */
|
|
10780
|
+
attached: boolean(),
|
|
10781
|
+
/**
|
|
10782
|
+
* True when the attachment replaced a live one for the same device. An
|
|
10783
|
+
* attach is idempotent by REPLACEMENT — two pollers on one camera would
|
|
10784
|
+
* double the broker's fanout and neither would know about the other.
|
|
10785
|
+
*/
|
|
10786
|
+
replaced: boolean()
|
|
10787
|
+
});
|
|
10788
|
+
var AudioDetachDeviceResultSchema = object({
|
|
10789
|
+
/** False when no attachment existed — detach is idempotent. */
|
|
10790
|
+
detached: boolean() });
|
|
10646
10791
|
var AudioClassificationResultSchema = object({
|
|
10647
10792
|
labels: array(AudioClassificationLabelSchema).readonly(),
|
|
10648
10793
|
rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
|
|
@@ -10651,7 +10796,7 @@ var AudioClassificationResultSchema = object({
|
|
|
10651
10796
|
method(object({
|
|
10652
10797
|
chunk: AudioChunkInputSchema,
|
|
10653
10798
|
settings: AudioAnalysisSettingsSchema
|
|
10654
|
-
}), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
|
|
10799
|
+
}), 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() }), {
|
|
10655
10800
|
kind: "mutation",
|
|
10656
10801
|
auth: "admin"
|
|
10657
10802
|
});
|
|
@@ -34910,12 +35055,24 @@ Object.freeze({
|
|
|
34910
35055
|
addonId: null,
|
|
34911
35056
|
access: "create"
|
|
34912
35057
|
},
|
|
35058
|
+
"audioAnalyzer.attachDevice": {
|
|
35059
|
+
capName: "audio-analyzer",
|
|
35060
|
+
capScope: "system",
|
|
35061
|
+
addonId: null,
|
|
35062
|
+
access: "create"
|
|
35063
|
+
},
|
|
34913
35064
|
"audioAnalyzer.classify": {
|
|
34914
35065
|
capName: "audio-analyzer",
|
|
34915
35066
|
capScope: "system",
|
|
34916
35067
|
addonId: null,
|
|
34917
35068
|
access: "view"
|
|
34918
35069
|
},
|
|
35070
|
+
"audioAnalyzer.detachDevice": {
|
|
35071
|
+
capName: "audio-analyzer",
|
|
35072
|
+
capScope: "system",
|
|
35073
|
+
addonId: null,
|
|
35074
|
+
access: "create"
|
|
35075
|
+
},
|
|
34919
35076
|
"audioAnalyzer.dispose": {
|
|
34920
35077
|
capName: "audio-analyzer",
|
|
34921
35078
|
capScope: "system",
|
|
@@ -40759,11 +40916,21 @@ Object.freeze({
|
|
|
40759
40916
|
form: "single",
|
|
40760
40917
|
optional: false
|
|
40761
40918
|
}],
|
|
40919
|
+
"audioAnalyzer.attachDevice": [{
|
|
40920
|
+
name: "deviceId",
|
|
40921
|
+
form: "single",
|
|
40922
|
+
optional: false
|
|
40923
|
+
}],
|
|
40762
40924
|
"audioAnalyzer.classify": [{
|
|
40763
40925
|
name: "deviceId",
|
|
40764
40926
|
form: "single",
|
|
40765
40927
|
optional: true
|
|
40766
40928
|
}],
|
|
40929
|
+
"audioAnalyzer.detachDevice": [{
|
|
40930
|
+
name: "deviceId",
|
|
40931
|
+
form: "single",
|
|
40932
|
+
optional: false
|
|
40933
|
+
}],
|
|
40767
40934
|
"audioMetrics.getCurrentSnapshot": [{
|
|
40768
40935
|
name: "deviceId",
|
|
40769
40936
|
form: "single",
|
|
@@ -42615,6 +42782,52 @@ Object.freeze({
|
|
|
42615
42782
|
"network-access": "ingress",
|
|
42616
42783
|
"smtp-provider": "email"
|
|
42617
42784
|
});
|
|
42785
|
+
var G711_SCALE_CORRECTION_DB = {
|
|
42786
|
+
PCMU: 20 * Math.log10(4),
|
|
42787
|
+
PCMA: 20 * Math.log10(8)
|
|
42788
|
+
};
|
|
42789
|
+
/**
|
|
42790
|
+
* Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
|
|
42791
|
+
* same intent on the ITU-T scale (D460).
|
|
42792
|
+
*
|
|
42793
|
+
* ## When this applies, and when it is the wrong thing to reach for
|
|
42794
|
+
*
|
|
42795
|
+
* An absolute-dBFS number in this repo is one of two things, and only one of
|
|
42796
|
+
* them converts:
|
|
42797
|
+
*
|
|
42798
|
+
* - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
|
|
42799
|
+
* is loud". It was true on the ITU-T scale before the epoch and it is true
|
|
42800
|
+
* after. The defect was never in the number; it was that 19 of this hub's
|
|
42801
|
+
* 25 cameras did not obey it. Converting such a number takes something
|
|
42802
|
+
* correct and makes it wrong, in order to preserve a bug.
|
|
42803
|
+
* - **A measurement taken through the old decoder** — a value someone read
|
|
42804
|
+
* off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
|
|
42805
|
+
* describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
|
|
42806
|
+
* louder. That is what this function is for.
|
|
42807
|
+
*
|
|
42808
|
+
* Telling the two apart is a question about PROVENANCE, not about arithmetic,
|
|
42809
|
+
* and it cannot be answered from the number. It is answered by the comment the
|
|
42810
|
+
* author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
|
|
42811
|
+
* mandatory.
|
|
42812
|
+
*
|
|
42813
|
+
* ## Why a function and not a typed-in number
|
|
42814
|
+
*
|
|
42815
|
+
* `-55 + 12.04` written into a source file is, six months later, completely
|
|
42816
|
+
* indistinguishable from a threshold somebody simply preferred. Calling this
|
|
42817
|
+
* keeps the derivation, the law, and the original measurement all visible at
|
|
42818
|
+
* the call site, so a future reader can disagree with the *premise* instead of
|
|
42819
|
+
* having to reverse-engineer the sum.
|
|
42820
|
+
*
|
|
42821
|
+
* **This is not a runtime gain.** It converts an authored CONSTANT once, where
|
|
42822
|
+
* it is declared. It must never be applied to a live sample or a stored
|
|
42823
|
+
* `AudioEvent.dbfs`: the decoder is correct now, and a second authority
|
|
42824
|
+
* adjusting numbers the decoder already got right is the original defect with
|
|
42825
|
+
* an extra place to argue with (D459).
|
|
42826
|
+
*/
|
|
42827
|
+
function ituDbfsFromPreEpoch(law, authoredDbfs) {
|
|
42828
|
+
return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
|
|
42829
|
+
}
|
|
42830
|
+
Math.round(ituDbfsFromPreEpoch("PCMU", -55));
|
|
42618
42831
|
/** Schema defaults — an untouched sub-field must author exactly these. */
|
|
42619
42832
|
var NC_AUDIO_DEFAULTS = {
|
|
42620
42833
|
hitPercent: 60,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/addon-provider-gree",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.95",
|
|
4
4
|
"description": "Gree air-conditioner device-provider addon for CamStack — wraps the @apocaliss92/nodegree local-UDP client (LAN discovery + AES control), exposing climate-control and fan-control",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"camstack",
|