@camstack/addon-terminal 0.1.99 → 0.1.101
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
|
@@ -5377,6 +5377,86 @@ var ZodIssueCode = {
|
|
|
5377
5377
|
/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
|
|
5378
5378
|
var ZodFirstPartyTypeKind;
|
|
5379
5379
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5380
|
+
//#endregion
|
|
5381
|
+
//#region ../types/dist/sleep-BnujYGPe.mjs
|
|
5382
|
+
/**
|
|
5383
|
+
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5384
|
+
* window to float samples (D455).
|
|
5385
|
+
*
|
|
5386
|
+
* ## Why a format at all
|
|
5387
|
+
*
|
|
5388
|
+
* D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
|
|
5389
|
+
* RATE, and the one consumer that needs 16 kHz resamples next to the model.
|
|
5390
|
+
* It left the FORMAT alone — the broker still turned each G.711 byte into a
|
|
5391
|
+
* 4-byte f32le sample before the bytes entered the transport, so every leg of
|
|
5392
|
+
* the plane carried four times the source. The plane crosses hub-main twice on
|
|
5393
|
+
* the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
|
|
5394
|
+
*
|
|
5395
|
+
* So the plane carries the source BYTES too, and whoever needs floats expands
|
|
5396
|
+
* them where it needs them. That is the same argument D450 made for the rate,
|
|
5397
|
+
* one step further along the same wire.
|
|
5398
|
+
*
|
|
5399
|
+
* ## Why the expansion lives here
|
|
5400
|
+
*
|
|
5401
|
+
* Two packages need it and they must never disagree: `addon-pipeline`'s broker
|
|
5402
|
+
* (which still has to serve a subscriber that did NOT ask for coded bytes —
|
|
5403
|
+
* `AudioChunkPlane` expands per subscription) and
|
|
5404
|
+
* `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
|
|
5405
|
+
* f32le window to the analyzer cap, whose `AudioChunkInput` contract is
|
|
5406
|
+
* unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
|
|
5407
|
+
* into their own dist (`self-contained` externals), so this travels with a
|
|
5408
|
+
* `camstack deploy` and needs no published server.
|
|
5409
|
+
*
|
|
5410
|
+
* A second μ-law table anywhere else is the defect this module exists to
|
|
5411
|
+
* prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
|
|
5412
|
+
* direction for the WebRTC egress — a different transform, not a copy.)
|
|
5413
|
+
*
|
|
5414
|
+
* ## Absent means f32le
|
|
5415
|
+
*
|
|
5416
|
+
* `format` is optional on the wire and its absence means `f32le` — today's
|
|
5417
|
+
* bytes, byte for byte. A peer that never heard of the field is served what it
|
|
5418
|
+
* has always been served, because the broker only emits a coded window to a
|
|
5419
|
+
* subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
|
|
5420
|
+
* That is the D448 `rawForward` negotiation, and it is what makes this
|
|
5421
|
+
* deployable one addon at a time across three nodes.
|
|
5422
|
+
*/
|
|
5423
|
+
/** Every byte format the audio chunk plane can carry. `f32le` is the default. */
|
|
5424
|
+
var AUDIO_CHUNK_FORMATS = [
|
|
5425
|
+
"f32le",
|
|
5426
|
+
"pcmu",
|
|
5427
|
+
"pcma"
|
|
5428
|
+
];
|
|
5429
|
+
/**
|
|
5430
|
+
* Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
|
|
5431
|
+
* to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
|
|
5432
|
+
*
|
|
5433
|
+
* Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
|
|
5434
|
+
* it buffers the coded bytes and the plane's consumers expand.
|
|
5435
|
+
*/
|
|
5436
|
+
function buildUlawTable() {
|
|
5437
|
+
const table = new Float32Array(256);
|
|
5438
|
+
for (let i = 0; i < 256; i++) {
|
|
5439
|
+
const complemented = ~i & 255;
|
|
5440
|
+
const sign = (complemented & 128) !== 0 ? -1 : 1;
|
|
5441
|
+
const exponent = complemented >> 4 & 7;
|
|
5442
|
+
table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
|
|
5443
|
+
}
|
|
5444
|
+
return table;
|
|
5445
|
+
}
|
|
5446
|
+
/** Build the A-law decode table (ITU-T G.711). */
|
|
5447
|
+
function buildAlawTable() {
|
|
5448
|
+
const table = new Float32Array(256);
|
|
5449
|
+
for (let i = 0; i < 256; i++) {
|
|
5450
|
+
const xored = i ^ 85;
|
|
5451
|
+
const sign = (xored & 128) !== 0 ? 1 : -1;
|
|
5452
|
+
const exponent = xored >> 4 & 7;
|
|
5453
|
+
const mantissa = xored & 15;
|
|
5454
|
+
table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
|
|
5455
|
+
}
|
|
5456
|
+
return table;
|
|
5457
|
+
}
|
|
5458
|
+
buildUlawTable();
|
|
5459
|
+
buildAlawTable();
|
|
5380
5460
|
Object.fromEntries([
|
|
5381
5461
|
{
|
|
5382
5462
|
id: "overview",
|
|
@@ -6669,11 +6749,20 @@ var SubscribeFramesResultSchema = object({
|
|
|
6669
6749
|
* (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
|
|
6670
6750
|
* / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
|
|
6671
6751
|
*/
|
|
6752
|
+
var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
|
|
6672
6753
|
var DecodedAudioChunkSchema = object({
|
|
6673
6754
|
data: _instanceof(Uint8Array),
|
|
6674
6755
|
sampleRate: number().int().positive(),
|
|
6675
6756
|
channels: number().int().positive(),
|
|
6676
|
-
timestamp: number()
|
|
6757
|
+
timestamp: number(),
|
|
6758
|
+
/**
|
|
6759
|
+
* Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
|
|
6760
|
+
* byte, for any peer that never heard of this field. A coded window
|
|
6761
|
+
* (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
|
|
6762
|
+
* subscription that DECLARED it accepts one, so absence can never mean
|
|
6763
|
+
* "coded bytes a consumer will read as floats" (D455).
|
|
6764
|
+
*/
|
|
6765
|
+
format: AudioChunkFormatSchema.optional()
|
|
6677
6766
|
});
|
|
6678
6767
|
/**
|
|
6679
6768
|
* Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
|
|
@@ -6685,7 +6774,18 @@ var DecodedAudioChunkSchema = object({
|
|
|
6685
6774
|
var SubscribeAudioChunksInputSchema = object({
|
|
6686
6775
|
brokerId: string(),
|
|
6687
6776
|
/** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
|
|
6688
|
-
tag: string().optional()
|
|
6777
|
+
tag: string().optional(),
|
|
6778
|
+
/**
|
|
6779
|
+
* Byte formats this subscriber can READ, best first. The broker serves the
|
|
6780
|
+
* chunk's own format when it is in this list and expands to `f32le`
|
|
6781
|
+
* otherwise, so a subscriber is never handed bytes it cannot interpret.
|
|
6782
|
+
*
|
|
6783
|
+
* Absent (or without the source format) means `f32le` — the behaviour every
|
|
6784
|
+
* subscriber had before D455, unchanged. This is the negotiation half of
|
|
6785
|
+
* the source-bytes lever: it is what lets the broker and its consumers
|
|
6786
|
+
* deploy one at a time across three nodes.
|
|
6787
|
+
*/
|
|
6788
|
+
accept: array(AudioChunkFormatSchema).readonly().optional()
|
|
6689
6789
|
});
|
|
6690
6790
|
/** Result of `stream-broker.subscribeAudioChunks`. */
|
|
6691
6791
|
var SubscribeAudioChunksResultSchema = object({
|
|
@@ -10740,6 +10840,51 @@ var AudioAnalysisSettingsSchema = object({
|
|
|
10740
10840
|
minConfidence: number().min(0).max(1).default(.3),
|
|
10741
10841
|
allowedClasses: array(string()).default([])
|
|
10742
10842
|
});
|
|
10843
|
+
/**
|
|
10844
|
+
* `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
|
|
10845
|
+
*
|
|
10846
|
+
* Until D461 the orchestrator drained the broker's chunk plane, accumulated
|
|
10847
|
+
* ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
|
|
10848
|
+
* nor consumed the audio: the PCM crossed hub-main twice for a process that
|
|
10849
|
+
* only buffered it. `attachDevice` inverts the direction — the analyzer opens
|
|
10850
|
+
* its own `subscribeAudioChunks` against the broker and the subscriber IS the
|
|
10851
|
+
* decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
|
|
10852
|
+
* way to the one expansion that feeds the model.
|
|
10853
|
+
*
|
|
10854
|
+
* The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
|
|
10855
|
+
* window, the per-device node assignment, the settings read) and therefore
|
|
10856
|
+
* still owns the attach/detach pair. It no longer owns the bytes.
|
|
10857
|
+
*/
|
|
10858
|
+
var AudioAttachDeviceInputSchema = object({
|
|
10859
|
+
deviceId: number(),
|
|
10860
|
+
/** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
|
|
10861
|
+
brokerId: string(),
|
|
10862
|
+
/**
|
|
10863
|
+
* `clusterRoles.ingestNode` — the node whose broker owns the source dial.
|
|
10864
|
+
* Every `streamBroker` call the attachment makes is pinned to it, exactly as
|
|
10865
|
+
* the orchestrator's poller pinned them before the move.
|
|
10866
|
+
*/
|
|
10867
|
+
ingestNodeId: string(),
|
|
10868
|
+
/**
|
|
10869
|
+
* Resolved once by the orchestrator at attach time, exactly as it was read
|
|
10870
|
+
* once per subscription before D461. The analyzer does NOT re-resolve per
|
|
10871
|
+
* window: a settings change re-attaches, which is what always happened.
|
|
10872
|
+
*/
|
|
10873
|
+
settings: AudioAnalysisSettingsSchema
|
|
10874
|
+
});
|
|
10875
|
+
var AudioAttachDeviceResultSchema = object({
|
|
10876
|
+
/** False only when the analyzer is shutting down and refused to attach. */
|
|
10877
|
+
attached: boolean(),
|
|
10878
|
+
/**
|
|
10879
|
+
* True when the attachment replaced a live one for the same device. An
|
|
10880
|
+
* attach is idempotent by REPLACEMENT — two pollers on one camera would
|
|
10881
|
+
* double the broker's fanout and neither would know about the other.
|
|
10882
|
+
*/
|
|
10883
|
+
replaced: boolean()
|
|
10884
|
+
});
|
|
10885
|
+
var AudioDetachDeviceResultSchema = object({
|
|
10886
|
+
/** False when no attachment existed — detach is idempotent. */
|
|
10887
|
+
detached: boolean() });
|
|
10743
10888
|
var AudioClassificationResultSchema = object({
|
|
10744
10889
|
labels: array(AudioClassificationLabelSchema).readonly(),
|
|
10745
10890
|
rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
|
|
@@ -10748,7 +10893,7 @@ var AudioClassificationResultSchema = object({
|
|
|
10748
10893
|
method(object({
|
|
10749
10894
|
chunk: AudioChunkInputSchema,
|
|
10750
10895
|
settings: AudioAnalysisSettingsSchema
|
|
10751
|
-
}), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
|
|
10896
|
+
}), 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() }), {
|
|
10752
10897
|
kind: "mutation",
|
|
10753
10898
|
auth: "admin"
|
|
10754
10899
|
});
|
|
@@ -26039,8 +26184,8 @@ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly
|
|
|
26039
26184
|
*
|
|
26040
26185
|
* An **empty array reads NOTHING** — `[]` is an empty page, never
|
|
26041
26186
|
* "every camera". A request for no devices is a request, not an
|
|
26042
|
-
* omission; same contract as `deviceManager.
|
|
26043
|
-
* `pipelineAnalytics.listRecentTracks`.
|
|
26187
|
+
* omission; same contract as `deviceManager.listAll`'s `deviceIds`
|
|
26188
|
+
* and `pipelineAnalytics.listRecentTracks`.
|
|
26044
26189
|
*
|
|
26045
26190
|
* Absent (`undefined`) is the omission, and keeps the cluster-wide view.
|
|
26046
26191
|
*/
|
|
@@ -34656,12 +34801,24 @@ Object.freeze({
|
|
|
34656
34801
|
addonId: null,
|
|
34657
34802
|
access: "create"
|
|
34658
34803
|
},
|
|
34804
|
+
"audioAnalyzer.attachDevice": {
|
|
34805
|
+
capName: "audio-analyzer",
|
|
34806
|
+
capScope: "system",
|
|
34807
|
+
addonId: null,
|
|
34808
|
+
access: "create"
|
|
34809
|
+
},
|
|
34659
34810
|
"audioAnalyzer.classify": {
|
|
34660
34811
|
capName: "audio-analyzer",
|
|
34661
34812
|
capScope: "system",
|
|
34662
34813
|
addonId: null,
|
|
34663
34814
|
access: "view"
|
|
34664
34815
|
},
|
|
34816
|
+
"audioAnalyzer.detachDevice": {
|
|
34817
|
+
capName: "audio-analyzer",
|
|
34818
|
+
capScope: "system",
|
|
34819
|
+
addonId: null,
|
|
34820
|
+
access: "create"
|
|
34821
|
+
},
|
|
34665
34822
|
"audioAnalyzer.dispose": {
|
|
34666
34823
|
capName: "audio-analyzer",
|
|
34667
34824
|
capScope: "system",
|
|
@@ -40505,11 +40662,21 @@ Object.freeze({
|
|
|
40505
40662
|
form: "single",
|
|
40506
40663
|
optional: false
|
|
40507
40664
|
}],
|
|
40665
|
+
"audioAnalyzer.attachDevice": [{
|
|
40666
|
+
name: "deviceId",
|
|
40667
|
+
form: "single",
|
|
40668
|
+
optional: false
|
|
40669
|
+
}],
|
|
40508
40670
|
"audioAnalyzer.classify": [{
|
|
40509
40671
|
name: "deviceId",
|
|
40510
40672
|
form: "single",
|
|
40511
40673
|
optional: true
|
|
40512
40674
|
}],
|
|
40675
|
+
"audioAnalyzer.detachDevice": [{
|
|
40676
|
+
name: "deviceId",
|
|
40677
|
+
form: "single",
|
|
40678
|
+
optional: false
|
|
40679
|
+
}],
|
|
40513
40680
|
"audioMetrics.getCurrentSnapshot": [{
|
|
40514
40681
|
name: "deviceId",
|
|
40515
40682
|
form: "single",
|
|
@@ -42361,6 +42528,52 @@ Object.freeze({
|
|
|
42361
42528
|
"network-access": "ingress",
|
|
42362
42529
|
"smtp-provider": "email"
|
|
42363
42530
|
});
|
|
42531
|
+
var G711_SCALE_CORRECTION_DB = {
|
|
42532
|
+
PCMU: 20 * Math.log10(4),
|
|
42533
|
+
PCMA: 20 * Math.log10(8)
|
|
42534
|
+
};
|
|
42535
|
+
/**
|
|
42536
|
+
* Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
|
|
42537
|
+
* same intent on the ITU-T scale (D460).
|
|
42538
|
+
*
|
|
42539
|
+
* ## When this applies, and when it is the wrong thing to reach for
|
|
42540
|
+
*
|
|
42541
|
+
* An absolute-dBFS number in this repo is one of two things, and only one of
|
|
42542
|
+
* them converts:
|
|
42543
|
+
*
|
|
42544
|
+
* - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
|
|
42545
|
+
* is loud". It was true on the ITU-T scale before the epoch and it is true
|
|
42546
|
+
* after. The defect was never in the number; it was that 19 of this hub's
|
|
42547
|
+
* 25 cameras did not obey it. Converting such a number takes something
|
|
42548
|
+
* correct and makes it wrong, in order to preserve a bug.
|
|
42549
|
+
* - **A measurement taken through the old decoder** — a value someone read
|
|
42550
|
+
* off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
|
|
42551
|
+
* describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
|
|
42552
|
+
* louder. That is what this function is for.
|
|
42553
|
+
*
|
|
42554
|
+
* Telling the two apart is a question about PROVENANCE, not about arithmetic,
|
|
42555
|
+
* and it cannot be answered from the number. It is answered by the comment the
|
|
42556
|
+
* author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
|
|
42557
|
+
* mandatory.
|
|
42558
|
+
*
|
|
42559
|
+
* ## Why a function and not a typed-in number
|
|
42560
|
+
*
|
|
42561
|
+
* `-55 + 12.04` written into a source file is, six months later, completely
|
|
42562
|
+
* indistinguishable from a threshold somebody simply preferred. Calling this
|
|
42563
|
+
* keeps the derivation, the law, and the original measurement all visible at
|
|
42564
|
+
* the call site, so a future reader can disagree with the *premise* instead of
|
|
42565
|
+
* having to reverse-engineer the sum.
|
|
42566
|
+
*
|
|
42567
|
+
* **This is not a runtime gain.** It converts an authored CONSTANT once, where
|
|
42568
|
+
* it is declared. It must never be applied to a live sample or a stored
|
|
42569
|
+
* `AudioEvent.dbfs`: the decoder is correct now, and a second authority
|
|
42570
|
+
* adjusting numbers the decoder already got right is the original defect with
|
|
42571
|
+
* an extra place to argue with (D459).
|
|
42572
|
+
*/
|
|
42573
|
+
function ituDbfsFromPreEpoch(law, authoredDbfs) {
|
|
42574
|
+
return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
|
|
42575
|
+
}
|
|
42576
|
+
Math.round(ituDbfsFromPreEpoch("PCMU", -55));
|
|
42364
42577
|
/** Schema defaults — an untouched sub-field must author exactly these. */
|
|
42365
42578
|
var NC_AUDIO_DEFAULTS = {
|
|
42366
42579
|
hitPercent: 60,
|
package/dist/addon.mjs
CHANGED
|
@@ -5354,6 +5354,86 @@ var ZodIssueCode = {
|
|
|
5354
5354
|
/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
|
|
5355
5355
|
var ZodFirstPartyTypeKind;
|
|
5356
5356
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5357
|
+
//#endregion
|
|
5358
|
+
//#region ../types/dist/sleep-BnujYGPe.mjs
|
|
5359
|
+
/**
|
|
5360
|
+
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5361
|
+
* window to float samples (D455).
|
|
5362
|
+
*
|
|
5363
|
+
* ## Why a format at all
|
|
5364
|
+
*
|
|
5365
|
+
* D450 took the plane off its 8 → 16 kHz upsample: it carries the SOURCE
|
|
5366
|
+
* RATE, and the one consumer that needs 16 kHz resamples next to the model.
|
|
5367
|
+
* It left the FORMAT alone — the broker still turned each G.711 byte into a
|
|
5368
|
+
* 4-byte f32le sample before the bytes entered the transport, so every leg of
|
|
5369
|
+
* the plane carried four times the source. The plane crosses hub-main twice on
|
|
5370
|
+
* the way to the analyzer, and the fleet's G.711 cameras are ~79 % of it.
|
|
5371
|
+
*
|
|
5372
|
+
* So the plane carries the source BYTES too, and whoever needs floats expands
|
|
5373
|
+
* them where it needs them. That is the same argument D450 made for the rate,
|
|
5374
|
+
* one step further along the same wire.
|
|
5375
|
+
*
|
|
5376
|
+
* ## Why the expansion lives here
|
|
5377
|
+
*
|
|
5378
|
+
* Two packages need it and they must never disagree: `addon-pipeline`'s broker
|
|
5379
|
+
* (which still has to serve a subscriber that did NOT ask for coded bytes —
|
|
5380
|
+
* `AudioChunkPlane` expands per subscription) and
|
|
5381
|
+
* `addon-pipeline-orchestrator`'s `AudioWindowAccumulator` (which flushes an
|
|
5382
|
+
* f32le window to the analyzer cap, whose `AudioChunkInput` contract is
|
|
5383
|
+
* unchanged and stays f32le). Both bundle the bare `@camstack/types` entry
|
|
5384
|
+
* into their own dist (`self-contained` externals), so this travels with a
|
|
5385
|
+
* `camstack deploy` and needs no published server.
|
|
5386
|
+
*
|
|
5387
|
+
* A second μ-law table anywhere else is the defect this module exists to
|
|
5388
|
+
* prevent. (`stream-broker.ts`'s `mulawToPcm` / `alawToPcm` are the ENCODE
|
|
5389
|
+
* direction for the WebRTC egress — a different transform, not a copy.)
|
|
5390
|
+
*
|
|
5391
|
+
* ## Absent means f32le
|
|
5392
|
+
*
|
|
5393
|
+
* `format` is optional on the wire and its absence means `f32le` — today's
|
|
5394
|
+
* bytes, byte for byte. A peer that never heard of the field is served what it
|
|
5395
|
+
* has always been served, because the broker only emits a coded window to a
|
|
5396
|
+
* subscription that DECLARED it accepts one (`AudioSubscribeOptions.accept`).
|
|
5397
|
+
* That is the D448 `rawForward` negotiation, and it is what makes this
|
|
5398
|
+
* deployable one addon at a time across three nodes.
|
|
5399
|
+
*/
|
|
5400
|
+
/** Every byte format the audio chunk plane can carry. `f32le` is the default. */
|
|
5401
|
+
var AUDIO_CHUNK_FORMATS = [
|
|
5402
|
+
"f32le",
|
|
5403
|
+
"pcmu",
|
|
5404
|
+
"pcma"
|
|
5405
|
+
];
|
|
5406
|
+
/**
|
|
5407
|
+
* Build the μ-law decode table (ITU-T G.711). Each of the 256 byte values maps
|
|
5408
|
+
* to a 16-bit PCM sample, normalised to [-1.0, 1.0] for f32le output.
|
|
5409
|
+
*
|
|
5410
|
+
* Moved here verbatim from `audio-rtp-decoder.ts`, which no longer decodes:
|
|
5411
|
+
* it buffers the coded bytes and the plane's consumers expand.
|
|
5412
|
+
*/
|
|
5413
|
+
function buildUlawTable() {
|
|
5414
|
+
const table = new Float32Array(256);
|
|
5415
|
+
for (let i = 0; i < 256; i++) {
|
|
5416
|
+
const complemented = ~i & 255;
|
|
5417
|
+
const sign = (complemented & 128) !== 0 ? -1 : 1;
|
|
5418
|
+
const exponent = complemented >> 4 & 7;
|
|
5419
|
+
table[i] = sign * ((8 * (complemented & 15) + 132 << exponent) - 132) / 32768;
|
|
5420
|
+
}
|
|
5421
|
+
return table;
|
|
5422
|
+
}
|
|
5423
|
+
/** Build the A-law decode table (ITU-T G.711). */
|
|
5424
|
+
function buildAlawTable() {
|
|
5425
|
+
const table = new Float32Array(256);
|
|
5426
|
+
for (let i = 0; i < 256; i++) {
|
|
5427
|
+
const xored = i ^ 85;
|
|
5428
|
+
const sign = (xored & 128) !== 0 ? 1 : -1;
|
|
5429
|
+
const exponent = xored >> 4 & 7;
|
|
5430
|
+
const mantissa = xored & 15;
|
|
5431
|
+
table[i] = sign * (exponent === 0 ? 16 * mantissa + 8 : 16 * mantissa + 264 << exponent - 1) / 32768;
|
|
5432
|
+
}
|
|
5433
|
+
return table;
|
|
5434
|
+
}
|
|
5435
|
+
buildUlawTable();
|
|
5436
|
+
buildAlawTable();
|
|
5357
5437
|
Object.fromEntries([
|
|
5358
5438
|
{
|
|
5359
5439
|
id: "overview",
|
|
@@ -6646,11 +6726,20 @@ var SubscribeFramesResultSchema = object({
|
|
|
6646
6726
|
* (the wire-serialisable supertype of `Buffer`) to match `DecodedFrameSchema`
|
|
6647
6727
|
* / `EncodedPacketSchema`'s precedent; a `Buffer` is assignable to it.
|
|
6648
6728
|
*/
|
|
6729
|
+
var AudioChunkFormatSchema = _enum(AUDIO_CHUNK_FORMATS);
|
|
6649
6730
|
var DecodedAudioChunkSchema = object({
|
|
6650
6731
|
data: _instanceof(Uint8Array),
|
|
6651
6732
|
sampleRate: number().int().positive(),
|
|
6652
6733
|
channels: number().int().positive(),
|
|
6653
|
-
timestamp: number()
|
|
6734
|
+
timestamp: number(),
|
|
6735
|
+
/**
|
|
6736
|
+
* Byte format of `data`. ABSENT MEANS `f32le` — today's bytes, byte for
|
|
6737
|
+
* byte, for any peer that never heard of this field. A coded window
|
|
6738
|
+
* (`pcmu` / `pcma`, one byte per sample) is only ever emitted to a
|
|
6739
|
+
* subscription that DECLARED it accepts one, so absence can never mean
|
|
6740
|
+
* "coded bytes a consumer will read as floats" (D455).
|
|
6741
|
+
*/
|
|
6742
|
+
format: AudioChunkFormatSchema.optional()
|
|
6654
6743
|
});
|
|
6655
6744
|
/**
|
|
6656
6745
|
* Input for `stream-broker.subscribeAudioChunks` (Phase 5 / D9). The
|
|
@@ -6662,7 +6751,18 @@ var DecodedAudioChunkSchema = object({
|
|
|
6662
6751
|
var SubscribeAudioChunksInputSchema = object({
|
|
6663
6752
|
brokerId: string(),
|
|
6664
6753
|
/** Short caller-identity tag (`audio-analyzer`, …) for `listClients`. */
|
|
6665
|
-
tag: string().optional()
|
|
6754
|
+
tag: string().optional(),
|
|
6755
|
+
/**
|
|
6756
|
+
* Byte formats this subscriber can READ, best first. The broker serves the
|
|
6757
|
+
* chunk's own format when it is in this list and expands to `f32le`
|
|
6758
|
+
* otherwise, so a subscriber is never handed bytes it cannot interpret.
|
|
6759
|
+
*
|
|
6760
|
+
* Absent (or without the source format) means `f32le` — the behaviour every
|
|
6761
|
+
* subscriber had before D455, unchanged. This is the negotiation half of
|
|
6762
|
+
* the source-bytes lever: it is what lets the broker and its consumers
|
|
6763
|
+
* deploy one at a time across three nodes.
|
|
6764
|
+
*/
|
|
6765
|
+
accept: array(AudioChunkFormatSchema).readonly().optional()
|
|
6666
6766
|
});
|
|
6667
6767
|
/** Result of `stream-broker.subscribeAudioChunks`. */
|
|
6668
6768
|
var SubscribeAudioChunksResultSchema = object({
|
|
@@ -10717,6 +10817,51 @@ var AudioAnalysisSettingsSchema = object({
|
|
|
10717
10817
|
minConfidence: number().min(0).max(1).default(.3),
|
|
10718
10818
|
allowedClasses: array(string()).default([])
|
|
10719
10819
|
});
|
|
10820
|
+
/**
|
|
10821
|
+
* `attachDevice` — the analyzer PULLS a camera's audio from the broker (D461).
|
|
10822
|
+
*
|
|
10823
|
+
* Until D461 the orchestrator drained the broker's chunk plane, accumulated
|
|
10824
|
+
* ~1 s windows and pushed them back out as `analyseChunk`. It neither produced
|
|
10825
|
+
* nor consumed the audio: the PCM crossed hub-main twice for a process that
|
|
10826
|
+
* only buffered it. `attachDevice` inverts the direction — the analyzer opens
|
|
10827
|
+
* its own `subscribeAudioChunks` against the broker and the subscriber IS the
|
|
10828
|
+
* decoder, so the coded G.711 bytes D455 put on the plane stay coded all the
|
|
10829
|
+
* way to the one expansion that feeds the model.
|
|
10830
|
+
*
|
|
10831
|
+
* The orchestrator still owns the POLICY (the `audioMode` gate, the on-motion
|
|
10832
|
+
* window, the per-device node assignment, the settings read) and therefore
|
|
10833
|
+
* still owns the attach/detach pair. It no longer owns the bytes.
|
|
10834
|
+
*/
|
|
10835
|
+
var AudioAttachDeviceInputSchema = object({
|
|
10836
|
+
deviceId: number(),
|
|
10837
|
+
/** Broker id (`<deviceId>/<camStreamId>`) carrying this camera's audio. */
|
|
10838
|
+
brokerId: string(),
|
|
10839
|
+
/**
|
|
10840
|
+
* `clusterRoles.ingestNode` — the node whose broker owns the source dial.
|
|
10841
|
+
* Every `streamBroker` call the attachment makes is pinned to it, exactly as
|
|
10842
|
+
* the orchestrator's poller pinned them before the move.
|
|
10843
|
+
*/
|
|
10844
|
+
ingestNodeId: string(),
|
|
10845
|
+
/**
|
|
10846
|
+
* Resolved once by the orchestrator at attach time, exactly as it was read
|
|
10847
|
+
* once per subscription before D461. The analyzer does NOT re-resolve per
|
|
10848
|
+
* window: a settings change re-attaches, which is what always happened.
|
|
10849
|
+
*/
|
|
10850
|
+
settings: AudioAnalysisSettingsSchema
|
|
10851
|
+
});
|
|
10852
|
+
var AudioAttachDeviceResultSchema = object({
|
|
10853
|
+
/** False only when the analyzer is shutting down and refused to attach. */
|
|
10854
|
+
attached: boolean(),
|
|
10855
|
+
/**
|
|
10856
|
+
* True when the attachment replaced a live one for the same device. An
|
|
10857
|
+
* attach is idempotent by REPLACEMENT — two pollers on one camera would
|
|
10858
|
+
* double the broker's fanout and neither would know about the other.
|
|
10859
|
+
*/
|
|
10860
|
+
replaced: boolean()
|
|
10861
|
+
});
|
|
10862
|
+
var AudioDetachDeviceResultSchema = object({
|
|
10863
|
+
/** False when no attachment existed — detach is idempotent. */
|
|
10864
|
+
detached: boolean() });
|
|
10720
10865
|
var AudioClassificationResultSchema = object({
|
|
10721
10866
|
labels: array(AudioClassificationLabelSchema).readonly(),
|
|
10722
10867
|
rawLabels: array(AudioClassificationLabelSchema).readonly().optional(),
|
|
@@ -10725,7 +10870,7 @@ var AudioClassificationResultSchema = object({
|
|
|
10725
10870
|
method(object({
|
|
10726
10871
|
chunk: AudioChunkInputSchema,
|
|
10727
10872
|
settings: AudioAnalysisSettingsSchema
|
|
10728
|
-
}), AudioAnalysisResultSchema.nullable(), { kind: "mutation" }), method(AudioChunkInputSchema, AudioClassificationResultSchema, { timeoutMs: 3e4 }), method(_void(), boolean()), method(_void(), _void(), { kind: "mutation" }), method(_void(), object({ backend: string() }), {
|
|
10873
|
+
}), 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() }), {
|
|
10729
10874
|
kind: "mutation",
|
|
10730
10875
|
auth: "admin"
|
|
10731
10876
|
});
|
|
@@ -26016,8 +26161,8 @@ includeCrops: boolean().optional() }).optional(), array(IdentitySchema).readonly
|
|
|
26016
26161
|
*
|
|
26017
26162
|
* An **empty array reads NOTHING** — `[]` is an empty page, never
|
|
26018
26163
|
* "every camera". A request for no devices is a request, not an
|
|
26019
|
-
* omission; same contract as `deviceManager.
|
|
26020
|
-
* `pipelineAnalytics.listRecentTracks`.
|
|
26164
|
+
* omission; same contract as `deviceManager.listAll`'s `deviceIds`
|
|
26165
|
+
* and `pipelineAnalytics.listRecentTracks`.
|
|
26021
26166
|
*
|
|
26022
26167
|
* Absent (`undefined`) is the omission, and keeps the cluster-wide view.
|
|
26023
26168
|
*/
|
|
@@ -34633,12 +34778,24 @@ Object.freeze({
|
|
|
34633
34778
|
addonId: null,
|
|
34634
34779
|
access: "create"
|
|
34635
34780
|
},
|
|
34781
|
+
"audioAnalyzer.attachDevice": {
|
|
34782
|
+
capName: "audio-analyzer",
|
|
34783
|
+
capScope: "system",
|
|
34784
|
+
addonId: null,
|
|
34785
|
+
access: "create"
|
|
34786
|
+
},
|
|
34636
34787
|
"audioAnalyzer.classify": {
|
|
34637
34788
|
capName: "audio-analyzer",
|
|
34638
34789
|
capScope: "system",
|
|
34639
34790
|
addonId: null,
|
|
34640
34791
|
access: "view"
|
|
34641
34792
|
},
|
|
34793
|
+
"audioAnalyzer.detachDevice": {
|
|
34794
|
+
capName: "audio-analyzer",
|
|
34795
|
+
capScope: "system",
|
|
34796
|
+
addonId: null,
|
|
34797
|
+
access: "create"
|
|
34798
|
+
},
|
|
34642
34799
|
"audioAnalyzer.dispose": {
|
|
34643
34800
|
capName: "audio-analyzer",
|
|
34644
34801
|
capScope: "system",
|
|
@@ -40482,11 +40639,21 @@ Object.freeze({
|
|
|
40482
40639
|
form: "single",
|
|
40483
40640
|
optional: false
|
|
40484
40641
|
}],
|
|
40642
|
+
"audioAnalyzer.attachDevice": [{
|
|
40643
|
+
name: "deviceId",
|
|
40644
|
+
form: "single",
|
|
40645
|
+
optional: false
|
|
40646
|
+
}],
|
|
40485
40647
|
"audioAnalyzer.classify": [{
|
|
40486
40648
|
name: "deviceId",
|
|
40487
40649
|
form: "single",
|
|
40488
40650
|
optional: true
|
|
40489
40651
|
}],
|
|
40652
|
+
"audioAnalyzer.detachDevice": [{
|
|
40653
|
+
name: "deviceId",
|
|
40654
|
+
form: "single",
|
|
40655
|
+
optional: false
|
|
40656
|
+
}],
|
|
40490
40657
|
"audioMetrics.getCurrentSnapshot": [{
|
|
40491
40658
|
name: "deviceId",
|
|
40492
40659
|
form: "single",
|
|
@@ -42338,6 +42505,52 @@ Object.freeze({
|
|
|
42338
42505
|
"network-access": "ingress",
|
|
42339
42506
|
"smtp-provider": "email"
|
|
42340
42507
|
});
|
|
42508
|
+
var G711_SCALE_CORRECTION_DB = {
|
|
42509
|
+
PCMU: 20 * Math.log10(4),
|
|
42510
|
+
PCMA: 20 * Math.log10(8)
|
|
42511
|
+
};
|
|
42512
|
+
/**
|
|
42513
|
+
* Restate a dBFS number that was MEASURED through the pre-epoch decoder as the
|
|
42514
|
+
* same intent on the ITU-T scale (D460).
|
|
42515
|
+
*
|
|
42516
|
+
* ## When this applies, and when it is the wrong thing to reach for
|
|
42517
|
+
*
|
|
42518
|
+
* An absolute-dBFS number in this repo is one of two things, and only one of
|
|
42519
|
+
* them converts:
|
|
42520
|
+
*
|
|
42521
|
+
* - **A statement about the scale** — "-55 dBFS is near silence", "-25 dBFS
|
|
42522
|
+
* is loud". It was true on the ITU-T scale before the epoch and it is true
|
|
42523
|
+
* after. The defect was never in the number; it was that 19 of this hub's
|
|
42524
|
+
* 25 cameras did not obey it. Converting such a number takes something
|
|
42525
|
+
* correct and makes it wrong, in order to preserve a bug.
|
|
42526
|
+
* - **A measurement taken through the old decoder** — a value someone read
|
|
42527
|
+
* off a meter that under-reported by exactly 4× (PCMU) or 8× (PCMA). It
|
|
42528
|
+
* describes a sound that was really {@link G711_SCALE_CORRECTION_DB} dB
|
|
42529
|
+
* louder. That is what this function is for.
|
|
42530
|
+
*
|
|
42531
|
+
* Telling the two apart is a question about PROVENANCE, not about arithmetic,
|
|
42532
|
+
* and it cannot be answered from the number. It is answered by the comment the
|
|
42533
|
+
* author left — which is why `scripts/check-dbfs-era.mts` makes leaving one
|
|
42534
|
+
* mandatory.
|
|
42535
|
+
*
|
|
42536
|
+
* ## Why a function and not a typed-in number
|
|
42537
|
+
*
|
|
42538
|
+
* `-55 + 12.04` written into a source file is, six months later, completely
|
|
42539
|
+
* indistinguishable from a threshold somebody simply preferred. Calling this
|
|
42540
|
+
* keeps the derivation, the law, and the original measurement all visible at
|
|
42541
|
+
* the call site, so a future reader can disagree with the *premise* instead of
|
|
42542
|
+
* having to reverse-engineer the sum.
|
|
42543
|
+
*
|
|
42544
|
+
* **This is not a runtime gain.** It converts an authored CONSTANT once, where
|
|
42545
|
+
* it is declared. It must never be applied to a live sample or a stored
|
|
42546
|
+
* `AudioEvent.dbfs`: the decoder is correct now, and a second authority
|
|
42547
|
+
* adjusting numbers the decoder already got right is the original defect with
|
|
42548
|
+
* an extra place to argue with (D459).
|
|
42549
|
+
*/
|
|
42550
|
+
function ituDbfsFromPreEpoch(law, authoredDbfs) {
|
|
42551
|
+
return authoredDbfs + G711_SCALE_CORRECTION_DB[law];
|
|
42552
|
+
}
|
|
42553
|
+
Math.round(ituDbfsFromPreEpoch("PCMU", -55));
|
|
42341
42554
|
/** Schema defaults — an untouched sub-field must author exactly these. */
|
|
42342
42555
|
var NC_AUDIO_DEFAULTS = {
|
|
42343
42556
|
hitPercent: 60,
|