#[cfg(all(feature = "capture", any(target_os = "macos", windows)))]
mod monitor;
#[cfg(all(feature = "capture", target_os = "linux"))]
mod screencast;
#[cfg(all(feature = "capture", any(target_os = "linux", target_os = "macos", windows)))]
mod session;
use anyhow::Result;
use image::RgbaImage;
#[cfg_attr(not(feature = "capture"), allow(dead_code))]
pub struct CaptureOptions {
pub cursor: bool,
#[cfg_attr(not(target_os = "linux"), allow(dead_code))]
pub pick_screen: bool,
pub screen: u32,
}
pub struct Capture {
pub image: RgbaImage,
pub display: Option<DisplayInfo>,
}
pub struct DisplayInfo {
#[cfg(target_os = "macos")]
pub id: String,
#[cfg(windows)]
pub name: String,
#[cfg(windows)]
pub width: u32,
#[cfg(windows)]
pub height: u32,
}
#[cfg(all(feature = "capture", target_os = "linux"))]
pub fn capture(opts: &CaptureOptions) -> Result<Capture> {
screencast::capture_screenshot(opts.cursor, opts.pick_screen, opts.screen)
}
#[cfg(all(feature = "capture", any(target_os = "macos", windows)))]
pub fn capture(opts: &CaptureOptions) -> Result<Capture> {
monitor::capture_screenshot(opts.cursor, opts.screen)
}
#[cfg(not(all(feature = "capture", any(target_os = "linux", target_os = "macos", windows))))]
pub fn capture(_opts: &CaptureOptions) -> Result<Capture> {
anyhow::bail!(
"this build has no capture backend (the `capture` feature is off); \
only --from-file works"
)
}
#[cfg(all(feature = "capture", any(target_os = "macos", windows)))]
pub fn screen_list() -> Result<String> {
monitor::screen_list()
}
#[cfg(all(not(feature = "capture"), any(target_os = "macos", windows)))]
pub fn screen_list() -> Result<String> {
anyhow::bail!("this build has no capture backend (the `capture` feature is off)")
}