@trillboards/edge-sdk 0.2.244 → 0.2.246
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/deploy/detector/bench/detect_frames.py +88 -0
- package/deploy/detector/bench/openvino_parity.py +152 -0
- package/deploy/detector/pyproject.toml +10 -1
- package/deploy/detector/tests/test_actor_tracking.py +32 -0
- package/deploy/detector/tests/test_actor_tracking_wire.py +11 -0
- package/deploy/detector/tests/test_openvino_engines.py +251 -0
- package/deploy/detector/tests/test_server.py +43 -0
- package/deploy/detector/tests/test_version_stamp.py +17 -4
- package/deploy/detector/trillboards_detector/_version.py +2 -2
- package/deploy/detector/trillboards_detector/actor_tracking.py +51 -0
- package/deploy/detector/trillboards_detector/cli.py +5 -0
- package/deploy/detector/trillboards_detector/detections.py +5 -0
- package/deploy/detector/trillboards_detector/execution.py +386 -0
- package/deploy/detector/trillboards_detector/loader.py +12 -1
- package/deploy/detector/trillboards_detector/registry.py +6 -0
- package/deploy/detector/trillboards_detector/server.py +41 -0
- package/deploy/detector/trillboards_detector/session.py +81 -3
- package/deploy/detector/trillboards_detector/track_records.py +113 -0
- package/deploy/windows/ci/test-alert-window-field.ps1 +28 -6
- package/deploy/windows/ci/test-detector-looks-field.ps1 +31 -7
- package/deploy/windows/ci/test-detector-reinstall.ps1 +474 -0
- package/deploy/windows/setup-detector.ps1 +122 -29
- package/dist/ActorTracking.d.ts +38 -0
- package/dist/ActorTracking.d.ts.map +1 -1
- package/dist/ActorTracking.js +40 -0
- package/dist/ActorTracking.js.map +1 -1
- package/dist/AlertClips.d.ts +12 -3
- package/dist/AlertClips.d.ts.map +1 -1
- package/dist/AlertClips.js +52 -11
- package/dist/AlertClips.js.map +1 -1
- package/dist/ChannelProber.d.ts +15 -0
- package/dist/ChannelProber.d.ts.map +1 -1
- package/dist/ChannelProber.js +61 -0
- package/dist/ChannelProber.js.map +1 -1
- package/dist/CloudSensingManager.d.ts.map +1 -1
- package/dist/CloudSensingManager.js +6 -1
- package/dist/CloudSensingManager.js.map +1 -1
- package/dist/ConnectorStatusClient.d.ts +9 -1
- package/dist/ConnectorStatusClient.d.ts.map +1 -1
- package/dist/ConnectorStatusClient.js +3 -0
- package/dist/ConnectorStatusClient.js.map +1 -1
- package/dist/DurableVlmCandidateSpool.d.ts +11 -0
- package/dist/DurableVlmCandidateSpool.d.ts.map +1 -1
- package/dist/DurableVlmCandidateSpool.js +31 -2
- package/dist/DurableVlmCandidateSpool.js.map +1 -1
- package/dist/EdgeAgent.js +1 -1
- package/dist/FrameGroupingShadow.d.ts +57 -0
- package/dist/FrameGroupingShadow.d.ts.map +1 -1
- package/dist/FrameGroupingShadow.js +123 -5
- package/dist/FrameGroupingShadow.js.map +1 -1
- package/dist/LocalDetectorClient.d.ts +25 -1
- package/dist/LocalDetectorClient.d.ts.map +1 -1
- package/dist/LocalDetectorClient.js +60 -0
- package/dist/LocalDetectorClient.js.map +1 -1
- package/dist/LocalVideoBuffer.d.ts +14 -2
- package/dist/LocalVideoBuffer.d.ts.map +1 -1
- package/dist/LocalVideoBuffer.js +23 -3
- package/dist/LocalVideoBuffer.js.map +1 -1
- package/dist/MainStreamRing.d.ts +246 -0
- package/dist/MainStreamRing.d.ts.map +1 -0
- package/dist/MainStreamRing.js +436 -0
- package/dist/MainStreamRing.js.map +1 -0
- package/dist/SensingProfileClient.d.ts +20 -0
- package/dist/SensingProfileClient.d.ts.map +1 -1
- package/dist/SensingProfileClient.js +13 -1
- package/dist/SensingProfileClient.js.map +1 -1
- package/dist/VideoSegmentUploader.d.ts +59 -8
- package/dist/VideoSegmentUploader.d.ts.map +1 -1
- package/dist/VideoSegmentUploader.js +143 -54
- package/dist/VideoSegmentUploader.js.map +1 -1
- package/dist/VlmCandidateBuffer.d.ts +13 -0
- package/dist/VlmCandidateBuffer.d.ts.map +1 -1
- package/dist/VlmCandidateBuffer.js.map +1 -1
- package/dist/autoSense.d.ts +4 -0
- package/dist/autoSense.d.ts.map +1 -1
- package/dist/autoSense.js +6 -0
- package/dist/autoSense.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +2 -0
- package/dist/cli.js.map +1 -1
- package/dist/connectorUpdate.d.ts +9 -0
- package/dist/connectorUpdate.d.ts.map +1 -1
- package/dist/connectorUpdate.js +22 -13
- package/dist/connectorUpdate.js.map +1 -1
- package/dist/continuousReview.d.ts +6 -2
- package/dist/continuousReview.d.ts.map +1 -1
- package/dist/continuousReview.js.map +1 -1
- package/dist/detectorBackendRelay.d.ts +24 -0
- package/dist/detectorBackendRelay.d.ts.map +1 -0
- package/dist/detectorBackendRelay.js +70 -0
- package/dist/detectorBackendRelay.js.map +1 -0
- package/dist/diagnose.d.ts +1 -1
- package/dist/diagnose.js +1 -1
- package/dist/localSensing.d.ts +3 -0
- package/dist/localSensing.d.ts.map +1 -1
- package/dist/localSensing.js +72 -3
- package/dist/localSensing.js.map +1 -1
- package/dist/pipelineSwitches.d.ts +59 -0
- package/dist/pipelineSwitches.d.ts.map +1 -0
- package/dist/pipelineSwitches.js +240 -0
- package/dist/pipelineSwitches.js.map +1 -0
- package/package.json +4 -4
- package/retained/RetainedCaptureClient.cjs +37 -2
- package/retained/WebsiteAdmissionCaptureClient.cjs +57 -2
- package/retained/__tests__/look-reuse.test.cjs +167 -0
- package/retained/manager.cjs +28 -2
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.MainStreamRing = exports.MAIN_STREAM_READMIT_BASE_MS = exports.MAIN_STREAM_PROBE_INTERVAL_MS = void 0;
|
|
37
|
+
exports.probeStateFor = probeStateFor;
|
|
38
|
+
const events_1 = require("events");
|
|
39
|
+
const fs = __importStar(require("fs"));
|
|
40
|
+
const path = __importStar(require("path"));
|
|
41
|
+
const crypto_1 = require("crypto");
|
|
42
|
+
const ChannelProber_1 = require("./ChannelProber");
|
|
43
|
+
/** At most one probe a day per camera, unless the knob appears again. */
|
|
44
|
+
exports.MAIN_STREAM_PROBE_INTERVAL_MS = 24 * 3600000;
|
|
45
|
+
/**
|
|
46
|
+
* After the recorder's own session is refused, the first re-probe waits this
|
|
47
|
+
* long and each failed one doubles it, up to the daily probe. A path that
|
|
48
|
+
* vanished under a recording session (the recorder rebooting, a channel
|
|
49
|
+
* flapping) costs minutes of main-stream footage, not a day; a recorder that
|
|
50
|
+
* keeps refusing is asked about seven times in the first day, then daily —
|
|
51
|
+
* never more than 2 failed logins an hour, under every NVR lock-out threshold.
|
|
52
|
+
*/
|
|
53
|
+
exports.MAIN_STREAM_READMIT_BASE_MS = 15 * 60000;
|
|
54
|
+
const STATE_FILE = 'main-stream.json';
|
|
55
|
+
/** Probe classes the recorder's own session ending with means "stop, report, probe again later". */
|
|
56
|
+
const REFUSAL_STATES = new Set(['nvr_busy', 'auth', 'bad_path']);
|
|
57
|
+
function loadRtspModule() {
|
|
58
|
+
try {
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
60
|
+
const mod = require('@trillboards/edge-platform-rtsp');
|
|
61
|
+
return typeof mod.MainStreamSession === 'function' && typeof mod.MainStreamRingOutput === 'function'
|
|
62
|
+
&& typeof mod.probeMainStream === 'function' && typeof mod.acquireMainStreamSlot === 'function'
|
|
63
|
+
? mod
|
|
64
|
+
: null;
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/** The probe state a failed probe's ffmpeg output names (ChannelProber's own classes). */
|
|
71
|
+
function probeStateFor(result) {
|
|
72
|
+
if (result.packets > 0 && result.stream)
|
|
73
|
+
return 'ok';
|
|
74
|
+
const failure = (0, ChannelProber_1.classifyFfmpegStderr)(result.stderr || '').failureClass;
|
|
75
|
+
switch (failure) {
|
|
76
|
+
case 'rtsp_auth':
|
|
77
|
+
case 'rtsp_forbidden':
|
|
78
|
+
return 'auth';
|
|
79
|
+
case 'nvr_busy':
|
|
80
|
+
return 'nvr_busy';
|
|
81
|
+
case 'bad_path':
|
|
82
|
+
return 'bad_path';
|
|
83
|
+
case 'rtsp_unreachable':
|
|
84
|
+
return 'unreachable';
|
|
85
|
+
case 'decode_error':
|
|
86
|
+
return 'error';
|
|
87
|
+
default:
|
|
88
|
+
// rtsp_timeout, no_frames: nothing arrived in time.
|
|
89
|
+
return 'timeout';
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function normalizeKnob(raw) {
|
|
93
|
+
return raw === 'probe' || raw === 'main' ? raw : 'sub';
|
|
94
|
+
}
|
|
95
|
+
function finiteOrNull(v, round) {
|
|
96
|
+
if (typeof v !== 'number' || !Number.isFinite(v) || v <= 0)
|
|
97
|
+
return null;
|
|
98
|
+
return round ? Math.round(v * round) / round : Math.round(v);
|
|
99
|
+
}
|
|
100
|
+
class MainStreamRing extends events_1.EventEmitter {
|
|
101
|
+
constructor(options) {
|
|
102
|
+
super();
|
|
103
|
+
this.knob = 'sub';
|
|
104
|
+
this.probe = null;
|
|
105
|
+
/**
|
|
106
|
+
* Failed main-stream attempts since the recorder's own session was refused
|
|
107
|
+
* (0: none). Sets the re-probe gap; back to 0 once the recorder delivers.
|
|
108
|
+
*/
|
|
109
|
+
this.readmits = 0;
|
|
110
|
+
this.probing = false;
|
|
111
|
+
this.session = null;
|
|
112
|
+
this.ring = null;
|
|
113
|
+
this.ringConfig = null;
|
|
114
|
+
this.stopped = false;
|
|
115
|
+
/** What 'change' last announced: whether the main stream was wanted, and whether it ran. */
|
|
116
|
+
this.announced = 'false|false';
|
|
117
|
+
this.dir = options.dir;
|
|
118
|
+
this.feedName = options.feedName;
|
|
119
|
+
this.now = options.now ?? Date.now;
|
|
120
|
+
this.log = options.log ?? ((level, message) => (level === 'warn' ? console.warn : console.log)(message));
|
|
121
|
+
this.rtsp = options.rtsp === undefined ? loadRtspModule() : options.rtsp;
|
|
122
|
+
this.sink = options.sink && typeof options.sink.adoptSegment === 'function' ? options.sink : null;
|
|
123
|
+
this.transport = options.transport ?? 'tcp';
|
|
124
|
+
this.ffmpegPath = options.ffmpegPath;
|
|
125
|
+
this.mainUrl = options.rtspUrl ? (0, ChannelProber_1.deriveMainStreamUrl)(options.rtspUrl) : null;
|
|
126
|
+
this.urlKey = this.mainUrl ? (0, crypto_1.createHash)('sha256').update(this.mainUrl).digest('hex').slice(0, 16) : null;
|
|
127
|
+
this.loadState();
|
|
128
|
+
}
|
|
129
|
+
/** The server's knob, on every answer (and the persisted one at start). Idempotent. */
|
|
130
|
+
setKnob(raw) {
|
|
131
|
+
if (this.stopped)
|
|
132
|
+
return;
|
|
133
|
+
const next = normalizeKnob(raw);
|
|
134
|
+
const previous = this.knob;
|
|
135
|
+
if (next !== previous) {
|
|
136
|
+
this.knob = next;
|
|
137
|
+
if (next === 'sub')
|
|
138
|
+
this.readmits = 0;
|
|
139
|
+
this.persist();
|
|
140
|
+
this.log('info', `[video] ${this.feedName}: main stream ${next === 'sub' ? 'off (the substream records the ring)'
|
|
141
|
+
: next === 'probe' ? 'probe only' : 'probe, then record it into the local ring'}`);
|
|
142
|
+
}
|
|
143
|
+
// Appearing (from `sub`) is the one moment a probe runs regardless of the
|
|
144
|
+
// last one; a camera never measured is probed whatever the knob was before.
|
|
145
|
+
if (next !== 'sub' && (previous === 'sub' || !this.probe))
|
|
146
|
+
void this.runProbe(previous === 'sub');
|
|
147
|
+
this.reconcile();
|
|
148
|
+
}
|
|
149
|
+
/** The 5-minute knob poll: a probe that came due (daily, or a refused recorder's re-probe), or one this connector refused itself. */
|
|
150
|
+
check() {
|
|
151
|
+
if (this.stopped || this.knob === 'sub')
|
|
152
|
+
return;
|
|
153
|
+
this.refreshFromRecorder();
|
|
154
|
+
const due = !this.probe || this.probe.state === 'session_limit' || this.probe.state === 'pending'
|
|
155
|
+
|| this.now() - this.probe.atMs >= this.probeIntervalMs();
|
|
156
|
+
if (due)
|
|
157
|
+
void this.runProbe(false);
|
|
158
|
+
}
|
|
159
|
+
/** The main stream should record the ring: the knob says main and the probe passed. */
|
|
160
|
+
wantsRing() {
|
|
161
|
+
return !this.stopped && this.knob === 'main' && this.probe?.state === 'ok'
|
|
162
|
+
&& this.mainUrl !== null && this.sink !== null && this.rtsp !== null;
|
|
163
|
+
}
|
|
164
|
+
/** The main stream IS recording the ring now: the feed's own session must record nothing. */
|
|
165
|
+
ringActive() {
|
|
166
|
+
return this.wantsRing() && this.session !== null && this.session.getState() === 'running'
|
|
167
|
+
&& this.ring !== null && this.ring.getStats().state !== 'unsupported_codec';
|
|
168
|
+
}
|
|
169
|
+
/** What the main stream records while it is wanted (the recorder's per-mode ring config), or null. */
|
|
170
|
+
record(config) {
|
|
171
|
+
this.ringConfig = config
|
|
172
|
+
? { dir: config.dir, segmentSeconds: config.segmentSeconds, label: config.label ?? null, enabled: config.enabled !== false }
|
|
173
|
+
: null;
|
|
174
|
+
this.reconcile();
|
|
175
|
+
}
|
|
176
|
+
/** Bytes per second of the main-stream segments closed, or null. */
|
|
177
|
+
bytesPerSecond() {
|
|
178
|
+
return this.ring?.getStats().measuredBytesPerSec ?? null;
|
|
179
|
+
}
|
|
180
|
+
/** The beacon's block: whenever the knob asks for the main stream, or a probe result is held. */
|
|
181
|
+
report() {
|
|
182
|
+
if (this.knob === 'sub' && !this.probe)
|
|
183
|
+
return null;
|
|
184
|
+
this.refreshFromRecorder();
|
|
185
|
+
const p = this.probe;
|
|
186
|
+
return {
|
|
187
|
+
probeState: p ? p.state : 'pending',
|
|
188
|
+
probedAt: p && p.state !== 'pending' ? new Date(p.atMs).toISOString() : null,
|
|
189
|
+
width: p?.width ?? null,
|
|
190
|
+
height: p?.height ?? null,
|
|
191
|
+
codec: p?.codec ?? null,
|
|
192
|
+
fps: p?.fps ?? null,
|
|
193
|
+
bitrateBps: p?.bitrateBps ?? null,
|
|
194
|
+
recording: this.recordingState(),
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
async stop() {
|
|
198
|
+
this.stopped = true;
|
|
199
|
+
const session = this.session;
|
|
200
|
+
this.session = null;
|
|
201
|
+
this.ring = null;
|
|
202
|
+
if (session)
|
|
203
|
+
await session.stop().catch(() => undefined);
|
|
204
|
+
}
|
|
205
|
+
// ── internals ────────────────────────────────────────────────────────────
|
|
206
|
+
/** Daily; after the recorder's session was refused, 15 min doubling per failed attempt, up to daily. */
|
|
207
|
+
probeIntervalMs() {
|
|
208
|
+
if (this.readmits <= 0 || !this.probe || this.probe.state === 'ok')
|
|
209
|
+
return exports.MAIN_STREAM_PROBE_INTERVAL_MS;
|
|
210
|
+
return Math.min(exports.MAIN_STREAM_PROBE_INTERVAL_MS, exports.MAIN_STREAM_READMIT_BASE_MS * 2 ** (this.readmits - 1));
|
|
211
|
+
}
|
|
212
|
+
recordingState() {
|
|
213
|
+
if (this.knob !== 'main')
|
|
214
|
+
return 'off';
|
|
215
|
+
if (!this.mainUrl || !this.sink || !this.rtsp || this.probe?.state === 'unsupported')
|
|
216
|
+
return 'unsupported';
|
|
217
|
+
const p = this.probe;
|
|
218
|
+
if (!p || p.state === 'pending' || this.probing)
|
|
219
|
+
return 'waiting';
|
|
220
|
+
if (p.state === 'session_limit')
|
|
221
|
+
return 'session_limit';
|
|
222
|
+
if (p.state !== 'ok')
|
|
223
|
+
return 'refused';
|
|
224
|
+
if (this.ring?.getStats().state === 'unsupported_codec')
|
|
225
|
+
return 'unsupported';
|
|
226
|
+
const state = this.session?.getState();
|
|
227
|
+
if (state === 'running')
|
|
228
|
+
return this.ring?.getStats().state === 'recording' ? 'recording' : 'starting';
|
|
229
|
+
if (state === 'starting')
|
|
230
|
+
return 'starting';
|
|
231
|
+
if (state === 'backoff')
|
|
232
|
+
return 'backoff';
|
|
233
|
+
if (state === 'session_limit')
|
|
234
|
+
return 'session_limit';
|
|
235
|
+
return 'waiting';
|
|
236
|
+
}
|
|
237
|
+
/** Start, refresh or stop the recorder to match the knob, the probe and the ring config; announce a change. */
|
|
238
|
+
reconcile() {
|
|
239
|
+
if (this.stopped)
|
|
240
|
+
return;
|
|
241
|
+
const want = this.wantsRing() && this.ringConfig !== null && this.ringConfig.enabled;
|
|
242
|
+
if (want) {
|
|
243
|
+
if (!this.session || !this.ring)
|
|
244
|
+
this.buildSession();
|
|
245
|
+
this.ring.setRecording({ ...this.ringConfig, codec: this.probe?.codec ?? null });
|
|
246
|
+
this.session.refresh();
|
|
247
|
+
this.session.start();
|
|
248
|
+
}
|
|
249
|
+
else if (this.session) {
|
|
250
|
+
const session = this.session;
|
|
251
|
+
this.session = null;
|
|
252
|
+
this.ring = null;
|
|
253
|
+
void session.stop().catch(() => undefined);
|
|
254
|
+
}
|
|
255
|
+
this.announce();
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Tell the recorder when the main stream starts or stops being WANTED (an
|
|
259
|
+
* `off` camera's ring becomes a local buffer of it) and when it starts or
|
|
260
|
+
* stops RUNNING (the ring changes hands).
|
|
261
|
+
*/
|
|
262
|
+
announce() {
|
|
263
|
+
const active = this.ringActive();
|
|
264
|
+
const signature = `${this.wantsRing()}|${active}`;
|
|
265
|
+
if (signature === this.announced)
|
|
266
|
+
return;
|
|
267
|
+
this.announced = signature;
|
|
268
|
+
try {
|
|
269
|
+
this.emit('change', active);
|
|
270
|
+
}
|
|
271
|
+
catch (err) {
|
|
272
|
+
this.log('warn', `[video] ${this.feedName}: a main stream 'change' listener threw: ${err instanceof Error ? err.message : String(err)}`);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
buildSession() {
|
|
276
|
+
const rtsp = this.rtsp;
|
|
277
|
+
const session = new rtsp.MainStreamSession({
|
|
278
|
+
rtspUrl: this.mainUrl,
|
|
279
|
+
transport: this.transport,
|
|
280
|
+
...(this.ffmpegPath ? { ffmpegPath: this.ffmpegPath } : {}),
|
|
281
|
+
onLog: (level, message) => this.log(level, `[video] ${this.feedName}: ${message}`),
|
|
282
|
+
});
|
|
283
|
+
const ring = new rtsp.MainStreamRingOutput({ sink: this.sink });
|
|
284
|
+
session.addOutput(ring);
|
|
285
|
+
session.on('state', () => this.announce());
|
|
286
|
+
session.on('session_end', (end) => {
|
|
287
|
+
if (end.stopped || end.progressed || this.session !== session)
|
|
288
|
+
return;
|
|
289
|
+
// A session that never delivered: the recorder refusing it stops the
|
|
290
|
+
// session (no loop against the recorder) and is reported; a sparse
|
|
291
|
+
// re-probe decides when it starts again. Anything else (unreachable,
|
|
292
|
+
// timed out, a broken stream) backs off in the session itself.
|
|
293
|
+
const state = probeStateFor({ stream: null, packets: 0, fps: null, bitrateBps: null, timedOut: false,
|
|
294
|
+
inputOpened: false, stderr: end.stderr });
|
|
295
|
+
if (!REFUSAL_STATES.has(state))
|
|
296
|
+
return;
|
|
297
|
+
this.readmits = Math.min(this.readmits + 1, 32);
|
|
298
|
+
// Recorded as the probe's state: the recorder starts again only when a probe passes.
|
|
299
|
+
this.setProbe({ ...(this.probe ?? this.emptyProbe()), state, atMs: this.now() });
|
|
300
|
+
this.log('warn', `[video] ${this.feedName}: the recorder refused the main-stream recording (${state}); ` +
|
|
301
|
+
`the substream keeps the ring; probing again in ${Math.round(this.probeIntervalMs() / 60000)} min`);
|
|
302
|
+
this.reconcile();
|
|
303
|
+
});
|
|
304
|
+
this.session = session;
|
|
305
|
+
this.ring = ring;
|
|
306
|
+
}
|
|
307
|
+
/** While the recorder holds the main stream, its own measurements are the probe's. */
|
|
308
|
+
refreshFromRecorder() {
|
|
309
|
+
const session = this.session;
|
|
310
|
+
if (!session || session.getState() !== 'running')
|
|
311
|
+
return;
|
|
312
|
+
if (this.readmits !== 0) {
|
|
313
|
+
// The recorder delivers again: the next refusal starts from the first gap.
|
|
314
|
+
this.readmits = 0;
|
|
315
|
+
this.persist();
|
|
316
|
+
}
|
|
317
|
+
const input = session.getStats().input;
|
|
318
|
+
const rate = this.ring?.getStats().measuredBytesPerSec ?? null;
|
|
319
|
+
if (!input)
|
|
320
|
+
return;
|
|
321
|
+
this.probe = {
|
|
322
|
+
state: 'ok',
|
|
323
|
+
atMs: this.now(),
|
|
324
|
+
width: finiteOrNull(input.width),
|
|
325
|
+
height: finiteOrNull(input.height),
|
|
326
|
+
codec: input.codec || null,
|
|
327
|
+
fps: finiteOrNull(input.fps, 100),
|
|
328
|
+
bitrateBps: rate !== null ? Math.round(rate * 8) : this.probe?.bitrateBps ?? null,
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
emptyProbe() {
|
|
332
|
+
return { state: 'pending', atMs: this.now(), width: null, height: null, codec: null, fps: null, bitrateBps: null };
|
|
333
|
+
}
|
|
334
|
+
async runProbe(appeared) {
|
|
335
|
+
if (this.stopped || this.probing || this.knob === 'sub')
|
|
336
|
+
return;
|
|
337
|
+
if (!this.mainUrl || !this.rtsp || !this.sink) {
|
|
338
|
+
if (this.probe?.state !== 'unsupported') {
|
|
339
|
+
this.setProbe({ ...this.emptyProbe(), state: 'unsupported' });
|
|
340
|
+
this.log('warn', `[video] ${this.feedName}: no main stream can be derived from this camera's URL (or this install cannot record one)`);
|
|
341
|
+
}
|
|
342
|
+
this.reconcile();
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
// The recorder's own session holds the camera's main stream: its measurements are the probe.
|
|
346
|
+
if (this.session && this.session.getState() === 'running') {
|
|
347
|
+
this.refreshFromRecorder();
|
|
348
|
+
this.persist();
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
const release = this.rtsp.acquireMainStreamSlot(this.mainUrl);
|
|
352
|
+
if (!release) {
|
|
353
|
+
this.setProbe({ ...(this.probe && this.probe.state === 'ok' ? this.probe : this.emptyProbe()), state: 'session_limit', atMs: this.now() });
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
this.probing = true;
|
|
357
|
+
if (!this.probe || appeared)
|
|
358
|
+
this.probe = { ...(this.probe ?? this.emptyProbe()), state: 'pending' };
|
|
359
|
+
let result = null;
|
|
360
|
+
try {
|
|
361
|
+
result = await this.rtsp.probeMainStream({ rtspUrl: this.mainUrl, transport: this.transport,
|
|
362
|
+
...(this.ffmpegPath ? { ffmpegPath: this.ffmpegPath } : {}) });
|
|
363
|
+
}
|
|
364
|
+
catch (err) {
|
|
365
|
+
result = { stream: null, packets: 0, fps: null, bitrateBps: null, timedOut: false, inputOpened: false,
|
|
366
|
+
stderr: err instanceof Error ? err.message : String(err) };
|
|
367
|
+
}
|
|
368
|
+
finally {
|
|
369
|
+
release();
|
|
370
|
+
this.probing = false;
|
|
371
|
+
}
|
|
372
|
+
if (this.stopped)
|
|
373
|
+
return;
|
|
374
|
+
const state = probeStateFor(result);
|
|
375
|
+
// A re-probe after a refusal that fails again doubles the gap to the next one.
|
|
376
|
+
if (state !== 'ok' && this.readmits > 0)
|
|
377
|
+
this.readmits = Math.min(this.readmits + 1, 32);
|
|
378
|
+
this.setProbe({
|
|
379
|
+
state,
|
|
380
|
+
atMs: this.now(),
|
|
381
|
+
width: finiteOrNull(result.stream?.width),
|
|
382
|
+
height: finiteOrNull(result.stream?.height),
|
|
383
|
+
codec: result.stream?.codec ?? null,
|
|
384
|
+
fps: finiteOrNull(result.fps, 100),
|
|
385
|
+
bitrateBps: finiteOrNull(result.bitrateBps),
|
|
386
|
+
});
|
|
387
|
+
this.log(state === 'ok' ? 'info' : 'warn', `[video] ${this.feedName}: main stream probe ${state}` +
|
|
388
|
+
(state === 'ok' ? ` (${this.probe.codec} ${this.probe.width}x${this.probe.height}, ${this.probe.fps} fps, ` +
|
|
389
|
+
`${this.probe.bitrateBps} b/s)` : ''));
|
|
390
|
+
this.reconcile();
|
|
391
|
+
}
|
|
392
|
+
setProbe(record) {
|
|
393
|
+
this.probe = record;
|
|
394
|
+
this.persist();
|
|
395
|
+
}
|
|
396
|
+
persist() {
|
|
397
|
+
try {
|
|
398
|
+
fs.mkdirSync(this.dir, { recursive: true });
|
|
399
|
+
const file = path.join(this.dir, STATE_FILE);
|
|
400
|
+
fs.writeFileSync(`${file}.tmp`, JSON.stringify({ version: 1, knob: this.knob, urlKey: this.urlKey, probe: this.probe,
|
|
401
|
+
readmits: this.readmits }));
|
|
402
|
+
fs.renameSync(`${file}.tmp`, file);
|
|
403
|
+
}
|
|
404
|
+
catch (err) {
|
|
405
|
+
this.log('warn', `[video] ${this.feedName}: could not save ${STATE_FILE}: ${err instanceof Error ? err.message : String(err)}`);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
loadState() {
|
|
409
|
+
try {
|
|
410
|
+
const raw = JSON.parse(fs.readFileSync(path.join(this.dir, STATE_FILE), 'utf8'));
|
|
411
|
+
if (raw?.version !== 1)
|
|
412
|
+
return;
|
|
413
|
+
this.knob = normalizeKnob(raw.knob);
|
|
414
|
+
// A probe of another URL (the recorder moved, the feed was re-paired) says nothing about this one.
|
|
415
|
+
const p = raw.probe;
|
|
416
|
+
if (raw.urlKey === this.urlKey && p && typeof p.state === 'string' && Number.isFinite(p.atMs)) {
|
|
417
|
+
this.probe = {
|
|
418
|
+
state: p.state === 'pending' ? 'pending' : p.state,
|
|
419
|
+
atMs: p.atMs,
|
|
420
|
+
width: finiteOrNull(p.width),
|
|
421
|
+
height: finiteOrNull(p.height),
|
|
422
|
+
codec: typeof p.codec === 'string' ? p.codec : null,
|
|
423
|
+
fps: finiteOrNull(p.fps, 100),
|
|
424
|
+
bitrateBps: finiteOrNull(p.bitrateBps),
|
|
425
|
+
};
|
|
426
|
+
if (Number.isInteger(raw.readmits) && raw.readmits > 0)
|
|
427
|
+
this.readmits = Math.min(raw.readmits, 32);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
catch {
|
|
431
|
+
/* never asked for the main stream on this box */
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
exports.MainStreamRing = MainStreamRing;
|
|
436
|
+
//# sourceMappingURL=MainStreamRing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MainStreamRing.js","sourceRoot":"","sources":["../src/MainStreamRing.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkMA,sCAmBC;AArND,mCAAsC;AACtC,uCAAyB;AACzB,2CAA6B;AAC7B,mCAAoC;AAEpC,mDAA4E;AA4F5E,yEAAyE;AAC5D,QAAA,6BAA6B,GAAG,EAAE,GAAG,OAAS,CAAC;AAC5D;;;;;;;GAOG;AACU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IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YACrG,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,iDAAiD;QACnD,CAAC;IACH,CAAC;CACF;AAzUD,wCAyUC"}
|
|
@@ -230,6 +230,13 @@ export interface CctvVideoKnobs {
|
|
|
230
230
|
beforeSeconds: number;
|
|
231
231
|
afterSeconds: number;
|
|
232
232
|
};
|
|
233
|
+
/**
|
|
234
|
+
* Which of the camera's streams fills its local ring
|
|
235
|
+
* (`sense_camera_settings.ring_stream`): `sub` (or absent, an older API) the
|
|
236
|
+
* feed's substream, as always; `probe` measure the main stream and report it;
|
|
237
|
+
* `main` probe, then record the MAIN stream into the ring (MainStreamRing).
|
|
238
|
+
*/
|
|
239
|
+
ringStream?: CctvRingStream;
|
|
233
240
|
/**
|
|
234
241
|
* Alerts on this camera still waiting for their clip (alert_windows) — the
|
|
235
242
|
* slow backstop behind the receipt the box polls after an alert-supporting
|
|
@@ -238,6 +245,7 @@ export interface CctvVideoKnobs {
|
|
|
238
245
|
alertClips?: AlertClipRequest[];
|
|
239
246
|
}
|
|
240
247
|
export type CctvVideoMode = 'off' | 'alert_windows' | 'continuous';
|
|
248
|
+
export type CctvRingStream = 'sub' | 'probe' | 'main';
|
|
241
249
|
/** One alert's clip request, as the receipt and the video knobs both serve it. */
|
|
242
250
|
export interface AlertClipRequest {
|
|
243
251
|
alertId: string;
|
|
@@ -247,7 +255,19 @@ export interface AlertClipRequest {
|
|
|
247
255
|
capturedAtMs: number;
|
|
248
256
|
beforeSeconds: number;
|
|
249
257
|
afterSeconds: number;
|
|
258
|
+
/**
|
|
259
|
+
* What the window is for: `alert` (the window around an alert), or a request
|
|
260
|
+
* (`request`, `theft_candidate`, …: services/video/clipRequests). Absent from
|
|
261
|
+
* an older API: an alert's window.
|
|
262
|
+
*/
|
|
263
|
+
kind?: string;
|
|
264
|
+
/**
|
|
265
|
+
* Which recording a REQUEST is cut from: `sub` or `main` (the camera's
|
|
266
|
+
* main-stream ring). An alert's window is cut from whatever the ring holds.
|
|
267
|
+
*/
|
|
268
|
+
stream?: CctvRingStreamName;
|
|
250
269
|
}
|
|
270
|
+
export type CctvRingStreamName = 'sub' | 'main';
|
|
251
271
|
/** A clip request, or null when any part of it is unusable. Shared by the knobs and the receipt. */
|
|
252
272
|
export declare function parseAlertClipRequest(raw: unknown): AlertClipRequest | null;
|
|
253
273
|
/** Every usable request in a list; anything else is dropped one entry at a time. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SensingProfileClient.d.ts","sourceRoot":"","sources":["../src/SensingProfileClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAqD,KAAK,uBAAuB,EAAC,MAAM,mBAAmB,CAAC;AACnH,OAAO,KAAK,EACV,oBAAoB,EAEpB,+BAA+B,EAC/B,0BAA0B,EAC1B,+BAA+B,EAChC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,KAAK,UAAU,EAAqB,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAG3D,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAwB,KAAK,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAE3F,OAAO,EAAwB,KAAK,sBAAsB,EAAC,MAAM,oBAAoB,CAAC;AACtF,OAAO,EAA2B,KAAK,oBAAoB,EAAC,MAAM,4BAA4B,CAAC;AAC/F,OAAO,EAA2C,KAAK,qBAAqB,EAAC,MAAM,mBAAmB,CAAC;AACvG,OAAO,EAA8C,KAAK,oBAAoB,EAAC,MAAM,kBAAkB,CAAC;AAExG,OAAO,EAAsC,KAAK,SAAS,EAAC,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"SensingProfileClient.d.ts","sourceRoot":"","sources":["../src/SensingProfileClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAqD,KAAK,uB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,oGAAoG;AACpG,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,OAAO,GAAG,gBAAgB,GAAG,IAAI,CAe3E;AAED,oFAAoF;AACpF,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,gBAAgB,EAAE,CAQvE;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,cAAc,GAAG,IAAI,GAAG,SAAS,CAiC/E;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,GAAG,SAAS,GAAG,aAAa,CAI1F;AAiDD,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAa;IACpC,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CAAU;gBAEzC,OAAO,EAAE,2BAA2B,EAAE,MAAM,CAAC,EAAE,UAAU;IAarE,+DAA+D;IAC/D,WAAW,IAAI,MAAM;IAIrB;;;OAGG;IACG,YAAY,IAAI,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC;IA4C5D,OAAO,CAAC,cAAc;CA6NvB;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,OAAO,GACX;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAO3C"}
|
|
@@ -21,6 +21,7 @@ const DetectorFields_1 = require("./DetectorFields");
|
|
|
21
21
|
const DetectorFieldProducer_1 = require("./DetectorFieldProducer");
|
|
22
22
|
const SceneMarks_1 = require("./SceneMarks");
|
|
23
23
|
const connectorUpdate_1 = require("./connectorUpdate");
|
|
24
|
+
const pipelineSwitches_1 = require("./pipelineSwitches");
|
|
24
25
|
/** Seconds in a UTC day — the most a daily budget can mean. */
|
|
25
26
|
const SECONDS_PER_DAY = 86400;
|
|
26
27
|
/** Segment bounds: the same 10..300 s the screen-group rail CHECKs for tablets. */
|
|
@@ -31,6 +32,7 @@ const MAX_ALERT_WINDOW_SIDE_SECONDS = 300;
|
|
|
31
32
|
/** At most this many clip requests are read from one answer (the server serves 16). */
|
|
32
33
|
const MAX_ALERT_CLIP_REQUESTS = 32;
|
|
33
34
|
const VIDEO_MODES = ['off', 'alert_windows', 'continuous'];
|
|
35
|
+
const RING_STREAMS = ['sub', 'probe', 'main'];
|
|
34
36
|
const TRIGGER_ID_RE = /^[a-z0-9_]{1,64}$/;
|
|
35
37
|
/** A clip request, or null when any part of it is unusable. Shared by the knobs and the receipt. */
|
|
36
38
|
function parseAlertClipRequest(raw) {
|
|
@@ -48,7 +50,12 @@ function parseAlertClipRequest(raw) {
|
|
|
48
50
|
return null;
|
|
49
51
|
if (beforeSeconds === null || afterSeconds === null || beforeSeconds + afterSeconds <= 0)
|
|
50
52
|
return null;
|
|
51
|
-
|
|
53
|
+
const request = { alertId: r.alertId, triggerId: r.triggerId, capturedAtMs: r.capturedAtMs, beforeSeconds, afterSeconds };
|
|
54
|
+
if (typeof r.kind === 'string' && /^[a-z_]{1,32}$/.test(r.kind))
|
|
55
|
+
request.kind = r.kind;
|
|
56
|
+
if (r.stream === 'sub' || r.stream === 'main')
|
|
57
|
+
request.stream = r.stream;
|
|
58
|
+
return request;
|
|
52
59
|
}
|
|
53
60
|
/** Every usable request in a list; anything else is dropped one entry at a time. */
|
|
54
61
|
function parseAlertClipRequests(raw) {
|
|
@@ -94,6 +101,9 @@ function parseVideoKnobs(raw) {
|
|
|
94
101
|
}
|
|
95
102
|
if (typeof obj.alerting === 'boolean')
|
|
96
103
|
knobs.alerting = obj.alerting;
|
|
104
|
+
if (typeof obj.ringStream === 'string' && RING_STREAMS.includes(obj.ringStream)) {
|
|
105
|
+
knobs.ringStream = obj.ringStream;
|
|
106
|
+
}
|
|
97
107
|
const window = obj.alertWindow;
|
|
98
108
|
if (window && typeof window === 'object' && !Array.isArray(window)) {
|
|
99
109
|
const before = int(window.beforeSeconds);
|
|
@@ -221,6 +231,8 @@ class SensingProfileClient {
|
|
|
221
231
|
// connector each channel lists (`connectorRelease`). Read before any status
|
|
222
232
|
// check, since a refusal can carry it too; it never affects the profile.
|
|
223
233
|
(0, connectorUpdate_1.noteConnectorReleaseAdvert)(parsed?.connectorRelease);
|
|
234
|
+
// The box's pipeline switches (plan v7 W8) ride the same poll, refusals included.
|
|
235
|
+
(0, pipelineSwitches_1.notePipelineSwitches)(parsed?.pipeline);
|
|
224
236
|
const refusal = result.statusCode === 503 && parsed?.success === false
|
|
225
237
|
&& parsed.reason === 'retained_native_models_not_eligible';
|
|
226
238
|
if (refusal) {
|