Code
Search code
capture::native lists and captures monitors and windows straight from the compositor when it offers a
way, and falls back to the ScreenCast portal otherwise:
- KWin: zkde_screencast_unstable_v1 (a PipeWire node on the session's daemon, read by the existing
screen capture) and the Plasma window list. Capture ends when KWin closes the stream.
- ext-image-copy-capture with the ext foreign toplevel list, and wlr-screencopy, into GBM DMA-BUFs
allocated on the compositor's device (GBM loaded at run time); shared memory where DMA-BUFs fail.
The frame pump waits for the next request, which raised capture from 16 to 30 fps.
VideoSource::Native { id, as_is } ("native:<id>[:as-is]" over IPC). A start that fails before its
first picture returns Failed::Unavailable and the portal asks instead. AFOGADOS_CAPTURE=portal|kwin|ext|wlr
forces a path. The portal pieces it reuses (session_node, format_param, capture) become pub(crate).
Adds wayland-protocols (staging), -wlr, -plasma and libloading.
Checked: no warnings, 150 lib tests. Headless KWin captured a monitor and a window on DMA-BUFs through
VAAPI. Headless sway ran ext and wlr at 91 frames in 3 s. tests/native_kwin.rs and native_wlroots.rs need a
headless compositor. Not run: a real Plasma session, Hyprland, rotated or y-inverted outputs.
afogados-media
The media core shared by the Afogados clients, as Rust crates in one Cargo workspace.
| Crate | Package | What it is |
|---|---|---|
media/ |
afogados-media (lib afogados_media) |
Screen/window capture (portal + PipeWire, Windows Graphics Capture, game hook), GPU encode (Vulkan Video, VAAPI, NVENC/AMF/QSV, x264), application audio, WHIP publishing over str0m, voice devices and the ipc request/event protocol. service::Media drives ipc::Server in-process. |
ffmpeg/ |
afogados-ffmpeg (lib afogados_ffmpeg) |
FFmpeg bindings, generated by bindgen from the system headers (FFMPEG_DIR on Windows). Shared by the media core (media::ffi re-exports it) and afogados_desktop, which enables the vaapi (Linux) and d3d11va (Windows) features for its decoder. |
voice-core/ |
afogados-voice-core |
The voice engine: DSP (AEC3, AGC2, RNNoise, DeepFilterNet), Opus framing, jitter buffers, the mixer and the voice transports, without devices or IPC. Vendors rnnoise. |
Who uses it
Every consumer depends on it by relative path to a sibling checkout (the same convention as
gpui-afogados): no git dependencies and no submodules. Clone this repository next to them:
dev/
afogados-media/ this repository
afogados_electron/ native/ -> afogados-media = { path = "../../afogados-media/media" }
afogados_desktop/ crates/app -> afogados-media = { path = "../../../afogados-media/media", ... }
stream_afogados/ mobile/modules/afogados-voice/rust -> afogados-voice-core = { path = "../../../../../afogados-media/voice-core" }
- afogados_electron wraps
ipc::Serverin theafogados-mediahelper executable (stdin/stdout JSON lines); it is a separate process because Electron links Chromium's FFmpeg. It uses the default features. - afogados_desktop links the library and uses
service::Media. Its GPUI stack runsasync-io, so it depends withdefault-features = false, features = ["portal-async-io"]. - The phone uses
afogados-voice-coreonly, with features["opus", "rust-crypto"].
Features of afogados-media
portal-tokio(default): ashpd on tokio.portal-async-io: ashpd on async-io. ashpd refuses both runtimes, so build with--no-default-features --features portal-async-iofor this one.
Build and test
Linux needs the system FFmpeg development files (the afogados-ffmpeg crate generates the bindings in
ffmpeg/build.rs; media::ffi re-exports them), pkg-config, PipeWire and Vulkan headers, and a C compiler.
The VAAPI headers are a feature of afogados-ffmpeg that afogados_desktop turns on; the other consumers do not
need libva.
cargo build --all-targets
cargo test # PipeWire / GPU / SFU tests are #[ignore]; see media/tests
cargo check -p afogados-media --no-default-features --features portal-async-io --all-targets
Windows builds are cross-compiled from Linux by afogados_electron (cargo-xwin, BtbN's FFmpeg in
FFMPEG_DIR; see that repository's scripts/ci_build.sh and docs/ARCHITECTURE.md), or built
natively with FFMPEG_DIR set. The Windows game-capture hook is looked up in AFOGADOS_HOOK_DIR,
obs-hook/ next to the executable, then media/third_party/obs-hook/ (gitignored).
Screen capture on Linux tries the compositor directly before the ScreenCast portal (media/src/capture/native/:
KWin's screencast, ext-image-copy-capture, wlr-screencopy, all on DMA-BUFs); AFOGADOS_CAPTURE=portal|kwin|ext|wlr
forces a path. Their tests need a headless compositor: media/tests/native_kwin.rs, media/tests/native_wlroots.rs.
media/examples/ hold diagnostic probes (whip_probe, voice_probe, loopback_probe,
publish_service); read the header of each before pointing one at a server.
History and license
History up to the extraction is that of afogados_electron's native/ directory (git subtree split); commits there that touch overlay/ and splash/ refer to packages that stayed in
Electron. No license has been chosen for these repositories yet (afogados_electron: "Undecided").