1use std::time::Duration;
2
3use crate::{audio::AudioFrame, config::SessionConfig, error::Result, frame::CaptureEvent};
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq)]
11pub enum BackendPreference {
12 Auto,
13 LinuxWaylandPortal,
14 LinuxX11,
15 MacScreenCaptureKit,
16 WindowsDxgi,
17 WindowsWgc,
18}
19
20#[derive(Debug, Clone, Copy, PartialEq, Eq)]
22pub enum BackendKind {
23 LinuxWaylandPortal,
24 LinuxX11,
25 LinuxPipeWireAudio,
26 MacScreenCaptureKit,
27 WindowsDxgi,
28 WindowsWgc,
29 WindowsWasapi,
30}
31
32#[derive(Debug, Clone, PartialEq, Eq)]
36pub struct BackendInfo {
37 pub kind: BackendKind,
38 pub supports_audio: bool,
39 pub zero_copy: bool,
40 pub notes: &'static str,
42}
43
44pub trait VideoBackend: Send {
53 fn info(&self) -> BackendInfo;
54 fn start(&mut self) -> Result<()>;
55 fn stop(&mut self) -> Result<()>;
56 fn next_event(&mut self, timeout: Option<Duration>) -> Result<CaptureEvent>;
57}
58
59pub trait AudioBackend: Send {
62 fn info(&self) -> BackendInfo;
63 fn start(&mut self) -> Result<()>;
64 fn stop(&mut self) -> Result<()>;
65 fn next_audio(&mut self, timeout: Option<Duration>) -> Result<AudioFrame>;
66}
67
68pub struct BackendBundle {
69 pub info: BackendInfo,
70 pub video: Option<Box<dyn VideoBackend>>,
71 pub audio: Option<Box<dyn AudioBackend>>,
72}
73
74pub trait BackendResolver {
75 fn resolve(&self, config: &SessionConfig) -> Result<BackendBundle>;
76}