CharlieDreemur's picture
RecreateAAA 0.1.0 from Recreate-AAA/Recreate-AAA@7da1a3d
966b234 verified
Raw History Blame Contribute Delete
2.36 kB
"""Public contract for gameplay-video source plugins."""
from __future__ import annotations
from dataclasses import dataclass, field
from pathlib import Path
from typing import Any, Mapping, Protocol
from bench_builder.video_plugin_options import PluginOptionSpec
class VideoSourcePluginError(RuntimeError):
"""Raised when a source cannot be opened or clipped."""
@dataclass(frozen=True)
class VideoSourceInput:
kind: str
url: str = ""
path: Path | None = None
filename: str = ""
@dataclass(frozen=True)
class VideoSourcePluginDescriptor:
plugin_id: str
display_name: str
input_kinds: tuple[str, ...]
options: tuple[PluginOptionSpec, ...] = ()
@dataclass(frozen=True)
class VideoSourceCapability:
ready: bool
reason: str
remote_preview: bool = False
selected_range: bool = True
@dataclass(frozen=True)
class ResolvedVideo:
plugin_id: str
source: VideoSourceInput
title: str
duration_seconds: float
preview_source: str | Path
metadata: Mapping[str, Any] = field(default_factory=dict)
@dataclass(frozen=True)
class VideoClipSelection:
start_seconds: float
end_seconds: float
@property
def duration_seconds(self) -> float:
return self.end_seconds - self.start_seconds
@dataclass(frozen=True)
class VideoClipArtifact:
plugin_id: str
path: Path
start_seconds: float
end_seconds: float
duration_seconds: float
class VideoSourcePlugin(Protocol):
descriptor: VideoSourcePluginDescriptor
def validate_options(
self, options: Mapping[str, Any] | None
) -> dict[str, Any]: ...
def supports(self, source: VideoSourceInput) -> bool: ...
def probe(
self, source: VideoSourceInput, options: Mapping[str, Any]
) -> VideoSourceCapability: ...
def resolve(
self, source: VideoSourceInput, options: Mapping[str, Any]
) -> ResolvedVideo: ...
def materialize_clip(
self,
video: ResolvedVideo,
selection: VideoClipSelection,
destination: Path,
options: Mapping[str, Any],
) -> VideoClipArtifact: ...
__all__ = [
"ResolvedVideo",
"VideoClipArtifact",
"VideoClipSelection",
"VideoSourceCapability",
"VideoSourceInput",
"VideoSourcePlugin",
"VideoSourcePluginDescriptor",
"VideoSourcePluginError",
]