@camstack/addon-post-analysis 1.2.51 → 1.2.52

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.
@@ -1,4 +1,3 @@
1
- import "node:crypto";
2
1
  //#region ../types/dist/event-category-41fKf-q9.mjs
3
2
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
4
3
  EventCategory["SystemBoot"] = "system.boot";
@@ -7136,473 +7135,6 @@ function sleep(ms) {
7136
7135
  return new Promise((resolve) => setTimeout(resolve, Math.max(0, ms)));
7137
7136
  }
7138
7137
  //#endregion
7139
- //#region ../types/dist/fmp4-box-splitter-B53u9-Nu.mjs
7140
- var AUDIO_ENCODER_BY_CODEC = {
7141
- opus: "libopus",
7142
- aac: "aac",
7143
- pcmu: "pcm_mulaw",
7144
- pcma: "pcm_alaw"
7145
- };
7146
- /**
7147
- * Camera-microphone audio, per codec. Lives HERE rather than in
7148
- * `encode-defaults.ts` only to avoid an import cycle (`encode-defaults` depends
7149
- * on these types); it is re-exported from there, which is where to read it.
7150
- *
7151
- * Every source in this repo is a mono camera mic. The former broker preset
7152
- * encoded Opus at `channels: 2`, spending bitrate duplicating one channel —
7153
- * that is the value this consolidation changed.
7154
- */
7155
- var AUDIO_PRESETS = {
7156
- aac: {
7157
- kind: "encode",
7158
- codec: "aac",
7159
- bitrateKbps: 128,
7160
- sampleRateHz: 48e3,
7161
- channels: 1
7162
- },
7163
- opus: {
7164
- kind: "encode",
7165
- codec: "opus",
7166
- bitrateKbps: 64,
7167
- sampleRateHz: 48e3,
7168
- channels: 1
7169
- },
7170
- pcmu: {
7171
- kind: "encode",
7172
- codec: "pcmu",
7173
- sampleRateHz: 8e3,
7174
- channels: 1
7175
- }
7176
- };
7177
- /** `-hide_banner -loglevel <level>` — every ffmpeg site opens with this. */
7178
- function logBannerArgs(level) {
7179
- return [
7180
- "-hide_banner",
7181
- "-loglevel",
7182
- level
7183
- ];
7184
- }
7185
- /** `true` when the resolved value means "decode in software" (⇒ no `-hwaccel`). */
7186
- function isSoftwareDecode(decodeHwAccel) {
7187
- return !decodeHwAccel || decodeHwAccel === "none" || decodeHwAccel === "copy";
7188
- }
7189
- /**
7190
- * Every INPUT option, in order, terminated by `-i <url>`. Nothing may be
7191
- * appended to this list by a caller — that is the whole point of the function.
7192
- */
7193
- function buildInputArgs(input, decodeHwAccel) {
7194
- const args = [];
7195
- if (!isSoftwareDecode(decodeHwAccel)) args.push("-hwaccel", String(decodeHwAccel));
7196
- if (input.extraArgs?.length) args.push(...input.extraArgs);
7197
- if (input.analyzeDurationUs !== void 0) args.push("-analyzeduration", String(input.analyzeDurationUs));
7198
- if (input.probeSizeBytes !== void 0) args.push("-probesize", String(input.probeSizeBytes));
7199
- if (input.fflags?.length) for (const flag of input.fflags) args.push("-fflags", flag);
7200
- if (input.rtspTransport) args.push("-rtsp_transport", input.rtspTransport);
7201
- args.push("-i", input.url);
7202
- return args;
7203
- }
7204
- /** The `-vf` filter args, or `[]` when a consumer `-vf` already claims the slot. */
7205
- function buildVideoFilterArgs(scale, outputArgs) {
7206
- if (!scale) return [];
7207
- if (outputArgs.some((a) => a === "-vf")) return [];
7208
- if (scale.mode === "exact") return ["-vf", `scale=${scale.width}:${scale.height}`];
7209
- return ["-vf", `scale='min(${scale.width},iw)':'min(${scale.height},ih)':force_original_aspect_ratio=decrease:force_divisible_by=2`];
7210
- }
7211
- /** Rate-control args for an encode plan. */
7212
- function buildRateControlArgs(video) {
7213
- const kbps = video.bitrateKbps;
7214
- if (kbps === void 0) return [];
7215
- const rc = video.rateControl ?? {
7216
- kind: "cap",
7217
- vbvSeconds: 2
7218
- };
7219
- const bufsize = Math.max(1, Math.round(kbps * rc.vbvSeconds));
7220
- return [
7221
- ...rc.kind === "cbr" ? ["-b:v", `${kbps}k`] : [],
7222
- "-maxrate",
7223
- `${kbps}k`,
7224
- "-bufsize",
7225
- `${bufsize}k`
7226
- ];
7227
- }
7228
- /** The whole video block (`-vf` … `-c:v` … knobs), after `-i`. */
7229
- function buildVideoArgs(video, outputArgs) {
7230
- if (video.kind === "copy") return [
7231
- "-c:v",
7232
- "copy",
7233
- ...video.bitstreamFilter ? ["-bsf:v", video.bitstreamFilter] : []
7234
- ];
7235
- const args = [
7236
- ...buildVideoFilterArgs(video.scale, outputArgs),
7237
- "-c:v",
7238
- video.encoder
7239
- ];
7240
- if (video.preset !== void 0) args.push("-preset", video.preset);
7241
- if (video.tune !== void 0) args.push("-tune", video.tune);
7242
- if (video.profile !== void 0) args.push("-profile:v", video.profile);
7243
- if (video.level !== void 0) args.push("-level", video.level);
7244
- if (video.pixelFormat !== void 0) args.push("-pix_fmt", video.pixelFormat);
7245
- if (video.fps !== void 0) args.push("-r", String(video.fps));
7246
- if (video.gopFrames !== void 0) args.push("-g", String(video.gopFrames));
7247
- if (video.forceKeyFramesSeconds !== void 0) args.push("-force_key_frames", `expr:gte(t,n_forced*${video.forceKeyFramesSeconds})`);
7248
- if (video.bf !== void 0) args.push("-bf", String(video.bf));
7249
- args.push(...buildRateControlArgs(video));
7250
- if (video.bitstreamFilter !== void 0) args.push("-bsf:v", video.bitstreamFilter);
7251
- return args;
7252
- }
7253
- /** The whole audio block, after `-i`. */
7254
- function buildAudioArgs(audio) {
7255
- if (audio.kind === "none") return ["-an"];
7256
- if (audio.kind === "copy") return ["-c:a", "copy"];
7257
- const args = [];
7258
- if (audio.filter !== void 0) args.push("-af", audio.filter);
7259
- args.push("-c:a", AUDIO_ENCODER_BY_CODEC[audio.codec]);
7260
- if (audio.application !== void 0) args.push("-application", audio.application);
7261
- if (audio.frameDurationMs !== void 0) args.push("-frame_duration", String(audio.frameDurationMs));
7262
- if (audio.globalHeader === true) args.push("-flags", "+global_header");
7263
- if (audio.sampleRateHz !== void 0) args.push("-ar", String(audio.sampleRateHz));
7264
- if (audio.bitrateKbps !== void 0) args.push("-b:a", `${audio.bitrateKbps}k`);
7265
- if (audio.vbvBufferKbits !== void 0) args.push("-bufsize", `${audio.vbvBufferKbits}k`);
7266
- if (audio.channels !== void 0) args.push("-ac", String(audio.channels));
7267
- return args;
7268
- }
7269
- /** RTP output-leg args (`-payload_type`, `-ssrc`, `-sdp_file`, `-f rtp <url>`). */
7270
- function buildRtpOutputArgs(out) {
7271
- const args = [];
7272
- if (out.payloadType !== void 0) args.push("-payload_type", String(out.payloadType));
7273
- if (out.ssrc !== void 0) args.push("-ssrc", String(out.ssrc));
7274
- if (out.sdpFile !== void 0) args.push("-sdp_file", out.sdpFile);
7275
- args.push("-f", "rtp", out.url);
7276
- return args;
7277
- }
7278
- /** `true` when the sink is a raw elementary bytestream that cannot mux audio. */
7279
- function isElementaryVideoSink(sink) {
7280
- return sink.kind === "stdout" && (sink.container === "h264" || sink.container === "hevc");
7281
- }
7282
- /**
7283
- * The fragmented-MP4 muxer flags, in the order the recorder has proven them
7284
- * (`recorder/addon/ffmpeg-args.ts` passes the same `movflags` string through
7285
- * `-segment_format_options`, across every vendor in the fleet):
7286
- *
7287
- * - `frag_keyframe` — cut a fragment at each key frame, so every fragment
7288
- * opens on a sync sample. HKSV's whole requirement.
7289
- * - `empty_moov` — write `ftyp`+`moov` up front with no samples in it, which
7290
- * is what makes the head a standalone INITIALISATION segment.
7291
- * - `default_base_moof` — fragment offsets are self-relative, so a fragment is
7292
- * demuxable without the bytes that preceded it. D31's byte-range read path
7293
- * depends on exactly this property of the recorder's segments.
7294
- */
7295
- var FMP4_MOVFLAGS = "+frag_keyframe+empty_moov+default_base_moof";
7296
- /**
7297
- * The terminal sink args for every non-`rtp-outputs` sink. Exhaustive over the
7298
- * union so a new member cannot fall through to `['-f', container, 'pipe:1']`,
7299
- * which is what a plain `container` read would have done for `mp4` — a valid
7300
- * argv that writes a NON-fragmented, unseekable-to-a-pipe MP4 and produces one
7301
- * unusable byte stream.
7302
- */
7303
- function buildStdoutOrRtspSinkArgs(sink) {
7304
- if (sink.kind === "rtsp-listen") return [
7305
- "-f",
7306
- "rtsp",
7307
- "-rtsp_transport",
7308
- "tcp",
7309
- "-rtsp_flags",
7310
- "listen",
7311
- sink.url
7312
- ];
7313
- if (sink.kind === "rtp-outputs") return [];
7314
- return sink.container === "mp4" ? buildFmp4SinkArgs(sink) : [
7315
- "-f",
7316
- sink.container,
7317
- "pipe:1"
7318
- ];
7319
- }
7320
- /**
7321
- * How far BELOW the negotiated fragment length `-min_frag_duration` is set.
7322
- *
7323
- * `-min_frag_duration` refuses to cut before that much media has accumulated,
7324
- * and then waits for the next key frame. Set to exactly `fragmentMs`, the
7325
- * commonest camera configuration in existence — a key-frame grid EQUAL to the
7326
- * requested fragment length — lands the deadline on the same instant as the key
7327
- * frame, loses the race, and skips to the following one: **every fragment comes
7328
- * out at twice the requested length.**
7329
- *
7330
- * Measured on the live fleet 2026-08-07, camera 615, `-c:v copy` (D84):
7331
- *
7332
- * | slot | GOP | `-min_frag_duration` | median gap |
7333
- * | --- | --- | --- | --- |
7334
- * | 1280×720 | 40 f @ 10 fps = 4.0 s | 4000 ms | **7944 ms** |
7335
- * | 1280×720 | 40 f @ 10 fps = 4.0 s | 3600 ms | 3973 ms |
7336
- * | 3840×2160 | 100 f @ 25 fps = 4.0 s | 4000 ms | 8042 ms |
7337
- * | 3840×2160 | 100 f @ 25 fps = 4.0 s | 3600 ms | 3998 ms |
7338
- *
7339
- * A doubled fragment is not a cosmetic overshoot: HKSV requires every fragment
7340
- * to be no longer than the length the controller SELECTED, so the shipped-but-
7341
- * inert phase-1 sink would have violated the contract on its first real clip.
7342
- *
7343
- * 10 % is chosen against the two failures either side of it. Too small and
7344
- * ordinary jitter (measured spread 3953-4096 ms) re-loses the race; too large
7345
- * and a source with a key frame slightly EARLY than the grid gets cut there,
7346
- * yielding a short fragment for no reason.
7347
- */
7348
- var FMP4_MIN_FRAG_MARGIN = .9;
7349
- /** `-movflags … -min_frag_duration <us> -f mp4 pipe:1`. */
7350
- function buildFmp4SinkArgs(sink) {
7351
- return [
7352
- "-movflags",
7353
- FMP4_MOVFLAGS,
7354
- "-min_frag_duration",
7355
- String(Math.max(0, Math.round(sink.fragmentMs * FMP4_MIN_FRAG_MARGIN * 1e3))),
7356
- "-f",
7357
- "mp4",
7358
- "pipe:1"
7359
- ];
7360
- }
7361
- /**
7362
- * A second output mapping source audio to RTP-over-UDP. `0:a:0?` makes the
7363
- * audio optional so a source with no audio skips it instead of failing the
7364
- * whole invocation.
7365
- */
7366
- function buildAudioSidecarArgs(sidecar) {
7367
- return [
7368
- "-map",
7369
- "0:a:0?",
7370
- ...buildAudioArgs(sidecar.codec === "pcma" ? {
7371
- kind: "encode",
7372
- codec: "pcma",
7373
- sampleRateHz: 8e3,
7374
- channels: 1
7375
- } : AUDIO_PRESETS[sidecar.codec]),
7376
- ...buildRtpOutputArgs({
7377
- url: sidecar.rtpUrl,
7378
- sdpFile: sidecar.sdpFile
7379
- })
7380
- ];
7381
- }
7382
- /**
7383
- * Assemble the full ffmpeg argument list. Layout:
7384
- *
7385
- * -hide_banner -loglevel <level>
7386
- * [-hwaccel <backend|auto>] ─┐ INPUT options — strictly before -i.
7387
- * [<input.extraArgs>] │
7388
- * [-fflags <flag>…] │
7389
- * [-rtsp_transport tcp] │
7390
- * -i <url> ─┘
7391
- * <video block> <threads> <audio block> ─┐ OUTPUT options.
7392
- * <consumer outputArgs verbatim> │
7393
- * <sink> ─┘ terminal
7394
- */
7395
- function buildFfmpegArgs(inv) {
7396
- const head = [...logBannerArgs(inv.logLevel), ...buildInputArgs(inv.input, inv.decodeHwAccel)];
7397
- const threadArgs = inv.threadCount > 0 ? ["-threads", String(inv.threadCount)] : [];
7398
- if (inv.sink.kind === "rtp-outputs") {
7399
- const videoLeg = inv.sink.video ? [
7400
- "-an",
7401
- "-map",
7402
- "0:v:0",
7403
- ...buildVideoArgs(inv.video, inv.outputArgs),
7404
- ...threadArgs,
7405
- ...inv.outputArgs,
7406
- ...buildRtpOutputArgs(inv.sink.video)
7407
- ] : [];
7408
- const audioLeg = inv.sink.audio ? [
7409
- "-vn",
7410
- "-map",
7411
- "0:a:0?",
7412
- ...buildAudioArgs(inv.audio),
7413
- ...buildRtpOutputArgs(inv.sink.audio)
7414
- ] : [];
7415
- return [
7416
- ...head,
7417
- ...videoLeg,
7418
- ...audioLeg
7419
- ];
7420
- }
7421
- const audioArgs = isElementaryVideoSink(inv.sink) ? ["-an"] : buildAudioArgs(inv.audio);
7422
- const sinkArgs = buildStdoutOrRtspSinkArgs(inv.sink);
7423
- return [
7424
- ...head,
7425
- ...buildVideoArgs(inv.video, inv.outputArgs),
7426
- ...threadArgs,
7427
- ...audioArgs,
7428
- ...inv.outputArgs,
7429
- ...sinkArgs,
7430
- ...inv.audioSidecar ? buildAudioSidecarArgs(inv.audioSidecar) : []
7431
- ];
7432
- }
7433
- var DEFAULT_MAX_UNIT_BYTES = 16 * 1024 * 1024;
7434
- /** Header size for a normal box, and for one carrying a 64-bit `largesize`. */
7435
- var BOX_HEADER_BYTES = 8;
7436
- var LARGE_BOX_HEADER_BYTES = 16;
7437
- var Fmp4BoxSplitter = class {
7438
- maxUnitBytes;
7439
- /** Bytes of the CURRENT unit plus any partial box after it. */
7440
- buffer = new Uint8Array(0);
7441
- /** Where the current unit starts inside {@link buffer}. */
7442
- unitStart = 0;
7443
- /** Where the box scanner has reached inside {@link buffer}. */
7444
- cursor = 0;
7445
- state = "init";
7446
- nextSequence = 0;
7447
- faultReason = null;
7448
- interstitial = /* @__PURE__ */ new Set();
7449
- constructor(options = {}) {
7450
- this.maxUnitBytes = options.maxUnitBytes ?? DEFAULT_MAX_UNIT_BYTES;
7451
- }
7452
- /**
7453
- * Non-null once the stream cannot be split. The splitter emits nothing
7454
- * further, so a caller polls this to kill the child rather than watching a
7455
- * silent stall — a fragmenter that quietly stops producing looks exactly like
7456
- * a camera with no motion.
7457
- */
7458
- get fault() {
7459
- return this.faultReason;
7460
- }
7461
- /** Bytes currently held. The memory bound, observable rather than asserted. */
7462
- get pendingBytes() {
7463
- return this.buffer.length - this.unitStart;
7464
- }
7465
- /**
7466
- * Top-level box types seen BETWEEN fragments and discarded — `mfra`, `free`,
7467
- * a stray `sidx`. Reported rather than dropped in silence: they are legal and
7468
- * useless to a fragment consumer, but a type nobody expected showing up here
7469
- * is the first symptom of a muxer that is not writing what we think it is.
7470
- */
7471
- get discardedInterstitialTypes() {
7472
- return [...this.interstitial];
7473
- }
7474
- /**
7475
- * Feed bytes; get back whatever units completed. Returns `[]` once faulted.
7476
- */
7477
- push(chunk) {
7478
- if (this.faultReason !== null || chunk.length === 0) return [];
7479
- this.append(chunk);
7480
- if (this.pendingBytes > this.maxUnitBytes) return this.fail(`a single fMP4 unit exceeded ${this.maxUnitBytes} bytes — this stream is not fragmented`);
7481
- return this.drainBoxes();
7482
- }
7483
- append(chunk) {
7484
- if (this.buffer.length === 0) {
7485
- this.buffer = chunk.slice();
7486
- return;
7487
- }
7488
- const next = new Uint8Array(this.buffer.length + chunk.length);
7489
- next.set(this.buffer, 0);
7490
- next.set(chunk, this.buffer.length);
7491
- this.buffer = next;
7492
- }
7493
- /** Consume every COMPLETE top-level box now in the buffer. */
7494
- drainBoxes() {
7495
- const units = [];
7496
- for (;;) {
7497
- const header = this.readHeader();
7498
- if (this.faultReason !== null) return units;
7499
- if (header === null) break;
7500
- if (this.cursor + header.totalBytes > this.buffer.length) break;
7501
- const boxStart = this.cursor;
7502
- const boxEnd = boxStart + header.totalBytes;
7503
- this.cursor = boxEnd;
7504
- const unit = this.consumeBox(header.type, boxStart, boxEnd);
7505
- if (this.faultReason !== null) return units;
7506
- if (unit !== null) units.push(unit);
7507
- }
7508
- this.compact();
7509
- return units;
7510
- }
7511
- /**
7512
- * Apply one box to the state machine. Returns a unit when this box CLOSED
7513
- * one, `null` otherwise.
7514
- */
7515
- consumeBox(type, boxStart, boxEnd) {
7516
- if (this.state === "init") {
7517
- if (type !== "moof") return null;
7518
- if (boxStart === this.unitStart) {
7519
- this.fail("a moof arrived before any initialisation box — there is no ftyp/moov to send");
7520
- return null;
7521
- }
7522
- const init = this.emit("init", this.unitStart, boxStart);
7523
- this.unitStart = boxStart;
7524
- this.state = "fragment";
7525
- return init;
7526
- }
7527
- if (this.state === "idle") {
7528
- if (type !== "moof") {
7529
- this.interstitial.add(type);
7530
- this.unitStart = boxEnd;
7531
- return null;
7532
- }
7533
- this.unitStart = boxStart;
7534
- this.state = "fragment";
7535
- return null;
7536
- }
7537
- if (type !== "mdat") return null;
7538
- const fragment = this.emit("fragment", this.unitStart, boxEnd);
7539
- this.unitStart = boxEnd;
7540
- this.state = "idle";
7541
- return fragment;
7542
- }
7543
- /**
7544
- * Parse the header at {@link cursor}, or `null` when too few bytes have
7545
- * arrived to know. Faults on a size the splitter cannot honour.
7546
- */
7547
- readHeader() {
7548
- const available = this.buffer.length - this.cursor;
7549
- if (available < BOX_HEADER_BYTES) return null;
7550
- const view = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
7551
- const size = view.getUint32(this.cursor);
7552
- const type = String.fromCharCode(this.buffer[this.cursor + 4] ?? 0, this.buffer[this.cursor + 5] ?? 0, this.buffer[this.cursor + 6] ?? 0, this.buffer[this.cursor + 7] ?? 0);
7553
- if (size === 0) {
7554
- this.fail(`box "${type}" declares size 0 (to EOF) — an unbounded box cannot be fragmented`);
7555
- return null;
7556
- }
7557
- if (size === 1) {
7558
- if (available < LARGE_BOX_HEADER_BYTES) return null;
7559
- const large = view.getBigUint64(this.cursor + BOX_HEADER_BYTES);
7560
- if (large > BigInt(this.maxUnitBytes)) {
7561
- this.fail(`box "${type}" declares ${large} bytes, over the ${this.maxUnitBytes} byte bound`);
7562
- return null;
7563
- }
7564
- return {
7565
- type,
7566
- totalBytes: Number(large)
7567
- };
7568
- }
7569
- if (size < BOX_HEADER_BYTES) {
7570
- this.fail(`box "${type}" declares an impossible size of ${size} bytes`);
7571
- return null;
7572
- }
7573
- return {
7574
- type,
7575
- totalBytes: size
7576
- };
7577
- }
7578
- emit(kind, start, end) {
7579
- const sequence = this.nextSequence;
7580
- this.nextSequence += 1;
7581
- return {
7582
- kind,
7583
- data: this.buffer.slice(start, end),
7584
- sequence
7585
- };
7586
- }
7587
- /**
7588
- * Drop everything already emitted or discarded. Without this the buffer is
7589
- * the whole stream and the process dies in hours, not minutes.
7590
- */
7591
- compact() {
7592
- if (this.unitStart === 0) return;
7593
- this.buffer = this.buffer.slice(this.unitStart);
7594
- this.cursor -= this.unitStart;
7595
- this.unitStart = 0;
7596
- }
7597
- fail(reason) {
7598
- this.faultReason = reason;
7599
- this.buffer = new Uint8Array(0);
7600
- this.unitStart = 0;
7601
- this.cursor = 0;
7602
- return [];
7603
- }
7604
- };
7605
- //#endregion
7606
7138
  //#region ../types/dist/err-msg-IQTHeDzc.mjs
7607
7139
  /**
7608
7140
  import { errMsg } from '@camstack/types'
@@ -9624,6 +9156,69 @@ var StreamFormatSchema = _enum([
9624
9156
  "mjpeg",
9625
9157
  "rtsp"
9626
9158
  ]);
9159
+ /** A container `produceEventMedia` can emit. */
9160
+ var EventMediaKindSchema = _enum(["mp4", "gif"]);
9161
+ /**
9162
+ * One produced artifact, referenced by HANDLE.
9163
+ *
9164
+ * Never inline bytes: a produced clip is 200 KB–5 MB and every consumer of this
9165
+ * method is in another runner ([D9](../../../../docs/decisions/adr-0009.md),
9166
+ * [D18](../../../../docs/decisions/adr-0018.md) — cross-process media is fetched
9167
+ * on demand, compressed, by handle). `bytes` is here so a caller can decide
9168
+ * whether it wants the fetch at all.
9169
+ */
9170
+ var EventMediaArtifactSchema = object({
9171
+ kind: EventMediaKindSchema,
9172
+ /** Opaque, single-camera, short-lived. Redeem with `fetchEventMedia`. */
9173
+ handle: string(),
9174
+ /**
9175
+ * The node holding the bytes — the ROUTING key for `fetchEventMedia`.
9176
+ *
9177
+ * `stream-broker` is a singleton cap and an unpinned call never leaves the
9178
+ * hub, so a handle produced on an agent's broker would be redeemed against
9179
+ * the hub's store and come back `null`. Same contract, same field name and
9180
+ * the same reason as `FrameHandleSchema.nodeId`: the producer stamps where it
9181
+ * lives and the consumer pins to it.
9182
+ */
9183
+ nodeId: string(),
9184
+ mime: string(),
9185
+ bytes: number().int(),
9186
+ width: number().int(),
9187
+ height: number().int()
9188
+ });
9189
+ /**
9190
+ * What a production actually covered — the answer to the only question an
9191
+ * operator asks about a notification clip.
9192
+ *
9193
+ * `fromTs`/`toTs` are WALL CLOCK, derived from the ring's own packet timeline,
9194
+ * so a caller can state "this clip starts 4.1 s before the event" instead of
9195
+ * inferring it from a duration. A production whose `fromTs` is later than the
9196
+ * event is a production with no pre-roll, and that is exactly the defect this
9197
+ * method exists to make visible rather than plausible.
9198
+ */
9199
+ var EventMediaCoverageSchema = object({
9200
+ fromTs: number(),
9201
+ toTs: number(),
9202
+ /** Encoded packets in the muxed window. */
9203
+ packets: number().int()
9204
+ });
9205
+ /**
9206
+ * The result of ONE cut, in every container the caller asked for.
9207
+ *
9208
+ * Every artifact in `media` came out of the SAME window of the SAME rendition —
9209
+ * that is the whole reason this is one method rather than one call per format.
9210
+ * A consumer attaching a gif and a video can no longer show two different
9211
+ * moments, because it never chose two sources.
9212
+ */
9213
+ var EventMediaProductionSchema = object({
9214
+ media: array(EventMediaArtifactSchema).readonly(),
9215
+ coverage: EventMediaCoverageSchema,
9216
+ /** The rendition actually cut from — what the default or the fallback chose. */
9217
+ profile: CamProfileSchema,
9218
+ /** `copy` = the camera's own H.264, untouched. `encode` = re-encoded (H.265
9219
+ * source, a downscale, or a playback rate other than 1). */
9220
+ video: _enum(["copy", "encode"])
9221
+ });
9627
9222
  var RtspRestreamEntrySchema = object({
9628
9223
  brokerId: string(),
9629
9224
  url: string(),
@@ -10023,6 +9618,34 @@ method(object({
10023
9618
  }), {
10024
9619
  kind: "mutation",
10025
9620
  auth: "admin"
9621
+ }), method(object({
9622
+ deviceId: number(),
9623
+ /** Absent = the largest H.264 rendition at or below 1080p, which is
9624
+ * also the one that can be copied. Falls back to whatever the ring
9625
+ * actually retained, and the answer says which. */
9626
+ profile: CamProfileSchema.optional(),
9627
+ aroundMs: number(),
9628
+ preSeconds: number().min(0).max(20).default(4),
9629
+ postSeconds: number().min(0).max(20).default(6),
9630
+ kinds: array(EventMediaKindSchema).min(1).default(["mp4"]),
9631
+ /** GIF geometry. The video keeps the source's own. */
9632
+ gifMaxWidth: number().int().min(120).max(1280).default(640),
9633
+ gifFps: number().int().min(1).max(15).default(8),
9634
+ /**
9635
+ * Playback rate, applied to EVERY container so they stay one clip.
9636
+ * `1` is real time and is what allows the copy branch.
9637
+ */
9638
+ speed: number().min(1).max(8).default(1)
9639
+ }), EventMediaProductionSchema, {
9640
+ kind: "mutation",
9641
+ auth: "admin"
9642
+ }), method(object({ handle: string() }), object({
9643
+ base64: string(),
9644
+ mime: string(),
9645
+ bytes: number().int()
9646
+ }).nullable(), {
9647
+ kind: "mutation",
9648
+ auth: "admin"
10026
9649
  }), method(_void(), array(CameraStreamSchema).readonly()), method(_void(), array(ProfileSlotSchema).readonly()), method(object({ brokerId: string() }), BrokerStatsSchema), method(object({ brokerId: string() }), object({
10027
9650
  probed: boolean(),
10028
9651
  summary: string()
@@ -32587,6 +32210,12 @@ Object.freeze({
32587
32210
  addonId: null,
32588
32211
  access: "create"
32589
32212
  },
32213
+ "streamBroker.fetchEventMedia": {
32214
+ capName: "stream-broker",
32215
+ capScope: "system",
32216
+ addonId: null,
32217
+ access: "create"
32218
+ },
32590
32219
  "streamBroker.getAllRtspEntries": {
32591
32220
  capName: "stream-broker",
32592
32221
  capScope: "system",
@@ -32671,6 +32300,12 @@ Object.freeze({
32671
32300
  addonId: null,
32672
32301
  access: "create"
32673
32302
  },
32303
+ "streamBroker.produceEventMedia": {
32304
+ capName: "stream-broker",
32305
+ capScope: "system",
32306
+ addonId: null,
32307
+ access: "create"
32308
+ },
32674
32309
  "streamBroker.publishCameraStream": {
32675
32310
  capName: "stream-broker",
32676
32311
  capScope: "system",
@@ -33680,4 +33315,4 @@ DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
33680
33315
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
33681
33316
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
33682
33317
  //#endregion
33683
- export { sleep as $, encodeVectorBase64 as A, vectorDimFromBase64 as B, alarmPanelCapability as C, customAction as D, cosineSimilarity as E, notificationRulesCapability as F, buildFfmpegArgs as G, zoneAnalyticsCapability as H, pipelineAnalyticsCapability as I, DeviceType as J, isSoftwareDecode as K, plateGalleryCapability as L, hfModelUrl as M, isScheduleActive as N, defineCustomActions as O, kebabToCamel as P, nodePin as Q, readDeviceStateFrom as R, addonWidgetsSourceCapability as S, buildEventKindDescriptor as T, errMsg as U, videoclipsCapability as V, Fmp4BoxSplitter as W, hydrateSchema as X, createEvent as Y, isDeviceScopedCap as Z, OpsLogEntrySchema as _, LabelAttributionSchema as a, object as at, TimelapseRuleSchema as b, NC_TAXONOMY as c, unknown as ct, NcRulePatchSchema as d, _enum as et, NcRuleSchema as f, NcTaxonomySchema as g, NcSnoozeSuppressedSchema as h, EVENT_PAD_MS as i, number as it, faceGalleryCapability as j, embeddingEncoderCapability as k, NcConditionDescriptorSchema as l, EventCategory as lt, NcSnoozeSchema as m, DEFAULT_EVENT_COLOR as n, boolean as nt, MACRO_LABELS as o, record as ot, NcSnoozeInputSchema as p, BaseAddon as q, EVENT_KIND_BY_CAP as r, literal as rt, NC_CONDITION_CATALOG as s, string as st, BaseDevice as t, array as tt, NcRuleInputSchema as u, RetrainStatusSchema as v, audioMetricsCapability as w, TrackSourceSchema as x, TimelapseRuleInputSchema as y, subKindsOf as z };
33318
+ export { boolean as $, encodeVectorBase64 as A, vectorDimFromBase64 as B, alarmPanelCapability as C, customAction as D, cosineSimilarity as E, notificationRulesCapability as F, DeviceType as G, zoneAnalyticsCapability as H, pipelineAnalyticsCapability as I, isDeviceScopedCap as J, createEvent as K, plateGalleryCapability as L, hfModelUrl as M, isScheduleActive as N, defineCustomActions as O, kebabToCamel as P, array as Q, readDeviceStateFrom as R, addonWidgetsSourceCapability as S, buildEventKindDescriptor as T, errMsg as U, videoclipsCapability as V, BaseAddon as W, sleep as X, nodePin as Y, _enum as Z, OpsLogEntrySchema as _, LabelAttributionSchema as a, unknown as at, TimelapseRuleSchema as b, NC_TAXONOMY as c, NcRulePatchSchema as d, literal as et, NcRuleSchema as f, NcTaxonomySchema as g, NcSnoozeSuppressedSchema as h, EVENT_PAD_MS as i, string as it, faceGalleryCapability as j, embeddingEncoderCapability as k, NcConditionDescriptorSchema as l, NcSnoozeSchema as m, DEFAULT_EVENT_COLOR as n, object as nt, MACRO_LABELS as o, EventCategory as ot, NcSnoozeInputSchema as p, hydrateSchema as q, EVENT_KIND_BY_CAP as r, record as rt, NC_CONDITION_CATALOG as s, BaseDevice as t, number as tt, NcRuleInputSchema as u, RetrainStatusSchema as v, audioMetricsCapability as w, TrackSourceSchema as x, TimelapseRuleInputSchema as y, subKindsOf as z };