web/workers: split up args by type

This commit is contained in:
jj 2025-03-29 14:15:40 +00:00
parent 53ca7700a5
commit a183265838
No known key found for this signature in database
3 changed files with 23 additions and 12 deletions

View File

@ -95,6 +95,7 @@ export const createSavePipeline = (info: CobaltLocalProcessingResponse, request:
workerId: crypto.randomUUID(), workerId: crypto.randomUUID(),
parentId, parentId,
workerArgs: { workerArgs: {
files: [],
ffargs, ffargs,
output: { output: {
type: info.output.type, type: info.output.type,

View File

@ -18,11 +18,11 @@ export const startWorker = async ({ worker, workerId, parentId, workerArgs }: Co
switch (worker) { switch (worker) {
case "remux": case "remux":
if (workerArgs?.files) { if (workerArgs.files) {
files = workerArgs.files; files = workerArgs.files;
} }
if (files?.length === 0) { if (files.length === 0) {
const parent = get(queue)[parentId]; const parent = get(queue)[parentId];
if (parent.state === "running" && parent.pipelineResults.length) { if (parent.state === "running" && parent.pipelineResults.length) {
files = parent.pipelineResults; files = parent.pipelineResults;
@ -42,9 +42,7 @@ export const startWorker = async ({ worker, workerId, parentId, workerArgs }: Co
break; break;
case "fetch": case "fetch":
if (workerArgs?.url) { await runFetchWorker(workerId, parentId, workerArgs.url)
await runFetchWorker(workerId, parentId, workerArgs.url)
}
break; break;
} }
} }

View File

@ -12,16 +12,28 @@ export type CobaltWorkerProgress = {
size: number, size: number,
} }
export type CobaltWorkerArgs = { export type CobaltFetchWorkerArgs = { url: string };
files?: CobaltFileReference[],
url?: string, export type CobaltRemuxWorkerArgs = {
ffargs?: string[], files: CobaltFileReference[],
output?: FileInfo, ffargs: string[],
output: FileInfo,
} }
export type CobaltPipelineItem = { export type CobaltPipelineItemBase = {
worker: CobaltWorkerType, worker: CobaltWorkerType,
workerId: string, workerId: string,
parentId: string, parentId: string,
workerArgs: CobaltWorkerArgs, };
type CobaltRemuxPipelineItem = CobaltPipelineItemBase & {
worker: "remux",
workerArgs: CobaltRemuxWorkerArgs,
} }
type CobaltFetchPipelineItem = CobaltPipelineItemBase & {
worker: "fetch",
workerArgs: CobaltFetchWorkerArgs,
}
export type CobaltPipelineItem = CobaltRemuxPipelineItem | CobaltFetchPipelineItem;