Watch
1
Fork
You've already forked afogados-media
0
0

Latest commit

maotovisk
dd0786a 2026-11-23 12:01:36 -03:00 67 commits

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::Server in the afogados-media helper 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 runs async-io, so it depends with default-features = false, features = ["portal-async-io"].
  • The phone uses afogados-voice-core only, 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-io for 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").