use crate::ForegroundExecutor;
use anyhow::Result;
use futures::channel::oneshot;
use gpui_shared_string::SharedString;
use gpui_types::{DevicePixels, Size};
#[cfg(all(
any(target_os = "windows", target_os = "linux"),
feature = "screen-capture"
))]
pub type PlatformScreenCaptureFrame = scap::frame::Frame;
#[cfg(not(feature = "screen-capture"))]
pub type PlatformScreenCaptureFrame = ();
#[cfg(all(target_os = "macos", feature = "screen-capture"))]
pub type PlatformScreenCaptureFrame =
objc2_core_foundation::CFRetained<objc2_core_video::CVImageBuffer>;
#[derive(Clone)]
pub struct SourceMetadata {
pub id: u64,
pub label: Option<SharedString>,
pub is_main: Option<bool>,
pub resolution: Size<DevicePixels>,
}
pub trait ScreenCaptureSource {
fn metadata(&self) -> Result<SourceMetadata>;
fn stream(
&self,
foreground_executor: &ForegroundExecutor,
frame_callback: Box<dyn Fn(ScreenCaptureFrame) + Send>,
) -> oneshot::Receiver<Result<Box<dyn ScreenCaptureStream>>>;
}
pub trait ScreenCaptureStream {
fn metadata(&self) -> Result<SourceMetadata>;
}
pub struct ScreenCaptureFrame(pub PlatformScreenCaptureFrame);