openlogi_camera/capture_types.rs
1//! Platform-independent capture vocabulary shared by every capture backend
2//! (AVFoundation on macOS, Media Foundation on Windows, stubs elsewhere).
3
4use thiserror::Error;
5
6/// One decoded camera frame, tightly-packed BGRA8 (`width * height * 4` bytes) —
7/// gpui's native texture order, so the preview uploads it without a channel
8/// swap. The snapshot path swaps to RGBA when it writes the PNG.
9#[derive(Clone)]
10pub struct Frame {
11 pub width: u32,
12 pub height: u32,
13 pub bgra: Vec<u8>,
14}
15
16/// Why a capture attempt failed.
17#[derive(Debug, Clone, Error)]
18pub enum CaptureError {
19 /// Camera permission is denied/restricted, or this process can't request
20 /// it (e.g. an unbundled macOS binary with no `NSCameraUsageDescription`).
21 #[error(
22 "camera access denied — grant Camera permission \
23 (on macOS, run inside an app bundle with NSCameraUsageDescription)"
24 )]
25 AccessDenied,
26 /// No camera matched the requested unique id.
27 #[error("no camera matched that id")]
28 NotFound,
29 /// The session ran but produced no frame within the timeout.
30 #[error("camera produced no frame in time")]
31 Timeout,
32 /// A platform capture object failed to construct.
33 #[error("capture setup failed: {0}")]
34 Setup(String),
35 /// Capture has no backend on this platform.
36 #[error("camera capture is not implemented on this platform")]
37 Unsupported,
38}