import type { MediaRendererDisplay } from "#types/media-renderer-display"; import type { DetectionBufferOptions, DetectionFrameSource, MediaFrameDiagnostics, MediaRendererDiagnosticsOptions, MediaRendererFit, MediaRendererPresentation, MediaRendererState, MediaRendererStateController, MediaSourceState } from "supervision-js-core"; import type { PreparedAnnotationWindowSnapshot } from "#renderers/prepared-annotation-window"; import type { DetectionFrame } from "supervision-js-core"; import type { DetectionPickResult, DetectionSelectionOptions, MediaInteractionOptions } from "supervision-js-core"; import type { DecodedMediaSource } from "#media/media-source"; import type { RenderPreparationOptions } from "#types/render-preparation"; import type { MediaFrameClock } from "#types/media-frame-clock"; import type { MediaFrameNavigation } from "#types/media-frame-navigation"; import type { AnnotationEditingEngine, PreviewOverlayData } from "supervision-js-core"; import type { MaskBrushPreviewOptions } from "../editing"; import type { ActiveDepthMap, MediaRendererDepthInput } from "#types/media-depth"; export { MediaRendererFit, MediaRendererPlaybackState, MediaSourceStatus, } from "supervision-js-core"; export type { AnnotationAntialiasing, MediaFrameDiagnostics, MediaFrameRenderTimings, MediaRendererDiagnosticsOptions, MediaRendererAssetError, MediaRendererPresentation, MediaRendererQuality, MediaRendererState, MediaDisplayAdjustments, MediaSourceState, } from "supervision-js-core"; /** Clock used by semantic detection frames supplied to a media renderer. */ export declare enum DetectionTimelineOrigin { /** Detection times already use the decoded media source's native timeline. */ MediaTimeline = "mediaTimeline", /** Detection time zero corresponds to the first decoded media sample. */ MediaStart = "mediaStart" } /** * Lower-level renderer options. * * Most applications should prefer `createMediaSession`, which wires media * preparation, detection buffering, and render preparation with defaults. */ export interface MediaRendererOptions extends MediaRendererPresentation { readonly container: HTMLElement; readonly src?: string | URL | Request; readonly source?: MediaRendererSource; readonly autoPlay?: boolean; readonly loop?: boolean; readonly playbackRate?: number; /** * @deprecated Nothing reads this. The renderer is video-only and audio * playback is deferred, so setting it changes nothing either way. */ readonly muted?: boolean; readonly fit?: MediaRendererFit; /** * Caps Pixi's render resolution relative to device pixels. * * Lower values reduce GPU memory and fill-rate pressure. For example, * capping a Retina display from DPR 2 to 1 renders one quarter as many * pixels, which can be useful for long videos or browsers under load. */ readonly maxDevicePixelRatio?: number; /** * Show distinct source pixels when the media-to-screen scale reaches * `minScale` CSS pixels per natural media pixel (including contain/cover * fit). Below that positive, finite threshold, media is smoothly sampled. * Omit to retain smooth sampling at every zoom. Annotation styles and the * source pixels returned by captureFrame are unaffected. */ readonly pixelInspection?: { readonly minScale: number; }; /** * Interleave raster masks with retained boxes and polygons by detection zIndex * (frame order breaks ties). Omit to retain the dense mask-below-geometry path. * Independent mask coverage costs one bit per cropped source pixel per mask. */ readonly maskOrder?: "detection"; readonly detectionFrames?: readonly DetectionFrame[]; readonly detectionSource?: DetectionFrameSource; readonly detectionBuffer?: DetectionBufferOptions; /** * Aligns detection timestamps with media whose first presentation timestamp * is not zero. Defaults to `MediaTimeline` for backward compatibility. */ readonly detectionTimelineOrigin?: DetectionTimelineOrigin; /** * Depth drawn by `depth` annotation renderers, separate from detection * frames. A map whose aspect ratio differs from the media's puts the * renderer in its error state. A manifest loads once the media's first * frame is up; one that fails leaves the media playing without depth. */ readonly depth?: MediaRendererDepthInput; readonly interaction?: MediaInteractionOptions; readonly renderPreparation?: RenderPreparationOptions; readonly diagnostics?: MediaRendererDiagnosticsOptions; readonly editingEngine?: AnnotationEditingEngine; readonly maskBrush?: MaskBrushPreviewOptions; /** Creates a media-sized brush preview after the source metadata is known. */ readonly createMaskBrush?: (dimensions: { readonly width: number; readonly height: number; }) => MaskBrushPreviewOptions; readonly previewOverlay?: () => PreviewOverlayData | null; readonly onFrame?: (diagnostics: MediaFrameDiagnostics) => void; readonly onSource?: (state: MediaSourceState) => void; readonly onState?: (state: MediaRendererState) => void; } /** * Provider contract for opening decoded media. * * This is primarily useful for advanced integrations. The default session path * supplies the built-in browser/Mediabunny source. */ export interface MediaRendererSource { open(): Promise; } /** * Encoder options for capturing the currently presented media frame. */ export interface MediaFrameCaptureOptions { /** * Encoded image MIME type. Defaults to `image/jpeg`. * * Browsers are only required to support `image/png`; unsupported types fall * back to the browser's default encoding, which the capture reports back in * `MediaFrameCapture.type`. */ readonly type?: string; /** * Lossy encoder quality between `0` and `1`. Defaults to `0.92`. Ignored by * lossless encoders such as `image/png`. */ readonly quality?: number; } /** * Encoded image of the media frame the renderer is currently presenting. * * The image holds raw media pixels without annotation layers, paired with the * presentation timestamp of that exact frame. */ export interface MediaFrameCapture { /** Encoded image bytes for the captured media frame. */ readonly blob: Blob; /** Presentation timestamp of the captured frame on the media timeline. */ readonly mediaTime: number; /** Encoded image MIME type produced by the browser. */ readonly type: string; /** Captured image width in media pixels. */ readonly width: number; /** Captured image height in media pixels. */ readonly height: number; } /** Screen-space bounds of a detection label after renderer layout. */ export interface DetectionLabelBounds { readonly x: number; readonly y: number; readonly width: number; readonly height: number; } /** * Lower-level renderer controller. * * Prefer `MediaSession` for application code unless you need to own media * preparation and detection buffering yourself. */ export interface MediaRenderer extends MediaRendererStateController { /** Exact frame timing when the source provides an index; null otherwise. */ readonly frameClock?: MediaFrameClock | null; /** Indexed moves and observable scrub landings for push-based indexed sources. */ readonly frameNavigation?: MediaFrameNavigation | null; /** * Resize engine-backed display-box output without reopening the source. * Resolves after the resized frame is presented; supersession rejects with AbortError. * Available only on sources that support live output sizing. */ setDisplay?(display: MediaRendererDisplay): Promise; play(): Promise; pause(): void; /** * Flips playback without the caller first reading which way it is going, so * a frame presented between the read and the call cannot invert the result. * Rejects when the play it decides on fails. */ togglePlayback(): Promise; /** Lands on `mediaTime` and resolves once the frame there is presented. */ seek(mediaTime: number): Promise; /** * Moves the playhead for a gesture that is still moving, such as a timeline * drag between pointer down and up. The frame that answers it may be an * approximation; `seek` is what lands the released position exactly. */ scrub(mediaTime: number): void; stepForward(): Promise; stepBackward(): Promise; setPlaybackRate(playbackRate: number): void; /** Re-read detections and redraw the currently presented media frame. */ refresh(): Promise; /** * Encodes the media frame that is currently presented. * * The renderer keeps decode and render ownership: the returned image is a * copy of the presented media pixels taken before encoding starts, so a frame * presented while the encoder runs cannot change the result. */ captureFrame(options?: MediaFrameCaptureOptions): Promise; /** Replaces selection; an ordered `detectionIds` list returns its last valid pick. */ setSelectedDetection(selection: DetectionSelectionOptions | null): DetectionPickResult | null; /** * Replaces the depth that `depth` renderers draw, or removes it with * `null`, and redraws the frame on screen. Rejects with a `RangeError` for a * malformed map or one whose aspect ratio differs from the media's. */ setDepth?(depth: MediaRendererDepthInput | null): Promise; /** * The depth map on screen, with the media size it is stretched over, or * null when no depth is drawn. Pass it to `readDepthAt` for a readout. */ getActiveDepth?(): ActiveDepthMap | null; /** * Explicit renders issued under the render-on-change policy, which a media * source that pushes presented frames and a still image run under: the count * moves when something on screen changed, so a paused, untouched renderer * holds it still. It is `null` when the renderer pulls samples from media * that plays, because Pixi's ticker then paints every animation frame and no * count describes that, so a `null` here is an answer rather than a failure. */ getRenderCount(): number | null; /** * Span and per-frame readiness of the prepared annotation window, for * instruments; null when the scene free-runs on the ticker or no window * exists, so a `null` here is an answer rather than a failure. */ getPreparedAnnotationWindow(): PreparedAnnotationWindowSnapshot | null; destroy(): void; getViewportTransform(): import("supervision-js-core").ViewportTransform; /** Apply an exact natural-media-to-CSS transform, including while locked. * The scale must be positive and finite. Locking suppresses pointer viewport * gestures; it does not block explicit toolbar or restored viewport state. */ setViewportTransform(transform: Partial>): void; /** Prevent pointer viewport gestures without blocking explicit transforms. */ setViewportLocked(locked: boolean): void; /** Convert container-relative CSS pixels to natural media pixels. */ screenToMedia(point: import("supervision-js-core").Point): import("supervision-js-core").Point; /** Convert natural media pixels to container-relative CSS pixels. */ mediaToScreen(point: import("supervision-js-core").Point): import("supervision-js-core").Point; /** * Returns the label rectangle exactly as laid out by the renderer. * * Coordinates are relative to the renderer container and already include * fit, pan, zoom, screen-stable label sizing, and media-edge clamping. */ getDetectionLabelBounds(detectionId: string | number): DetectionLabelBounds | null; panViewportBy(dx: number, dy: number): void; zoomViewportAt(point: import("supervision-js-core").Point, factor: number): void; zoomViewportFromWheel(point: import("supervision-js-core").Point, deltaY: number): void; } //# sourceMappingURL=media-renderer.d.ts.map