"""Capture Manager — orchestrates frame and audio capture streams. Provides a unified interface for the inference layer to get the latest frame and audio chunk with a single call. """ from __future__ import annotations import logging from typing import Optional, Tuple from capture.audio_capture import AudioChunk, AudioCapturer from capture.frame_capture import FrameCapture, FrameCapturer logger = logging.getLogger(__name__) class CaptureManager: """Unified manager for frame and audio capture streams.""" def __init__(self, config, window_title: Optional[str] = None) -> None: self.frame_capturer = FrameCapturer(config, window_title=window_title) self.audio_capturer = AudioCapturer(config) async def start(self) -> None: """Start both capture streams.""" await self.frame_capturer.start() await self.audio_capturer.start() logger.info("CaptureManager started") async def stop(self) -> None: """Stop both capture streams.""" await self.frame_capturer.stop() await self.audio_capturer.stop() logger.info("CaptureManager stopped") async def get_latest(self) -> Tuple[Optional[FrameCapture], Optional[AudioChunk]]: """Return the latest (frame, audio) pair. Frame may be None if no new frame is available since last call. Audio may be None if audio capture is disabled or chunk is silent. """ frame = await self.frame_capturer.get_latest() audio = await self.audio_capturer.get_latest() return frame, audio