@vestra-player/sdk 1.7.6 → 1.7.8
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/CHANGELOG.md +25 -0
- package/dist/api-requests.js +15 -0
- package/dist/capability-rules.js +46 -21
- package/dist/commands.d.ts +12 -4
- package/dist/commands.js +13 -12
- package/dist/docs-tree.json.gz +0 -0
- package/dist/host-capabilities.js +18 -0
- package/dist/media.d.ts +108 -1
- package/dist/media.js +20 -0
- package/dist/player-runtime.d.ts +1 -0
- package/dist/player-runtime.js +1 -0
- package/dist/plugin/media.d.ts +26 -0
- package/dist/plugin/media.js +166 -0
- package/dist/plugin/player.d.ts +7 -1
- package/dist/plugin/player.js +3 -1
- package/dist/plugin/testing/index.d.ts +100 -3
- package/dist/plugin/testing/index.js +54 -3
- package/dist/plugin/testing/internals.d.ts +13 -0
- package/dist/plugin/testing/jobs.js +348 -1
- package/dist/plugin/testing/media.js +29 -0
- package/dist/plugin/types/base.d.ts +2 -2
- package/dist/plugin/types/snapshots.d.ts +511 -1
- package/dist/wire.d.ts +28 -0
- package/llms.txt +2 -2
- package/package.json +1 -1
|
@@ -11,6 +11,7 @@ import { randomBytes } from "node:crypto";
|
|
|
11
11
|
import { HostError } from "../../wire.js";
|
|
12
12
|
import { localSocketPath } from "../local.js";
|
|
13
13
|
import { isCurrentProducer } from "./media.js";
|
|
14
|
+
import { MEDIA_SOURCE_LIMITS } from "../media.js";
|
|
14
15
|
/** `jobs.start`'s `encoding`, checked against the player's sets. */
|
|
15
16
|
export function validEncoding(value) {
|
|
16
17
|
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
@@ -42,7 +43,158 @@ export function failStream(host, inner, producerId, message) {
|
|
|
42
43
|
}
|
|
43
44
|
/** The default handlers of this area's wire methods, by method name. */
|
|
44
45
|
export function jobsHandlers(host, inner) {
|
|
45
|
-
|
|
46
|
+
/** A file's facts: `mediaFiles`, else a 1080p30 H.264 + AAC file. */
|
|
47
|
+
const facts = (path) => {
|
|
48
|
+
const file = host.mediaFiles.get(path) ?? {};
|
|
49
|
+
return {
|
|
50
|
+
duration: file.duration ?? host.source.duration ?? 60,
|
|
51
|
+
status: file.status ?? "ok",
|
|
52
|
+
video: file.video === undefined
|
|
53
|
+
? {
|
|
54
|
+
codec: "h264",
|
|
55
|
+
width: 1920,
|
|
56
|
+
height: 1080,
|
|
57
|
+
fps: 30,
|
|
58
|
+
pixelFormat: "yuv420p",
|
|
59
|
+
}
|
|
60
|
+
: file.video,
|
|
61
|
+
audio: file.audio === undefined
|
|
62
|
+
? { codec: "aac", sampleRate: 48000, channels: 2 }
|
|
63
|
+
: file.audio,
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
const known = (token) => {
|
|
67
|
+
const value = String(token);
|
|
68
|
+
if (!host.sourceReferences.has(value))
|
|
69
|
+
throw new HostError("missing", "no such source reference");
|
|
70
|
+
return value;
|
|
71
|
+
};
|
|
72
|
+
/** A file's version: what the player's size and modification time are. */
|
|
73
|
+
const version = (path) => host.mediaFiles.get(path)?.version ?? 0;
|
|
74
|
+
/** As the player: gone, rewritten since remembered, or as it was. */
|
|
75
|
+
const status = (token) => {
|
|
76
|
+
const { path, version: was } = host.sourceReferences.get(token);
|
|
77
|
+
const file = facts(path);
|
|
78
|
+
if (file.status === "missing")
|
|
79
|
+
return "missing";
|
|
80
|
+
return file.status === "changed" || version(path) !== (was ?? 0)
|
|
81
|
+
? "changed"
|
|
82
|
+
: "ok";
|
|
83
|
+
};
|
|
84
|
+
const describe = (token) => {
|
|
85
|
+
const { path } = host.sourceReferences.get(token);
|
|
86
|
+
const file = facts(path);
|
|
87
|
+
return {
|
|
88
|
+
token,
|
|
89
|
+
name: path.split(/[/\\]/).pop() ?? path,
|
|
90
|
+
duration: file.duration,
|
|
91
|
+
status: status(token),
|
|
92
|
+
video: file.video,
|
|
93
|
+
audio: file.audio,
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
/** The player's `media_copy::fits_mp4`: codecs a copy writes into MP4. */
|
|
97
|
+
const fitsMp4 = (file) => ["h264", "hevc", "av1", "mpeg4"].includes(file?.video?.codec ?? "") &&
|
|
98
|
+
(!file?.audio ||
|
|
99
|
+
["aac", "mp3", "ac3", "eac3", "alac"].includes(file.audio.codec));
|
|
100
|
+
// The player's check (`media_sources::check`) over the fake facts.
|
|
101
|
+
const exportCheck = (parts) => {
|
|
102
|
+
// The player's bounds (`media_sources::parts_valid`).
|
|
103
|
+
if (!Array.isArray(parts) ||
|
|
104
|
+
parts.length === 0 ||
|
|
105
|
+
parts.length > MEDIA_SOURCE_LIMITS.parts ||
|
|
106
|
+
parts.some((part) => typeof part?.source !== "string" ||
|
|
107
|
+
part.source === "" ||
|
|
108
|
+
!Number.isFinite(part.start) ||
|
|
109
|
+
!Number.isFinite(part.end) ||
|
|
110
|
+
part.start < 0 ||
|
|
111
|
+
part.end > MEDIA_SOURCE_LIMITS.partEnd) ||
|
|
112
|
+
parts.reduce((sum, part) => sum + Math.max(0, part.end - part.start), 0) >
|
|
113
|
+
MEDIA_SOURCE_LIMITS.totalSeconds)
|
|
114
|
+
throw new HostError("invalid", `1–${MEDIA_SOURCE_LIMITS.parts} parts with a token and finite times from 0 to ${MEDIA_SOURCE_LIMITS.partEnd} s (${MEDIA_SOURCE_LIMITS.totalSeconds} s in all) required`);
|
|
115
|
+
const blocking = [];
|
|
116
|
+
const files = parts.map((part, index) => {
|
|
117
|
+
const reference = host.sourceReferences.get(part.source);
|
|
118
|
+
if (!reference) {
|
|
119
|
+
blocking.push({ part: index, problem: "unknown" });
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
const file = facts(reference.path);
|
|
123
|
+
const now = status(part.source);
|
|
124
|
+
if (now !== "ok")
|
|
125
|
+
blocking.push({ part: index, problem: now });
|
|
126
|
+
if (!file.video)
|
|
127
|
+
blocking.push({ part: index, problem: "noVideo" });
|
|
128
|
+
else if (part.end <= part.start ||
|
|
129
|
+
part.end - part.start < 1 / file.video.fps - 1e-6 ||
|
|
130
|
+
part.end > file.duration + 0.001)
|
|
131
|
+
blocking.push({
|
|
132
|
+
part: index,
|
|
133
|
+
problem: "range",
|
|
134
|
+
duration: file.duration,
|
|
135
|
+
});
|
|
136
|
+
return file;
|
|
137
|
+
});
|
|
138
|
+
const reasons = [];
|
|
139
|
+
const first = files[0]?.video ? files[0] : null;
|
|
140
|
+
const audio = (a) => a ? `${a.codec} ${a.sampleRate} Hz ${a.channels} ch` : "none";
|
|
141
|
+
if (first?.video)
|
|
142
|
+
files.forEach((file, part) => {
|
|
143
|
+
if (part === 0 || !file?.video)
|
|
144
|
+
return;
|
|
145
|
+
const v = file.video;
|
|
146
|
+
const f = first.video;
|
|
147
|
+
if (v.codec !== f.codec)
|
|
148
|
+
reasons.push({
|
|
149
|
+
part,
|
|
150
|
+
field: "videoCodec",
|
|
151
|
+
value: v.codec,
|
|
152
|
+
expected: f.codec,
|
|
153
|
+
});
|
|
154
|
+
if (v.width !== f.width || v.height !== f.height)
|
|
155
|
+
reasons.push({
|
|
156
|
+
part,
|
|
157
|
+
field: "size",
|
|
158
|
+
value: `${v.width}×${v.height}`,
|
|
159
|
+
expected: `${f.width}×${f.height}`,
|
|
160
|
+
});
|
|
161
|
+
if (v.fps !== f.fps)
|
|
162
|
+
reasons.push({ part, field: "fps", value: v.fps, expected: f.fps });
|
|
163
|
+
if (v.pixelFormat !== f.pixelFormat)
|
|
164
|
+
reasons.push({
|
|
165
|
+
part,
|
|
166
|
+
field: "pixelFormat",
|
|
167
|
+
value: v.pixelFormat,
|
|
168
|
+
expected: f.pixelFormat,
|
|
169
|
+
});
|
|
170
|
+
if (audio(file.audio) !== audio(first.audio))
|
|
171
|
+
reasons.push({
|
|
172
|
+
part,
|
|
173
|
+
field: "audio",
|
|
174
|
+
value: audio(file.audio),
|
|
175
|
+
expected: audio(first.audio),
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
const mp4 = fitsMp4(first);
|
|
179
|
+
return {
|
|
180
|
+
blocking,
|
|
181
|
+
copy: reasons.length > 0 || !first
|
|
182
|
+
? { ok: false, reasons }
|
|
183
|
+
: { ok: true, container: mp4 ? "mp4" : "mkv" },
|
|
184
|
+
encode: first?.video
|
|
185
|
+
? {
|
|
186
|
+
width: first.video.width + (first.video.width % 2),
|
|
187
|
+
height: first.video.height + (first.video.height % 2),
|
|
188
|
+
fps: first.video.fps,
|
|
189
|
+
audio: files.some((file) => file?.audio)
|
|
190
|
+
? { sampleRate: 48000, channels: 2 }
|
|
191
|
+
: null,
|
|
192
|
+
}
|
|
193
|
+
: null,
|
|
194
|
+
duration: parts.reduce((sum, part) => sum + Math.max(0, part.end - part.start), 0),
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
const handlers = {
|
|
46
198
|
"snapshot.capture": (p) => {
|
|
47
199
|
const expected = p.expected;
|
|
48
200
|
if (expected.generation !== host.source.stamp.generation ||
|
|
@@ -70,6 +222,8 @@ export function jobsHandlers(host, inner) {
|
|
|
70
222
|
"snapshot.state": (p) => host.snapshots.get(Number(p.snapshotId)) ?? null,
|
|
71
223
|
"snapshot.release": (p) => void host.snapshots.delete(Number(p.snapshotId)),
|
|
72
224
|
"jobs.start": (p) => {
|
|
225
|
+
if (p.parts !== undefined)
|
|
226
|
+
return startParts(p);
|
|
73
227
|
if (!host.snapshots.has(Number(p.snapshotId)))
|
|
74
228
|
throw new HostError("missing", "snapshot released");
|
|
75
229
|
const kind = String(p.kind);
|
|
@@ -124,12 +278,57 @@ export function jobsHandlers(host, inner) {
|
|
|
124
278
|
const current = structuredClone(job);
|
|
125
279
|
const made = inner.exportJobs.get(job.jobId);
|
|
126
280
|
const clip = made?.clip;
|
|
281
|
+
const join = made?.join;
|
|
127
282
|
if (job.status === "queued") {
|
|
128
283
|
job.status = "running";
|
|
129
284
|
if (clip) {
|
|
130
285
|
const total = clip.end - clip.start;
|
|
131
286
|
job.progress = { done: total / 2, total };
|
|
132
287
|
}
|
|
288
|
+
// A join is half written: in its middle part.
|
|
289
|
+
if (join)
|
|
290
|
+
job.progress = {
|
|
291
|
+
done: join.total / 2,
|
|
292
|
+
total: join.total,
|
|
293
|
+
part: Math.ceil(join.parts / 2),
|
|
294
|
+
parts: join.parts,
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
else if (job.status === "running" &&
|
|
298
|
+
join &&
|
|
299
|
+
!host.exportFailure &&
|
|
300
|
+
join.tokens.some((token) => status(token) !== "ok")) {
|
|
301
|
+
// As the player: a part whose file went or changed ends the job.
|
|
302
|
+
const index = join.tokens.findIndex((token) => status(token) !== "ok");
|
|
303
|
+
const gone = status(join.tokens[index]) === "missing";
|
|
304
|
+
Object.assign(job, {
|
|
305
|
+
status: "failed",
|
|
306
|
+
outcome: {
|
|
307
|
+
error: {
|
|
308
|
+
code: gone ? "source-missing" : "source-changed",
|
|
309
|
+
message: `part ${index + 1} ${gone ? "is missing" : "changed since it was added"}`,
|
|
310
|
+
},
|
|
311
|
+
},
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
else if (job.status === "running" && join && !host.exportFailure) {
|
|
315
|
+
const destination = join.mode === "copy"
|
|
316
|
+
? made.destination.replace(/(\.(mp4|m4v|mov|mkv|webm))?$/i, `.${join.container}`)
|
|
317
|
+
: made.destination;
|
|
318
|
+
Object.assign(job, {
|
|
319
|
+
status: "completed",
|
|
320
|
+
publicationStarted: true,
|
|
321
|
+
facts: {
|
|
322
|
+
join: {
|
|
323
|
+
mode: join.mode,
|
|
324
|
+
container: join.container,
|
|
325
|
+
parts: join.written,
|
|
326
|
+
target: null,
|
|
327
|
+
},
|
|
328
|
+
},
|
|
329
|
+
outcome: { destination },
|
|
330
|
+
progress: { done: join.total, total: join.total },
|
|
331
|
+
});
|
|
133
332
|
}
|
|
134
333
|
else if (job.status === "running" && host.exportFailure)
|
|
135
334
|
Object.assign(job, {
|
|
@@ -175,6 +374,154 @@ export function jobsHandlers(host, inner) {
|
|
|
175
374
|
return { jobId: job.jobId, cancel: "requested" };
|
|
176
375
|
},
|
|
177
376
|
"jobs.operation": () => ({ status: "unknown" }),
|
|
377
|
+
"media.sources.remember": (p) => {
|
|
378
|
+
const path = host.source.source;
|
|
379
|
+
if (p.expected !== undefined &&
|
|
380
|
+
(p.expected.generation !==
|
|
381
|
+
host.source.stamp.generation ||
|
|
382
|
+
p.expected.intentVersion !==
|
|
383
|
+
host.source.stamp.intentVersion))
|
|
384
|
+
throw new HostError("stale", "source intent changed");
|
|
385
|
+
if (!path ||
|
|
386
|
+
path.includes("://") ||
|
|
387
|
+
!["ready", "ended"].includes(host.source.phase) ||
|
|
388
|
+
host.mediaFiles.get(path)?.status === "missing")
|
|
389
|
+
throw new HostError("unsupported", "only a local file can be referenced");
|
|
390
|
+
// The same file as it is (path, size and time: `version`): its token.
|
|
391
|
+
for (const [token, reference] of host.sourceReferences)
|
|
392
|
+
if (reference.path === path &&
|
|
393
|
+
(reference.version ?? 0) === version(path))
|
|
394
|
+
return describe(token);
|
|
395
|
+
if (host.sourceReferences.size >= MEDIA_SOURCE_LIMITS.references)
|
|
396
|
+
throw new HostError("limit", `a plugin holds at most ${MEDIA_SOURCE_LIMITS.references} references`);
|
|
397
|
+
const token = `src-${randomBytes(16).toString("hex")}`;
|
|
398
|
+
host.sourceReferences.set(token, { path, version: version(path) });
|
|
399
|
+
return describe(token);
|
|
400
|
+
},
|
|
401
|
+
"media.sources.get": (p) => describe(known(p.token)),
|
|
402
|
+
"media.sources.list": () => [...host.sourceReferences.keys()].map(describe),
|
|
403
|
+
"media.sources.forget": (p) => void host.sourceReferences.delete(String(p.token)),
|
|
404
|
+
// The player's own dialog: answered from `dialogAnswers` like a file
|
|
405
|
+
// dialog (a one-path array picks that file, `null` cancels).
|
|
406
|
+
"media.sources.locate": (p) => {
|
|
407
|
+
const token = known(p.token);
|
|
408
|
+
const answer = host.dialogAnswers.shift();
|
|
409
|
+
if (answer === undefined)
|
|
410
|
+
throw new Error("test host: no dialog answer queued");
|
|
411
|
+
if (answer !== null && !Array.isArray(answer))
|
|
412
|
+
throw new Error("test host: a confirm answer was queued");
|
|
413
|
+
if (answer === null)
|
|
414
|
+
return null;
|
|
415
|
+
host.sourceReferences.set(token, {
|
|
416
|
+
path: answer[0],
|
|
417
|
+
version: version(answer[0]),
|
|
418
|
+
});
|
|
419
|
+
return describe(token);
|
|
420
|
+
},
|
|
421
|
+
"jobs.check": (p) => {
|
|
422
|
+
// As the player: parts or a snapshot, one of them.
|
|
423
|
+
if ((p.snapshotId === undefined) === (p.parts === undefined))
|
|
424
|
+
throw new HostError("invalid", "jobs.check takes parts or a snapshotId, one of them");
|
|
425
|
+
if (p.snapshotId === undefined) {
|
|
426
|
+
// Parts carry their own ends; `end` is the snapshot form's.
|
|
427
|
+
if (p.end !== undefined && p.end !== null)
|
|
428
|
+
throw new HostError("invalid", "end belongs to a snapshotId check; parts carry their own end");
|
|
429
|
+
return exportCheck(p.parts);
|
|
430
|
+
}
|
|
431
|
+
// A snapshot's clip: one part from the current file's facts.
|
|
432
|
+
const snapshot = host.snapshots.get(Number(p.snapshotId));
|
|
433
|
+
if (!snapshot)
|
|
434
|
+
throw new HostError("unknown-expired", "snapshot unavailable");
|
|
435
|
+
const end = Number(p.end);
|
|
436
|
+
if (!(end > snapshot.time && end <= snapshot.duration))
|
|
437
|
+
throw new HostError("invalid", "end must be after the snapshot time and within its duration");
|
|
438
|
+
const file = facts(snapshot.source);
|
|
439
|
+
const fps = file.video?.fps ?? 30;
|
|
440
|
+
const processed = snapshot.kind === "processed";
|
|
441
|
+
return {
|
|
442
|
+
blocking: file.video ? [] : [{ part: 0, problem: "noVideo" }],
|
|
443
|
+
copy: processed
|
|
444
|
+
? {
|
|
445
|
+
ok: false,
|
|
446
|
+
reasons: [
|
|
447
|
+
{ part: 0, field: "effects", value: null, expected: null },
|
|
448
|
+
],
|
|
449
|
+
}
|
|
450
|
+
: { ok: true, container: fitsMp4(file) ? "mp4" : "mkv" },
|
|
451
|
+
// The source's size (even), as the player's target; a processed
|
|
452
|
+
// snapshot's picture is the source's in the test host.
|
|
453
|
+
encode: file.video
|
|
454
|
+
? {
|
|
455
|
+
width: file.video.width + (file.video.width % 2),
|
|
456
|
+
height: file.video.height + (file.video.height % 2),
|
|
457
|
+
fps,
|
|
458
|
+
audio: file.audio ? { sampleRate: 48000, channels: 2 } : null,
|
|
459
|
+
}
|
|
460
|
+
: null,
|
|
461
|
+
duration: end - snapshot.time,
|
|
462
|
+
};
|
|
463
|
+
},
|
|
464
|
+
};
|
|
465
|
+
/** `jobs.start { parts }`: an export of remembered files' parts. */
|
|
466
|
+
function startParts(p) {
|
|
467
|
+
const parts = p.parts;
|
|
468
|
+
const copy = p.kind === "rawCopy";
|
|
469
|
+
if (!Array.isArray(parts) ||
|
|
470
|
+
parts.length === 0 ||
|
|
471
|
+
parts.length > MEDIA_SOURCE_LIMITS.parts ||
|
|
472
|
+
parts.some((part) => !(part.end > part.start)) ||
|
|
473
|
+
parts.reduce((sum, part) => sum + (part.end - part.start), 0) >
|
|
474
|
+
MEDIA_SOURCE_LIMITS.totalSeconds ||
|
|
475
|
+
!["rawCopy", "rawMp4"].includes(String(p.kind)) ||
|
|
476
|
+
p.snapshotId !== undefined ||
|
|
477
|
+
p.end !== undefined ||
|
|
478
|
+
p.sampleTime !== undefined ||
|
|
479
|
+
p.quality !== undefined ||
|
|
480
|
+
(p.encoding !== undefined && (copy || !validEncoding(p.encoding))) ||
|
|
481
|
+
(p.container !== undefined && !copy))
|
|
482
|
+
throw new HostError("invalid", "invalid export of parts");
|
|
483
|
+
parts.forEach((part, index) => {
|
|
484
|
+
if (!host.sourceReferences.has(part.source))
|
|
485
|
+
throw new HostError("missing", `part ${index} names no source reference of this plugin`);
|
|
486
|
+
});
|
|
487
|
+
const checked = exportCheck(parts);
|
|
488
|
+
host.exports.push(structuredClone(p));
|
|
489
|
+
const jobId = ++inner.next.job;
|
|
490
|
+
host.jobs.set(jobId, {
|
|
491
|
+
jobId,
|
|
492
|
+
status: "queued",
|
|
493
|
+
publicationStarted: false,
|
|
494
|
+
facts: null,
|
|
495
|
+
outcome: null,
|
|
496
|
+
progress: null,
|
|
497
|
+
});
|
|
498
|
+
inner.exportJobs.set(jobId, {
|
|
499
|
+
destination: String(p.destination),
|
|
500
|
+
clip: null,
|
|
501
|
+
join: {
|
|
502
|
+
tokens: parts.map((part) => part.source),
|
|
503
|
+
parts: parts.length,
|
|
504
|
+
total: checked.duration,
|
|
505
|
+
mode: copy ? "copy" : "mp4",
|
|
506
|
+
container: !copy
|
|
507
|
+
? "mp4"
|
|
508
|
+
: p.container === "mkv" ||
|
|
509
|
+
(p.container !== "mp4" &&
|
|
510
|
+
checked.copy.ok &&
|
|
511
|
+
checked.copy.container === "mkv")
|
|
512
|
+
? "mkv"
|
|
513
|
+
: "mp4",
|
|
514
|
+
// A copy starts each part on a "keyframe" 1 s early, as clips do.
|
|
515
|
+
written: parts.map((part) => ({
|
|
516
|
+
start: copy ? Math.max(0, part.start - 1) : part.start,
|
|
517
|
+
end: part.end,
|
|
518
|
+
})),
|
|
519
|
+
},
|
|
520
|
+
});
|
|
521
|
+
return { jobId, status: "queued" };
|
|
522
|
+
}
|
|
523
|
+
return {
|
|
524
|
+
...handlers,
|
|
178
525
|
"producer.prepare": async () => {
|
|
179
526
|
const id = ++inner.next.producer;
|
|
180
527
|
const tcp = host.producerTransport === "tcp";
|
|
@@ -484,6 +484,35 @@ export function mediaHandlers(host, inner) {
|
|
|
484
484
|
}
|
|
485
485
|
return result;
|
|
486
486
|
},
|
|
487
|
+
// The player's `media.sources.open`: the token's file opened as a
|
|
488
|
+
// `source.submit` open under the plugin's operation id, at `start`.
|
|
489
|
+
"media.sources.open": (p) => {
|
|
490
|
+
const reference = host.sourceReferences.get(String(p.token));
|
|
491
|
+
if (!reference)
|
|
492
|
+
throw new HostError("missing", "no such source reference");
|
|
493
|
+
const file = host.mediaFiles.get(reference.path) ?? {};
|
|
494
|
+
if (file.status === "missing")
|
|
495
|
+
throw new HostError("source-missing", "the file is missing");
|
|
496
|
+
if (file.status === "changed" ||
|
|
497
|
+
(file.version ?? 0) !== (reference.version ?? 0))
|
|
498
|
+
throw new HostError("source-changed", "the file changed since it was remembered");
|
|
499
|
+
const start = p.start === undefined ? 0 : Number(p.start);
|
|
500
|
+
const duration = file.duration ?? host.source.duration ?? 60;
|
|
501
|
+
if (!(start >= 0 && start < duration))
|
|
502
|
+
throw new HostError("invalid", "start must be before the file's end");
|
|
503
|
+
const intent = {
|
|
504
|
+
kind: "open",
|
|
505
|
+
source: reference.path,
|
|
506
|
+
startPaused: false,
|
|
507
|
+
};
|
|
508
|
+
host.sourceOpens.push({ token: String(p.token), start });
|
|
509
|
+
const ticket = sourceIntent(host, inner, intent);
|
|
510
|
+
// Loaded at once, at the start (the player's `start=`).
|
|
511
|
+
host.setSource({ phase: "ready", duration, position: start });
|
|
512
|
+
const result = { status: "completed", ...ticket };
|
|
513
|
+
inner.sourceBook.set(Number(p.operationId), result);
|
|
514
|
+
return result;
|
|
515
|
+
},
|
|
487
516
|
"source.operation": (p) => {
|
|
488
517
|
const result = inner.sourceBook.get(Number(p.operationId));
|
|
489
518
|
if (!result)
|
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
RenderingReasonCode,
|
|
7
7
|
RenderingState,
|
|
8
8
|
} from "./services.ts";
|
|
9
|
-
import type { ExportJob, Snapshot } from "./snapshots.ts";
|
|
9
|
+
import type { ExportJob, MediaSources, Snapshot } from "./snapshots.ts";
|
|
10
10
|
import type { Resolver } from "./sources.ts";
|
|
11
11
|
import type { PropValue, View } from "./ui-content.ts";
|
|
12
12
|
import type { Panel, Window } from "./ui-layout.ts";
|
|
@@ -123,7 +123,7 @@ export interface Disposable {
|
|
|
123
123
|
* | `unknown`, `rejected`, `expired` | After a transport problem the SDK could not confirm the outcome (does not happen in normal operation). |
|
|
124
124
|
* | `activation` | The plugin opened a tool window while its activation was still pending and the player could not track it. |
|
|
125
125
|
* | `command` | The player could not run or update a command it no longer knows for this plugin (removed meanwhile, or another plugin's). |
|
|
126
|
-
* | `export-failed` | An export job ({@link ExportJob}) failed: the code of its `outcome.error`, not a rejection; `message` has the worker's or FFmpeg's reason. |
|
|
126
|
+
* | `export-failed`, `source-missing`, `source-changed`, `no-space` | An export job ({@link ExportJob}) failed: the code of its `outcome.error`, not a rejection; `message` has the worker's or FFmpeg's reason. An export of parts ({@link MediaCapture.export}) ends `source-missing` when a part's file is gone and `source-changed` when it changed since it was remembered; {@link MediaSources.open} rejects with them. An export of parts ends `no-space` when the disk has less room than its estimate. |
|
|
127
127
|
* | `input-overflow` | `openStream` input: the player's queue of physical key transitions was full; the input was revoked and its keys released. |
|
|
128
128
|
* | `internal` | An internal step of the player failed (keeping an operation's result, a subtitle or media job); `message` has the reason. |
|
|
129
129
|
* | `javascript`, `slint` | {@link Packages.validate}: the package's entry module does not pass `node --check` / one of its Slint files does not compile; `message` has the diagnostics. |
|