gpui_platform/
screen_capture.rs1use crate::ForegroundExecutor;
4use anyhow::Result;
5use futures::channel::oneshot;
6use gpui_shared_string::SharedString;
7use gpui_types::{DevicePixels, Size};
8
9#[cfg(all(
10 any(target_os = "windows", target_os = "linux"),
11 feature = "screen-capture"
12))]
13pub type PlatformScreenCaptureFrame = scap::frame::Frame;
15#[cfg(not(feature = "screen-capture"))]
16pub type PlatformScreenCaptureFrame = ();
18#[cfg(all(target_os = "macos", feature = "screen-capture"))]
19pub type PlatformScreenCaptureFrame = core_video::image_buffer::CVImageBuffer;
21
22#[derive(Clone)]
24pub struct SourceMetadata {
25 pub id: u64,
27 pub label: Option<SharedString>,
29 pub is_main: Option<bool>,
31 pub resolution: Size<DevicePixels>,
33}
34
35pub trait ScreenCaptureSource {
37 fn metadata(&self) -> Result<SourceMetadata>;
39
40 fn stream(
43 &self,
44 foreground_executor: &ForegroundExecutor,
45 frame_callback: Box<dyn Fn(ScreenCaptureFrame) + Send>,
46 ) -> oneshot::Receiver<Result<Box<dyn ScreenCaptureStream>>>;
47}
48
49pub trait ScreenCaptureStream {
51 fn metadata(&self) -> Result<SourceMetadata>;
53}
54
55pub struct ScreenCaptureFrame(pub PlatformScreenCaptureFrame);