"""UVC camera controls — platform-aware factory.""" from __future__ import annotations import logging import platform from app.camera.uvc.base import UvcControllerBase, UvcParam, UvcParamInfo logger = logging.getLogger(__name__) def make_uvc_controller(device_name: str) -> UvcControllerBase: """ Return the best available UVC controller for the current platform. Falls back to NullUvcController if the required native library is absent. """ system = platform.system() if system == "Windows": try: from app.camera.uvc.windows import WindowsUvcController # noqa: PLC0415 ctrl = WindowsUvcController(device_name) logger.info("UVC: Windows controller (duvc-ctl) loaded for '%s'", device_name) return ctrl except ImportError: logger.warning( "UVC: duvc-ctl not installed — install with: pip install duvc-ctl" ) elif system == "Darwin": try: from app.camera.uvc.macos import MacUvcController # noqa: PLC0415 ctrl = MacUvcController(device_name) logger.info("UVC: macOS controller loaded for '%s'", device_name) return ctrl except ImportError: logger.warning( "UVC: pyuvc not installed — UVC controls unavailable on macOS" ) else: logger.warning("UVC: platform '%s' not supported — controls unavailable", system) from app.camera.uvc.stub import NullUvcController # noqa: PLC0415 return NullUvcController() __all__ = ["make_uvc_controller", "UvcControllerBase", "UvcParam", "UvcParamInfo"]