Skip to content

Implement the AVFoundation driver#4

Closed
oleksandrvoyager wants to merge 11 commits into
masterfrom
alex/avf
Closed

Implement the AVFoundation driver#4
oleksandrvoyager wants to merge 11 commits into
masterfrom
alex/avf

Conversation

@oleksandrvoyager
Copy link
Copy Markdown
Member

No description provided.

Copy link
Copy Markdown

@isaac-asimov-bot isaac-asimov-bot Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ CI failed

Show all
Platform Name Status Details
All Formatting Details
macOS Build library Details
macOS Build library (no default features) Details
macOS Build binaries Details
macOS Build tests Details
macOS Build examples Details
macOS Run tests Details
macOS Run doctests Details
Linux Build library Details
Linux Build library (no default features) Details
Linux Build binaries Details
Linux Build tests Details
Linux Build examples Details
Linux Run tests Details
Linux Run doctests Details
Windows Build library Details
Windows Build library (no default features) Details
Windows Build binaries Details
Windows Build tests Details
Windows Build examples Details
Windows Run tests Details
Windows Run doctests Details

=============================================

Platform Name Status Details
macOS Build library Details
Linux Build library Details
Windows Build library Details

@artob artob changed the title Implement AVFoundation driver Implement the AVFoundation driver Dec 10, 2025
@artob artob requested a review from Copilot December 10, 2025 01:00
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements an AVFoundation-based camera driver for iOS and macOS, enabling native video capture on Apple platforms. The implementation adds frame capture callbacks, configures capture sessions with device selection and format settings, and provides an FFI layer for Swift integration.

Key Changes:

  • Implemented the AvfCameraDriver with full AVFoundation capture session management including device discovery, format configuration, and BGRA frame delivery
  • Added Frame and FrameCallback abstractions to support asynchronous frame delivery from camera drivers
  • Created iOS FFI layer (ffi.rs) exposing C-ABI functions for camera operations and AVCaptureSession access

Reviewed changes

Copilot reviewed 10 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
vendor/rust-core-video-sys Added submodule for Core Video bindings
src/shared/open.rs Updated open_camera to accept frame callback and refined platform-specific driver selection with proper cfg guards
src/shared/mod.rs Exposed new frame module and constrained ffmpeg feature to supported platforms
src/shared/frame.rs Introduced Frame struct and PixelFormat enum for representing video frame data
src/shared/error.rs Added DriverError variant for platform-specific driver failures
src/shared/drivers/ffmpeg.rs Removed redundant compile-time platform check
src/shared/drivers/avf.rs Complete AVFoundation driver implementation with device discovery, format configuration, and frame capture
src/shared/driver.rs Added FrameCallback type alias for frame delivery
src/lib.rs Exposed iOS FFI module
src/ffi.rs New iOS FFI layer with C-compatible functions for camera control and session access
Cargo.toml Added objc2-core-media feature, vendored core-video-sys, and configured library output types

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ffi.rs Outdated
Comment thread src/shared/drivers/avf.rs
Comment thread src/shared/open.rs Outdated
pub fn open_camera(
input_url: impl AsRef<str>,
config: CameraConfig,
callback: FrameCallback,
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The callback parameter is now required in open_camera, but several driver implementations (ffmpeg, dshow, v4l2) do not appear to use it. This creates an inconsistent API where callers must provide a callback that may be ignored. Consider making the callback optional or ensuring all drivers support it.

Suggested change
callback: FrameCallback,
callback: Option<FrameCallback>,

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

@isaac-asimov-bot isaac-asimov-bot Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ CI failed

Show all
Platform Name Status Details
All Formatting Details
Linux Build library Details
Linux Build library (no default features) Details
Linux Build binaries Details
Linux Build tests Details
Linux Build examples Details
Linux Run tests Details
Linux Run doctests Details
Windows Build library Details
Windows Build library (no default features) Details
Windows Build binaries Details
Windows Build tests Details
Windows Build examples Details
Windows Run tests Details
Windows Run doctests Details
macOS Build library Details
macOS Build library (no default features) Details
macOS Build binaries Details
macOS Build tests Details
macOS Build examples Details
macOS Run tests Details
macOS Run doctests Details

=============================================

Platform Name Status Details
Linux Build library Details
Windows Build library Details
macOS Build library Details

@artob
Copy link
Copy Markdown
Member

artob commented Dec 20, 2025

@oleksandrvoyager Lots of merge conflicts now, what do you suggest to do?

# Conflicts:
#	Cargo.lock
#	Cargo.toml
#	src/shared/driver.rs
#	src/shared/drivers/avf.rs
#	src/shared/drivers/ffmpeg.rs
#	src/shared/error.rs
#	src/shared/frame.rs
#	src/shared/open.rs
Copy link
Copy Markdown

@isaac-asimov-bot isaac-asimov-bot Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ CI failed

Show all
Platform Name Status Details
All Formatting Details
Windows Build library Details
Windows Build library (no default features) Details
Windows Build binaries Details
Windows Build tests Details
Windows Build examples Details
Windows Run tests Details
Windows Run doctests Details
Linux Build library Details
Linux Build library (no default features) Details
Linux Build binaries Details
Linux Build tests Details
Linux Build examples Details
Linux Run tests Details
Linux Run doctests Details
macOS Build library Details
macOS Build library (no default features) Details
macOS Build binaries Details
macOS Build tests Details
macOS Build examples Details
macOS Run tests Details
macOS Run doctests Details

=============================================

Platform Name Status Details
All Formatting Details
Windows Build library Details
Linux Build library Details
macOS Build library Details

@oleksandrvoyager oleksandrvoyager deleted the alex/avf branch January 6, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants