Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
cap-camera-mediafoundation
Ergonomic Rust wrapper around Windows Media Foundation API for camera capture, providing safe abstractions while maintaining low-level control. Aims to mirror how Chromium consumes Media Foundation.
Purpose
Provides safe access to Windows camera devices through Media Foundation's Capture Engine, handling COM initialization, device enumeration, format negotiation, and asynchronous frame delivery.
Key Features
- Device Discovery:
DeviceSourcesIteratorfor enumerating video capture devices - Format Enumeration: Access to native media types supported by each device
- Asynchronous Capture: Channel-based frame delivery via
CaptureHandle - Memory Safety: RAII buffer locking with
IMFMediaBufferExttrait - Error Handling: Comprehensive error types and retry logic for Media Foundation timing issues
Core APIs
Device Management
initialize_mediafoundation()- Initialize MF subsystemDeviceSourcesIterator::new()- Enumerate available camerasDevice::name(),Device::id(),Device::model_id()- Device metadataDevice::formats()- Iterator over supportedIMFMediaTypeformats
Capture Pipeline
Device::start_capturing(format)- Begin async capture with specified formatCaptureHandle::sample_rx()- ReceiveIMFSampleframes via channelCaptureHandle::event_rx()- ReceiveCaptureEngineEventstatus updates
Frame Processing
VideoSample::bytes()- Extract frame data as byte arrayIMFMediaBufferExt::lock()- Safe buffer access with automatic unlock
Architecture
Bridges Media Foundation's callback-based model to Rust's ownership system using channels for cross-thread communication, RAII for resource management, and comprehensive error handling for production reliability.