Files
VoelinClient/crates/voelin-media/Cargo.toml
T
faumarayandClaude Sonnet 5.5 e325b65d42 ashpd on async-io in voelin-media (pipewire) and voelin-platform (portal)
GPUI's Linux backend enables ashpd's `async-io` feature, and ashpd 0.13.13
refuses `async-io` and `tokio` at once (compile_error! in its lib.rs), so
a binary could not hold the portals and gpui-kit. voelin-media's `pipewire`
feature (the screen-cast and camera portals) and voelin-platform's `portal`
feature (global shortcuts, file chooser, proxy resolver) now ask ashpd for
`async-io`; Cargo.lock loses ashpd's edge to tokio and nothing else (the
package set is the same: THIRD_PARTY_NOTICES.md is unchanged and
`scripts/notices.sh --check` clean).

What zbus 5.19 does with the features (read in its abstractions/mod.rs):
with both `async-io` and `tokio` compiled in it picks per connection, tokio
when a tokio runtime is current on the calling thread, else async-io with an
I/O thread of its own. The workspace has both on already (notify-rust asks
for zbus/tokio, secret-service and others for its defaults), so the engine's
portal calls, which run inside its tokio runtime, still use tokio; a caller
with no runtime (GPUI's foreground executor) gets the I/O thread. Built on
its own, voelin-media has `async-io` only.

The source needed no change beyond a doc comment (capture/portal.rs said
the connection needs a tokio runtime). tests/proxy.rs gains a second test on
the same stand-in portal: ashpd's ProxyResolver called from a thread with no
tokio runtime, polled by hand, gets the answer. Both tests run again under
`dbus-run-session` on a bus of their own (the harness takes the test's name).

Checked on Rust 1.95.0: fmt and clippy (-D warnings, --no-deps) of the own
crates; `cargo test -p voelin-platform -p voelin-media`: all pass, including
tests/proxy.rs (2 tests), the portal-less-bus tests of both crates run with
no session bus (`unavailable_without_session_bus`, the `proxy::tests` that
need none), and tests/pipewire_apps.rs against a private PipeWire and
WirePlumber (found on PATH, ran: 2 passed in 2.7 s). The live portal
(a desktop's screen-cast dialog, the shortcut binding) was not exercised:
no desktop session is used by these runs.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-27 06:18:00 +03:00

123 lines
6.0 KiB
TOML

[package]
name = "voelin-media"
version = "0.1.0"
description = "Video frames, pixel conversion, video codecs (VP8/VP9, H.264, AV1) and screen / system-audio capture for streams."
edition.workspace = true
rust-version.workspace = true
license.workspace = true
repository.workspace = true
publish.workspace = true
[features]
# Every codec backend: desktop builds have all encoders and decoders.
default = ["vpx", "openh264", "openh264-download", "ffmpeg", "av1", "x11", "pipewire", "wlroots", "segment"]
# VP8 and VP9 through the system libvpx (pkg-config `vpx`).
vpx = ["dep:libvpx-native-sys"]
# H.264 through Cisco's prebuilt OpenH264 library, loaded at runtime. The
# OpenH264 source is never compiled in (see docs/media.md).
openh264 = ["dep:openh264"]
# Download of Cisco's OpenH264 binary over HTTPS with a SHA-256 check.
openh264-download = ["openh264", "dep:reqwest", "dep:bzip2", "dep:sha2"]
# Video encoders through FFmpeg loaded at runtime (never linked or shipped):
# VA-API, NVENC, Quick Sync, AMF, Media Foundation, VideoToolbox, x264,
# SVT-AV1, ... whatever the installed FFmpeg has (see docs/media.md).
ffmpeg = ["dep:libloading", "dep:rustix"]
# AV1 decoding through libdav1d (pkg-config `dav1d` >= 1.3; on Windows
# vcpkg's or our MinGW build, see .github/actions/system-deps and
# docker/windows.Dockerfile).
av1 = ["dep:dav1d"]
# X11 screen capture (Linux).
x11 = ["dep:x11rb", "dep:memmap2", "dep:rustix"]
# Wayland screen capture (ScreenCast portal + PipeWire, shared memory or
# LINEAR DMA-BUFs) and PipeWire system audio (Linux).
# MJPEG cameras are decoded with zune-jpeg (already in the tree through
# `image`).
pipewire = ["dep:ashpd", "dep:pipewire", "dep:memmap2", "dep:rustix", "dep:zune-core", "dep:zune-jpeg"]
# Screen capture on wlroots compositors (Sway, Hyprland, river, ...) without
# the portal: ext-image-copy-capture-v1 or wlr-screencopy-unstable-v1 (Linux).
wlroots = ["dep:wayland-client", "dep:wayland-protocols", "dep:wayland-protocols-wlr", "dep:memmap2", "dep:rustix"]
# The studio's background replacement finds the person with a segmentation
# model (PP-HumanSeg, ONNX, bundled in `models/`) run on the CPU by tract.
# Without it the background is cut around a centred oval.
segment = ["dep:tract-onnx"]
# The studio's WHIP output: a WebRTC session (str0m) set up over HTTP. Needs
# str0m's crypto provider, the same one voelin-stream uses.
whip = ["str0m/aws-lc-rs", "dep:reqwest"]
[dependencies]
bzip2 = { version = "0.6.1", optional = true }
dav1d = { version = "0.11.1", optional = true }
libloading = { version = "0.8.9", optional = true }
libvpx-native-sys = { version = "5.0.17", optional = true }
openh264 = { version = "0.9.8", default-features = false, features = ["libloading"], optional = true }
reqwest = { version = "0.13.5", default-features = false, features = ["rustls"], optional = true }
# Lock-free single-producer rings from capture threads to the stream mixer.
rtrb = "0.4.0"
# Scene graphs are serialised into the `studio.scenes` setting.
serde = { version = "1", features = ["derive"] }
# Studio sources: text rasterising and image files.
ab_glyph = "0.2.32"
image = { version = "0.25.10", default-features = false, features = ["jpeg", "png"] }
sha2 = { version = "0.10.9", optional = true }
# Its media types (`MediaKind`, `MediaTime`) are in `stream::EncodedFrame`, and
# `Codec` converts to and from its codec type.
str0m = { version = "0.23.1", default-features = false }
thiserror = "2.0.21"
tract-onnx = { version = "0.23.8", optional = true }
tokio = { version = "1", features = ["sync"] }
tracing = "0.1.44"
yuv = "0.8.19"
[target.'cfg(target_os = "linux")'.dependencies]
# `async-io`, not `tokio`: GPUI's Linux backend enables ashpd's `async-io`, ashpd
# refuses both at once, and a front end holds the portals and GPUI in one binary.
# zbus then runs a connection on its own I/O thread, or on tokio when it is made
# inside a tokio runtime and another crate turns zbus's `tokio` feature on.
ashpd = { version = "0.13.13", default-features = false, features = ["camera", "screencast", "async-io"], optional = true }
memmap2 = { version = "0.9.11", optional = true }
pipewire = { version = "0.10.1", optional = true }
rustix = { version = "1.1.5", features = ["event", "fs", "stdio"], optional = true }
wayland-client = { version = "0.31.15", optional = true }
wayland-protocols = { version = "0.32.13", features = ["client", "staging"], optional = true }
wayland-protocols-wlr = { version = "0.3.12", features = ["client"], optional = true }
x11rb = { version = "0.13.2", features = ["randr", "shm", "xfixes"], optional = true }
zune-core = { version = "0.5.3", default-features = false, optional = true }
zune-jpeg = { version = "0.5.15", optional = true }
[target.'cfg(target_os = "android")'.dependencies]
ndk = { version = "0.9.0", default-features = false, features = ["media", "api-level-29"] }
[target.'cfg(windows)'.dependencies]
wasapi = "0.24.0"
# Process names for the list of applications with audio sessions,
# and studio cameras (Media Foundation).
windows = { version = "0.62", features = ["Win32_Foundation", "Win32_Media_MediaFoundation", "Win32_System_Com", "Win32_System_Threading"] }
windows-capture = "2.0.1"
[dev-dependencies]
criterion = "0.8"
# Opus packets to feed the RTMP output's AAC encoder in tests (the voice
# codec's crate, already in the tree through voelin-audio).
opus2 = "0.4"
serde_json = "1"
# The H.264 `profile-level-id` the signalling offers, to check it against the
# SPS the encoders really emit (`tests/ffmpeg.rs`). A cycle through a
# dev-dependency, which cargo allows: voelin-stream depends on this crate for
# the frame and layer types, so this crate's unit tests see itself twice, and
# only primitives and voelin-stream's own types cross between the copies.
voelin-stream = { path = "../voelin-stream" }
# Logs of integration tests (`RUST_LOG`).
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
tokio = { version = "1", features = ["macros", "rt", "rt-multi-thread", "time"] }
[[bench]]
name = "convert"
harness = false
[[bench]]
name = "mix"
harness = false
[lints]
workspace = true