@trillboards/edge-platform-rtsp 0.2.4 → 0.2.6

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.
@@ -0,0 +1,615 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
4
+ import { spawn } from 'child_process';
5
+ import type { CameraProvider } from '@trillboards/edge-core';
6
+ import { type CropRegion, type RTSPCameraConfig } from './RTSPCameraProvider';
7
+ /**
8
+ * RTSPStreamCameraProvider — video frames off an RTSP camera/NVR channel as a
9
+ * LONG-LIVED ffmpeg session feeding a bounded in-memory ring, so that a LOOK
10
+ * becomes a memory read instead of an RTSP handshake.
11
+ *
12
+ * ── THE PROBLEM THIS EXISTS TO REMOVE, AND IT IS ONE MEASUREMENT ───────────
13
+ *
14
+ * `RTSPCameraProvider.buildCaptureArgs` spawns ONE ffmpeg per grab with
15
+ * `-frames:v 1`, so every look pays a process start, a full RTSP
16
+ * DESCRIBE/SETUP/PLAY handshake, and a wait for the camera's next keyframe
17
+ * before anything can be decoded. Measured through that provider against
18
+ * mediamtx re-streaming a real CCTV clip at the documented degraded profile
19
+ * (640x360 / 399 kbps): p50 **1,986-2,025 ms** per grab at a 1-2 s keyframe
20
+ * interval, 4,005 ms at 4 s. The control — the SAME ffmpeg args against a local
21
+ * file, so spawn + decode + scale + pad + JPEG encode with no stream — is
22
+ * **20-30 ms**. So ~99% of a look is session SETUP, not imaging.
23
+ *
24
+ * That is the whole catch-rate problem. An event is catchable only if a look
25
+ * lands inside it, so catch rate is bounded by `E[min(d/T,1)]` for a look
26
+ * cadence `T`; the Brief group (median ~2.4 s, heavy sub-second tail) needs
27
+ * **0.75 s** to clear the 90% target, which is 2.7x BELOW what one grab
28
+ * physically costs. `connectorCadence.ts` says so in as many words: "Closing
29
+ * that gap needs a persistent RTSP session — one long-lived ffmpeg per feed
30
+ * instead of one per grab — which is an architecture change, not a number."
31
+ * This is that change.
32
+ *
33
+ * Measured through THIS provider against the same rig: the handshake is paid
34
+ * ONCE at open, and thereafter frames arrive every ~250 ms (`streamFps` 4) and
35
+ * `getFrame()` returns in **microseconds** because it reads the newest frame
36
+ * out of memory. See `scripts/measure-persistent-capture.mjs` for the driver
37
+ * and the committed numbers.
38
+ *
39
+ * ── PROCESS COUNT GOES DOWN, NOT UP. SAY IT OUT LOUD ───────────────────────
40
+ *
41
+ * A reviewer reads "persistent session" as "more load on the recorder". It is
42
+ * the opposite, and the incident this package is written around is the reason.
43
+ * A 32-channel NVR once accumulated **28 simultaneous ffmpeg children** because
44
+ * one-shot pulls started outliving the cadence, and the recorder answered with
45
+ * rotating timeouts, CSeq mismatches and cameras flapping into "needs
46
+ * attention" — which is why `CaptureAdmission` caps at 2 concurrent pulls per
47
+ * physical recorder
48
+ * (.claude/lessons/2026-08-17-rtsp-session-admission-and-frame-integrity.md).
49
+ *
50
+ * Compare the two designs on the SAME 16-feed recorder:
51
+ *
52
+ * per-grab (today) 16 feeds x 1 look / 16 s = 1.0 RTSP session SETUP per
53
+ * second, forever — 3,600 DESCRIBE/SETUP/PLAY/TEARDOWN
54
+ * cycles per hour and 3,600 process spawns per hour, with
55
+ * 2 concurrent at any instant and an unbounded pile-up
56
+ * under load (the incident).
57
+ *
58
+ * persistent 16 session setups TOTAL, then nothing. 16 processes,
59
+ * bounded by construction, and 16 concurrent substream
60
+ * readers — which is exactly what the recorder's OWN
61
+ * client app opens for a 16-up grid view, i.e. its designed
62
+ * workload.
63
+ *
64
+ * So the churn goes to zero and the process count per hour falls by ~225x. The
65
+ * one number that goes UP is steady-state concurrent sessions (2 -> N), and
66
+ * that is why the persistent lane is bounded per recorder and degrades rather
67
+ * than fails — see ADMISSION below.
68
+ *
69
+ * That bound used to be a guess. It was validated against mediamtx, which
70
+ * serves any number of readers and therefore cannot refuse anything, so the
71
+ * only property that actually matters here was untestable on the rig. Measured
72
+ * 2026-08-19 against two real implementations, the ceiling ranges from **4**
73
+ * (Happytime ONVIF/RTSP Server, a fixed pool with no config key) to **>=160**
74
+ * (Nx Media Server 6.1.2.42921, never refused). It is a property of the
75
+ * recorder, so the lane LEARNS it — see `DEFAULT_MAX_STREAM_SESSIONS_PER_SOURCE`
76
+ * and `StreamSessionAdmission.learnCeiling`.
77
+ *
78
+ * ── ADMISSION: A SECOND LANE, AND IT REFUSES RATHER THAN QUEUES ────────────
79
+ *
80
+ * A long-lived session cannot be admitted from `CaptureAdmission`: a permanent
81
+ * holder of a 2-slot pool is a 50% permanent tax on frame capture for that
82
+ * recorder, and two of them deadlock it entirely. So persistent sessions are
83
+ * admitted from `streamAdmissionBySource`, keyed by the SAME
84
+ * `captureSourceKey(url)` — host:port, credentials and channel path
85
+ * deliberately excluded so 32 channels of one NVR share one budget — counted in
86
+ * their OWN pool with its own cap. Exactly the split `RTSPAudioProvider` uses,
87
+ * for exactly the same reason.
88
+ *
89
+ * The lane never queues. A queued video session would be admitted minutes later
90
+ * against a scene nobody is asking about any more, and a feed waiting on a slot
91
+ * is a feed that is not sensing.
92
+ *
93
+ * ── DEGRADE, NEVER FAIL. THIS IS THE PROPERTY THAT LETS THIS SHIP ──────────
94
+ *
95
+ * When the persistent session cannot be had — the recorder's lane is full, or
96
+ * the recorder refuses the session, or ffmpeg cannot hold it open — this
97
+ * provider does NOT throw. It falls back to an internal `RTSPCameraProvider`
98
+ * and runs the per-grab path, which is precisely what the connector does today.
99
+ * So no camera that works today can be broken by this change; the worst case is
100
+ * that it is no faster than it was.
101
+ *
102
+ * The degrade is a REPORTED STATE, never a hidden branch: `getStats().mode` is
103
+ * `'persistent' | 'per_grab'`, `degradedReason` says which of the three causes
104
+ * fired, and it is logged at warn. A silent downgrade would be the same defect
105
+ * as a silent drop — it would move the problem somewhere nobody looks.
106
+ *
107
+ * ── A DEAD STREAM MUST BE LOUD, AND A PERSISTENT SESSION MAKES THAT HARDER ─
108
+ *
109
+ * The connector's recurring defect is a signal that cannot report its own
110
+ * failure: a recorder that accepts a connection and then stops sending frames
111
+ * is ~50 minutes of beacon silence rendered as "connector not running". A
112
+ * persistent session makes that MORE likely, because the process is still
113
+ * alive and the socket is still open. Three things make it loud instead:
114
+ *
115
+ * 1. `getFrame()` NEVER returns a frame it has already returned. It waits up
116
+ * to `frameWaitMs` for a genuinely new one and then throws
117
+ * `RtspStreamStaleError` carrying the age. Handing back a stale frame is
118
+ * the failure mode, not the fallback: it would keep stamping the camera's
119
+ * `lastFrameAtMs`, and a frozen camera would report as healthy forever.
120
+ * 2. The error message is worded so `classifyRtspFailureClass` reads it as
121
+ * `no_frames` — the recorder answered, no video arrived — and NOT as a
122
+ * reachability class, which would wrongly implicate the LAN grant. The
123
+ * ffmpeg stderr summary is deliberately kept OUT of that message and put
124
+ * in `getStats().lastErrorMessage`, so the classification is deterministic
125
+ * instead of depending on which warning ffmpeg happened to print.
126
+ * 3. `getStats()` DERIVES `frameAgeMs`, `running`, `mode` and the counters
127
+ * live on every call. There is no cached capability boolean. On the
128
+ * Android fleet `cap_audio_classification` is false FLEET-WIDE, including
129
+ * on devices shipping live classifications, because a flag was latched at
130
+ * boot from a value that was still "probing" and nothing ever re-wrote it
131
+ * (docs/runbooks/audio-sensing-substrate.md).
132
+ *
133
+ * A CLEAN EXIT IS A FAULT HERE. `code === 0` means success on the one-shot
134
+ * path; on a persistent session it means the stream ended, which is never what
135
+ * we asked for. Measured against the rig: killing the publisher made ffmpeg
136
+ * exit 0 within 26 ms, and freezing it (session held open, no RTP) made ffmpeg
137
+ * exit 0 after ~10 s with "Failed reading RTSP data: End of file". Both are
138
+ * restarts here, both are counted, and neither is ever silent.
139
+ *
140
+ * ── BOUNDED MEMORY, ENFORCED ON ADMISSION ─────────────────────────────────
141
+ *
142
+ * `VlmCandidateBuffer` gets this right and this copies its discipline: the
143
+ * ceiling is checked on the way IN, in exact bytes, and every eviction is
144
+ * COUNTED. A ring that grows under back-pressure is an OOM on a 7 GB box.
145
+ *
146
+ * There are TWO bounds because there are two places bytes accumulate, and the
147
+ * second one is the easy one to miss: the ring holds complete frames, but the
148
+ * SPLITTER holds a partially-received one. A stream that emits an SOI and then
149
+ * never an EOI — a corrupt feed, a mid-frame protocol change — would grow that
150
+ * accumulator without limit. `maxFrameBytes` bounds it, and an overflow resyncs
151
+ * and is counted as `oversizeFrames`.
152
+ *
153
+ * ── JPEG ONLY, ON PURPOSE ─────────────────────────────────────────────────
154
+ *
155
+ * `RTSPCameraProvider` supports `outputFormat: 'rgb24'` for the ONNX face
156
+ * zoo. A persistent rgb24 stream is 640x480x3 = 921,600 bytes per frame, i.e.
157
+ * 3.7 MB/s per camera at 4 fps and ~59 MB/s across 16 feeds, through pipes and
158
+ * into a ring. The same stream as MJPEG is ~0.12 MB/s per camera (measured:
159
+ * 29.6 KB/frame at q:v 11 on the degraded profile). So this provider is JPEG
160
+ * only and the rgb24 zoo keeps the one-shot path, which is also the right split
161
+ * by product: the zoo is the DOOH audience rail, and the look-cadence problem
162
+ * is the CCTV sensing rail.
163
+ *
164
+ * ── RATE LIMITING WITHOUT FABRICATION ─────────────────────────────────────
165
+ *
166
+ * The output is rate-limited with the `fps` filter rather than by an output
167
+ * `-r`, and the difference matters for constraint 3. The `fps` filter is driven
168
+ * BY ARRIVING INPUT FRAMES: when no frames arrive it emits nothing. Verified
169
+ * against the rig — freezing the source produced zero further output, so a
170
+ * frozen camera cannot manufacture "fresh" frames and defeat the staleness
171
+ * signal. Decode cost is unaffected by the filter (ffmpeg must decode the
172
+ * stream to produce any frame at all); what `streamFps` bounds is scale, pad,
173
+ * JPEG encode and pipe traffic.
174
+ *
175
+ * ── SECRET HYGIENE, INHERITED ─────────────────────────────────────────────
176
+ *
177
+ * RTSP URLs carry passwords. Exactly as the other two providers do, the URL is
178
+ * written to a 0600 ffconcat file and only the temp path reaches argv, so a
179
+ * password never appears in `ps` output; stderr is scrubbed through
180
+ * `sanitizeStreamUrlForLog` before it can reach a log line.
181
+ */
182
+ /** The recorder's persistent-session lane is full. Degrade, never queue. */
183
+ export declare class RtspStreamAdmissionError extends Error {
184
+ readonly code = "RTSP_STREAM_SESSION_LIMIT";
185
+ constructor(sourceKey: string, limit: number);
186
+ }
187
+ /**
188
+ * No NEW frame arrived within the deadline.
189
+ *
190
+ * The wording is load bearing. `classifyRtspFailureClass` tests, in order,
191
+ * auth -> nvr-busy -> unreachable -> timeout -> decode -> no-frames, so this
192
+ * message must avoid every earlier class's vocabulary ("timeout", "timed out",
193
+ * "refused", "corrupt", "eof") and must contain "no frame". A stale persistent
194
+ * session is not a reachability failure — the recorder answered and the socket
195
+ * is up — and misclassifying it as one would send the health surface to
196
+ * `local_network_denied` and blame the operator's macOS LAN grant for a camera
197
+ * that is plainly reachable.
198
+ */
199
+ export declare class RtspStreamStaleError extends Error {
200
+ readonly code = "RTSP_STREAM_STALE";
201
+ readonly ageMs: number;
202
+ constructor(url: string, ageMs: number, restarts: number);
203
+ }
204
+ /**
205
+ * The per-grab provider this one degrades to.
206
+ *
207
+ * `CameraProvider.getFrame()` is declared as `Promise<Buffer | EdgeImageData>`
208
+ * because a locally-attached webcam adapter may hand back decoded pixels. Every
209
+ * RTSP path in this package produces encoded bytes, and this provider is JPEG
210
+ * only, so the fallback is narrowed here rather than cast at the call site — a
211
+ * cast would be a claim, and this is a constraint.
212
+ */
213
+ export type PerGrabCameraProvider = Omit<CameraProvider, 'getFrame'> & {
214
+ getFrame(): Promise<Buffer>;
215
+ };
216
+ /** Why a feed is running the per-grab path instead of a persistent session. */
217
+ export type StreamDegradeReason =
218
+ /** The recorder's persistent-session lane was already full. */
219
+ 'session_limit'
220
+ /** ffmpeg could not hold a session open through `openValidationAttempts`. */
221
+ | 'session_unavailable'
222
+ /** The caller asked for the per-grab path explicitly. */
223
+ | 'disabled';
224
+ export type StreamCaptureMode = 'persistent' | 'per_grab';
225
+ /**
226
+ * Our POLICY ceiling on persistent sessions to one recorder — never a claim
227
+ * about what the recorder can hold.
228
+ *
229
+ * ── THIS USED TO BE A STATED JUDGEMENT AND IT WAS WRONG IN BOTH DIRECTIONS ─
230
+ *
231
+ * It read: "A STATED JUDGEMENT, not a measurement… mediamtx serves any number
232
+ * of readers, so the rig cannot find a real NVR's ceiling." That was honest
233
+ * about its own ignorance and still shipped a number into the one place the
234
+ * ignorance mattered. Measured 2026-08-19 against two real implementations
235
+ * with `scripts/measure-rtsp-session-ceiling.mjs` (a raw RTSP client, so the
236
+ * refusal is graded by which request was refused and how, not by an ffmpeg
237
+ * exit code):
238
+ *
239
+ * Happytime ONVIF/RTSP Server V8.1 4 sessions, then the server
240
+ * CLOSES THE TCP CONNECTION with
241
+ * no RTSP status at all (0-1 ms).
242
+ * Its own log: "rtsp_listen_rx,
243
+ * rua_get_idle_rua return NULL".
244
+ * A fixed pool, with no config key.
245
+ * Nx Media Server 6.1.2.42921 >=160 sessions, never refused.
246
+ * mediamtx unbounded (the original validation target,
247
+ * which is why none of this was
248
+ * visible).
249
+ *
250
+ * 16 is 4x ABOVE the first and 10x BELOW the second, so no constant is the
251
+ * answer: the ceiling is a property of the recorder. Above it the damage is not
252
+ * merely "some feeds stay on the slow path" — measured on Happytime with the
253
+ * cap at 4, the fifth feed degraded to per-grab exactly as designed and then
254
+ * produced NO FRAMES AT ALL, because the recorder was full of our own
255
+ * persistent sessions and the fallback needs a session too.
256
+ *
257
+ * So the real limit is LEARNED per recorder — see
258
+ * `StreamSessionAdmission.learnCeiling`, which records what the recorder did
259
+ * the first time it refused and sheds our own over-quota sessions down to it,
260
+ * keeping `STREAM_SESSION_RESERVE_FOR_PER_GRAB` slots free for the fallback.
261
+ * This constant is only where the search STARTS, and the two directions are not
262
+ * symmetric: starting too low costs nothing but the latency win on some feeds
263
+ * (they run the per-grab path the connector ran before this architecture),
264
+ * while starting too high costs a round trip per feed before the lane learns.
265
+ * 16 is kept because it is above every deployment this connector is sized for
266
+ * (`connectorCadence.ts` puts a host at seven or fewer feeds) and Nx proves a
267
+ * real NVR is nowhere near bothered by it.
268
+ */
269
+ export declare const DEFAULT_MAX_STREAM_SESSIONS_PER_SOURCE = 16;
270
+ /** A complete JPEG ends at this offset; -1 = need more bytes; -2 = malformed. */
271
+ export declare const JPEG_NEED_MORE = -1;
272
+ export declare const JPEG_MALFORMED = -2;
273
+ /**
274
+ * Offset just past the EOI of the JPEG starting at `start`, by walking JPEG
275
+ * segments — NOT by scanning for the `FF D9` byte pair.
276
+ *
277
+ * A plain byte scan is wrong and the failure is silent. Marker segments carry
278
+ * arbitrary payloads (a DQT's 64 quantisation values, a DHT's code lengths, an
279
+ * APPn's contents), any of which may contain `FF D9`, and a scanner that found
280
+ * one would cut the frame short and hand a truncated JPEG downstream — which
281
+ * `RTSPCameraProvider` already refuses on the one-shot path precisely because a
282
+ * truncated JPEG renders as grey and becomes alert evidence.
283
+ *
284
+ * So: step over each segment by its declared length until SOS, then scan the
285
+ * entropy-coded data honouring JPEG byte stuffing (`FF 00` is a literal `FF`,
286
+ * `FF D0`-`FF D7` are restart markers, `FF FF` is fill) until a real marker
287
+ * appears. In ffmpeg's baseline MJPEG output that marker is EOI.
288
+ */
289
+ export declare function jpegFrameEnd(buf: Buffer, start?: number): number;
290
+ /**
291
+ * Cuts a byte stream of concatenated JPEGs into whole frames, with a HARD
292
+ * ceiling on the partially-received one.
293
+ *
294
+ * The ceiling is the bound people forget: the ring is bounded, but the thing
295
+ * feeding it is an accumulator, and an accumulator with no cap is the same leak
296
+ * one layer up. On overflow the accumulator is dropped and the splitter resyncs
297
+ * to the next SOI, and the event is COUNTED rather than swallowed.
298
+ */
299
+ export declare class MjpegFrameSplitter {
300
+ private readonly maxFrameBytes;
301
+ private acc;
302
+ private oversize;
303
+ private resyncs;
304
+ constructor(maxFrameBytes: number);
305
+ getOversizeFrames(): number;
306
+ getResyncs(): number;
307
+ getPendingBytes(): number;
308
+ reset(): void;
309
+ /** Append a chunk and return every complete frame it completed, in order. */
310
+ push(chunk: Buffer): Buffer[];
311
+ /** Drop bytes up to the next SOI. Returns false when there is no next SOI. */
312
+ private resyncToNextSoi;
313
+ }
314
+ /**
315
+ * Bounded newest-first frame ring. Byte- and count-bounded, enforced when a
316
+ * frame is ADMITTED, and every eviction counted — `VlmCandidateBuffer`'s
317
+ * discipline, for the same reason: a silent eviction moves a lost frame from
318
+ * one invisible place to another.
319
+ */
320
+ export declare class FrameRing {
321
+ private readonly maxFrames;
322
+ private readonly maxBytes;
323
+ private frames;
324
+ private bytes;
325
+ private evicted;
326
+ private rejected;
327
+ private seq;
328
+ constructor(maxFrames: number, maxBytes: number);
329
+ /** Admit a frame. Returns its sequence number, or null if it cannot fit. */
330
+ push(bytes: Buffer, atMs: number): number | null;
331
+ newest(): {
332
+ bytes: Buffer;
333
+ atMs: number;
334
+ seq: number;
335
+ } | null;
336
+ getBytes(): number;
337
+ getFrames(): number;
338
+ getEvicted(): number;
339
+ getRejected(): number;
340
+ clear(): void;
341
+ }
342
+ /** Test seam: forget every recorder's persistent-session budget. */
343
+ export declare function __resetStreamAdmissionForTests(): void;
344
+ /** Live persistent-session occupancy for a recorder, for diagnostics. */
345
+ export declare function streamSessionStatsFor(streamUrl: string): {
346
+ key: string;
347
+ active: number;
348
+ limit: number;
349
+ learnedCeiling: number | null;
350
+ } | null;
351
+ export interface RTSPStreamCameraConfig {
352
+ /** RTSP stream URL. Credentials never reach argv — see the header. */
353
+ rtspUrl: string;
354
+ /** Output width in pixels (default 640). */
355
+ width?: number;
356
+ /** Output height in pixels (default 480). */
357
+ height?: number;
358
+ /** Mosaic tile carve, applied BEFORE scale — same math as the one-shot path. */
359
+ crop?: CropRegion;
360
+ /** RTSP transport. Default 'tcp'. */
361
+ transport?: 'tcp' | 'udp';
362
+ /** Socket I/O timeout (µs). Default 12000000. */
363
+ timeoutUs?: number;
364
+ /** ffmpeg binary. Default 'ffmpeg'. */
365
+ ffmpegPath?: string;
366
+ /** ffmpeg major version, for the `-timeout` vs `-stimeout` split. Default 6. */
367
+ ffmpegMajorVersion?: number;
368
+ /** JPEG quality 1-100. Default 70, matching the one-shot path. */
369
+ jpegQuality?: number;
370
+ /**
371
+ * Frames DECODED-AND-ENCODED per second by the session. Default 4 (250 ms).
372
+ *
373
+ * This is the ceiling on how fresh a look can be, so it must sit comfortably
374
+ * under the look cadence: at `LOOK_INTERVAL_MS` = 500 ms a 4 fps stream
375
+ * always has an unseen frame in hand and `getFrame()` never blocks. Raising
376
+ * it does not reduce decode cost (ffmpeg decodes the stream regardless) but
377
+ * does raise scale/encode/pipe cost, which is the only per-frame cost this
378
+ * knob controls.
379
+ */
380
+ streamFps?: number;
381
+ /**
382
+ * Decoder/encoder threads for the session. Default 1, and that is a
383
+ * MEASUREMENT, not thrift — see `DEFAULT_DECODER_THREADS`.
384
+ */
385
+ decoderThreads?: number;
386
+ /** Persistent sessions per recorder host:port. Default 16 — see the constant. */
387
+ maxStreamSessionsPerSource?: number;
388
+ /** Complete frames held in the ring. Default 4. */
389
+ ringMaxFrames?: number;
390
+ /** Total bytes of complete frames held. Default 4 MiB. */
391
+ ringMaxBytes?: number;
392
+ /** Ceiling on one partially-received frame. Default 2 MiB. */
393
+ maxFrameBytes?: number;
394
+ /**
395
+ * How long `getFrame()` waits for a NEW frame before declaring the stream
396
+ * stale. Default `max(3000, 6 x frame interval)`.
397
+ */
398
+ frameWaitMs?: number;
399
+ /** Session-start attempts before degrading to per-grab. Default 2. */
400
+ openValidationAttempts?: number;
401
+ /** First restart delay (ms), doubling to `maxRestartDelayMs`. Default 1000. */
402
+ restartDelayMs?: number;
403
+ /** Backoff ceiling (ms). Default 60000. */
404
+ maxRestartDelayMs?: number;
405
+ /**
406
+ * Force the per-grab path. The provider still presents one interface, and
407
+ * `getStats().degradedReason` reports `'disabled'` so the choice is visible.
408
+ */
409
+ persistent?: boolean;
410
+ /** Passed through to the per-grab fallback provider. */
411
+ fallbackConfig?: Partial<RTSPCameraConfig>;
412
+ /** DHCP recovery hook, forwarded to the per-grab fallback. */
413
+ streamUrlResolver?: RTSPCameraConfig['streamUrlResolver'];
414
+ /** Injected spawn, for tests. */
415
+ spawnFn?: typeof spawn;
416
+ /** Injected per-grab fallback, for tests. */
417
+ fallbackFactory?: (config: RTSPCameraConfig) => PerGrabCameraProvider;
418
+ /** Clock injection for tests. */
419
+ now?: () => number;
420
+ /** Optional log sink; messages are already URL-scrubbed. */
421
+ onLog?: (level: 'debug' | 'info' | 'warn' | 'error', message: string) => void;
422
+ }
423
+ export interface RTSPStreamStats {
424
+ opened: boolean;
425
+ /** Which path this feed is ACTUALLY running. Derived, never latched. */
426
+ mode: StreamCaptureMode;
427
+ degradedReason: StreamDegradeReason | null;
428
+ /** True when an ffmpeg session is currently alive. */
429
+ running: boolean;
430
+ /** Complete frames in the ring, and their exact byte total. */
431
+ bufferedFrames: number;
432
+ bufferedBytes: number;
433
+ /** Bytes of a partially-received frame. */
434
+ pendingBytes: number;
435
+ /** ffmpeg session starts, including restarts. */
436
+ sessionStarts: number;
437
+ restarts: number;
438
+ /** Frames admitted to the ring over the session's life. */
439
+ framesDecoded: number;
440
+ /** Frames handed to a caller by getFrame(). */
441
+ framesServed: number;
442
+ /** Ring evictions (a newer frame displaced an unread older one). */
443
+ framesEvicted: number;
444
+ /** Frames refused because one frame exceeded the whole byte budget. */
445
+ framesRejected: number;
446
+ /** Partial frames dropped for exceeding `maxFrameBytes`. */
447
+ oversizeFrames: number;
448
+ /** Splitter resyncs after malformed bytes. */
449
+ resyncs: number;
450
+ /** getFrame() calls that found no new frame within the deadline. */
451
+ staleReads: number;
452
+ /** Wall-clock ms of the newest frame, or null. */
453
+ lastFrameAtMs: number | null;
454
+ /** Age of the newest frame at the moment getStats() was called, or null. */
455
+ frameAgeMs: number | null;
456
+ lastErrorMessage: string | null;
457
+ }
458
+ /**
459
+ * One instance per feed. Implements the SAME `CameraProvider` interface as
460
+ * `RTSPCameraProvider`, so every consumer is unchanged — but `getFrame()` reads
461
+ * the newest frame out of the ring the long-lived session is filling, rather
462
+ * than spawning a process and handshaking a stream per call.
463
+ */
464
+ export declare class RTSPStreamCameraProvider implements CameraProvider {
465
+ private readonly rtspUrl;
466
+ private readonly width;
467
+ private readonly height;
468
+ private readonly crop?;
469
+ private readonly transport;
470
+ private readonly timeoutUs;
471
+ private readonly ffmpegPath;
472
+ private readonly ffmpegMajorVersion;
473
+ private readonly jpegQuality;
474
+ private readonly streamFps;
475
+ private readonly decoderThreads;
476
+ private readonly frameIntervalMs;
477
+ private readonly maxStreamSessionsPerSource;
478
+ private readonly frameWaitMs;
479
+ private readonly openValidationAttempts;
480
+ private readonly restartDelayMs;
481
+ private readonly maxRestartDelayMs;
482
+ private readonly persistentRequested;
483
+ private readonly spawnFn;
484
+ private readonly now;
485
+ private readonly onLog?;
486
+ private readonly buildFallback;
487
+ private readonly ring;
488
+ private readonly splitter;
489
+ private opened;
490
+ private mode;
491
+ private degradedReason;
492
+ private fallback;
493
+ /**
494
+ * Why the per-grab fallback could not open, when it could not.
495
+ *
496
+ * Kept because the alternative is what shipped: a feed whose fallback failed
497
+ * answered `getFrame()` with "Camera not opened. Call open() first." — a
498
+ * PROGRAMMING error message for a RECORDER condition, thrown from
499
+ * `RTSPCameraProvider` after this provider had already been told, in words,
500
+ * that the recorder refused. Measured on Happytime at its 4-session ceiling:
501
+ * `open()` carried "Failed reading RTSP data: End of file" and `getFrame()`
502
+ * threw the not-opened message, so the one classifiable fact was discarded
503
+ * one frame later.
504
+ */
505
+ private fallbackOpenError;
506
+ private proc;
507
+ /** This recorder's persistent-session lane, for the learned ceiling. */
508
+ private admission;
509
+ private releaseAdmission;
510
+ private restartTimer;
511
+ private currentRestartDelay;
512
+ private cleanupInput;
513
+ private startingUp;
514
+ private sessionStarts;
515
+ private restarts;
516
+ private framesDecoded;
517
+ private framesServed;
518
+ private staleReads;
519
+ private lastFrameAtMs;
520
+ private lastServedSeq;
521
+ private lastErrorMessage;
522
+ /** Resolvers waiting for the next frame. Woken by `admitFrame`. */
523
+ private frameWaiters;
524
+ constructor(config: RTSPStreamCameraConfig);
525
+ /**
526
+ * Take a recorder session slot and start streaming. NEVER throws because the
527
+ * persistent path was unavailable — it degrades to the per-grab provider and
528
+ * says so. It throws only when the per-grab path ALSO fails, which is exactly
529
+ * what the connector does today, so no working camera can be broken here.
530
+ */
531
+ open(_deviceId?: string): Promise<void>;
532
+ /**
533
+ * Drop this feed's persistent session because the recorder's learned ceiling
534
+ * turned out to be lower than the lane believed.
535
+ *
536
+ * Synchronous and non-throwing by contract — the admission pool calls this
537
+ * while it is reconciling occupancy, and an exception or an await here would
538
+ * leave the pool's accounting mid-flight. The transition itself is the one
539
+ * this provider already implements everywhere else: stop the session, report
540
+ * `per_grab` / `session_limit`, and build the fallback. The fallback's own
541
+ * `open()` is deliberately left to run on its promise; `getFrame()` reports
542
+ * its failure rather than the generic not-opened message.
543
+ */
544
+ private shedPersistentSession;
545
+ /**
546
+ * The newest frame this feed has produced AND NOT YET SERVED.
547
+ *
548
+ * On the persistent path this is a memory read — microseconds — when a fresh
549
+ * frame is in hand, which at `streamFps` 4 against a 500 ms look cadence is
550
+ * every time. When it is not, the call waits up to `frameWaitMs` and is woken
551
+ * by the next arrival; a wait that expires is a STALE STREAM and throws.
552
+ *
553
+ * Never returning a repeat is the whole loudness guarantee. Handing back the
554
+ * same frame would report a frozen camera as healthy forever, and would also
555
+ * feed the motion detector a constant — which is the documented `file://`
556
+ * fixture trap (`-frames:v 1` with no `-ss` returns frame 0 forever), where
557
+ * the gate calibrates against a constant and settles into `no_motion`
558
+ * permanently.
559
+ */
560
+ getFrame(): Promise<Buffer>;
561
+ getResolution(): {
562
+ width: number;
563
+ height: number;
564
+ };
565
+ getFps(): number;
566
+ isOpen(): boolean;
567
+ close(): Promise<void>;
568
+ /**
569
+ * Every field DERIVED on each call. There is no cached capability boolean
570
+ * here and one must never be added — see the header on
571
+ * `cap_audio_classification`.
572
+ */
573
+ getStats(): RTSPStreamStats;
574
+ private degradeTo;
575
+ private releaseSlot;
576
+ /** The newest frame if it has not been served yet, else null. */
577
+ private takeFreshFrame;
578
+ private waitForFrame;
579
+ private wakeWaiters;
580
+ private admitFrame;
581
+ /**
582
+ * ffmpeg args for a CONTINUOUS MJPEG pull. The URL goes into a 0600 ffconcat
583
+ * file exactly as the other two providers do, so it never reaches argv.
584
+ */
585
+ private buildInputArgs;
586
+ buildArgs(): {
587
+ args: string[];
588
+ cleanup: () => void;
589
+ };
590
+ /**
591
+ * Start one ffmpeg session. Resolves on the FIRST decoded frame — which is
592
+ * the only evidence that matters, because a spawned process that never
593
+ * produces an image is precisely the failure this provider exists to make
594
+ * loud. Rejects when the session ends before that.
595
+ */
596
+ private startSession;
597
+ private stopProcess;
598
+ /**
599
+ * A session ended. While the provider is open this ALWAYS schedules a restart
600
+ * with capped exponential backoff, and it is never allowed to give up. On the
601
+ * Ember fleet `shouldGiveUp` retired a camera permanently after a fixed 411 s
602
+ * and NOTHING re-armed it — `onCameraStartFailed` was telemetry-only, no
603
+ * config push restarted the analyzer, and `setMaxRetries` had zero call sites
604
+ * — so 7,359 escalations became permanent silence
605
+ * (docs/runbooks/ember-camera-health-taxonomy.md). The cap is what keeps a
606
+ * never-give-up retry from being a hammer.
607
+ *
608
+ * Waiters are woken on the way out so a `getFrame()` blocked on a session
609
+ * that just died reaches its stale error rather than sitting out the full
610
+ * deadline for a stream that is provably not coming back.
611
+ */
612
+ private handleSessionEnd;
613
+ private log;
614
+ }
615
+ //# sourceMappingURL=RTSPStreamCameraProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RTSPStreamCameraProvider.d.ts","sourceRoot":"","sources":["../src/RTSPStreamCameraProvider.ts"],"names":[],"mappings":";;;AAAA,OAAO,EAAE,KAAK,EAAgB,MAAM,eAAe,CAAC;AAIpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EASL,KAAK,UAAU,EACf,KAAK,gBAAgB,EACtB,MAAM,sBAAsB,CAAC;AAG9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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