File size: 2,358 Bytes
966b234 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | """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",
]
|