import { MediaRendererPlaybackState } from "#types/media-renderer"; import type { PresentedFrameChannel, PresentedFrameNavigation } from "./presented-frame-channel"; export interface MediaRendererTransport { play(): Promise; pause(): void; togglePlayback(): Promise; scrub(mediaTime: number): void; commit(mediaTime: number): Promise; resizeOutput(resize: () => Promise): Promise; step(direction: 1 | -1): Promise; setPlaybackRate(rate: number): void; /** Holds a producer frame before the scene can display it. */ protectPresentation(mediaTime: number, signal: AbortSignal): Promise | null; /** Releases a ready presentation hold after the scene acknowledges its frame. */ didPresentFrame(): Promise | void; destroy(): void; } export interface MediaRendererTransportOptions { /** Replay from the start when the producer reports the source ended. */ readonly loop: boolean; readonly channel: PresentedFrameChannel; readonly onPlaybackRate: (rate: number) => void; readonly onPlaybackState: (state: MediaRendererPlaybackState) => void; readonly onPlayheadTime: (mediaTime: number) => void; /** * The playhead has moved to a frame that is not on screen yet. Reported apart * from `onPlaybackState` because the state a seek settles from is the one the * transport keeps reporting throughout it. * * True for a scrub as well as for a landing, so pair it with `onScrubbing` to * tell a viewer who is waiting from one who is dragging. */ readonly onSeeking: (seeking: boolean) => void; /** * A drag is open on the playhead. Published as the drag opens and closes * without waiting for the producer, whose next word on a slow source is * seconds away. */ readonly onScrubbing: (scrubbing: boolean) => void; /** Buffered playback. Awaited before the producer is asked to run. */ readonly waitForReadiness?: (mediaTime: number, signal: AbortSignal) => Promise; /** * A bounded wait for whatever annotates `mediaTime`, or null when nothing is * missing. Asked on every playhead move, so answering null has to be cheap. * * This is what stops a producer already at speed, so what it waits for has to * be something that gives up on its own. Left out, playback is held once and * never again, and a producer outrunning whatever feeds it runs on past * frames that have nothing to draw. * * `signal` aborts once anything else settles playback, so a hold the viewer * has already paused or seeked past is not still holding a play nobody asked * for. */ readonly holdForReadiness?: (mediaTime: number, signal: AbortSignal) => Promise | null; /** Readiness required before a producer frame may enter the scene. */ readonly waitForPresentationReadiness?: (mediaTime: number, signal: AbortSignal) => Promise | null; /** Drops a guarded frame synchronously when navigation supersedes it. */ readonly invalidatePresentedFrame?: () => void; /** Opens an acknowledgment that settles after the scene accepts the frame * where the producer's navigation landed. */ readonly beginPresentedFrameNavigation?: (preserveCurrent?: boolean) => PresentedFrameNavigation; } /** * The renderer's playback surface over a producer that owns the playhead. * Seconds meet milliseconds here and nowhere else. * * A drag is a pair: every `scrub` belongs to one gesture the producer is told * about, and the `commit` that lands it releases that gesture, so a producer * that froze itself for the drag is the one deciding whether to resume. The * drag and the settle travel as separate signals: which of the two a viewer is * looking at is the host's judgement, not the transport's. */ export declare function createMediaRendererTransport(options: MediaRendererTransportOptions): MediaRendererTransport; //# sourceMappingURL=media-renderer-transport.d.ts.map