@camstack/addon-pipeline 1.2.274 → 1.2.275
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/audio-analyzer/index.js +2 -2
- package/dist/audio-analyzer/index.mjs +2 -2
- package/dist/{default-detection-model-CAWhHQo2.js → default-detection-model-6lCvep7n.js} +1 -1
- package/dist/{default-detection-model-BXwE-Dvo.mjs → default-detection-model-dQSwHHfx.mjs} +1 -1
- package/dist/detection-pipeline/index.js +4 -4
- package/dist/detection-pipeline/index.mjs +4 -4
- package/dist/{dist-g5MfpiBh.mjs → dist-C1pCVJk7.mjs} +440 -32
- package/dist/{dist-k6Vu-AhZ.js → dist-NYjn7hkE.js} +469 -31
- package/dist/motion-wasm/index.js +1 -1
- package/dist/motion-wasm/index.mjs +1 -1
- package/dist/{node-BXsHQH5h.mjs → node--UY0iepi.mjs} +1 -1
- package/dist/{node--u_jUObS.js → node-CVYY8a4y.js} +1 -1
- package/dist/pipeline-runner/index.js +3 -3
- package/dist/pipeline-runner/index.mjs +3 -3
- package/dist/{process-memory-Gl3EowL-.mjs → process-memory-BQOfL3Ig.mjs} +1 -1
- package/dist/{process-memory-DN7opum2.js → process-memory-DDvuSEMJ.js} +1 -1
- package/dist/recorder/index.js +495 -35
- package/dist/recorder/index.mjs +495 -35
- package/dist/{segment-demux-js-sYP_jndp.mjs → segment-demux-js-B0_aAzN0.mjs} +1 -1
- package/dist/{segment-demux-js-DHX8o8pI.js → segment-demux-js-DVupBBc4.js} +1 -1
- package/dist/stream-broker/_stub.js +2 -2
- package/dist/stream-broker/{_virtual_mf-localSharedImportMap___mfe_internal__addon_stream_broker_widgets-CEy8IryH.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_stream_broker_widgets-BrNGbvkl.mjs} +2 -2
- package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-BV2tQ1w3.mjs +26 -0
- package/dist/stream-broker/{_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-MU3_q1MX.mjs → _virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-BnLVuoDg.mjs} +1 -1
- package/dist/stream-broker/demux-worker-child.js +1 -1
- package/dist/stream-broker/demux-worker-child.mjs +1 -1
- package/dist/stream-broker/{hostInit-UKNN4qes.mjs → hostInit-CSJt3rp0.mjs} +2 -2
- package/dist/stream-broker/index.js +526 -69
- package/dist/stream-broker/index.mjs +526 -69
- package/dist/stream-broker/remoteEntry.js +1 -1
- package/package.json +1 -1
- package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-BlXyfeXU.mjs +0 -26
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-emK7D4bc.js");
|
|
2
|
-
const require_dist = require("./dist-
|
|
2
|
+
const require_dist = require("./dist-NYjn7hkE.js");
|
|
3
3
|
let node_fs = require("node:fs");
|
|
4
4
|
node_fs = require_chunk.__toESM(node_fs);
|
|
5
5
|
let node_child_process = require("node:child_process");
|
package/dist/recorder/index.js
CHANGED
|
@@ -3,8 +3,8 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
const require_chunk = require("../chunk-emK7D4bc.js");
|
|
6
|
-
const require_dist = require("../dist-
|
|
7
|
-
const require_node = require("../node
|
|
6
|
+
const require_dist = require("../dist-NYjn7hkE.js");
|
|
7
|
+
const require_node = require("../node-CVYY8a4y.js");
|
|
8
8
|
const require_hub_hostname = require("../hub-hostname-DAJXlOgV.js");
|
|
9
9
|
const require_restream_intent = require("../restream-intent-7uDNqMKs.js");
|
|
10
10
|
const require_retire_root_keys = require("../retire-root-keys-Csb8z2f3.js");
|
|
@@ -6129,6 +6129,21 @@ function errnoCode(raw) {
|
|
|
6129
6129
|
}
|
|
6130
6130
|
//#endregion
|
|
6131
6131
|
//#region src/recorder/addon/export-engine.ts
|
|
6132
|
+
/**
|
|
6133
|
+
* How long an operator's authorised wake stays spendable.
|
|
6134
|
+
*
|
|
6135
|
+
* One authorised yes is ONE wake (D558 § 5.2 rule 3), and the two ways a job
|
|
6136
|
+
* outlives its yes without anybody meaning it are both real here: it can sit
|
|
6137
|
+
* behind {@link EXPORT_MAX_CONCURRENT} long renders, and it can be re-queued
|
|
6138
|
+
* after a restart. Five minutes is generous against a job measured at 4–6 s
|
|
6139
|
+
* end to end and short enough that a camera is never woken for a tap the
|
|
6140
|
+
* operator has forgotten making.
|
|
6141
|
+
*
|
|
6142
|
+
* Past it the export FAILS with `wake-expired` — a named row the operator can
|
|
6143
|
+
* retry with one tap, which re-asks for the authorisation — rather than
|
|
6144
|
+
* silently waking the camera on a yes from an hour ago.
|
|
6145
|
+
*/
|
|
6146
|
+
var CLIP_WAKE_TTL_MS = 5 * 6e4;
|
|
6132
6147
|
/** Stderr lines retained for the failure LOG. ffmpeg prints one line per failed
|
|
6133
6148
|
* segment before the decisive "Error opening input" summary, so a short tail can
|
|
6134
6149
|
* push the actual cause out of the window (it very nearly did — the line that
|
|
@@ -6137,6 +6152,42 @@ function errnoCode(raw) {
|
|
|
6137
6152
|
var STDERR_TAIL_LINES$1 = 40;
|
|
6138
6153
|
var TIME_RE = /time=(\d+):(\d+):(\d+(?:\.\d+)?)/;
|
|
6139
6154
|
/**
|
|
6155
|
+
* How far a delivered clip's duration may sit from its catalog span before it
|
|
6156
|
+
* is worth a line. A remux rounds, a GOP boundary moves a fraction of a
|
|
6157
|
+
* second; two seconds is past both and well under D568's own "materially
|
|
6158
|
+
* shorter" retry threshold, so this reports a disagreement the PRODUCER
|
|
6159
|
+
* already decided to serve rather than second-guessing its completion rule.
|
|
6160
|
+
*/
|
|
6161
|
+
var CLIP_DURATION_TOLERANCE_MS = 2e3;
|
|
6162
|
+
/**
|
|
6163
|
+
* The source id of the recorder's OWN `videoclips` provider — a visit over
|
|
6164
|
+
* footage we wrote, not a file a camera holds (D560).
|
|
6165
|
+
*
|
|
6166
|
+
* Duplicating the literal rather than importing `videoclips-provider.ts`
|
|
6167
|
+
* keeps the engine free of the provider (and of the analytics event reads it
|
|
6168
|
+
* carries); the two are pinned together by
|
|
6169
|
+
* `export-engine-clip-fetch.spec.ts`.
|
|
6170
|
+
*/
|
|
6171
|
+
var ANALYTICS_CLIP_SOURCE = "analytics";
|
|
6172
|
+
/**
|
|
6173
|
+
* Read a producer's refusal as one of the named clip-export failures.
|
|
6174
|
+
*
|
|
6175
|
+
* A producer that speaks the vocabulary is believed — `clipExportFailureOf`
|
|
6176
|
+
* recovers its token, so a `sleeping` stays `sleeping` all the way to the
|
|
6177
|
+
* modal. Anything else is `fetch-failed` **with the producer's words kept
|
|
6178
|
+
* verbatim**: inventing a more specific token from prose is how a surface's
|
|
6179
|
+
* table came to render every refusal on this fleet as `Refused: <prose>`
|
|
6180
|
+
* (ClipStillRefusalCode's own docblock). The one exception is the size bound,
|
|
6181
|
+
* which the producer states in numbers rather than in a token, and which the
|
|
6182
|
+
* operator must be able to tell from a network failure.
|
|
6183
|
+
*/
|
|
6184
|
+
function classifyClipFetchFailure(detail) {
|
|
6185
|
+
const spoken = require_dist.clipExportFailureOf(detail);
|
|
6186
|
+
if (spoken !== null) return spoken;
|
|
6187
|
+
if (/too large/i.test(detail)) return "too-large-to-transfer";
|
|
6188
|
+
return "fetch-failed";
|
|
6189
|
+
}
|
|
6190
|
+
/**
|
|
6140
6191
|
* The floor under which an MP4 cannot hold a single decodable frame.
|
|
6141
6192
|
*
|
|
6142
6193
|
* **Exit 0 is not the same question as "the file holds a video".** A timelapse
|
|
@@ -6218,6 +6269,13 @@ var ExportEngine = class {
|
|
|
6218
6269
|
}
|
|
6219
6270
|
}
|
|
6220
6271
|
async render(id) {
|
|
6272
|
+
const existing = await getExportRecord(this.deps.state, id);
|
|
6273
|
+
if (!existing) return;
|
|
6274
|
+
const subject = require_dist.exportSubjectOf(existing);
|
|
6275
|
+
if (subject.kind === "clip" && subject.source !== ANALYTICS_CLIP_SOURCE) {
|
|
6276
|
+
await this.fetchClip(id, existing, subject);
|
|
6277
|
+
return;
|
|
6278
|
+
}
|
|
6221
6279
|
const rec = await patchExport(this.deps.state, id, {
|
|
6222
6280
|
state: "rendering",
|
|
6223
6281
|
progressPct: 0
|
|
@@ -6246,6 +6304,187 @@ var ExportEngine = class {
|
|
|
6246
6304
|
}
|
|
6247
6305
|
}
|
|
6248
6306
|
/**
|
|
6307
|
+
* The CLIP branch: one by-handle fetch, under a bound, written straight to
|
|
6308
|
+
* the export path. No playlist, no ffmpeg, no second completion rule.
|
|
6309
|
+
*
|
|
6310
|
+
* The recorder cannot produce these bytes itself — talking to the camera is
|
|
6311
|
+
* the owning addon's monopoly (one session per host, the sleep gate before
|
|
6312
|
+
* `getApi()`, a cmd-5 transfer whose completion is an idle window proved
|
|
6313
|
+
* against the catalog span, D549 17 / D568) — and there is no addon→addon
|
|
6314
|
+
* byte transport, so the producer's own cap read is the seam (D558 § 3).
|
|
6315
|
+
*
|
|
6316
|
+
* `progressPct` stays `null` for the whole fetch. The job is measured at
|
|
6317
|
+
* 4–6 s end to end and only two of its phases have a real denominator; a
|
|
6318
|
+
* ramp would be a number nothing measured (D558 § 5.1).
|
|
6319
|
+
*
|
|
6320
|
+
* Every exit is named. A branch that accepts work and produces nothing is
|
|
6321
|
+
* the branch this repo keeps losing work in (D391), and a clip export has
|
|
6322
|
+
* five such branches a footage render does not have.
|
|
6323
|
+
*/
|
|
6324
|
+
async fetchClip(id, rec, subject) {
|
|
6325
|
+
const tags = { deviceId: rec.deviceId };
|
|
6326
|
+
const now = (this.deps.now ?? Date.now)();
|
|
6327
|
+
if (subject.wake !== void 0 && now - rec.createdAt > 3e5) {
|
|
6328
|
+
const waitedMs = now - rec.createdAt;
|
|
6329
|
+
this.deps.logger.warn("clip export refused: it outlived the wake it was granted", {
|
|
6330
|
+
tags,
|
|
6331
|
+
meta: {
|
|
6332
|
+
exportId: id,
|
|
6333
|
+
clipId: subject.clipId,
|
|
6334
|
+
waitedMs,
|
|
6335
|
+
ttlMs: CLIP_WAKE_TTL_MS
|
|
6336
|
+
}
|
|
6337
|
+
});
|
|
6338
|
+
await this.fail(id, require_dist.clipExportFailure("wake-expired", `queued ${Math.round(waitedMs / 1e3)}s ago, past the ${Math.round(CLIP_WAKE_TTL_MS / 1e3)}s an authorised wake stays spendable — ask again to wake the camera`));
|
|
6339
|
+
return;
|
|
6340
|
+
}
|
|
6341
|
+
const fetchClipBytes = this.deps.fetchClipBytes;
|
|
6342
|
+
const writeExportFile = this.deps.writeExportFile;
|
|
6343
|
+
if (fetchClipBytes === void 0 || writeExportFile === void 0) {
|
|
6344
|
+
this.deps.logger.error("clip export refused: this recorder has no clip byte reader wired", {
|
|
6345
|
+
tags,
|
|
6346
|
+
meta: {
|
|
6347
|
+
exportId: id,
|
|
6348
|
+
clipId: subject.clipId
|
|
6349
|
+
}
|
|
6350
|
+
});
|
|
6351
|
+
await this.fail(id, require_dist.clipExportFailure("fetch-failed", "this recorder has no clip byte reader wired"));
|
|
6352
|
+
return;
|
|
6353
|
+
}
|
|
6354
|
+
await patchExport(this.deps.state, id, {
|
|
6355
|
+
state: "rendering",
|
|
6356
|
+
progressPct: null
|
|
6357
|
+
});
|
|
6358
|
+
this.deps.logger.info("clip export fetch starting", {
|
|
6359
|
+
tags,
|
|
6360
|
+
meta: {
|
|
6361
|
+
exportId: id,
|
|
6362
|
+
clipId: subject.clipId,
|
|
6363
|
+
source: subject.source,
|
|
6364
|
+
provider: subject.provider,
|
|
6365
|
+
profile: subject.profile,
|
|
6366
|
+
wake: subject.wake ?? "none"
|
|
6367
|
+
}
|
|
6368
|
+
});
|
|
6369
|
+
let answer;
|
|
6370
|
+
try {
|
|
6371
|
+
answer = await fetchClipBytes({
|
|
6372
|
+
deviceId: subject.deviceId,
|
|
6373
|
+
clipId: subject.clipId,
|
|
6374
|
+
profile: subject.profile,
|
|
6375
|
+
maxBytes: require_dist.RECORDING_EXPORT_MAX_READ_BYTES,
|
|
6376
|
+
...subject.wake !== void 0 ? { wake: subject.wake } : {}
|
|
6377
|
+
});
|
|
6378
|
+
} catch (err) {
|
|
6379
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
6380
|
+
const code = classifyClipFetchFailure(detail);
|
|
6381
|
+
this.deps.logger.warn("clip export fetch failed", {
|
|
6382
|
+
tags,
|
|
6383
|
+
meta: {
|
|
6384
|
+
exportId: id,
|
|
6385
|
+
clipId: subject.clipId,
|
|
6386
|
+
reason: code,
|
|
6387
|
+
error: detail
|
|
6388
|
+
}
|
|
6389
|
+
});
|
|
6390
|
+
await this.fail(id, require_dist.clipExportFailure(code, detail));
|
|
6391
|
+
return;
|
|
6392
|
+
}
|
|
6393
|
+
if (this.cancelled.has(id)) {
|
|
6394
|
+
this.cancelled.delete(id);
|
|
6395
|
+
await this.fail(id, "cancelled");
|
|
6396
|
+
return;
|
|
6397
|
+
}
|
|
6398
|
+
const bytes = Buffer.from(answer.base64, "base64");
|
|
6399
|
+
if (bytes.byteLength > 52428800) {
|
|
6400
|
+
this.deps.logger.warn("clip export refused: the answer exceeded the transfer bound", {
|
|
6401
|
+
tags,
|
|
6402
|
+
meta: {
|
|
6403
|
+
exportId: id,
|
|
6404
|
+
bytes: bytes.byteLength,
|
|
6405
|
+
maxBytes: require_dist.RECORDING_EXPORT_MAX_READ_BYTES
|
|
6406
|
+
}
|
|
6407
|
+
});
|
|
6408
|
+
await this.fail(id, require_dist.clipExportFailure("too-large-to-transfer", `${bytes.byteLength} > ${require_dist.RECORDING_EXPORT_MAX_READ_BYTES} bytes`));
|
|
6409
|
+
return;
|
|
6410
|
+
}
|
|
6411
|
+
if (bytes.byteLength < 1024) {
|
|
6412
|
+
this.deps.logger.error("clip export produced no video", {
|
|
6413
|
+
tags,
|
|
6414
|
+
meta: {
|
|
6415
|
+
exportId: id,
|
|
6416
|
+
clipId: subject.clipId,
|
|
6417
|
+
bytes: bytes.byteLength,
|
|
6418
|
+
minBytes: EXPORT_MIN_PLAUSIBLE_BYTES
|
|
6419
|
+
}
|
|
6420
|
+
});
|
|
6421
|
+
await this.fail(id, require_dist.clipExportFailure("fetch-failed", `the source answered ${bytes.byteLength} bytes, under the ${EXPORT_MIN_PLAUSIBLE_BYTES} a playable MP4 needs`));
|
|
6422
|
+
return;
|
|
6423
|
+
}
|
|
6424
|
+
const outPath = this.deps.outPath(rec);
|
|
6425
|
+
try {
|
|
6426
|
+
await writeExportFile(outPath, bytes);
|
|
6427
|
+
} catch (err) {
|
|
6428
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
6429
|
+
this.deps.logger.error("clip export could not be written", {
|
|
6430
|
+
tags,
|
|
6431
|
+
meta: {
|
|
6432
|
+
exportId: id,
|
|
6433
|
+
outPath,
|
|
6434
|
+
error: detail
|
|
6435
|
+
}
|
|
6436
|
+
});
|
|
6437
|
+
await this.deps.removeFile(outPath);
|
|
6438
|
+
await this.fail(id, require_dist.clipExportFailure("fetch-failed", `could not write the export: ${detail}`));
|
|
6439
|
+
return;
|
|
6440
|
+
}
|
|
6441
|
+
const servedPatch = answer.served !== rec.profile ? { profile: answer.served } : {};
|
|
6442
|
+
if (answer.served !== rec.profile) this.deps.logger.warn("clip export served a different twin than the catalog projected", {
|
|
6443
|
+
tags,
|
|
6444
|
+
meta: {
|
|
6445
|
+
exportId: id,
|
|
6446
|
+
clipId: subject.clipId,
|
|
6447
|
+
asked: subject.profile,
|
|
6448
|
+
projected: rec.profile,
|
|
6449
|
+
served: answer.served
|
|
6450
|
+
}
|
|
6451
|
+
});
|
|
6452
|
+
const claimedMs = rec.toMs - rec.fromMs;
|
|
6453
|
+
if (answer.durationMs !== void 0 && Math.abs(answer.durationMs - claimedMs) > CLIP_DURATION_TOLERANCE_MS) this.deps.logger.warn("clip export duration disagrees with the catalog row", {
|
|
6454
|
+
tags,
|
|
6455
|
+
meta: {
|
|
6456
|
+
exportId: id,
|
|
6457
|
+
clipId: subject.clipId,
|
|
6458
|
+
catalogSpanMs: claimedMs,
|
|
6459
|
+
deliveredMs: answer.durationMs
|
|
6460
|
+
}
|
|
6461
|
+
});
|
|
6462
|
+
await patchExport(this.deps.state, id, {
|
|
6463
|
+
state: "ready",
|
|
6464
|
+
progressPct: 100,
|
|
6465
|
+
fileBytes: bytes.byteLength,
|
|
6466
|
+
error: null,
|
|
6467
|
+
...servedPatch
|
|
6468
|
+
});
|
|
6469
|
+
this.deps.logger.info("clip export ready", {
|
|
6470
|
+
tags,
|
|
6471
|
+
meta: {
|
|
6472
|
+
exportId: id,
|
|
6473
|
+
clipId: subject.clipId,
|
|
6474
|
+
outPath,
|
|
6475
|
+
bytes: bytes.byteLength,
|
|
6476
|
+
served: answer.served
|
|
6477
|
+
}
|
|
6478
|
+
});
|
|
6479
|
+
this.deps.emit(require_dist.EventCategory.RecordingExportCompleted, {
|
|
6480
|
+
exportId: id,
|
|
6481
|
+
fileBytes: bytes.byteLength,
|
|
6482
|
+
deviceId: rec.deviceId,
|
|
6483
|
+
...rec.options.title !== void 0 ? { title: rec.options.title } : {},
|
|
6484
|
+
...rec.options.notifyTargetIds !== void 0 && rec.options.notifyTargetIds.length > 0 ? { notifyTargetIds: rec.options.notifyTargetIds } : {}
|
|
6485
|
+
});
|
|
6486
|
+
}
|
|
6487
|
+
/**
|
|
6249
6488
|
* The record's options with any dense overlay moved onto ffmpeg's clock.
|
|
6250
6489
|
*
|
|
6251
6490
|
* The translation is reported on EVERY render that carries an overlay, not
|
|
@@ -6681,6 +6920,22 @@ function isInterrupted(record) {
|
|
|
6681
6920
|
return record.state === "queued" || record.state === "rendering";
|
|
6682
6921
|
}
|
|
6683
6922
|
/**
|
|
6923
|
+
* Did this row carry an operator's authorised WAKE?
|
|
6924
|
+
*
|
|
6925
|
+
* A re-queue is the third of the three ways D558 § 5.2 rule 3 names for
|
|
6926
|
+
* spending one yes twice, and it is the quietest: the row reaches the fetch
|
|
6927
|
+
* hours after the tap, wakes the camera, and nothing in the log says the
|
|
6928
|
+
* operator did not ask for it. So a clip export holding a wake is FAILED by
|
|
6929
|
+
* name instead — a row he can retry with one tap, which re-asks for the
|
|
6930
|
+
* authorisation. A clip export WITHOUT a wake is re-queued like any render:
|
|
6931
|
+
* there is nothing to spend, and a sleeping camera refuses at its own gate
|
|
6932
|
+
* exactly as it did the first time.
|
|
6933
|
+
*/
|
|
6934
|
+
function carriesAnAuthorisedWake(record) {
|
|
6935
|
+
const subject = require_dist.exportSubjectOf(record);
|
|
6936
|
+
return subject.kind === "clip" && subject.wake !== void 0;
|
|
6937
|
+
}
|
|
6938
|
+
/**
|
|
6684
6939
|
* Hand every interrupted row back to the engine, once, at boot.
|
|
6685
6940
|
*
|
|
6686
6941
|
* A row past its `expiresAt` is FAILED rather than re-rendered: hours of
|
|
@@ -6708,6 +6963,19 @@ async function reconcileInterruptedExports(deps) {
|
|
|
6708
6963
|
toMs: row.toMs,
|
|
6709
6964
|
createdAt: row.createdAt
|
|
6710
6965
|
};
|
|
6966
|
+
if (carriesAnAuthorisedWake(row)) {
|
|
6967
|
+
expired += 1;
|
|
6968
|
+
await patchExport(deps.state, row.id, {
|
|
6969
|
+
state: "failed",
|
|
6970
|
+
progressPct: null,
|
|
6971
|
+
error: require_dist.clipExportFailure("wake-expired", "interrupted by a restart — one authorised wake is one wake, so ask again to wake the camera")
|
|
6972
|
+
});
|
|
6973
|
+
deps.logger.warn("clip export abandoned: it was interrupted while holding a wake", {
|
|
6974
|
+
tags,
|
|
6975
|
+
meta
|
|
6976
|
+
});
|
|
6977
|
+
continue;
|
|
6978
|
+
}
|
|
6711
6979
|
if (row.expiresAt <= now) {
|
|
6712
6980
|
expired += 1;
|
|
6713
6981
|
await patchExport(deps.state, row.id, {
|
|
@@ -13877,6 +14145,20 @@ function createVideoclipsProvider(deps) {
|
|
|
13877
14145
|
}),
|
|
13878
14146
|
format: "hls"
|
|
13879
14147
|
};
|
|
14148
|
+
},
|
|
14149
|
+
/**
|
|
14150
|
+
* This source has no bytes to hand over, and says so rather than
|
|
14151
|
+
* inventing a path to them.
|
|
14152
|
+
*
|
|
14153
|
+
* An `analytics` clip is a time WINDOW over footage the recorder already
|
|
14154
|
+
* owns — there is no file behind it, and a caller that wants it as one
|
|
14155
|
+
* asks for it as an EXPORT, where the source playlist and
|
|
14156
|
+
* `export-dense-map` handle the holes a visit spans by construction
|
|
14157
|
+
* (D558 § 5.4.3). Reading it here would be this addon fetching from
|
|
14158
|
+
* itself, over a cap channel, in base64.
|
|
14159
|
+
*/
|
|
14160
|
+
readClipBytes: async ({ clipId }) => {
|
|
14161
|
+
throw new Error(`videoclips: "${clipId}" is an analytics visit — a window over recorded footage with no file behind it. Export it through recordingExport with the same clip subject; the recorder renders it from its own segments.`);
|
|
13880
14162
|
}
|
|
13881
14163
|
};
|
|
13882
14164
|
}
|
|
@@ -17282,6 +17564,81 @@ function makeBrokerCall(handle) {
|
|
|
17282
17564
|
return (fn) => handle.call(fn, BROKER_READY_TIMEOUT_MS);
|
|
17283
17565
|
}
|
|
17284
17566
|
//#endregion
|
|
17567
|
+
//#region src/recorder/addon/export-clip-catalog.ts
|
|
17568
|
+
/**
|
|
17569
|
+
* Catalog page size for the confirm.
|
|
17570
|
+
*
|
|
17571
|
+
* One local day is the window (`ExportClipSubject.catalogWindow`) and a busy
|
|
17572
|
+
* day on 592 measured 546 rows, so 1 000 holds a day with room and still
|
|
17573
|
+
* bounds a pathological camera. A truncated page would read as "this clip is
|
|
17574
|
+
* gone", which is the one answer this gate must never give wrongly.
|
|
17575
|
+
*/
|
|
17576
|
+
var EXPORT_CLIP_CATALOG_LIMIT = 1e3;
|
|
17577
|
+
/**
|
|
17578
|
+
* Which twin this row can actually serve for the asked profile.
|
|
17579
|
+
*
|
|
17580
|
+
* The mapping is the one D549 15 already fixed — `low | mid` → the sub file,
|
|
17581
|
+
* `high` → the main twin — and both ids are resolved at LISTING time, so this
|
|
17582
|
+
* never re-searches the camera. A row that holds only one twin answers with
|
|
17583
|
+
* the one it has and the caller SAYS so: the ask stays on `subject.profile`
|
|
17584
|
+
* and this lands on the record's top-level `profile`, so a week later the row
|
|
17585
|
+
* still tells the operator he was handed the sub stream.
|
|
17586
|
+
*
|
|
17587
|
+
* A row with no `streams` block at all is not a fallback and not a guess: the
|
|
17588
|
+
* ask is carried through and the producer's own `served` is what corrects it.
|
|
17589
|
+
*/
|
|
17590
|
+
function servedTwinFor(clip, asked) {
|
|
17591
|
+
const streams = clip.streams;
|
|
17592
|
+
if (streams === void 0) return asked;
|
|
17593
|
+
const hasMain = streams.main !== void 0;
|
|
17594
|
+
const hasSub = streams.sub !== void 0;
|
|
17595
|
+
if (asked === "high") return hasMain ? "high" : hasSub ? "low" : asked;
|
|
17596
|
+
return hasSub ? asked : hasMain ? "high" : asked;
|
|
17597
|
+
}
|
|
17598
|
+
/**
|
|
17599
|
+
* Judge one catalog answer for one clip subject. Pure — the I/O is the
|
|
17600
|
+
* caller's, so every refusal below is unit-testable without a camera.
|
|
17601
|
+
*/
|
|
17602
|
+
function judgeClipRow(subject, rows) {
|
|
17603
|
+
const clip = rows.find((row) => row.id === subject.clipId);
|
|
17604
|
+
if (clip === void 0) return {
|
|
17605
|
+
ok: false,
|
|
17606
|
+
refusal: {
|
|
17607
|
+
code: "catalog-miss",
|
|
17608
|
+
detail: `"${subject.sourceLabel}" does not list ${subject.clipId} between ${subject.catalogWindow.sinceMs} and ${subject.catalogWindow.untilMs}`
|
|
17609
|
+
}
|
|
17610
|
+
};
|
|
17611
|
+
if (clip.playable === false) return {
|
|
17612
|
+
ok: false,
|
|
17613
|
+
refusal: {
|
|
17614
|
+
code: "no-file-for-window",
|
|
17615
|
+
detail: clip.unplayableReason ?? "no bytes"
|
|
17616
|
+
}
|
|
17617
|
+
};
|
|
17618
|
+
if (clip.inProgress === true) return {
|
|
17619
|
+
ok: false,
|
|
17620
|
+
refusal: {
|
|
17621
|
+
code: "clip-in-progress",
|
|
17622
|
+
detail: "the camera is still writing this recording, so it has no end to export yet"
|
|
17623
|
+
}
|
|
17624
|
+
};
|
|
17625
|
+
const { startMs, endMs } = clip.timeRange;
|
|
17626
|
+
if (!(startMs < endMs)) return {
|
|
17627
|
+
ok: false,
|
|
17628
|
+
refusal: {
|
|
17629
|
+
code: "catalog-miss",
|
|
17630
|
+
detail: `the row carries no usable span (${startMs}..${endMs})`
|
|
17631
|
+
}
|
|
17632
|
+
};
|
|
17633
|
+
return {
|
|
17634
|
+
ok: true,
|
|
17635
|
+
accepted: {
|
|
17636
|
+
clip,
|
|
17637
|
+
served: servedTwinFor(clip, subject.profile)
|
|
17638
|
+
}
|
|
17639
|
+
};
|
|
17640
|
+
}
|
|
17641
|
+
//#endregion
|
|
17285
17642
|
//#region src/recorder/addon/recording-export-provider.ts
|
|
17286
17643
|
/** Content type of every rendered export — the engine only ever writes MP4. */
|
|
17287
17644
|
var EXPORT_CONTENT_TYPE = "video/mp4";
|
|
@@ -17309,12 +17666,6 @@ function exportFileName(rec) {
|
|
|
17309
17666
|
async function hasFootage(index, deviceId, profile, fromMs, toMs) {
|
|
17310
17667
|
return (await index.segmentsInWindow(deviceId, profile, fromMs, toMs)).some((s) => s.startMs < toMs && s.startMs + s.durMs > fromMs);
|
|
17311
17668
|
}
|
|
17312
|
-
/** Canonical `profiles[]`, falling back to the legacy singular `profile`. */
|
|
17313
|
-
function resolveExportProfiles(input) {
|
|
17314
|
-
if (input.profiles !== void 0 && input.profiles.length > 0) return [...input.profiles];
|
|
17315
|
-
if (typeof input.profile === "string" && input.profile.length > 0) return [input.profile];
|
|
17316
|
-
return [];
|
|
17317
|
-
}
|
|
17318
17669
|
/** Load a record or throw a clear NOT_FOUND-style error. */
|
|
17319
17670
|
async function requireRecord(state, exportId) {
|
|
17320
17671
|
const rec = await getExportRecord(state, exportId);
|
|
@@ -17323,37 +17674,133 @@ async function requireRecord(state, exportId) {
|
|
|
17323
17674
|
}
|
|
17324
17675
|
/** Build the `recordingExport` provider over the injected deps. */
|
|
17325
17676
|
function buildRecordingExportProvider(deps) {
|
|
17677
|
+
/**
|
|
17678
|
+
* Persist one `queued` row and hand it to the engine. The ONE place a record
|
|
17679
|
+
* is born, for both kinds — so the fields nothing about the subject decides
|
|
17680
|
+
* (the lifetime, the audit stamp, the null progress) cannot drift apart.
|
|
17681
|
+
*/
|
|
17682
|
+
const queueOne = async (fields, options, now) => {
|
|
17683
|
+
const saved = await upsertExport(deps.state, {
|
|
17684
|
+
...fields,
|
|
17685
|
+
id: deps.newId(),
|
|
17686
|
+
options,
|
|
17687
|
+
state: "queued",
|
|
17688
|
+
progressPct: null,
|
|
17689
|
+
fileBytes: null,
|
|
17690
|
+
expiresAt: now + options.maxLifeMs,
|
|
17691
|
+
deleteAfterDownload: options.deleteAfterDownload,
|
|
17692
|
+
downloadedAt: null,
|
|
17693
|
+
createdAt: now,
|
|
17694
|
+
createdBy: deps.createdBy(),
|
|
17695
|
+
error: null
|
|
17696
|
+
});
|
|
17697
|
+
deps.engine.enqueue(saved.id);
|
|
17698
|
+
return saved;
|
|
17699
|
+
};
|
|
17700
|
+
/**
|
|
17701
|
+
* The clip branch's fail-fast gate — the catalog, never the recording index.
|
|
17702
|
+
*
|
|
17703
|
+
* Refuses BEFORE a row exists, so an operator gets the reason in the answer
|
|
17704
|
+
* to his own tap instead of discovering it on a `failed` row a minute later,
|
|
17705
|
+
* and so a refusal never spends a wake.
|
|
17706
|
+
*/
|
|
17707
|
+
const createClipExport = async (subject, options) => {
|
|
17708
|
+
const tags = { deviceId: subject.deviceId };
|
|
17709
|
+
if (options.timelapse !== void 0 || options.speed !== void 0 && options.speed !== 1) {
|
|
17710
|
+
const detail = "a clip is remuxed, never re-timed — drop speed/timelapse";
|
|
17711
|
+
deps.logger.warn("clip export refused: a render option a remux cannot honour", {
|
|
17712
|
+
tags,
|
|
17713
|
+
meta: {
|
|
17714
|
+
clipId: subject.clipId,
|
|
17715
|
+
speed: options.speed,
|
|
17716
|
+
timelapse: options.timelapse
|
|
17717
|
+
}
|
|
17718
|
+
});
|
|
17719
|
+
throw new Error(require_dist.clipExportFailure("unsupported-option", detail));
|
|
17720
|
+
}
|
|
17721
|
+
let rows;
|
|
17722
|
+
try {
|
|
17723
|
+
rows = await deps.clipCatalog.listClips({
|
|
17724
|
+
deviceId: subject.deviceId,
|
|
17725
|
+
since: subject.catalogWindow.sinceMs,
|
|
17726
|
+
until: subject.catalogWindow.untilMs,
|
|
17727
|
+
provider: subject.provider,
|
|
17728
|
+
limit: EXPORT_CLIP_CATALOG_LIMIT
|
|
17729
|
+
});
|
|
17730
|
+
} catch (err) {
|
|
17731
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
17732
|
+
deps.logger.warn("clip export refused: the clip catalog could not be read", {
|
|
17733
|
+
tags,
|
|
17734
|
+
meta: {
|
|
17735
|
+
clipId: subject.clipId,
|
|
17736
|
+
provider: subject.provider,
|
|
17737
|
+
error: detail
|
|
17738
|
+
}
|
|
17739
|
+
});
|
|
17740
|
+
throw new Error(require_dist.clipExportFailure("catalog-unreachable", detail), { cause: err });
|
|
17741
|
+
}
|
|
17742
|
+
const outcome = judgeClipRow(subject, rows);
|
|
17743
|
+
if (!outcome.ok) {
|
|
17744
|
+
deps.logger.warn("clip export refused by the catalog gate", {
|
|
17745
|
+
tags,
|
|
17746
|
+
meta: {
|
|
17747
|
+
clipId: subject.clipId,
|
|
17748
|
+
provider: subject.provider,
|
|
17749
|
+
reason: outcome.refusal.code,
|
|
17750
|
+
detail: outcome.refusal.detail
|
|
17751
|
+
}
|
|
17752
|
+
});
|
|
17753
|
+
throw new Error(require_dist.clipExportFailure(outcome.refusal.code, outcome.refusal.detail));
|
|
17754
|
+
}
|
|
17755
|
+
const { clip, served } = outcome.accepted;
|
|
17756
|
+
const record = await queueOne({
|
|
17757
|
+
deviceId: subject.deviceId,
|
|
17758
|
+
profile: served,
|
|
17759
|
+
fromMs: clip.timeRange.startMs,
|
|
17760
|
+
toMs: clip.timeRange.endMs,
|
|
17761
|
+
subject
|
|
17762
|
+
}, options, deps.now());
|
|
17763
|
+
deps.logger.info("clip export queued", {
|
|
17764
|
+
tags,
|
|
17765
|
+
meta: {
|
|
17766
|
+
exportId: record.id,
|
|
17767
|
+
clipId: subject.clipId,
|
|
17768
|
+
source: subject.source,
|
|
17769
|
+
provider: subject.provider,
|
|
17770
|
+
askedProfile: subject.profile,
|
|
17771
|
+
servedProfile: served,
|
|
17772
|
+
wake: subject.wake ?? "none",
|
|
17773
|
+
fromMs: record.fromMs,
|
|
17774
|
+
toMs: record.toMs
|
|
17775
|
+
}
|
|
17776
|
+
});
|
|
17777
|
+
return record;
|
|
17778
|
+
};
|
|
17326
17779
|
return {
|
|
17327
17780
|
createExport: async (input) => {
|
|
17328
|
-
const
|
|
17329
|
-
|
|
17330
|
-
|
|
17781
|
+
const subject = require_dist.resolveCreateExportSubject(input);
|
|
17782
|
+
if (subject.kind === "clip") return await createClipExport(subject, input.options);
|
|
17783
|
+
const { deviceId, profiles, fromMs, toMs } = subject;
|
|
17784
|
+
const { options } = input;
|
|
17331
17785
|
if (!(fromMs < toMs)) throw new Error(`recording-export: invalid range ${fromMs}..${toMs}`);
|
|
17332
17786
|
for (const profile of profiles) if (!await hasFootage(deps.index, deviceId, profile, fromMs, toMs)) throw new Error(`recording-export: no footage for ${deviceId}/${profile} in ${fromMs}..${toMs}`);
|
|
17333
17787
|
const now = deps.now();
|
|
17334
|
-
|
|
17335
|
-
|
|
17336
|
-
|
|
17337
|
-
|
|
17338
|
-
|
|
17339
|
-
|
|
17340
|
-
|
|
17341
|
-
|
|
17342
|
-
|
|
17343
|
-
|
|
17344
|
-
|
|
17345
|
-
|
|
17346
|
-
|
|
17347
|
-
|
|
17348
|
-
|
|
17349
|
-
|
|
17350
|
-
createdBy: deps.createdBy(),
|
|
17351
|
-
error: null
|
|
17352
|
-
};
|
|
17353
|
-
const saved = await upsertExport(deps.state, record);
|
|
17354
|
-
deps.engine.enqueue(saved.id);
|
|
17355
|
-
first ??= saved;
|
|
17356
|
-
}
|
|
17788
|
+
const [head, ...rest] = profiles;
|
|
17789
|
+
if (head === void 0) throw new Error("recording-export: profiles must contain at least one profile");
|
|
17790
|
+
const first = await queueOne({
|
|
17791
|
+
deviceId,
|
|
17792
|
+
profile: head,
|
|
17793
|
+
fromMs,
|
|
17794
|
+
toMs,
|
|
17795
|
+
subject
|
|
17796
|
+
}, options, now);
|
|
17797
|
+
for (const profile of rest) await queueOne({
|
|
17798
|
+
deviceId,
|
|
17799
|
+
profile,
|
|
17800
|
+
fromMs,
|
|
17801
|
+
toMs,
|
|
17802
|
+
subject
|
|
17803
|
+
}, options, now);
|
|
17357
17804
|
return first;
|
|
17358
17805
|
},
|
|
17359
17806
|
listExports: ({ deviceId }) => listExportsFor(deps.state, deviceId),
|
|
@@ -19128,7 +19575,19 @@ var RecorderV2Addon = class extends require_dist.BaseAddon {
|
|
|
19128
19575
|
outPath: exportOutPath,
|
|
19129
19576
|
statBytes: async (p) => (await node_fs.promises.stat(p)).size,
|
|
19130
19577
|
removeFile: removeExportFile,
|
|
19131
|
-
emit: (category, data) => this.emitExportEvent(category, data)
|
|
19578
|
+
emit: (category, data) => this.emitExportEvent(category, data),
|
|
19579
|
+
now: () => Date.now(),
|
|
19580
|
+
fetchClipBytes: async (req) => await this.ctx.api.videoclips.readClipBytes.query({
|
|
19581
|
+
deviceId: req.deviceId,
|
|
19582
|
+
clipId: req.clipId,
|
|
19583
|
+
profile: req.profile,
|
|
19584
|
+
maxBytes: req.maxBytes,
|
|
19585
|
+
...req.wake !== void 0 ? { wake: req.wake } : {}
|
|
19586
|
+
}),
|
|
19587
|
+
writeExportFile: async (p, bytes) => {
|
|
19588
|
+
await node_fs.promises.mkdir(node_path.default.dirname(p), { recursive: true });
|
|
19589
|
+
await node_fs.promises.writeFile(p, bytes);
|
|
19590
|
+
}
|
|
19132
19591
|
});
|
|
19133
19592
|
const exportProvider = buildRecordingExportProvider({
|
|
19134
19593
|
state: exportsState,
|
|
@@ -19137,6 +19596,7 @@ var RecorderV2Addon = class extends require_dist.BaseAddon {
|
|
|
19137
19596
|
if (this.index.hydrationOf(deviceId, fromMs, toMs) !== "hydrated") await hydrateWindowFromStorage(this.index, deviceId, fromMs, toMs, this.resolvedLocations, this.ctx.logger, this.segmentHours ?? void 0);
|
|
19138
19597
|
return this.index.segments(deviceId, profile);
|
|
19139
19598
|
} },
|
|
19599
|
+
clipCatalog: { listClips: async (input) => await this.ctx.api.videoclips.listClips.query(input) },
|
|
19140
19600
|
now: () => Date.now(),
|
|
19141
19601
|
newId: () => (0, node_crypto.randomUUID)(),
|
|
19142
19602
|
createdBy: () => "operator",
|