/** * @category composable */ export interface IFragment { compile(compiler: ICompiler): void; clone(): IFragment; } /** * @category composable */ export interface IPlaceholder { readonly dependencies: IFragment[]; materialize(): T; } /** * @category composable */ export declare function isPlaceholder(obj: any): obj is IPlaceholder; /** * @category composable */ export declare class Placeholder implements IPlaceholder { protected getter: () => T; readonly dependencies: IFragment[]; constructor(getter: () => T, dependencies?: IFragment[]); materialize(): T; map(fn: (value: T) => U): Placeholder; } /** * @category composable */ export interface ISource extends IFragment, IPlaceholder { outputs: StreamRef[]; named(...names: string[]): this; [Symbol.iterator](): IterableIterator; } /** * @category composable */ export interface ISink extends IFragment { inputs: Stream[]; } /** * @category composable */ export interface IFilter extends ISource, ISink { } /** * @category composable */ export declare type Stream = string | StreamRef | ISource; /** * @category composable */ export declare abstract class StreamRef implements IFragment, IPlaceholder { static normalize(streams: Stream[]): StreamRef[]; static normalize(streams: Stream): StreamRef; static normalizeAll(streams: Stream | Stream[]): StreamRef[]; get dependencies(): this[]; readonly name: string; abstract compile(compiler: ICompiler): void; abstract named(name: string): this; abstract clone(): StreamRef; select(suffix: string): SelectStreamRef; materialize(): string; } /** * @category composable */ export declare class SelectStreamRef extends StreamRef { selector: string; parentStream: StreamRef; get name(): string; constructor(parentStream: StreamRef, selector: string); named(name: string): this; compile(compiler: ICompiler): void; clone(): SelectStreamRef; } /** * @category composable */ export declare class StaticStream extends StreamRef { readonly name: string; constructor(name: string); named(name: string): this; compile(compiler: ICompiler): this; clone(): StaticStream; } /** * @category composable */ export declare type FragmentLike = IFragment; /** * @category composable */ export interface ICompiler { readonly filterGraph: FiltergraphCommandOptions; readonly inputs: CommandOptions; readonly outputs: CommandOptions; readonly options: CommandOptions; readonly command: CommandOptions; compile(...fragments: FragmentLike[]): this; clone(): ICompiler; hasStreamName(stream: Stream): boolean; getStreamName(stream: Stream): string; setStreamName(stream: Stream, name: string): this; getInputStreamName(stream: Stream): number; getStreamRef(stream: Stream): StreamRef; toString(): string; } /** * A command is composed of fragments: these can be an [[Input]], an [[Output]], a [[Filter]], a [[Composite]] or a [[StreamRef]]. * * This class is responsible for creating the command from multiple fragments. These fragments can be passed to it's constructor, or to it's [[`Compiler.compile`]] method. * ```typescript * const input = new Input( 'movie.mkv' ); * * const filter = new Filter( input.select( 'v' ), 'scale', { width: 1080, height: 720 } ); * * const output = new Output( 'movie.mp4', [ '-map', filter, '-map', input.select( 'a' ) ] ); * * const compiler = new Compiler( output ); * * // Any aditional fragments can be passed on to the compile method * compiler.compile( output ); * ``` * * Once all necessary fragments are compiled, you can obtain the [[CommandOptions]] as a string through [[`CommandOptions.toString`]] or an array of strings through [[`CommandOptions.toArray`]] * ```typescript * compiler.command.toString(); * compiler.command.toArray(); * ``` * * A compiler can be cloned at any time. This is useful when you want to create multiple, similar commands, * so you don't have to recompile every fragment, but can compile them first, and then clone the compiler as many times as necessary. * * @category composable */ export declare class Compiler implements ICompiler { protected streamRefs: Map; protected streams: PrefixableIdentifierGenerator; protected sources: IndexableIdentifierGenerator; protected compiledFragments: Set; filterGraph: FiltergraphCommandOptions; inputs: CommandOptions; outputs: CommandOptions; options: CommandOptions; get command(): CommandOptions; constructor(...fragments: FragmentLike[]); compile(...fragments: FragmentLike[]): this; clone(): ICompiler; getStreamRef(stream: Stream): StreamRef; hasStreamName(stream: Stream): boolean; getStreamName(stream: Stream): string; getInputStreamName(stream: Stream): number; setStreamName(stream: Stream, name: string): this; } /** * @category composable */ export declare function command(...fragments: FragmentLike[]): CommandOptions; /** * @category composable */ export declare class CommandOptions { options: string[]; constructor(options?: string[]); clone(): CommandOptions; toArray(): string[]; toString(): string; } /** * @category composable */ export declare class FiltergraphCommandOptions extends CommandOptions { options: string[]; constructor(options?: string[]); appendFilter(filter: string): void; clone(): FiltergraphCommandOptions; } /** * @category composable */ export declare abstract class IdentifierGenerator { cache: Map; seed: number; constructor(seed?: number); abstract generate(id: number): K; has(key: T): boolean; getCached(key: T): K; get(key: T): K; set(key: T, name: K): void; } /** * @category composable */ export declare class PrefixableIdentifierGenerator extends IdentifierGenerator { prefix: string; constructor(prefix: string, seed?: number); generate(id: number): string; clone(): PrefixableIdentifierGenerator; } /** * @category composable */ export declare class IndexableIdentifierGenerator extends IdentifierGenerator { generate(id: number): number; clone(): IndexableIdentifierGenerator; }