Use scap library to implement screensharing on X11 (#27807)
While `scap` does have support for Wayland and Windows, but haven't seen screensharing work properly there yet. So for now just adding support for X11 screensharing. WIP branches for enabling wayland and windows support: * https://github.com/zed-industries/zed/tree/wayland-screenshare * https://github.com/zed-industries/zed/tree/windows-screenshare Release Notes: - Added support for screensharing on X11 (Linux) --------- Co-authored-by: Conrad <conrad@zed.dev> Co-authored-by: Mikayla <mikayla@zed.dev> Co-authored-by: Junkui Zhang <364772080@qq.com>
This commit is contained in:
parent
7bc62de267
commit
c2afc2271b
20 changed files with 624 additions and 49 deletions
|
@ -26,6 +26,12 @@ mod test;
|
|||
#[cfg(target_os = "windows")]
|
||||
mod windows;
|
||||
|
||||
#[cfg(all(
|
||||
any(target_os = "linux", target_os = "freebsd"),
|
||||
any(feature = "wayland", feature = "x11"),
|
||||
))]
|
||||
pub(crate) mod scap_screen_capture;
|
||||
|
||||
use crate::{
|
||||
Action, AnyWindowHandle, App, AsyncWindowContext, BackgroundExecutor, Bounds,
|
||||
DEFAULT_WINDOW_SIZE, DevicePixels, DispatchEventResult, Font, FontId, FontMetrics, FontRun,
|
||||
|
@ -158,6 +164,7 @@ pub(crate) trait Platform: 'static {
|
|||
None
|
||||
}
|
||||
|
||||
fn is_screen_capture_supported(&self) -> bool;
|
||||
fn screen_capture_sources(
|
||||
&self,
|
||||
) -> oneshot::Receiver<Result<Vec<Box<dyn ScreenCaptureSource>>>>;
|
||||
|
@ -246,13 +253,14 @@ pub trait PlatformDisplay: Send + Sync + Debug {
|
|||
/// A source of on-screen video content that can be captured.
|
||||
pub trait ScreenCaptureSource {
|
||||
/// Returns the video resolution of this source.
|
||||
fn resolution(&self) -> Result<Size<Pixels>>;
|
||||
fn resolution(&self) -> Result<Size<DevicePixels>>;
|
||||
|
||||
/// Start capture video from this source, invoking the given callback
|
||||
/// with each frame.
|
||||
fn stream(
|
||||
&self,
|
||||
frame_callback: Box<dyn Fn(ScreenCaptureFrame)>,
|
||||
foreground_executor: &ForegroundExecutor,
|
||||
frame_callback: Box<dyn Fn(ScreenCaptureFrame) + Send>,
|
||||
) -> oneshot::Receiver<Result<Box<dyn ScreenCaptureStream>>>;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue