import type { Logger } from 'zapo-js'; import { type InboundVideoFrame, type InboundVideoRtpPacket, type WaCallMediaEvent, type WaCallMediaMessage, type WaCallMediaPlanUpdate, type WaCallReaction } from '@zapo-js/voip-media'; /** What a session hears back from wherever its media runs. */ export interface WaCallMediaLinkEvents { /** Media started flowing: the call is accepted and a relay leg is up. */ onActive(): void; onRelayLost(reason: string): void; onReaction(reaction: WaCallReaction): void; onInboundAudio(pcm: Float32Array): void; onInboundVideoRtp(packet: InboundVideoRtpPacket): void; onInboundVideo(frame: InboundVideoFrame): void; onOutboundAudioFinished(): void; /** A plan change for a host elsewhere to apply; only a remote link emits it. */ onPlan(message: WaCallMediaMessage): void; } /** * What a session talks to about media: the session publishes the plan, and the link * decides whether it runs in this process or on a host elsewhere. */ export interface WaCallMediaLink { /** Readies the media side; the local link loads the codec. */ start(): Promise; apply(update: WaCallMediaPlanUpdate): Promise; stop(): void; sendReaction(reaction: string): boolean; sendVideoFrame(data: Uint8Array, timestampUs: number): number; loadAudio(audioPath: string): Promise; setExternalAudioMode(enabled: boolean): void; feedLiveAudio(data: Float32Array): number; getLiveBufferMs(): number; /** An event from the remote host; the local link has none to take. */ handleEvent(event: WaCallMediaEvent): void; /** The whole plan as it stands, for a remote host that joins late or lost track. */ snapshot(): WaCallMediaMessage | null; } export interface WaLocalCallMediaOptions { readonly logger: Logger; readonly events: WaCallMediaLinkEvents; readonly useOriginalRelayPort: boolean; readonly useRawUdpTransport: boolean; } /** * Media carried in this process: a plane on the Node host, clocked and fed by the audio * engine, whose one capture clock runs from the warmup silence into the real source. */ export declare class WaLocalCallMedia implements WaCallMediaLink { private readonly plane; private readonly audio; constructor(options: WaLocalCallMediaOptions); start(): Promise; apply(update: WaCallMediaPlanUpdate): Promise; stop(): void; sendReaction(reaction: string): boolean; sendVideoFrame(data: Uint8Array, timestampUs: number): number; loadAudio(audioPath: string): Promise; setExternalAudioMode(enabled: boolean): void; feedLiveAudio(data: Float32Array): number; getLiveBufferMs(): number; handleEvent(): void; snapshot(): null; } /** * Media carried by a host elsewhere: the plan leaves through * {@link WaCallMediaLinkEvents.onPlan} and the host's events come back via {@link handleEvent}. */ export declare class WaRemoteCallMedia implements WaCallMediaLink { private readonly events; private readonly sequencer; private active; private stopped; constructor(callId: string, events: WaCallMediaLinkEvents); start(): Promise; apply(update: WaCallMediaPlanUpdate): Promise; stop(): void; /** Reactions ride the media, so the host carrying it is the one that sends them. */ sendReaction(): boolean; /** Video rides the media, so the host carrying it is the one that sends it. */ sendVideoFrame(): number; loadAudio(): Promise; setExternalAudioMode(): void; feedLiveAudio(): number; getLiveBufferMs(): number; handleEvent(event: WaCallMediaEvent): void; snapshot(): WaCallMediaMessage; }