///
import { InferredFormatInfo } from "./types/ffmpeg";
import { Flags } from "./types/flags";
import { ChunkData, FormatMetadata, GraphInstance, StreamMetadata, WriteChunkData } from "./types/graph";
declare type MessageType = keyof Messages;
interface Messages {
load: {
send: {
wasm: ArrayBuffer;
};
reply: {
wasm: ArrayBuffer;
};
};
getMetadata: {
send: {
fileSize: number;
};
reply: {
container: FormatMetadata;
streams: StreamMetadata[];
};
};
inferFormatInfo: {
send: {
format: string;
url: string;
};
reply: InferredFormatInfo;
};
buildGraph: {
send: {
graphInstance: GraphInstance;
flags: Flags;
};
reply: void;
};
nextFrame: {
send: void;
reply: {
outputs: {
[nodeId in string]?: WriteChunkData[];
};
endWriting: boolean;
progress: number;
};
};
deleteGraph: {
send: void;
reply: void;
};
releaseWorkerBuffer: {
send: {
buffer: Uint8Array;
};
reply: void;
};
}
declare type BackMessageType = keyof BackMessages;
interface BackMessages {
read: {
send: undefined;
reply: {
inputs: ChunkData[];
};
};
seek: {
send: {
pos: number;
};
reply: void;
};
releaseMainBuffer: {
send: {
buffers: Uint8Array[];
};
reply: void;
};
}
interface AllMessages extends Messages, BackMessages {
}
declare type AllReplyCallback = (t: AllMessages[T]['send'], id: string, transferArr: TransferArray) => AllMessages[T]['reply'] | Promise;
declare type TransferArray = (Transferable | VideoFrame | AudioData)[];
/**
* only allow one access, others wait in promise
*/
export declare class Lock {
#private;
/**
*
* @returns unlock function
*/
start(): Promise<() => void>;
}
export declare class FFWorker {
worker: Worker;
lock: Lock;
constructor(worker: Worker);
send(sendMsg: T, data: Messages[T]['send'], transferArray: TransferArray, id?: string): Promise;
reply(msgType: T, callback: AllReplyCallback, id: string): void;
close(): void;
}
/**
*
*/
export declare class WorkerHandlers {
reply(msgType: T, callback: AllReplyCallback): void;
send(msgType: T, data: BackMessages[T]['send'], transferArray: TransferArray, id: string): Promise;
}
export {};