-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Use libwebrtc's DesktopCapturer for screen capture #42670
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
0c5daae to
b078823
Compare
b078823 to
0e67b6b
Compare
|
Nice! I'm very excited about fixing Wayland screen-sharing. We'd definitely need the webrtc build caching stuff to merge this though... thanks for fighting with that. Also looks like you removed the screen selector; is there an easy path to bring that back through webRTC's stuff? |
I split off the required build changes to a trivially small PR so it's easy for upstream to review that quickly: livekit/rust-sdks#784 (Edit: that has been merged, waiting on upstream to tag a new release)
Yeah, that took several weeks of yak shaving before I could actually work on Zed. 🪒 My CPU is not super fast (Intel Core i7 8550U) so there was lots of waiting involved.
I have not removed that, though the existing GUI code will need some work because applications can't have their own UI for that on Wayland. The XDG Desktop Portal doesn't expose the available screens/windows to applications; libwebrtc returns a single dummy CaptureSource with an empty string for a title. When DesktopCapturer::start_capture is called, the XDG Desktop Portal presents its GUI for the user to choose the screen (and/or window if enabled). |
4fe9304 to
1874bfa
Compare
|
I tested this on a call with my friend @NOTtheMessiah and he was able to see me sharing my screen from Wayland! 🎉 |
0a1b90c to
7fbf32f
Compare
96bd7d8 to
a429980
Compare
a429980 to
c95550c
Compare
|
The main upstream PR adding Rust bindings for libwebrtc's DesktopCapturer class (livekit/rust-sdks#725) has been merged. 🎉 There are still several smaller PRs awaiting review upstream (tracked in the PR description) that would need to be merged for Zed to be able to use Livekit's crates.io releases. @NOTtheMessiah will be working on updating the livekit-libwebrtc Nix package this week to get it working with this branch. |
c95550c to
38d1465
Compare
|
@Be-ing Amazing! I'm also happy to pull your changes into Zed's fork if you think it'll be a while before those are merged. Did you figure out the screen-share freezing issue we saw when sharing from macOS -> Wayland? |
We could do that, but let's see where those Livekit PRs are at by the time the Nix package is updated.
I have not reproduced that. |
|
@NOTtheMessiah and I were on a call yesterday trying to update the Nix livekit-libwebrtc package. We tried using Nix's gclient2nix script to update the package's sources from the Chromium build system's bespoke gclient tool. However, that script's output didn't specify some of the required Git repositories and the build failed. Rather than spend more time troubleshooting gclient2nix, I will polish my script to generate a source code archive for libwebrtc. The source code archive is made from the output of gclient; it's ready to build as-is without downstream packagers needing to mess with gclient (which downloads 9 GB of junk that mostly isn't needed for libwebrtc). I'll publish that source code as a release artifact on my fork so we don't have to wait for Livekit to review that to update the Nix package. I was already planning to do that eventually to make it easier to package Zed in other package managers (packaging policies generally forbid using prebuilt binaries as Livekit's webrtc-sys crate does). Since that is now blocking this PR, I'll prioritize it. |
91eb2ce to
81523d1
Compare
|
Hi @Be-ing ,In case you're blocked by the LiveKit PR review process or any other tasks awaiting input / work from the LiveKit team, please feel free to tag me as a reviewer or send me an email (shijing.xian@livekit.io). I'd be happy to help expedite the process. |
in buildInputs
This adds support for screen sharing on Wayland (fixes zed-industries#28754). libwebrtc replaces scap, which aims to be cross platform but was only used on Windows and X11. The X11 support relied on an out-of-tree branch on which the original author closed their own pull request (CapSoftware/scap#124). This also replaces Zed's platform-specific code on macOS. Switching to a single cross platform library simplifies the code by removing the need for Zed to have its own traits for cross platform abstraction.
81523d1 to
71ca6c4
Compare
This adds support for screen sharing on Wayland (fixes #28754). I am not able to test on Windows and macOS, so I will need help testing those.
libwebrtc replaces scap, which aims to be cross platform but was only used on Windows and X11. The X11 support relied on an out-of-tree branch on which the original author closed their own pull request (CapSoftware/scap#124). This also replaces Zed's platform-specific code on macOS. Switching to a single cross platform library simplifies the code by removing the need for Zed to have its own traits for cross platform abstraction.
This uses my branch of the Livekit Rust SDK. This branch merges several pull requests I have awaiting review upstream:
Currently, the webrtc-sys crate from Livekit downloads a prebuilt static libwebrtc C++ library (which is a nonstarter for Linux distro packagers). This branch requires changes to how the C++ library is built. Because those changes in livekit/rust-sdks#725 have not yet been merged upstream, you must build libwebrtc from source to build this branch on Linux. My Livekit branch will build libwebrtc from source during the Cargo build if you set theLK_LIBWEBRTC_SOURCEenvironment variable to the absolute path of an archive of the libwebrtc source code. In my Livekit branch, there is a script to generate this source code archive, which you can do by running:git clone https://github.com/Be-ing/rust-sdks.git -b zed cd rust-sdks/webrtc-sys/libwebrtc/ ./generate-source-archive.shThis script takes a long time to run because libwebrtc is developed as part of Chromium. Thus, it requires downloading about 9 GB of junk that isn't needed for libwebrtc. Thegenerate-source-archive.shscript removes a bunch of that junk to strip it down to a 125 MB .tar.xz archive, which I hope will be published upstream by Livekit when my PRs are reviewed and merged.Release Notes:
TODO: