Revert "Use scap library to implement screensharing on X11 (#27807)" (#28141)

This reverts commit c2afc2271b.

Build on ARM if failing, likely because `c_char` is `u8` on arm and `i8`
on x86:

```
error[E0308]: mismatched types
   --> /home/runner/.cargo/git/checkouts/scap-40ad33e1dd47aaea/5715067/src/targets/linux/mod.rs:75:74
    |
75  |     let result = unsafe { XmbTextPropertyToTextList(display, &mut xname, &mut list, &mut count) };
    |                           -------------------------                      ^^^^^^^^^ expected `*mut *mut *mut u8`, found `&mut *mut *mut i8`
    |                           |
    |                           arguments to this function are incorrect
    |
    = note:    expected raw pointer `*mut *mut *mut u8`
            found mutable reference `&mut *mut *mut i8`
note: function defined here
   --> /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/x11-2.21.0/src/xlib.rs:552:10
    |
552 |   pub fn XmbTextPropertyToTextList (_4: *mut Display, _3: *const XTextProperty, _2: *mut *mut *mut c_char, _1: *mut c_int) -> c_int,
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^
```

Release Notes:

- N/A
This commit is contained in:
Michael Sloan 2025-04-05 00:01:27 -06:00 committed by GitHub
parent 6ddad64af1
commit c1259c136e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 49 additions and 624 deletions

View file

@ -25,7 +25,7 @@ async-trait.workspace = true
collections.workspace = true
cpal = "0.15"
futures.workspace = true
gpui = { workspace = true, features = ["x11", "wayland"] }
gpui.workspace = true
gpui_tokio.workspace = true
http_client_tls.workspace = true
image.workspace = true
@ -41,12 +41,7 @@ workspace-hack.workspace = true
[target.'cfg(not(all(target_os = "windows", target_env = "gnu")))'.dependencies]
libwebrtc = { rev = "80bb8f4c9112789f7c24cc98d8423010977806a6", git = "https://github.com/zed-industries/livekit-rust-sdks" }
livekit = { rev = "80bb8f4c9112789f7c24cc98d8423010977806a6", git = "https://github.com/zed-industries/livekit-rust-sdks", features = [
"__rustls-tls"
] }
[target.'cfg(any(target_os = "linux", target_os = "freebsd"))'.dependencies]
scap.workspace = true
livekit = { rev = "80bb8f4c9112789f7c24cc98d8423010977806a6", git = "https://github.com/zed-industries/livekit-rust-sdks", features = ["__rustls-tls"] }
[target.'cfg(target_os = "macos")'.dependencies]
core-foundation.workspace = true

View file

@ -336,7 +336,7 @@ pub(crate) async fn capture_local_video_track(
.await?;
let capture_stream = capture_source
.stream(cx.foreground_executor(), {
.stream({
let track_source = track_source.clone();
Box::new(move |frame| {
if let Some(buffer) = video_frame_buffer_to_webrtc(frame) {
@ -620,49 +620,7 @@ fn video_frame_buffer_to_webrtc(frame: ScreenCaptureFrame) -> Option<impl AsRef<
}
}
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
fn video_frame_buffer_to_webrtc(frame: ScreenCaptureFrame) -> Option<impl AsRef<dyn VideoBuffer>> {
use libwebrtc::native::yuv_helper::argb_to_nv12;
use livekit::webrtc::prelude::NV12Buffer;
match frame.0 {
scap::frame::Frame::BGRx(frame) => {
let mut buffer = NV12Buffer::new(frame.width as u32, frame.height as u32);
let (stride_y, stride_uv) = buffer.strides();
let (data_y, data_uv) = buffer.data_mut();
argb_to_nv12(
&frame.data,
frame.width as u32 * 4,
data_y,
stride_y,
data_uv,
stride_uv,
frame.width,
frame.height,
);
Some(buffer)
}
scap::frame::Frame::YUVFrame(yuvframe) => {
let mut buffer = NV12Buffer::with_strides(
yuvframe.width as u32,
yuvframe.height as u32,
yuvframe.luminance_stride as u32,
yuvframe.chrominance_stride as u32,
);
let (luminance, chrominance) = buffer.data_mut();
luminance.copy_from_slice(yuvframe.luminance_bytes.as_slice());
chrominance.copy_from_slice(yuvframe.chrominance_bytes.as_slice());
Some(buffer)
}
_ => {
log::error!(
"Expected BGRx or YUV frame from scap screen capture but got some other format."
);
None
}
}
}
#[cfg(target_os = "windows")]
#[cfg(not(target_os = "macos"))]
fn video_frame_buffer_to_webrtc(_frame: ScreenCaptureFrame) -> Option<impl AsRef<dyn VideoBuffer>> {
None as Option<Box<dyn VideoBuffer>>
}