crates/camera-avfoundation/README.md
Ergonomic Rust wrapper around macOS AVFoundation API for camera capture, providing safe abstractions while maintaining low-level control. Built on top of the cidre framework for Apple platform APIs. Aims to mirror how Chromium consumes AVFoundation.
Provides safe access to macOS camera devices through AVFoundation's capture system, handling device enumeration, format negotiation, color space management, and callback-based frame delivery.
list_video_devices() for enumerating built-in, external, and desk view camerasCallbackOutputDelegateImageBufExt trait and BaseAddrLockGuardlist_video_devices() - Enumerate available cameras (built-in, external, desk view)av::CaptureDevice (name, unique ID, formats)CallbackOutputDelegate - Custom delegate for handling frame callbacksCallbackOutputDelegateInner::new(callback) - Create delegate with closure-based frame handlerImageBufExt::base_addr_lock() - Safe pixel buffer access with automatic unlockBaseAddrLockGuard::plane_data(index) - Extract planar frame data as byte slicesBridges AVFoundation's delegate-based model to Rust's ownership system using closures for frame callbacks, RAII for pixel buffer management, and comprehensive color space handling. The capture pipeline requires careful device configuration locking to prevent format overwrites during session startup.