Skip to content

Video Decode Worker Control Adapter

app.infrastructure.adapters.video_decode_worker_control_adapter

View source code

Explicit adapter wrapping VideoDecodeWorker to VideoDecodeWorkerControlInterface.

See Also

Layer: Infrastructure. Context: Implements concrete processing and I/O behind application-facing contracts.

VideoDecodeWorkerControlAdapter

Bases: VideoDecodeWorkerControlInterface

Explicit adapter that wraps a concrete VideoDecodeWorker instance and exposes the VideoDecodeWorkerControlInterface contract.

In normal usage the concrete VideoDecodeWorker already satisfies VideoDecodeWorkerControlInterface via structural subtyping (Protocol), so this adapter is not required for runtime correctness. It exists to:

  • Provide an explicit, named boundary at the infrastructure/application seam.
  • Enable test doubles that replace the real worker without subclassing VideoDecodeWorker.

Only the control-surface methods (set_active, stop, get_cached_frame_at_index) are delegated; low-level ring-buffer and signal internals stay on the concrete worker.

PARAMETER DESCRIPTION
worker

Concrete video decode worker controlled by this adapter.

TYPE: VideoDecodeWorker

__init__(worker: VideoDecodeWorker) -> None

get_cached_frame_at_index(idx: int) -> RGBFrame | None

Retrieve a decoded frame from the worker's ring buffer.

PARAMETER DESCRIPTION
idx

Zero-based frame index to look up.

TYPE: int

RETURNS DESCRIPTION
RGBFrame | None

Cached RGB frame, or None when the index is not in the buffer.

set_active(active: bool, resume_idx: int = 0) -> None

Activate or deactivate the wrapped decode worker.

PARAMETER DESCRIPTION
active

Whether the worker should decode frames.

TYPE: bool

resume_idx

Frame index from which decoding should resume when activated.

TYPE: int DEFAULT: 0

stop() -> None

Stop the wrapped decode worker and release its reader resources.