feat(codec): encodage matériel VA-API, H.264 et VP9 sur le GPU
CI / Formatting, tests and builds (push) Failing after 1m29s
CI / Formatting, tests and builds (push) Failing after 1m29s
Un encodeur GStreamer derrière le trait VideoEncoder (fonctionnalité vaapi): appsrc BGRA, vapostproc vers NV12 sur le GPU, vah264lpenc ou vavp9lpenc, appsink. Un appel par image comme libvpx, sans image B, image clé sur demande. H.264 part en constrained baseline, mode 1, et rs-rtc le négocie; VP9 matériel garde la négociation existante. Sans greffon va, sans pilote ou réglage « Encoder sur la carte graphique » décoché, VP9 passe par libvpx et H.264 retombe en VP8, avec un avertissement. Une reprise ou un changement de source qui ne retrouverait pas le codec négocié est refusé. --software force libvpx en ligne de commande. Mesuré en 1080p30 dans Firefox: 17 % d'un cœur pour tout l'hôte au lieu de 80 % en VP8 logiciel, latence médiane 27 ms. 1080p60 tient à 26-35 %. Corrigé en chemin: la cadence adaptative partait de la première image, lente au démarrage d'un encodeur, et ne remontait plus; les dix premières images ne comptent plus. VP9 logiciel passe de 16 à 60 i/s. Le paquet Nix active vaapi et fournit le greffon et les pilotes VA-API de nixpkgs. Le contrôle des licences lit toutes les fonctionnalités. Décision dans l'ADR 0012, mesures dans docs/perf.md. Refs #57 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
70ec8a6a9f
commit
075fb2e48e
34 files changed
+1604
-90
No files matched your search
@@ -135,6 +135,19 @@ jobs:
|
||||
echo "libpipewire-0.3 missing on the runner: Wayland capture not checked"
|
||||
fi
|
||||
|
||||
- name: Hardware encoding (VA-API)
|
||||
run: |
|
||||
set -euo pipefail
|
||||
# The `vaapi` feature links GStreamer (#57). Without its development
|
||||
# files the step says so and passes, like the PipeWire one. The
|
||||
# encoder tests skip themselves on a runner without a GPU.
|
||||
if pkg-config --exists gstreamer-app-1.0 gstreamer-video-1.0; then
|
||||
cargo clippy -p rs-codec -p rs-session --features rs-session/vaapi --all-targets -- -D warnings
|
||||
cargo test -p rs-codec --features vaapi
|
||||
else
|
||||
echo "GStreamer development files missing on the runner: hardware encoding not checked"
|
||||
fi
|
||||
|
||||
- name: The binary starts
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
@@ -20,7 +20,8 @@ local `rustscreen.local` en mDNS, viewer React qui reprend seul après
|
||||
une coupure ou une veille, tourne l'image et suit le thème, coque desktop Tauri avec icône de
|
||||
barre système, réglages persistants, interface en français et en anglais, inhibition de veille,
|
||||
journal JSON local et archive de diagnostics.
|
||||
Ce qui manque: la capture Windows et macOS, et l'encodeur matériel. Les messages de l'hôte
|
||||
Ce qui manque: la capture Windows et macOS, et l'encodeur matériel hors Linux (sous Linux, VA-API
|
||||
par GStreamer, fonctionnalité `vaapi`, ADR 0012). Les messages de l'hôte
|
||||
(erreurs, avertissements, refus de réglages) partent en codes (`Notice`) que la coque traduit sous
|
||||
`desktop.host` (#75); le test `notices` refuse un code sans traduction.
|
||||
|
||||
@@ -163,6 +164,8 @@ cargo run --release -p rs-session --features pipewire --bin rustscreen-cli -- --
|
||||
cargo run -p rs-session --bin rustscreen-cli -- --diagnostics
|
||||
# VP9 au lieu de VP8 (même qualité pour moins de débit, 1,6x le calcul), une fenêtre par le portail
|
||||
cargo run --release -p rs-session --features pipewire --bin rustscreen-cli -- --codec vp9 --pick-window
|
||||
# H.264 ou VP9 sur le GPU (VA-API, ADR 0012); --software force libvpx
|
||||
cargo run --release -p rs-session --features pipewire,vaapi --bin rustscreen-cli -- --codec h264
|
||||
```
|
||||
|
||||
La coque desktop demande WebKitGTK au build: elle a son propre workspace Cargo et son shell Nix.
|
||||
|
||||
Generated
+294
-4
@@ -125,6 +125,12 @@ version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
|
||||
|
||||
[[package]]
|
||||
name = "atomic_refcell"
|
||||
version = "0.1.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "21e4227379beff4205943696e6c3e0cd809bacdf3f0edd6e3dd153e2269571a4"
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.5.1"
|
||||
@@ -266,7 +272,7 @@ dependencies = [
|
||||
"bitflags",
|
||||
"cexpr",
|
||||
"clang-sys",
|
||||
"itertools",
|
||||
"itertools 0.13.0",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"regex",
|
||||
@@ -843,12 +849,34 @@ version = "0.3.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e"
|
||||
|
||||
[[package]]
|
||||
name = "futures-executor"
|
||||
version = "0.3.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "031b47cf1a3c6cc8bc2fc76cd437f521619387907d469316e7c0bc278f1f5432"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-task",
|
||||
"futures-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-io"
|
||||
version = "0.3.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed"
|
||||
|
||||
[[package]]
|
||||
name = "futures-macro"
|
||||
version = "0.3.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 3.0.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-sink"
|
||||
version = "0.3.34"
|
||||
@@ -868,6 +896,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-macro",
|
||||
"futures-sink",
|
||||
"futures-task",
|
||||
"pin-project-lite",
|
||||
@@ -959,12 +988,202 @@ dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gio-sys"
|
||||
version = "0.22.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c28739f914c15b87a9856000bed9cbd5b3a8afbca5e982d9a299e1601422cb5"
|
||||
dependencies = [
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"libc",
|
||||
"system-deps 9.0.1",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glib"
|
||||
version = "0.22.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e4cf9e5bd8713f1990a92c422998826e0fb34824277b46bc59757373483c6694"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-executor",
|
||||
"futures-task",
|
||||
"futures-util",
|
||||
"gio-sys",
|
||||
"glib-macros",
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"libc",
|
||||
"memchr",
|
||||
"smallvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glib-macros"
|
||||
version = "0.22.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c9597c68fa7bdf4154a3079642cd21c4dccac0b0bdd2897d82861523bf91e7b9"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 3.0.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glib-sys"
|
||||
version = "0.22.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "99b38907e67e40dec9b60f858bcada952598719cb512a13eb13d6cdcd16f8295"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"system-deps 9.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glob"
|
||||
version = "0.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b"
|
||||
|
||||
[[package]]
|
||||
name = "gobject-sys"
|
||||
version = "0.22.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "07595c9ba696bd9819cb6a8df39f08078f3dd679508fe052dd558492c2053834"
|
||||
dependencies = [
|
||||
"glib-sys",
|
||||
"libc",
|
||||
"system-deps 9.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gstreamer"
|
||||
version = "0.25.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f4237e2066a25ecb7e54be6c066409e30615920265b9799b8d560ef8ac9857c6"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
"glib",
|
||||
"gstreamer-sys",
|
||||
"itertools 0.15.0",
|
||||
"kstring",
|
||||
"libc",
|
||||
"muldiv",
|
||||
"num-integer",
|
||||
"num-rational",
|
||||
"option-operations",
|
||||
"pastey",
|
||||
"pin-project-lite",
|
||||
"smallvec",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gstreamer-app"
|
||||
version = "0.25.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "97f8ae9238c2352398dcc084de28df3f7099af216ac6c160b52318d23f25c010"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
"glib",
|
||||
"gstreamer",
|
||||
"gstreamer-app-sys",
|
||||
"gstreamer-base",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gstreamer-app-sys"
|
||||
version = "0.25.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0798b8aef6694341d40bb81edc759f8979b896b59f9f0f45d8cfa3bb7bf2e743"
|
||||
dependencies = [
|
||||
"glib-sys",
|
||||
"gstreamer-base-sys",
|
||||
"gstreamer-sys",
|
||||
"libc",
|
||||
"system-deps 9.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gstreamer-base"
|
||||
version = "0.25.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "17cbd8f59586a369c40d4b0d2f3a61cf9e9287b3cf5503cdcd8e7c5faa99265e"
|
||||
dependencies = [
|
||||
"atomic_refcell",
|
||||
"cfg-if",
|
||||
"glib",
|
||||
"gstreamer",
|
||||
"gstreamer-base-sys",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gstreamer-base-sys"
|
||||
version = "0.25.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b05f77bfd76b5afee6b29c27dae19eaf5018b5cf8d0d17520f3de44c6385c32"
|
||||
dependencies = [
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"gstreamer-sys",
|
||||
"libc",
|
||||
"system-deps 9.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gstreamer-sys"
|
||||
version = "0.25.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "436d9532847489a8285d57b8c3670762c12a18f777fdc2ab159b52e0e6f521b9"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"libc",
|
||||
"system-deps 9.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gstreamer-video"
|
||||
version = "0.25.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ffe4d77b2a5e679973d9c6b6c052da8cda86b83f5c268872f8691fde693fde84"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"futures-channel",
|
||||
"glib",
|
||||
"gstreamer",
|
||||
"gstreamer-base",
|
||||
"gstreamer-video-sys",
|
||||
"libc",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gstreamer-video-sys"
|
||||
version = "0.25.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ef455da22edca97ac9299d682b868227f3d9217b303748ce0161b31ae82dc106"
|
||||
dependencies = [
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"gstreamer-base-sys",
|
||||
"gstreamer-sys",
|
||||
"libc",
|
||||
"system-deps 9.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "h2"
|
||||
version = "0.4.20"
|
||||
@@ -1164,6 +1383,15 @@ dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b4baf93f58d4425749ca49a51c50ebab072c5df6994d08fed93541c331481dc"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.18"
|
||||
@@ -1191,6 +1419,15 @@ dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "kstring"
|
||||
version = "2.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "558bf9508a558512042d3095138b1f7b8fe90c5467d94f9f1da28b3731c5dbd1"
|
||||
dependencies = [
|
||||
"static_assertions",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.5.1"
|
||||
@@ -1226,7 +1463,7 @@ dependencies = [
|
||||
"libspa-sys",
|
||||
"nom 8.0.0",
|
||||
"rustix",
|
||||
"system-deps",
|
||||
"system-deps 7.0.8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1237,7 +1474,7 @@ checksum = "3b6e17bdaf63ed0d5e4144022624032b41fd9733112e8c74ac26fc9bf1291924"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
"cc",
|
||||
"system-deps",
|
||||
"system-deps 7.0.8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1378,6 +1615,12 @@ dependencies = [
|
||||
"pxfm",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "muldiv"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "956787520e75e9bd233246045d19f42fb73242759cc57fba9611d940ae96d4b0"
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.31.3"
|
||||
@@ -1443,6 +1686,16 @@ dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-rational"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824"
|
||||
dependencies = [
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.19"
|
||||
@@ -1467,6 +1720,15 @@ version = "1.21.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
||||
|
||||
[[package]]
|
||||
name = "option-operations"
|
||||
version = "0.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aca39cf52b03268400c16eeb9b56382ea3c3353409309b63f5c8f0b1faf42754"
|
||||
dependencies = [
|
||||
"pastey",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ordered-stream"
|
||||
version = "0.2.0"
|
||||
@@ -1477,6 +1739,12 @@ dependencies = [
|
||||
"pin-project-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pastey"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2ee67f1008b1ba2321834326597b8e186293b049a023cdef258527550b9935b4"
|
||||
|
||||
[[package]]
|
||||
name = "pem"
|
||||
version = "4.0.0"
|
||||
@@ -1530,7 +1798,7 @@ checksum = "9ce653f53e63e5b93853218092ee9a8906a5d082c92f3f1db26316955dd63ce0"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
"libspa-sys",
|
||||
"system-deps",
|
||||
"system-deps 7.0.8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1751,6 +2019,9 @@ name = "rs-codec"
|
||||
version = "0.5.0"
|
||||
dependencies = [
|
||||
"env-libvpx-sys",
|
||||
"gstreamer",
|
||||
"gstreamer-app",
|
||||
"gstreamer-video",
|
||||
"rs-capture",
|
||||
"rs-proto",
|
||||
"thiserror",
|
||||
@@ -2215,6 +2486,12 @@ dependencies = [
|
||||
"der",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "static_assertions"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
||||
|
||||
[[package]]
|
||||
name = "str0m"
|
||||
version = "0.24.1"
|
||||
@@ -2339,6 +2616,19 @@ dependencies = [
|
||||
"version-compare",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "system-deps"
|
||||
version = "9.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "db551ad38aac61d5e0343e0eeeb0163be3115c4e23b6a025959570ee0c03c67d"
|
||||
dependencies = [
|
||||
"cfg-expr",
|
||||
"heck",
|
||||
"pkg-config",
|
||||
"toml",
|
||||
"version-compare",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "target-lexicon"
|
||||
version = "0.13.5"
|
||||
|
||||
Generated
+316
-49
@@ -156,7 +156,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "241b621213072e993be4f6f3a9e4b45f65b7e6faad43001be957184b7bb1824b"
|
||||
dependencies = [
|
||||
"atk-sys",
|
||||
"glib",
|
||||
"glib 0.18.5",
|
||||
"libc",
|
||||
]
|
||||
|
||||
@@ -166,8 +166,8 @@ version = "0.18.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c5e48b684b0ca77d2bbadeef17424c2ea3c897d44d566a1617e7e8f30614d086"
|
||||
dependencies = [
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"glib-sys 0.18.1",
|
||||
"gobject-sys 0.18.0",
|
||||
"libc",
|
||||
"system-deps 6.2.2",
|
||||
]
|
||||
@@ -178,6 +178,12 @@ version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
|
||||
|
||||
[[package]]
|
||||
name = "atomic_refcell"
|
||||
version = "0.1.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "21e4227379beff4205943696e6c3e0cd809bacdf3f0edd6e3dd153e2269571a4"
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.5.1"
|
||||
@@ -325,7 +331,7 @@ dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"cexpr",
|
||||
"clang-sys",
|
||||
"itertools",
|
||||
"itertools 0.13.0",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"regex",
|
||||
@@ -471,7 +477,7 @@ checksum = "8ca26ef0159422fb77631dc9d17b102f253b876fe1586b03b803e63a309b4ee2"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"cairo-sys-rs",
|
||||
"glib",
|
||||
"glib 0.18.5",
|
||||
"libc",
|
||||
"once_cell",
|
||||
"thiserror 1.0.69",
|
||||
@@ -483,7 +489,7 @@ version = "0.18.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "685c9fa8e590b8b3d678873528d83411db17242a73fccaed827770ea0fedda51"
|
||||
dependencies = [
|
||||
"glib-sys",
|
||||
"glib-sys 0.18.1",
|
||||
"libc",
|
||||
"system-deps 6.2.2",
|
||||
]
|
||||
@@ -1495,7 +1501,7 @@ dependencies = [
|
||||
"gdk-pixbuf",
|
||||
"gdk-sys",
|
||||
"gio",
|
||||
"glib",
|
||||
"glib 0.18.5",
|
||||
"libc",
|
||||
"pango",
|
||||
]
|
||||
@@ -1508,7 +1514,7 @@ checksum = "50e1f5f1b0bfb830d6ccc8066d18db35c487b1b2b1e8589b5dfe9f07e8defaec"
|
||||
dependencies = [
|
||||
"gdk-pixbuf-sys",
|
||||
"gio",
|
||||
"glib",
|
||||
"glib 0.18.5",
|
||||
"libc",
|
||||
"once_cell",
|
||||
]
|
||||
@@ -1519,9 +1525,9 @@ version = "0.18.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f9839ea644ed9c97a34d129ad56d38a25e6756f99f3a88e15cd39c20629caf7"
|
||||
dependencies = [
|
||||
"gio-sys",
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"gio-sys 0.18.1",
|
||||
"glib-sys 0.18.1",
|
||||
"gobject-sys 0.18.0",
|
||||
"libc",
|
||||
"system-deps 6.2.2",
|
||||
]
|
||||
@@ -1534,9 +1540,9 @@ checksum = "5c2d13f38594ac1e66619e188c6d5a1adb98d11b2fcf7894fc416ad76aa2f3f7"
|
||||
dependencies = [
|
||||
"cairo-sys-rs",
|
||||
"gdk-pixbuf-sys",
|
||||
"gio-sys",
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"gio-sys 0.18.1",
|
||||
"glib-sys 0.18.1",
|
||||
"gobject-sys 0.18.0",
|
||||
"libc",
|
||||
"pango-sys",
|
||||
"pkg-config",
|
||||
@@ -1550,8 +1556,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "140071d506d223f7572b9f09b5e155afbd77428cd5cc7af8f2694c41d98dfe69"
|
||||
dependencies = [
|
||||
"gdk-sys",
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"glib-sys 0.18.1",
|
||||
"gobject-sys 0.18.0",
|
||||
"libc",
|
||||
"pkg-config",
|
||||
"system-deps 6.2.2",
|
||||
@@ -1566,7 +1572,7 @@ dependencies = [
|
||||
"gdk",
|
||||
"gdkx11-sys",
|
||||
"gio",
|
||||
"glib",
|
||||
"glib 0.18.5",
|
||||
"libc",
|
||||
"x11",
|
||||
]
|
||||
@@ -1578,7 +1584,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e2e7445fe01ac26f11601db260dd8608fe172514eb63b3b5e261ea6b0f4428d"
|
||||
dependencies = [
|
||||
"gdk-sys",
|
||||
"glib-sys",
|
||||
"glib-sys 0.18.1",
|
||||
"libc",
|
||||
"system-deps 6.2.2",
|
||||
"x11",
|
||||
@@ -1651,8 +1657,8 @@ dependencies = [
|
||||
"futures-core",
|
||||
"futures-io",
|
||||
"futures-util",
|
||||
"gio-sys",
|
||||
"glib",
|
||||
"gio-sys 0.18.1",
|
||||
"glib 0.18.5",
|
||||
"libc",
|
||||
"once_cell",
|
||||
"pin-project-lite",
|
||||
@@ -1666,13 +1672,26 @@ version = "0.18.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "37566df850baf5e4cb0dfb78af2e4b9898d817ed9263d1090a2df958c64737d2"
|
||||
dependencies = [
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"glib-sys 0.18.1",
|
||||
"gobject-sys 0.18.0",
|
||||
"libc",
|
||||
"system-deps 6.2.2",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gio-sys"
|
||||
version = "0.22.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c28739f914c15b87a9856000bed9cbd5b3a8afbca5e982d9a299e1601422cb5"
|
||||
dependencies = [
|
||||
"glib-sys 0.22.9",
|
||||
"gobject-sys 0.22.9",
|
||||
"libc",
|
||||
"system-deps 9.0.1",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glib"
|
||||
version = "0.18.5"
|
||||
@@ -1685,10 +1704,10 @@ dependencies = [
|
||||
"futures-executor",
|
||||
"futures-task",
|
||||
"futures-util",
|
||||
"gio-sys",
|
||||
"glib-macros",
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"gio-sys 0.18.1",
|
||||
"glib-macros 0.18.5",
|
||||
"glib-sys 0.18.1",
|
||||
"gobject-sys 0.18.0",
|
||||
"libc",
|
||||
"memchr",
|
||||
"once_cell",
|
||||
@@ -1696,6 +1715,27 @@ dependencies = [
|
||||
"thiserror 1.0.69",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glib"
|
||||
version = "0.22.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e4cf9e5bd8713f1990a92c422998826e0fb34824277b46bc59757373483c6694"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-executor",
|
||||
"futures-task",
|
||||
"futures-util",
|
||||
"gio-sys 0.22.9",
|
||||
"glib-macros 0.22.9",
|
||||
"glib-sys 0.22.9",
|
||||
"gobject-sys 0.22.9",
|
||||
"libc",
|
||||
"memchr",
|
||||
"smallvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glib-macros"
|
||||
version = "0.18.5"
|
||||
@@ -1710,6 +1750,18 @@ dependencies = [
|
||||
"syn 2.0.119",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glib-macros"
|
||||
version = "0.22.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c9597c68fa7bdf4154a3079642cd21c4dccac0b0bdd2897d82861523bf91e7b9"
|
||||
dependencies = [
|
||||
"heck 0.5.0",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 3.0.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glib-sys"
|
||||
version = "0.18.1"
|
||||
@@ -1720,6 +1772,16 @@ dependencies = [
|
||||
"system-deps 6.2.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glib-sys"
|
||||
version = "0.22.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "99b38907e67e40dec9b60f858bcada952598719cb512a13eb13d6cdcd16f8295"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"system-deps 9.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glob"
|
||||
version = "0.3.4"
|
||||
@@ -1732,11 +1794,145 @@ version = "0.18.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0850127b514d1c4a4654ead6dedadb18198999985908e6ffe4436f53c785ce44"
|
||||
dependencies = [
|
||||
"glib-sys",
|
||||
"glib-sys 0.18.1",
|
||||
"libc",
|
||||
"system-deps 6.2.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gobject-sys"
|
||||
version = "0.22.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "07595c9ba696bd9819cb6a8df39f08078f3dd679508fe052dd558492c2053834"
|
||||
dependencies = [
|
||||
"glib-sys 0.22.9",
|
||||
"libc",
|
||||
"system-deps 9.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gstreamer"
|
||||
version = "0.25.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f4237e2066a25ecb7e54be6c066409e30615920265b9799b8d560ef8ac9857c6"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
"glib 0.22.10",
|
||||
"gstreamer-sys",
|
||||
"itertools 0.15.0",
|
||||
"kstring",
|
||||
"libc",
|
||||
"muldiv",
|
||||
"num-integer",
|
||||
"num-rational",
|
||||
"option-operations",
|
||||
"pastey",
|
||||
"pin-project-lite",
|
||||
"smallvec",
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gstreamer-app"
|
||||
version = "0.25.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "97f8ae9238c2352398dcc084de28df3f7099af216ac6c160b52318d23f25c010"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
"glib 0.22.10",
|
||||
"gstreamer",
|
||||
"gstreamer-app-sys",
|
||||
"gstreamer-base",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gstreamer-app-sys"
|
||||
version = "0.25.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0798b8aef6694341d40bb81edc759f8979b896b59f9f0f45d8cfa3bb7bf2e743"
|
||||
dependencies = [
|
||||
"glib-sys 0.22.9",
|
||||
"gstreamer-base-sys",
|
||||
"gstreamer-sys",
|
||||
"libc",
|
||||
"system-deps 9.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gstreamer-base"
|
||||
version = "0.25.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "17cbd8f59586a369c40d4b0d2f3a61cf9e9287b3cf5503cdcd8e7c5faa99265e"
|
||||
dependencies = [
|
||||
"atomic_refcell",
|
||||
"cfg-if",
|
||||
"glib 0.22.10",
|
||||
"gstreamer",
|
||||
"gstreamer-base-sys",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gstreamer-base-sys"
|
||||
version = "0.25.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b05f77bfd76b5afee6b29c27dae19eaf5018b5cf8d0d17520f3de44c6385c32"
|
||||
dependencies = [
|
||||
"glib-sys 0.22.9",
|
||||
"gobject-sys 0.22.9",
|
||||
"gstreamer-sys",
|
||||
"libc",
|
||||
"system-deps 9.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gstreamer-sys"
|
||||
version = "0.25.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "436d9532847489a8285d57b8c3670762c12a18f777fdc2ab159b52e0e6f521b9"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"glib-sys 0.22.9",
|
||||
"gobject-sys 0.22.9",
|
||||
"libc",
|
||||
"system-deps 9.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gstreamer-video"
|
||||
version = "0.25.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ffe4d77b2a5e679973d9c6b6c052da8cda86b83f5c268872f8691fde693fde84"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"futures-channel",
|
||||
"glib 0.22.10",
|
||||
"gstreamer",
|
||||
"gstreamer-base",
|
||||
"gstreamer-video-sys",
|
||||
"libc",
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gstreamer-video-sys"
|
||||
version = "0.25.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ef455da22edca97ac9299d682b868227f3d9217b303748ce0161b31ae82dc106"
|
||||
dependencies = [
|
||||
"glib-sys 0.22.9",
|
||||
"gobject-sys 0.22.9",
|
||||
"gstreamer-base-sys",
|
||||
"gstreamer-sys",
|
||||
"libc",
|
||||
"system-deps 9.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gtk"
|
||||
version = "0.18.2"
|
||||
@@ -1750,7 +1946,7 @@ dependencies = [
|
||||
"gdk",
|
||||
"gdk-pixbuf",
|
||||
"gio",
|
||||
"glib",
|
||||
"glib 0.18.5",
|
||||
"gtk-sys",
|
||||
"gtk3-macros",
|
||||
"libc",
|
||||
@@ -1768,9 +1964,9 @@ dependencies = [
|
||||
"cairo-sys-rs",
|
||||
"gdk-pixbuf-sys",
|
||||
"gdk-sys",
|
||||
"gio-sys",
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"gio-sys 0.18.1",
|
||||
"glib-sys 0.18.1",
|
||||
"gobject-sys 0.18.0",
|
||||
"libc",
|
||||
"pango-sys",
|
||||
"system-deps 6.2.2",
|
||||
@@ -2190,6 +2386,15 @@ dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b4baf93f58d4425749ca49a51c50ebab072c5df6994d08fed93541c331481dc"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.18"
|
||||
@@ -2203,7 +2408,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca5671e9ffce8ffba57afc24070e906da7fc4b1ba66f2cabebf61bf2ea257fcc"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"glib",
|
||||
"glib 0.18.5",
|
||||
"javascriptcore-rs-sys",
|
||||
]
|
||||
|
||||
@@ -2213,8 +2418,8 @@ version = "1.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "af1be78d14ffa4b75b66df31840478fef72b51f8c2465d4ca7c194da9f7a5124"
|
||||
dependencies = [
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"glib-sys 0.18.1",
|
||||
"gobject-sys 0.18.0",
|
||||
"libc",
|
||||
"system-deps 6.2.2",
|
||||
]
|
||||
@@ -2370,6 +2575,15 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "kstring"
|
||||
version = "2.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "558bf9508a558512042d3095138b1f7b8fe90c5467d94f9f1da28b3731c5dbd1"
|
||||
dependencies = [
|
||||
"static_assertions",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.5.1"
|
||||
@@ -2382,7 +2596,7 @@ version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "03589b9607c868cc7ae54c0b2a22c8dc03dd41692d48f2d7df73615c6a95dc0a"
|
||||
dependencies = [
|
||||
"glib",
|
||||
"glib 0.18.5",
|
||||
"gtk",
|
||||
"gtk-sys",
|
||||
"libappindicator-sys",
|
||||
@@ -2638,6 +2852,12 @@ dependencies = [
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "muldiv"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "956787520e75e9bd233246045d19f42fb73242759cc57fba9611d940ae96d4b0"
|
||||
|
||||
[[package]]
|
||||
name = "ndk"
|
||||
version = "0.9.0"
|
||||
@@ -2739,6 +2959,16 @@ dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-rational"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824"
|
||||
dependencies = [
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.19"
|
||||
@@ -2987,6 +3217,15 @@ version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
|
||||
|
||||
[[package]]
|
||||
name = "option-operations"
|
||||
version = "0.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aca39cf52b03268400c16eeb9b56382ea3c3353409309b63f5c8f0b1faf42754"
|
||||
dependencies = [
|
||||
"pastey",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ordered-stream"
|
||||
version = "0.2.0"
|
||||
@@ -3004,7 +3243,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ca27ec1eb0457ab26f3036ea52229edbdb74dee1edd29063f5b9b010e7ebee4"
|
||||
dependencies = [
|
||||
"gio",
|
||||
"glib",
|
||||
"glib 0.18.5",
|
||||
"libc",
|
||||
"once_cell",
|
||||
"pango-sys",
|
||||
@@ -3016,8 +3255,8 @@ version = "0.18.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "436737e391a843e5933d6d9aa102cb126d501e815b83601365a948a518555dc5"
|
||||
dependencies = [
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"glib-sys 0.18.1",
|
||||
"gobject-sys 0.18.0",
|
||||
"libc",
|
||||
"system-deps 6.2.2",
|
||||
]
|
||||
@@ -3045,6 +3284,12 @@ dependencies = [
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pastey"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2ee67f1008b1ba2321834326597b8e186293b049a023cdef258527550b9935b4"
|
||||
|
||||
[[package]]
|
||||
name = "pem"
|
||||
version = "4.0.0"
|
||||
@@ -3545,6 +3790,9 @@ name = "rs-codec"
|
||||
version = "0.5.0"
|
||||
dependencies = [
|
||||
"env-libvpx-sys",
|
||||
"gstreamer",
|
||||
"gstreamer-app",
|
||||
"gstreamer-video",
|
||||
"rs-capture",
|
||||
"thiserror 2.0.21",
|
||||
"tokio",
|
||||
@@ -4213,7 +4461,7 @@ checksum = "471f924a40f31251afc77450e781cb26d55c0b650842efafc9c6cbd2f7cc4f9f"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"gio",
|
||||
"glib",
|
||||
"glib 0.18.5",
|
||||
"libc",
|
||||
"soup3-sys",
|
||||
]
|
||||
@@ -4224,9 +4472,9 @@ version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ebe8950a680a12f24f15ebe1bf70db7af98ad242d9db43596ad3108aab86c27"
|
||||
dependencies = [
|
||||
"gio-sys",
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"gio-sys 0.18.1",
|
||||
"glib-sys 0.18.1",
|
||||
"gobject-sys 0.18.0",
|
||||
"libc",
|
||||
"system-deps 6.2.2",
|
||||
]
|
||||
@@ -4256,6 +4504,12 @@ version = "1.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596"
|
||||
|
||||
[[package]]
|
||||
name = "static_assertions"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
||||
|
||||
[[package]]
|
||||
name = "static_vcruntime"
|
||||
version = "3.0.0"
|
||||
@@ -4451,6 +4705,19 @@ dependencies = [
|
||||
"version-compare",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "system-deps"
|
||||
version = "9.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "db551ad38aac61d5e0343e0eeeb0163be3115c4e23b6a025959570ee0c03c67d"
|
||||
dependencies = [
|
||||
"cfg-expr 0.20.10",
|
||||
"heck 0.5.0",
|
||||
"pkg-config",
|
||||
"toml 1.1.8+spec-1.1.0",
|
||||
"version-compare",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tao"
|
||||
version = "0.37.2"
|
||||
@@ -5531,10 +5798,10 @@ dependencies = [
|
||||
"gdk",
|
||||
"gdk-sys",
|
||||
"gio",
|
||||
"gio-sys",
|
||||
"glib",
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"gio-sys 0.18.1",
|
||||
"glib 0.18.5",
|
||||
"glib-sys 0.18.1",
|
||||
"gobject-sys 0.18.0",
|
||||
"gtk",
|
||||
"gtk-sys",
|
||||
"javascriptcore-rs",
|
||||
@@ -5553,9 +5820,9 @@ dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"cairo-sys-rs",
|
||||
"gdk-sys",
|
||||
"gio-sys",
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"gio-sys 0.18.1",
|
||||
"glib-sys 0.18.1",
|
||||
"gobject-sys 0.18.0",
|
||||
"gtk-sys",
|
||||
"javascriptcore-rs-sys",
|
||||
"libc",
|
||||
|
||||
@@ -26,6 +26,8 @@ default = ["custom-protocol"]
|
||||
custom-protocol = ["tauri/custom-protocol"]
|
||||
# Real Wayland capture (ADR 0009), like the command-line binary.
|
||||
pipewire = ["rs-session/pipewire"]
|
||||
# Hardware encoding (#57), like the command-line binary.
|
||||
vaapi = ["rs-session/vaapi"]
|
||||
|
||||
[dependencies]
|
||||
rs-diag = { path = "../../../crates/rs-diag" }
|
||||
|
||||
@@ -4,4 +4,4 @@
|
||||
* Video codec of the shares (#67). VP9 keeps the same quality at a lower
|
||||
* bitrate, but costs 1.6x the CPU of VP8 (`docs/perf.md`).
|
||||
*/
|
||||
export type Codec = "vp8" | "vp9";
|
||||
export type Codec = "vp8" | "vp9" | "h264";
|
||||
@@ -43,6 +43,11 @@ limit: number,
|
||||
* Quality offered when a share starts.
|
||||
*/
|
||||
quality: QualityPreset, codec: Codec,
|
||||
/**
|
||||
* Let the GPU encode when it can (#57): VP9 and H.264 through VA-API.
|
||||
* Off, libvpx encodes everything; H.264 then falls back on VP8.
|
||||
*/
|
||||
hardware_encoding: boolean,
|
||||
/**
|
||||
* Minutes during which the QR code and the short code let a new device in
|
||||
* (#19). `0`: no limit. Devices already admitted come back after the
|
||||
|
||||
@@ -12,7 +12,7 @@ import { type Host, rejectionsOf } from '../lib/host';
|
||||
import { noticeOf, outcomeSummary, say } from '../lib/view';
|
||||
|
||||
const QUALITIES: QualityPreset[] = ['saver', 'balanced', 'sharp'];
|
||||
const CODECS: Codec[] = ['vp8', 'vp9'];
|
||||
const CODECS: Codec[] = ['vp8', 'vp9', 'h264'];
|
||||
const THEMES: Theme[] = ['system', 'light', 'dark'];
|
||||
const CLOSE_ACTIONS: CloseAction[] = ['tray', 'quit'];
|
||||
|
||||
@@ -221,6 +221,14 @@ export function SettingsDialog({ host, autostart, onClose, onSaved }: Props) {
|
||||
))}
|
||||
</select>
|
||||
</Field>
|
||||
<label className='checkbox' title={t('hardwareEncodingHelp')}>
|
||||
<input
|
||||
type='checkbox'
|
||||
checked={settings.hardware_encoding}
|
||||
onChange={(e) => change('hardware_encoding', e.target.checked)}
|
||||
/>
|
||||
{t('hardwareEncoding')}
|
||||
</label>
|
||||
<Field id={`${id}-theme`} label={t('theme')}>
|
||||
<select
|
||||
id={`${id}-theme`}
|
||||
|
||||
@@ -16,6 +16,15 @@ tracing.workspace = true
|
||||
# Direct binding to libvpx: `vpx-encode` controlled neither the lag queue nor
|
||||
# forced keyframes (#67). The `unsafe` code lives in `src/vpx.rs`.
|
||||
env-libvpx-sys = "5.1.3"
|
||||
# Hardware encoding through VA-API (#57), behind the `vaapi` feature: GStreamer
|
||||
# drives the GPU's encoder, its `va` plugin and the driver are found at
|
||||
# runtime. Without them, the host falls back on libvpx.
|
||||
gstreamer = { version = "0.25", optional = true }
|
||||
gstreamer-app = { version = "0.25", optional = true }
|
||||
gstreamer-video = { version = "0.25", optional = true }
|
||||
|
||||
[features]
|
||||
vaapi = ["dep:gstreamer", "dep:gstreamer-app", "dep:gstreamer-video"]
|
||||
|
||||
[dev-dependencies]
|
||||
rs-proto = { path = "../rs-proto" }
|
||||
@@ -0,0 +1,83 @@
|
||||
//! Cost of the VA-API encoder (#57) for one image, as the encoding thread
|
||||
//! sees it: the call returns once the GPU handed back the access unit.
|
||||
//!
|
||||
//! cargo run --release -p rs-codec --features vaapi --example bench_hardware -- 1920x1080 h264 60
|
||||
//!
|
||||
//! Prints the median and p95 of the call, and the CPU time of the process per
|
||||
//! image: the latency decides whether 60 images per second fit (16.7 ms), the
|
||||
//! CPU time is what the GPU saves.
|
||||
|
||||
#[cfg(feature = "vaapi")]
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
use std::time::Instant;
|
||||
|
||||
use rs_codec::{BgraFrame, EncodeConfig, HardwareEncoder, VideoCodec, VideoEncoder};
|
||||
|
||||
let mut args = std::env::args().skip(1);
|
||||
let size = args.next().unwrap_or_else(|| "1920x1080".into());
|
||||
let codec: VideoCodec = args.next().unwrap_or_else(|| "h264".into()).parse()?;
|
||||
let fps: u8 = args.next().map_or(Ok(60), |f| f.parse())?;
|
||||
let (width, height) = size
|
||||
.split_once('x')
|
||||
.and_then(|(w, h)| Some((w.parse::<u32>().ok()?, h.parse::<u32>().ok()?)))
|
||||
.ok_or("size: WxH")?;
|
||||
let mut encoder = HardwareEncoder::new(EncodeConfig {
|
||||
width,
|
||||
height,
|
||||
fps,
|
||||
bitrate_kbps: 6000,
|
||||
codec,
|
||||
})?;
|
||||
let frames: Vec<Vec<u8>> = (0..8)
|
||||
.map(|n| {
|
||||
let mut data = vec![235u8; (width * height * 4) as usize];
|
||||
for (i, b) in data.iter_mut().enumerate().step_by(4 * 7) {
|
||||
*b = ((i / 4 + n * 3) % 255) as u8;
|
||||
}
|
||||
data
|
||||
})
|
||||
.collect();
|
||||
let cpu = || {
|
||||
let stat = std::fs::read_to_string("/proc/self/stat").unwrap_or_default();
|
||||
let fields: Vec<u64> = stat
|
||||
.rsplit(')')
|
||||
.next()
|
||||
.unwrap_or_default()
|
||||
.split_whitespace()
|
||||
.skip(11)
|
||||
.take(2)
|
||||
.filter_map(|f| f.parse().ok())
|
||||
.collect();
|
||||
fields.iter().sum::<u64>()
|
||||
};
|
||||
let mut times = Vec::new();
|
||||
let count = 300;
|
||||
let cpu_before = cpu();
|
||||
for i in 0..count {
|
||||
let data = &frames[i % frames.len()];
|
||||
let frame = BgraFrame {
|
||||
data,
|
||||
width: width as usize,
|
||||
height: height as usize,
|
||||
};
|
||||
let start = Instant::now();
|
||||
let _ = encoder.encode(&frame);
|
||||
times.push(start.elapsed().as_secs_f64() * 1000.0);
|
||||
}
|
||||
let ticks = cpu() - cpu_before;
|
||||
times.sort_by(f64::total_cmp);
|
||||
let hz = 100.0;
|
||||
println!(
|
||||
"{size} {} : call median {:.1} ms, p95 {:.1} ms; CPU {:.1} ms per image",
|
||||
codec.as_str(),
|
||||
times[times.len() / 2],
|
||||
times[times.len() * 95 / 100],
|
||||
ticks as f64 / hz * 1000.0 / count as f64
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "vaapi"))]
|
||||
fn main() {
|
||||
eprintln!("build with --features vaapi");
|
||||
}
|
||||
@@ -20,6 +20,8 @@ pub enum VideoCodec {
|
||||
#[default]
|
||||
Vp8,
|
||||
Vp9,
|
||||
/// Hardware only (#57): constrained baseline, Annex B.
|
||||
H264,
|
||||
}
|
||||
|
||||
impl VideoCodec {
|
||||
@@ -27,6 +29,7 @@ impl VideoCodec {
|
||||
match self {
|
||||
Self::Vp8 => "vp8",
|
||||
Self::Vp9 => "vp9",
|
||||
Self::H264 => "h264",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +38,7 @@ impl VideoCodec {
|
||||
match self {
|
||||
Self::Vp8 => "VP8",
|
||||
Self::Vp9 => "VP9",
|
||||
Self::H264 => "H264",
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,7 +50,10 @@ impl std::str::FromStr for VideoCodec {
|
||||
match value.to_ascii_lowercase().as_str() {
|
||||
"vp8" => Ok(Self::Vp8),
|
||||
"vp9" => Ok(Self::Vp9),
|
||||
other => Err(format!("unknown codec: {other} (expected: vp8 or vp9)")),
|
||||
"h264" => Ok(Self::H264),
|
||||
other => Err(format!(
|
||||
"unknown codec: {other} (expected: vp8, vp9 or h264)"
|
||||
)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -87,6 +94,25 @@ pub trait VideoEncoder: Send {
|
||||
fn reconfigure(&mut self, width: u32, height: u32) -> Result<(), EncodeError>;
|
||||
}
|
||||
|
||||
/// The encoder chosen at runtime, libvpx or the GPU's (#57).
|
||||
impl VideoEncoder for Box<dyn VideoEncoder> {
|
||||
fn encode(&mut self, frame: &BgraFrame) -> Result<Vec<Vec<u8>>, EncodeError> {
|
||||
(**self).encode(frame)
|
||||
}
|
||||
|
||||
fn request_keyframe(&mut self) {
|
||||
(**self).request_keyframe();
|
||||
}
|
||||
|
||||
fn config(&self) -> EncodeConfig {
|
||||
(**self).config()
|
||||
}
|
||||
|
||||
fn reconfigure(&mut self, width: u32, height: u32) -> Result<(), EncodeError> {
|
||||
(**self).reconfigure(width, height)
|
||||
}
|
||||
}
|
||||
|
||||
/// Real-time libvpx encoder, VP8 or VP9.
|
||||
pub struct VpxEncoder {
|
||||
inner: Context,
|
||||
@@ -282,6 +308,7 @@ mod tests {
|
||||
let key = match codec {
|
||||
VideoCodec::Vp8 => vp8_key(&packets[0]),
|
||||
VideoCodec::Vp9 => vp9_key(&packets[0]),
|
||||
VideoCodec::H264 => unreachable!("libvpx codecs only"),
|
||||
};
|
||||
assert!(key, "{codec:?}: the first image is a keyframe");
|
||||
}
|
||||
@@ -298,6 +325,7 @@ mod tests {
|
||||
let key = |p: &[u8]| match codec {
|
||||
VideoCodec::Vp8 => vp8_key(p),
|
||||
VideoCodec::Vp9 => vp9_key(p),
|
||||
VideoCodec::H264 => unreachable!("libvpx codecs only"),
|
||||
};
|
||||
for _ in 0..3 {
|
||||
encoder.encode(&frame).unwrap();
|
||||
@@ -352,7 +380,8 @@ mod tests {
|
||||
fn the_codec_name_parses_both_ways() {
|
||||
assert_eq!("vp8".parse::<VideoCodec>(), Ok(VideoCodec::Vp8));
|
||||
assert_eq!("VP9".parse::<VideoCodec>(), Ok(VideoCodec::Vp9));
|
||||
assert!("h264".parse::<VideoCodec>().is_err());
|
||||
assert_eq!("h264".parse::<VideoCodec>(), Ok(VideoCodec::H264));
|
||||
assert!("av1".parse::<VideoCodec>().is_err());
|
||||
assert_eq!(VideoCodec::Vp9.rtp_name(), "VP9");
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,373 @@
|
||||
//! Hardware encoding through VA-API (#57), H.264 or VP9.
|
||||
//!
|
||||
//! libvpx costs more than two cores for 1080p60 on the development machine; the
|
||||
//! GPU's encoder does the same work for almost nothing (measures in
|
||||
//! `docs/perf.md`). GStreamer drives it: the BGRA image goes in through an
|
||||
//! `appsrc`, `vapostproc` converts it to NV12 on the GPU, the low-power encoder
|
||||
//! (`vah264lpenc`, `vavp9lpenc`) compresses it, and the access unit comes out
|
||||
//! of an `appsink`, one call to [`VideoEncoder::encode`] per image like
|
||||
//! libvpx: no queue, no B-frame, a keyframe on request.
|
||||
//!
|
||||
//! What GStreamer needs is found at runtime: its `va` plugin and the GPU's
|
||||
//! VA-API driver. [`HardwareEncoder::new`] fails cleanly without them, and the
|
||||
//! caller falls back on libvpx.
|
||||
|
||||
use std::time::Duration;
|
||||
|
||||
use gstreamer as gst;
|
||||
use gstreamer::prelude::*;
|
||||
use gstreamer_app as gst_app;
|
||||
|
||||
use crate::color::BgraFrame;
|
||||
use crate::encoder::{EncodeConfig, EncodeError, VideoCodec, VideoEncoder};
|
||||
|
||||
/// How long an image may take through the GPU before it counts as lost. A
|
||||
/// low-power encoder answers within a few milliseconds; a frozen driver must
|
||||
/// not freeze the capture thread.
|
||||
const PULL_TIMEOUT: Duration = Duration::from_millis(500);
|
||||
|
||||
/// Seconds between two periodic keyframes, as libvpx does: a viewer that lost
|
||||
/// a packet recovers within that delay even without asking.
|
||||
const KEYFRAME_INTERVAL_S: u32 = 5;
|
||||
|
||||
pub struct HardwareEncoder {
|
||||
pipeline: gst::Pipeline,
|
||||
source: gst_app::AppSrc,
|
||||
sink: gst_app::AppSink,
|
||||
config: EncodeConfig,
|
||||
frames: u64,
|
||||
keyframe_requested: bool,
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for HardwareEncoder {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.debug_struct("HardwareEncoder")
|
||||
.field("config", &self.config)
|
||||
.finish_non_exhaustive()
|
||||
}
|
||||
}
|
||||
|
||||
impl HardwareEncoder {
|
||||
/// Opens the GPU encoder for `config.codec`. VP8 has no VA-API encoder on
|
||||
/// current GPUs: it is refused, like a machine without the plugin.
|
||||
pub fn new(config: EncodeConfig) -> Result<Self, EncodeError> {
|
||||
gst::init().map_err(|e| EncodeError::Init(format!("GStreamer: {e}")))?;
|
||||
let description = pipeline_description(&config)?;
|
||||
let pipeline = gst::parse::launch(&description)
|
||||
.map_err(|e| EncodeError::Init(format!("VA-API pipeline: {e}")))?
|
||||
.downcast::<gst::Pipeline>()
|
||||
.map_err(|_| EncodeError::Init("VA-API pipeline: not a pipeline".into()))?;
|
||||
let source = element::<gst_app::AppSrc>(&pipeline, "source")?;
|
||||
let sink = element::<gst_app::AppSink>(&pipeline, "sink")?;
|
||||
pipeline
|
||||
.set_state(gst::State::Playing)
|
||||
.map_err(|e| EncodeError::Init(format!("VA-API pipeline cannot start: {e}")))?;
|
||||
let encoder = Self {
|
||||
pipeline,
|
||||
source,
|
||||
sink,
|
||||
config,
|
||||
frames: 0,
|
||||
keyframe_requested: false,
|
||||
};
|
||||
// A missing driver often shows only once the pipeline runs: the
|
||||
// error is on the bus right away.
|
||||
encoder.check_bus()?;
|
||||
Ok(encoder)
|
||||
}
|
||||
|
||||
/// Tells whether this machine can encode `codec` on its GPU, without
|
||||
/// keeping anything open. For the diagnostics and the interface.
|
||||
pub fn available(codec: VideoCodec) -> bool {
|
||||
let probe = EncodeConfig {
|
||||
width: 64,
|
||||
height: 64,
|
||||
fps: 30,
|
||||
bitrate_kbps: 500,
|
||||
codec,
|
||||
};
|
||||
let Ok(mut encoder) = Self::new(probe) else {
|
||||
return false;
|
||||
};
|
||||
let black = vec![0u8; 64 * 64 * 4];
|
||||
let frame = BgraFrame {
|
||||
data: &black,
|
||||
width: 64,
|
||||
height: 64,
|
||||
};
|
||||
encoder.encode(&frame).is_ok()
|
||||
}
|
||||
|
||||
fn check_bus(&self) -> Result<(), EncodeError> {
|
||||
let Some(bus) = self.pipeline.bus() else {
|
||||
return Ok(());
|
||||
};
|
||||
while let Some(message) = bus.pop_filtered(&[gst::MessageType::Error]) {
|
||||
if let gst::MessageView::Error(error) = message.view() {
|
||||
return Err(EncodeError::Encode(format!(
|
||||
"VA-API: {} ({})",
|
||||
error.error(),
|
||||
error.debug().unwrap_or_default()
|
||||
)));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn timestamp(&self) -> gst::ClockTime {
|
||||
let fps = u64::from(self.config.fps.max(1));
|
||||
gst::ClockTime::from_nseconds(self.frames * 1_000_000_000 / fps)
|
||||
}
|
||||
}
|
||||
|
||||
impl VideoEncoder for HardwareEncoder {
|
||||
fn encode(&mut self, frame: &BgraFrame) -> Result<Vec<Vec<u8>>, EncodeError> {
|
||||
let expected = self.config.width as usize * self.config.height as usize * 4;
|
||||
if frame.data.len() != expected {
|
||||
return Err(EncodeError::Encode(format!(
|
||||
"image of {} bytes for a {}x{} encoder",
|
||||
frame.data.len(),
|
||||
self.config.width,
|
||||
self.config.height
|
||||
)));
|
||||
}
|
||||
if std::mem::take(&mut self.keyframe_requested) {
|
||||
// In stream order, before the image it applies to.
|
||||
let event = gstreamer_video::DownstreamForceKeyUnitEvent::builder()
|
||||
.all_headers(true)
|
||||
.build();
|
||||
self.source.send_event(event);
|
||||
}
|
||||
let mut buffer = gst::Buffer::from_mut_slice(frame.data.to_vec());
|
||||
{
|
||||
let buffer = buffer.get_mut().ok_or(EncodeError::NoFrame)?;
|
||||
let pts = self.timestamp();
|
||||
buffer.set_pts(pts);
|
||||
buffer.set_duration(gst::ClockTime::from_nseconds(
|
||||
1_000_000_000 / u64::from(self.config.fps.max(1)),
|
||||
));
|
||||
}
|
||||
self.frames += 1;
|
||||
self.source
|
||||
.push_buffer(buffer)
|
||||
.map_err(|e| EncodeError::Encode(format!("VA-API: {e:?}")))?;
|
||||
|
||||
let mut packets = Vec::new();
|
||||
let mut wait = gst::ClockTime::from_nseconds(PULL_TIMEOUT.as_nanos() as u64);
|
||||
// One access unit per image; any other ready one is taken as well,
|
||||
// without waiting.
|
||||
while let Some(sample) = self.sink.try_pull_sample(wait) {
|
||||
wait = gst::ClockTime::ZERO;
|
||||
let Some(buffer) = sample.buffer() else {
|
||||
continue;
|
||||
};
|
||||
let map = buffer
|
||||
.map_readable()
|
||||
.map_err(|_| EncodeError::Encode("VA-API: unreadable buffer".into()))?;
|
||||
packets.push(map.as_slice().to_vec());
|
||||
}
|
||||
if packets.is_empty() {
|
||||
self.check_bus()?;
|
||||
return Err(EncodeError::NoFrame);
|
||||
}
|
||||
Ok(packets)
|
||||
}
|
||||
|
||||
fn request_keyframe(&mut self) {
|
||||
self.keyframe_requested = true;
|
||||
}
|
||||
|
||||
fn config(&self) -> EncodeConfig {
|
||||
self.config
|
||||
}
|
||||
|
||||
fn reconfigure(&mut self, width: u32, height: u32) -> Result<(), EncodeError> {
|
||||
// A new pipeline at the new size, opened before the old one goes: a
|
||||
// failure leaves the stream as it was. Its first image is a keyframe.
|
||||
let config = EncodeConfig {
|
||||
width,
|
||||
height,
|
||||
..self.config
|
||||
};
|
||||
*self = Self::new(config)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for HardwareEncoder {
|
||||
fn drop(&mut self) {
|
||||
let _ = self.pipeline.set_state(gst::State::Null);
|
||||
}
|
||||
}
|
||||
|
||||
fn element<T: IsA<gst::Element>>(pipeline: &gst::Pipeline, name: &str) -> Result<T, EncodeError> {
|
||||
pipeline
|
||||
.by_name(name)
|
||||
.and_then(|e| e.downcast::<T>().ok())
|
||||
.ok_or_else(|| EncodeError::Init(format!("VA-API pipeline: no {name}")))
|
||||
}
|
||||
|
||||
/// The pipeline for `config`. Low latency everywhere: a live source, no
|
||||
/// B-frame, a single reference, a short rate-control buffer, an appsink that
|
||||
/// does not sync on a clock.
|
||||
fn pipeline_description(config: &EncodeConfig) -> Result<String, EncodeError> {
|
||||
let fps = u32::from(config.fps.max(1));
|
||||
let keyframes = fps * KEYFRAME_INTERVAL_S;
|
||||
// Half a second of buffer, like the libvpx settings: rate spikes stay
|
||||
// short, so does the latency they cause.
|
||||
let cpb = config.bitrate_kbps / 2;
|
||||
let encoder = match config.codec {
|
||||
// Constrained baseline: what every WebRTC browser decodes, hardware
|
||||
// decoders of phones included. Annex B byte stream, one access unit
|
||||
// per buffer, SPS and PPS before every keyframe.
|
||||
VideoCodec::H264 => format!(
|
||||
"vah264lpenc bitrate={bitrate} rate-control=cbr cpb-size={cpb} \
|
||||
key-int-max={keyframes} b-frames=0 ref-frames=1 cabac=false \
|
||||
! video/x-h264,profile=constrained-baseline \
|
||||
! h264parse config-interval=-1 \
|
||||
! video/x-h264,stream-format=byte-stream,alignment=au",
|
||||
bitrate = config.bitrate_kbps,
|
||||
),
|
||||
VideoCodec::Vp9 => format!(
|
||||
"vavp9lpenc bitrate={bitrate} rate-control=cbr cpb-size={cpb} \
|
||||
key-int-max={keyframes} ref-frames=1 \
|
||||
! video/x-vp9",
|
||||
bitrate = config.bitrate_kbps,
|
||||
),
|
||||
VideoCodec::Vp8 => {
|
||||
return Err(EncodeError::Init(
|
||||
"no VA-API encoder for VP8: use libvpx".into(),
|
||||
));
|
||||
}
|
||||
};
|
||||
Ok(format!(
|
||||
"appsrc name=source is-live=true format=time do-timestamp=false block=false \
|
||||
caps=video/x-raw,format=BGRA,width={width},height={height},framerate={fps}/1 \
|
||||
! vapostproc ! video/x-raw(memory:VAMemory),format=NV12 \
|
||||
! {encoder} \
|
||||
! appsink name=sink sync=false max-buffers=8 drop=false",
|
||||
width = config.width,
|
||||
height = config.height,
|
||||
))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn config(codec: VideoCodec) -> EncodeConfig {
|
||||
EncodeConfig {
|
||||
width: 320,
|
||||
height: 240,
|
||||
fps: 30,
|
||||
bitrate_kbps: 1000,
|
||||
codec,
|
||||
}
|
||||
}
|
||||
|
||||
/// Bars that move, so that the encoder has something to say.
|
||||
fn image(width: usize, height: usize, shift: usize) -> Vec<u8> {
|
||||
let mut data = vec![0u8; width * height * 4];
|
||||
for (i, pixel) in data.as_chunks_mut::<4>().0.iter_mut().enumerate() {
|
||||
let x = (i % width + shift) % width;
|
||||
pixel.copy_from_slice(&[(x * 255 / width) as u8, 128, 255 - (x as u8), 255]);
|
||||
}
|
||||
data
|
||||
}
|
||||
|
||||
/// Runs only where the GPU answers: elsewhere (CI runner, sandbox) there
|
||||
/// is nothing to check, and the fallback is tested by the caller.
|
||||
fn encoder(codec: VideoCodec) -> Option<HardwareEncoder> {
|
||||
match HardwareEncoder::new(config(codec)) {
|
||||
Ok(encoder) => Some(encoder),
|
||||
Err(error) => {
|
||||
eprintln!("no VA-API {}: {error}, test skipped", codec.as_str());
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn h264_comes_out_as_annex_b_with_its_parameters_and_a_keyframe_on_request() {
|
||||
let Some(mut encoder) = encoder(VideoCodec::H264) else {
|
||||
return;
|
||||
};
|
||||
let mut units = Vec::new();
|
||||
for i in 0..10 {
|
||||
if i == 5 {
|
||||
encoder.request_keyframe();
|
||||
}
|
||||
let data = image(320, 240, i * 7);
|
||||
let frame = BgraFrame {
|
||||
data: &data,
|
||||
width: 320,
|
||||
height: 240,
|
||||
};
|
||||
match encoder.encode(&frame) {
|
||||
Ok(packets) => units.extend(packets),
|
||||
Err(EncodeError::NoFrame) => {}
|
||||
Err(e) => panic!("{e}"),
|
||||
}
|
||||
}
|
||||
assert!(
|
||||
units.len() >= 8,
|
||||
"{} access units for 10 images",
|
||||
units.len()
|
||||
);
|
||||
let nal_types = |unit: &[u8]| -> Vec<u8> {
|
||||
unit.windows(4)
|
||||
.enumerate()
|
||||
.filter(|(_, w)| w[..3] == [0, 0, 1] || *w == [0, 0, 0, 1])
|
||||
.filter_map(|(i, w)| {
|
||||
let start = i + if w[2] == 1 { 3 } else { 4 };
|
||||
unit.get(start).map(|b| b & 0x1f)
|
||||
})
|
||||
.collect()
|
||||
};
|
||||
// SPS (7), PPS (8) and an IDR slice (5) in the first unit.
|
||||
let first = nal_types(&units[0]);
|
||||
assert!(
|
||||
first.contains(&7) && first.contains(&8) && first.contains(&5),
|
||||
"{first:?}"
|
||||
);
|
||||
// And again for the requested keyframe, a few units later.
|
||||
let idr = units[1..]
|
||||
.iter()
|
||||
.filter(|u| nal_types(u).contains(&5))
|
||||
.count();
|
||||
assert!(idr >= 1, "no keyframe after the request");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vp9_produces_frames_and_follows_a_new_size() {
|
||||
let Some(mut encoder) = encoder(VideoCodec::Vp9) else {
|
||||
return;
|
||||
};
|
||||
let data = image(320, 240, 0);
|
||||
let frame = BgraFrame {
|
||||
data: &data,
|
||||
width: 320,
|
||||
height: 240,
|
||||
};
|
||||
let packets = encoder.encode(&frame).expect("a VP9 frame");
|
||||
// An uncompressed VP9 header starts with the frame marker 0b10.
|
||||
assert_eq!(packets[0][0] >> 6, 0b10);
|
||||
encoder.reconfigure(640, 360).expect("new size");
|
||||
let bigger = image(640, 360, 0);
|
||||
let frame = BgraFrame {
|
||||
data: &bigger,
|
||||
width: 640,
|
||||
height: 360,
|
||||
};
|
||||
assert!(encoder.encode(&frame).is_ok());
|
||||
assert_eq!(encoder.config().width, 640);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vp8_is_refused_rather_than_mislabelled() {
|
||||
assert!(matches!(
|
||||
HardwareEncoder::new(config(VideoCodec::Vp8)),
|
||||
Err(EncodeError::Init(_))
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -5,14 +5,17 @@
|
||||
//! libvpx through a direct binding), and the result comes out through the
|
||||
//! [`FrameSource`] trait consumed by `rs-rtc` ([`pipeline`] bridges the two).
|
||||
//!
|
||||
//! The hardware H.264 encoder will come behind the same trait, without
|
||||
//! touching the rest of the pipeline (issue #53).
|
||||
//! The hardware encoder ([`hardware`], `vaapi` feature, #57) sits behind the
|
||||
//! same trait: H.264 or VP9 on the GPU through VA-API, without touching the
|
||||
//! rest of the pipeline.
|
||||
//!
|
||||
//! Build dependency: libvpx. See `scripts/build-libvpx.sh` and AGENTS.md.
|
||||
|
||||
pub mod color;
|
||||
pub mod encoder;
|
||||
pub mod frame;
|
||||
#[cfg(feature = "vaapi")]
|
||||
pub mod hardware;
|
||||
pub mod ivf;
|
||||
pub mod pipeline;
|
||||
mod vpx;
|
||||
@@ -20,5 +23,7 @@ mod vpx;
|
||||
pub use color::{BgraFrame, ColorError, bgra_to_i420};
|
||||
pub use encoder::{EncodeConfig, EncodeError, VideoCodec, VideoEncoder, VpxEncoder};
|
||||
pub use frame::{FrameSource, SharedFrames, SharedMedia, SharedPlayback, SyntheticFrames};
|
||||
#[cfg(feature = "vaapi")]
|
||||
pub use hardware::HardwareEncoder;
|
||||
pub use ivf::{IvfError, IvfFile};
|
||||
pub use pipeline::{LiveSource, LiveStats, SourceView};
|
||||
@@ -253,6 +253,7 @@ impl LiveSource {
|
||||
if (frame.width, frame.height) != (current.width, current.height) {
|
||||
match encoder.reconfigure(frame.width, frame.height) {
|
||||
Ok(()) => {
|
||||
cadence.warm_up();
|
||||
tracing::info!(
|
||||
event = "resolution_changed",
|
||||
before = ?(current.width, current.height),
|
||||
@@ -499,6 +500,8 @@ struct AdaptiveCadence {
|
||||
work: Option<Duration>,
|
||||
/// Encoded frames in a row with room to spare for the faster cadence.
|
||||
roomy: u32,
|
||||
/// Frames still to ignore: the first ones of a new encoder (#57).
|
||||
warming: u32,
|
||||
}
|
||||
|
||||
/// Lower the cadence when the work takes more than this share of a period.
|
||||
@@ -509,6 +512,12 @@ const RAISE_BELOW: f64 = 0.5;
|
||||
const RAISE_AFTER: u32 = 60;
|
||||
/// The slowest cadence the adaptation goes down to.
|
||||
const MIN_FPS: u8 = 15;
|
||||
/// Frames not counted after the encoder opens or changes size. The first ones
|
||||
/// are slow for reasons that do not last (a GPU pipeline starting, the first
|
||||
/// keyframe): counted, they halved the cadence of a hardware encoder that
|
||||
/// then never came back, its 9 to 13 ms per 1080p frame being above the
|
||||
/// raising threshold (#57).
|
||||
const WARM_UP_FRAMES: u32 = 10;
|
||||
|
||||
impl AdaptiveCadence {
|
||||
fn new(max_fps: u8) -> Self {
|
||||
@@ -518,9 +527,16 @@ impl AdaptiveCadence {
|
||||
fps: max_fps,
|
||||
work: None,
|
||||
roomy: 0,
|
||||
warming: WARM_UP_FRAMES,
|
||||
}
|
||||
}
|
||||
|
||||
/// A new encoder, or a new size: its first frames say nothing yet.
|
||||
fn warm_up(&mut self) {
|
||||
self.warming = WARM_UP_FRAMES;
|
||||
self.work = None;
|
||||
}
|
||||
|
||||
fn fps(&self) -> u8 {
|
||||
self.fps
|
||||
}
|
||||
@@ -538,6 +554,10 @@ impl AdaptiveCadence {
|
||||
/// Records the work time of an encoded frame; returns the new cadence
|
||||
/// when it changes.
|
||||
fn record(&mut self, work: Duration) -> Option<u8> {
|
||||
if self.warming > 0 {
|
||||
self.warming -= 1;
|
||||
return None;
|
||||
}
|
||||
let smoothed = match self.work {
|
||||
Some(previous) => previous.mul_f64(0.9) + work.mul_f64(0.1),
|
||||
None => work,
|
||||
@@ -570,6 +590,7 @@ mod tests {
|
||||
#[test]
|
||||
fn the_cadence_halves_when_the_work_does_not_fit_and_comes_back() {
|
||||
let mut cadence = AdaptiveCadence::new(60);
|
||||
cadence.warming = 0;
|
||||
// 15 ms of work per frame: above 85 % of the 16.7 ms period at 60 fps.
|
||||
assert_eq!(cadence.record(Duration::from_millis(15)), Some(30));
|
||||
assert_eq!(cadence.fps(), 30);
|
||||
@@ -596,6 +617,25 @@ mod tests {
|
||||
assert_eq!(thirty.fps(), 30);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_slow_start_does_not_halve_the_cadence() {
|
||||
// A GPU pipeline: the first frames take 40 ms, then 11 ms each,
|
||||
// which fits 60 fps but not the raising threshold. Counted, the
|
||||
// start would have left it at 30 for good.
|
||||
let mut cadence = AdaptiveCadence::new(60);
|
||||
for _ in 0..WARM_UP_FRAMES {
|
||||
assert_eq!(cadence.record(Duration::from_millis(40)), None);
|
||||
}
|
||||
for _ in 0..300 {
|
||||
cadence.record(Duration::from_millis(11));
|
||||
}
|
||||
assert_eq!(cadence.fps(), 60);
|
||||
// Same after a change of size.
|
||||
cadence.warm_up();
|
||||
assert_eq!(cadence.record(Duration::from_millis(40)), None);
|
||||
assert_eq!(cadence.fps(), 60);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_frame_is_due_after_most_of_a_period() {
|
||||
let cadence = AdaptiveCadence::new(30);
|
||||
|
||||
@@ -116,6 +116,13 @@ impl Context {
|
||||
VideoCodec::Vp8 => unsafe { vpx_codec_vp8_cx() },
|
||||
// SAFETY: same.
|
||||
VideoCodec::Vp9 => unsafe { vpx_codec_vp9_cx() },
|
||||
// The hardware encoder's (#57): never opened here.
|
||||
VideoCodec::H264 => {
|
||||
return Err(VpxError {
|
||||
call: "vpx_codec_enc_init",
|
||||
message: "H.264 is not a libvpx codec".into(),
|
||||
});
|
||||
}
|
||||
};
|
||||
if iface.is_null() {
|
||||
return Err(VpxError {
|
||||
@@ -190,6 +197,8 @@ impl Context {
|
||||
|
||||
fn apply_controls(&mut self, settings: &EncoderSettings) -> Result<(), VpxError> {
|
||||
match settings.codec {
|
||||
// Refused by `open`: there is no context to control.
|
||||
VideoCodec::H264 => {}
|
||||
VideoCodec::Vp8 => {
|
||||
// Negative: fixed speed, without adapting to the time left.
|
||||
// -6 is libwebrtc's value for VP8 on a desktop computer.
|
||||
|
||||
@@ -107,6 +107,7 @@ impl Session {
|
||||
.clear_codecs()
|
||||
.enable_vp8(codec == rs_codec::VideoCodec::Vp8)
|
||||
.enable_vp9(codec == rs_codec::VideoCodec::Vp9)
|
||||
.enable_h264(codec == rs_codec::VideoCodec::H264)
|
||||
.set_vp9_packetizer_mode(Vp9PacketizerMode::NonFlexible);
|
||||
let mut rtc = config.build(started);
|
||||
// The advertised candidate must be an address the browser can reach:
|
||||
@@ -296,11 +297,35 @@ impl Session {
|
||||
/// VP8 by the luck of the advertising order, and wrong for VP9 (#67). For VP9,
|
||||
/// only profile 0 (8 bits, 4:2:0) matches what the encoder produces; a
|
||||
/// parameter without a profile means profile 0 (RFC 9628).
|
||||
///
|
||||
/// For H.264 (#57), the hardware encoder produces constrained baseline in
|
||||
/// non-interleaved mode: `packetization-mode=1`, a profile of the baseline
|
||||
/// family (`42xxxx`), the constrained one (`42e0xx`) first. Main or High would
|
||||
/// announce tools the stream does not use; baseline in mode 0 would forbid the
|
||||
/// fragmentation units a 1080p keyframe needs.
|
||||
fn pick_pt<'a>(
|
||||
params: impl Iterator<Item = &'a PayloadParams>,
|
||||
codec: rs_codec::VideoCodec,
|
||||
) -> Option<Pt> {
|
||||
let params: Vec<&PayloadParams> = params.collect();
|
||||
if codec == rs_codec::VideoCodec::H264 {
|
||||
let baseline = |constrained: bool| {
|
||||
params.iter().find(|p| {
|
||||
let spec = p.spec();
|
||||
let profile = spec.format.profile_level_id.unwrap_or(0) >> 8;
|
||||
spec.codec == Codec::H264
|
||||
&& spec.format.packetization_mode == Some(1)
|
||||
&& if constrained {
|
||||
profile == 0x42e0
|
||||
} else {
|
||||
profile >> 8 == 0x42
|
||||
}
|
||||
})
|
||||
};
|
||||
return baseline(true).or_else(|| baseline(false)).map(|p| p.pt());
|
||||
}
|
||||
params
|
||||
.into_iter()
|
||||
.filter(|p| {
|
||||
let spec = p.spec();
|
||||
match codec {
|
||||
@@ -308,6 +333,7 @@ fn pick_pt<'a>(
|
||||
rs_codec::VideoCodec::Vp9 => {
|
||||
spec.codec == Codec::Vp9 && spec.format.profile_id.unwrap_or(0) == 0
|
||||
}
|
||||
rs_codec::VideoCodec::H264 => false,
|
||||
}
|
||||
})
|
||||
.map(|p| p.pt())
|
||||
@@ -434,6 +460,21 @@ mod tests {
|
||||
assert_eq!(pt.map(|pt| vp8.contains(&pt)), Some(true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn h264_is_answered_as_constrained_baseline_mode_1() {
|
||||
let (answer, pt) = negotiate(rs_codec::VideoCodec::H264);
|
||||
assert!(pts_of(&answer, "VP8").is_empty(), "{answer}");
|
||||
assert!(pts_of(&answer, "VP9").is_empty(), "{answer}");
|
||||
let pt = pt.expect("an H.264 payload type");
|
||||
let fmtp = format!("a=fmtp:{pt} ");
|
||||
let line = answer
|
||||
.lines()
|
||||
.find(|l| l.starts_with(&fmtp))
|
||||
.expect("H.264 parameters");
|
||||
assert!(line.contains("packetization-mode=1"), "{line}");
|
||||
assert!(line.contains("profile-level-id=42e0"), "{line}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn payload_type_follows_the_codec_not_the_order() {
|
||||
use str0m::format::{CodecSpec, FormatParams};
|
||||
|
||||
@@ -10,6 +10,9 @@ repository.workspace = true
|
||||
[features]
|
||||
# Real Wayland capture. Needs libpipewire-0.3 and libclang at build time (ADR 0009).
|
||||
pipewire = ["rs-capture/pipewire"]
|
||||
# Hardware encoding through VA-API (#57). Needs GStreamer at build time; its
|
||||
# `va` plugin and a GPU driver at runtime, libvpx otherwise.
|
||||
vaapi = ["rs-codec/vaapi"]
|
||||
|
||||
[dependencies]
|
||||
rs-capture = { path = "../rs-capture" }
|
||||
|
||||
@@ -35,7 +35,9 @@ options:
|
||||
--port N listen port (settings, otherwise 8099)
|
||||
--limit N number of viewers (settings, otherwise 5)
|
||||
--size WxH size of the test pattern or virtual screen (1280x720, 1920x1080)
|
||||
--codec CODEC vp8 or vp9 (settings, otherwise vp8; vp9: less bitrate, more CPU)
|
||||
--codec CODEC vp8, vp9 or h264 (settings, otherwise vp8). vp9 and h264 go to
|
||||
the GPU when it can (VA-API); h264 falls back on vp8 without it
|
||||
--software encode on the processor only (libvpx), whatever the settings say
|
||||
--viewer DIR directory of the built viewer
|
||||
--tls serve over HTTPS with a self-signed certificate
|
||||
--source NAME force the capture backend: portal, x11 or synthetic
|
||||
@@ -86,6 +88,7 @@ struct Options {
|
||||
viewer: Option<PathBuf>,
|
||||
size: Option<(u32, u32)>,
|
||||
codec: Option<VideoCodec>,
|
||||
software: bool,
|
||||
}
|
||||
|
||||
fn read_options(args: impl Iterator<Item = String>) -> Result<Options, String> {
|
||||
@@ -120,6 +123,7 @@ fn read_options(args: impl Iterator<Item = String>) -> Result<Options, String> {
|
||||
options.codec = Some(v.parse()?);
|
||||
}
|
||||
"--tls" => options.tls = true,
|
||||
"--software" => options.software = true,
|
||||
"--synthetic" | "-S" => options.synthetic = true,
|
||||
// The French spellings of earlier releases stay accepted: scripts
|
||||
// and launchers may still use them.
|
||||
@@ -242,6 +246,7 @@ async fn main() -> Result<(), Error> {
|
||||
port: options.port,
|
||||
limit: options.limit,
|
||||
codec: options.codec,
|
||||
software: options.software,
|
||||
},
|
||||
log_dir: log.dir.clone(),
|
||||
autostart: None,
|
||||
@@ -503,7 +508,12 @@ mod tests {
|
||||
);
|
||||
assert!(read(&["--teleport"]).unwrap_err().contains("--teleport"));
|
||||
assert!(read(&["a.ivf", "b.ivf"]).unwrap_err().contains("b.ivf"));
|
||||
assert!(read(&["--codec", "h264"]).unwrap_err().contains("h264"));
|
||||
assert!(read(&["--codec", "av1"]).unwrap_err().contains("av1"));
|
||||
assert_eq!(
|
||||
read(&["--codec", "h264"]).unwrap().codec,
|
||||
Some(VideoCodec::H264)
|
||||
);
|
||||
assert!(read(&["--software"]).unwrap().software);
|
||||
assert!(read(&["--codec"]).unwrap_err().contains("--codec"));
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,9 @@ use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
use rs_capture::{ScreenCapturer, SyntheticCapturer};
|
||||
use rs_codec::{EncodeConfig, IvfFile, LiveSource, SharedPlayback, VideoCodec, VpxEncoder};
|
||||
use rs_codec::{
|
||||
EncodeConfig, IvfFile, LiveSource, SharedPlayback, VideoCodec, VideoEncoder, VpxEncoder,
|
||||
};
|
||||
#[cfg(feature = "pipewire")]
|
||||
use rs_platform::PortalInfo;
|
||||
use rs_proto::{SourceId, SourceKind, StreamSettings};
|
||||
@@ -30,6 +32,8 @@ pub struct StartedCapture {
|
||||
pub portal: Option<rs_platform::Session>,
|
||||
pub source: SharedSource,
|
||||
pub encode: Option<EncodeConfig>,
|
||||
/// Why the hardware encoder was not used although asked for, if so.
|
||||
pub fallback: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
@@ -106,7 +110,7 @@ impl StartCaptureError {
|
||||
pub async fn start(
|
||||
choice: &SourceChoice,
|
||||
settings: &StreamSettings,
|
||||
codec: VideoCodec,
|
||||
codec: Encoding,
|
||||
#[cfg_attr(not(feature = "pipewire"), allow(unused_variables))] portal: Option<
|
||||
&rs_platform::PortalInfo,
|
||||
>,
|
||||
@@ -171,6 +175,7 @@ pub async fn start(
|
||||
portal: None,
|
||||
source,
|
||||
encode: None,
|
||||
fallback: None,
|
||||
})
|
||||
}
|
||||
SourceChoice::X11 { id } => x11(id.clone(), settings, codec).await,
|
||||
@@ -196,7 +201,7 @@ pub async fn start(
|
||||
async fn x11(
|
||||
id: String,
|
||||
settings: &StreamSettings,
|
||||
codec: VideoCodec,
|
||||
codec: Encoding,
|
||||
) -> Result<StartedCapture, StartCaptureError> {
|
||||
let settings = *settings;
|
||||
tokio::task::spawn_blocking(move || {
|
||||
@@ -244,7 +249,7 @@ async fn x11(
|
||||
async fn x11(
|
||||
_: String,
|
||||
_: &StreamSettings,
|
||||
_: VideoCodec,
|
||||
_: Encoding,
|
||||
) -> Result<StartedCapture, StartCaptureError> {
|
||||
Err(StartCaptureError::NoX11)
|
||||
}
|
||||
@@ -254,23 +259,24 @@ fn spawn_live<C>(
|
||||
mut capturer: C,
|
||||
size: (u32, u32),
|
||||
settings: &StreamSettings,
|
||||
codec: VideoCodec,
|
||||
codec: Encoding,
|
||||
id: &SourceId,
|
||||
source: SharedSource,
|
||||
) -> Result<StartedCapture, StartCaptureError>
|
||||
where
|
||||
C: ScreenCapturer + 'static,
|
||||
{
|
||||
let config = EncodeConfig {
|
||||
let wanted = EncodeConfig {
|
||||
width: size.0 & !1,
|
||||
height: size.1 & !1,
|
||||
fps: settings.max_fps,
|
||||
bitrate_kbps: settings.max_bitrate_kbps,
|
||||
codec,
|
||||
codec: codec.codec,
|
||||
};
|
||||
// An encoder that fails to initialize must fail the start, not a viewer's
|
||||
// connection.
|
||||
let encoder = VpxEncoder::new(config)?;
|
||||
let (encoder, fallback) = open_encoder(wanted, codec)?;
|
||||
let config = encoder.config();
|
||||
capturer.start(id)?;
|
||||
tracing::info!(
|
||||
width = config.width,
|
||||
@@ -287,9 +293,79 @@ where
|
||||
portal: None,
|
||||
source,
|
||||
encode: Some(config),
|
||||
fallback,
|
||||
})
|
||||
}
|
||||
|
||||
/// What to encode: the codec, and whether the GPU may do it (#57).
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct Encoding {
|
||||
pub codec: VideoCodec,
|
||||
pub hardware: bool,
|
||||
}
|
||||
|
||||
impl Encoding {
|
||||
/// libvpx only: what a command line asking for `--codec vp8` gets, and
|
||||
/// the tests.
|
||||
pub fn software(codec: VideoCodec) -> Self {
|
||||
Self {
|
||||
codec,
|
||||
hardware: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The encoder for `encoding`: the GPU's when allowed and present, libvpx
|
||||
/// otherwise. H.264 exists only on the GPU: without it, the share falls back
|
||||
/// on VP8, which every browser decodes, and says so (`fallback`, the reason).
|
||||
fn open_encoder(
|
||||
config: EncodeConfig,
|
||||
encoding: Encoding,
|
||||
) -> Result<(Box<dyn VideoEncoder>, Option<String>), StartCaptureError> {
|
||||
let mut fallback = None;
|
||||
if !encoding.hardware && config.codec == VideoCodec::H264 {
|
||||
fallback = Some("hardware encoding is turned off".to_string());
|
||||
}
|
||||
if encoding.hardware && config.codec != VideoCodec::Vp8 {
|
||||
match hardware_encoder(config) {
|
||||
Ok(encoder) => {
|
||||
tracing::info!(codec = config.codec.as_str(), "hardware encoder (VA-API)");
|
||||
return Ok((encoder, None));
|
||||
}
|
||||
Err(error) => {
|
||||
tracing::warn!(
|
||||
event = "hardware_encoder_unavailable",
|
||||
codec = config.codec.as_str(),
|
||||
%error,
|
||||
"falling back on libvpx"
|
||||
);
|
||||
fallback = Some(error.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
let config = if config.codec == VideoCodec::H264 {
|
||||
EncodeConfig {
|
||||
codec: VideoCodec::Vp8,
|
||||
..config
|
||||
}
|
||||
} else {
|
||||
config
|
||||
};
|
||||
Ok((Box::new(VpxEncoder::new(config)?), fallback))
|
||||
}
|
||||
|
||||
#[cfg(feature = "vaapi")]
|
||||
fn hardware_encoder(config: EncodeConfig) -> Result<Box<dyn VideoEncoder>, rs_codec::EncodeError> {
|
||||
Ok(Box::new(rs_codec::HardwareEncoder::new(config)?))
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "vaapi"))]
|
||||
fn hardware_encoder(_: EncodeConfig) -> Result<Box<dyn VideoEncoder>, rs_codec::EncodeError> {
|
||||
Err(rs_codec::EncodeError::Init(
|
||||
"this build has no hardware encoding (`vaapi` feature)".into(),
|
||||
))
|
||||
}
|
||||
|
||||
/// State directory, next to the logs: the portal restore token lives there,
|
||||
/// so the screen is not asked for again at every launch.
|
||||
#[cfg(feature = "pipewire")]
|
||||
@@ -321,7 +397,7 @@ async fn portal_pipewire(
|
||||
size: Option<(u32, u32)>,
|
||||
portal: Option<&PortalInfo>,
|
||||
settings: &StreamSettings,
|
||||
codec: VideoCodec,
|
||||
codec: Encoding,
|
||||
) -> Result<StartedCapture, StartCaptureError> {
|
||||
use rs_capture::pipewire::{PipeWireCapturer, PipeWireOptions};
|
||||
use rs_platform::SourceType;
|
||||
|
||||
@@ -64,8 +64,11 @@ impl DiagnosticsContext {
|
||||
codec: rs_codec::VideoCodec::Vp8,
|
||||
})
|
||||
.is_ok(),
|
||||
"vp9_exposed": false,
|
||||
"hardware": false,
|
||||
"vp9_exposed": true,
|
||||
// Asked to the GPU at export time only: opening it takes a
|
||||
// fraction of a second (#57).
|
||||
"hardware_built": cfg!(feature = "vaapi"),
|
||||
"hardware": hardware_codecs(),
|
||||
"config": self.encode.map(|c| serde_json::json!({
|
||||
"width": c.width,
|
||||
"height": c.height,
|
||||
@@ -88,3 +91,18 @@ impl DiagnosticsContext {
|
||||
Ok((name, bytes))
|
||||
}
|
||||
}
|
||||
|
||||
/// The codecs this machine's GPU encodes through VA-API (#57).
|
||||
#[cfg(feature = "vaapi")]
|
||||
fn hardware_codecs() -> Vec<&'static str> {
|
||||
[rs_codec::VideoCodec::H264, rs_codec::VideoCodec::Vp9]
|
||||
.into_iter()
|
||||
.filter(|codec| rs_codec::HardwareEncoder::available(*codec))
|
||||
.map(rs_codec::VideoCodec::as_str)
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "vaapi"))]
|
||||
fn hardware_codecs() -> Vec<&'static str> {
|
||||
Vec::new()
|
||||
}
|
||||
@@ -63,6 +63,8 @@ pub struct Overrides {
|
||||
pub limit: Option<u8>,
|
||||
/// Video codec of this launch (`--codec`). `None`: the one in the settings.
|
||||
pub codec: Option<rs_codec::VideoCodec>,
|
||||
/// `--software`: libvpx only for this launch, whatever the settings say.
|
||||
pub software: bool,
|
||||
}
|
||||
|
||||
/// Handle to the host, free to clone.
|
||||
@@ -135,7 +137,7 @@ struct Active {
|
||||
settings: StreamSettings,
|
||||
/// Kept to restart the capture after sleep: open sessions negotiated this
|
||||
/// codec, switching would give them a black screen.
|
||||
codec: rs_codec::VideoCodec,
|
||||
codec: capture::Encoding,
|
||||
server: Server,
|
||||
tls: Option<TlsMaterial>,
|
||||
listen: SocketAddr,
|
||||
@@ -536,6 +538,14 @@ impl Host {
|
||||
"connected viewers negotiated the codec of the current share",
|
||||
)),
|
||||
);
|
||||
change(
|
||||
"hardware_encoding",
|
||||
new.hardware_encoding != old.hardware_encoding,
|
||||
Some((
|
||||
"pending_hardware_encoding",
|
||||
"the encoder of the current share stays until the next one",
|
||||
)),
|
||||
);
|
||||
change(
|
||||
"quality",
|
||||
new.quality != old.quality,
|
||||
@@ -610,10 +620,14 @@ impl Host {
|
||||
let settings = self.settings();
|
||||
let overrides = self.0.config.overrides;
|
||||
let stream_settings = StreamSettings::for_preset(settings.quality);
|
||||
let codec = overrides.codec.unwrap_or(match settings.codec {
|
||||
rs_store::Codec::Vp8 => rs_codec::VideoCodec::Vp8,
|
||||
rs_store::Codec::Vp9 => rs_codec::VideoCodec::Vp9,
|
||||
});
|
||||
let codec = capture::Encoding {
|
||||
codec: overrides.codec.unwrap_or(match settings.codec {
|
||||
rs_store::Codec::Vp8 => rs_codec::VideoCodec::Vp8,
|
||||
rs_store::Codec::Vp9 => rs_codec::VideoCodec::Vp9,
|
||||
rs_store::Codec::H264 => rs_codec::VideoCodec::H264,
|
||||
}),
|
||||
hardware: settings.hardware_encoding && !overrides.software,
|
||||
};
|
||||
let limit = overrides.limit.unwrap_or(settings.limit);
|
||||
let port = overrides.port.unwrap_or(settings.port);
|
||||
|
||||
@@ -635,7 +649,27 @@ impl Host {
|
||||
portal,
|
||||
source,
|
||||
encode,
|
||||
fallback,
|
||||
} = started;
|
||||
// What was actually opened: the sessions negotiate it, and a restart
|
||||
// after sleep or a source switch must produce it again.
|
||||
let codec = capture::Encoding {
|
||||
codec: encode.map_or(codec.codec, |e| e.codec),
|
||||
..codec
|
||||
};
|
||||
if let Some(reason) = fallback {
|
||||
self.warn(
|
||||
Notice::new(
|
||||
"hardware_fallback",
|
||||
format!(
|
||||
"Hardware encoding unavailable, {} is encoded by the processor: {reason}",
|
||||
codec.codec.rtp_name()
|
||||
),
|
||||
)
|
||||
.with("codec", codec.codec.rtp_name())
|
||||
.with("detail", &reason),
|
||||
);
|
||||
}
|
||||
let media = SwitchableMedia::new(media);
|
||||
|
||||
let tls = if self.0.config.tls {
|
||||
@@ -926,6 +960,21 @@ impl Host {
|
||||
)
|
||||
.await
|
||||
.map_err(|e| e.notice())?;
|
||||
// Viewers negotiated this codec: a fallback to another one would give
|
||||
// them a black screen. The current capture stays.
|
||||
if let Some(encode) = started.encode
|
||||
&& encode.codec != opened.codec.codec
|
||||
{
|
||||
let _ = tokio::task::spawn_blocking(move || drop(started)).await;
|
||||
return Err(Notice::new(
|
||||
"codec_lost",
|
||||
format!(
|
||||
"the new capture cannot be encoded as {}: the share keeps its source",
|
||||
opened.codec.codec.rtp_name()
|
||||
),
|
||||
)
|
||||
.with("codec", opened.codec.codec.rtp_name()));
|
||||
}
|
||||
let old_media = opened.media.replace(started.media);
|
||||
let old_live = std::mem::replace(&mut opened.live, started.live.clone());
|
||||
let old_portal = std::mem::replace(&mut opened.portal, started.portal);
|
||||
|
||||
@@ -31,6 +31,7 @@ async fn host(name: &str, port: u16) -> (Host, TempDir) {
|
||||
port: Some(port),
|
||||
limit: None,
|
||||
codec: None,
|
||||
software: false,
|
||||
},
|
||||
log_dir: None,
|
||||
autostart: None,
|
||||
@@ -425,6 +426,32 @@ async fn the_media_takes_its_port_in_the_firewall_range() {
|
||||
std::net::UdpSocket::bind(("0.0.0.0", base)).expect("released with the share");
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn h264_without_the_gpu_falls_back_on_vp8_and_says_so() {
|
||||
let (host, _dir) = host("fallback", 0).await;
|
||||
let mut settings = host.settings();
|
||||
settings.codec = rs_store::Codec::H264;
|
||||
// The forced failure: hardware encoding off, so the GPU is not even asked.
|
||||
settings.hardware_encoding = false;
|
||||
host.update_settings(settings).await.expect("settings");
|
||||
host.start(test_pattern())
|
||||
.await
|
||||
.expect("the share starts anyway");
|
||||
let state = host.state();
|
||||
let warning = state
|
||||
.warnings
|
||||
.iter()
|
||||
.find(|w| w.code == "hardware_fallback")
|
||||
.expect("the fallback is said");
|
||||
assert_eq!(warning.params["codec"], "VP8", "{warning:?}");
|
||||
// And what viewers negotiate is the codec actually encoded.
|
||||
assert_eq!(
|
||||
host.context().encode.map(|e| e.codec),
|
||||
Some(rs_codec::VideoCodec::Vp8)
|
||||
);
|
||||
host.stop().await;
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn stopping_tells_viewers_the_share_ended_and_frees_the_port() {
|
||||
if no_network() {
|
||||
|
||||
@@ -139,6 +139,7 @@ async fn startup_opens_no_outbound_connection() {
|
||||
port: Some(0),
|
||||
limit: None,
|
||||
codec: None,
|
||||
software: false,
|
||||
},
|
||||
log_dir: log.dir.clone(),
|
||||
autostart: None,
|
||||
|
||||
@@ -75,6 +75,8 @@ pub enum Codec {
|
||||
#[default]
|
||||
Vp8,
|
||||
Vp9,
|
||||
/// On the GPU only (#57); VP8 when the machine has no H.264 encoder.
|
||||
H264,
|
||||
}
|
||||
|
||||
/// What closing the desktop application window does (#22).
|
||||
@@ -152,6 +154,9 @@ pub struct Settings {
|
||||
#[serde(alias = "qualite")]
|
||||
pub quality: QualityPreset,
|
||||
pub codec: Codec,
|
||||
/// Let the GPU encode when it can (#57): VP9 and H.264 through VA-API.
|
||||
/// Off, libvpx encodes everything; H.264 then falls back on VP8.
|
||||
pub hardware_encoding: bool,
|
||||
/// Minutes during which the QR code and the short code let a new device in
|
||||
/// (#19). `0`: no limit. Devices already admitted come back after the
|
||||
/// deadline.
|
||||
@@ -201,6 +206,7 @@ impl Default for Settings {
|
||||
limit: 5,
|
||||
quality: QualityPreset::Balanced,
|
||||
codec: Codec::default(),
|
||||
hardware_encoding: true,
|
||||
code_validity_min: 60,
|
||||
autostart: false,
|
||||
close_action: CloseAction::default(),
|
||||
@@ -672,6 +678,7 @@ mod tests {
|
||||
version: 1,
|
||||
port: 9443,
|
||||
media_port: 0,
|
||||
hardware_encoding: true,
|
||||
interface: Some("enp3s0".into()),
|
||||
theme: Theme::Dark,
|
||||
language: Some("pt-BR".into()),
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
# ADR 0012: encodage matériel par VA-API, piloté par GStreamer
|
||||
|
||||
Statut: adoptée le 30 octobre 2026 (issue #57).
|
||||
|
||||
## Contexte
|
||||
|
||||
libvpx coûte plus de deux cœurs pour du 1080p60 sur la machine de développement, et VP9 logiciel
|
||||
ne tient pas 30 i/s. Les GPU Intel et AMD récents encodent H.264 et VP9 en basse consommation
|
||||
(VA-API, entrée `EncSliceLP`) pour presque rien. Trois façons d'y accéder depuis Rust:
|
||||
|
||||
- **libva directement**: c'est à l'appelant d'écrire les en-têtes du flux (SPS, PPS, en-têtes de
|
||||
tranche H.264, en-tête non compressé VP9), de gérer les surfaces et le contrôle de débit. Des
|
||||
milliers de lignes `unsafe` par codec, à tenir à jour par génération de GPU.
|
||||
- **FFmpeg (`h264_vaapi`, `vp9_vaapi`)**: complet, mais une dépendance lourde dont l'ABI change à
|
||||
chaque version majeure, et dont les liaisons Rust suivent mal.
|
||||
- **GStreamer (`vah264lpenc`, `vavp9lpenc`)**: les encodeurs `va` de gst-plugins-bad écrivent les
|
||||
en-têtes, le pipeline convertit BGRA en NV12 sur le GPU (`vapostproc`), et `gstreamer-rs` est
|
||||
maintenu par le projet GStreamer lui-même. PipeWire, déjà requis pour la capture Wayland, en
|
||||
vient.
|
||||
|
||||
## Décision
|
||||
|
||||
1. **GStreamer, derrière le trait `VideoEncoder`** (`rs-codec::hardware`, fonctionnalité `vaapi`):
|
||||
`appsrc` BGRA, `vapostproc` vers NV12, encodeur basse consommation, `appsink`. Un appel par
|
||||
image, comme libvpx: pas de file, pas d'image B, une seule référence, image clé sur demande par
|
||||
l'événement `force-key-unit`.
|
||||
2. **H.264 constrained baseline, mode de paquetisation 1**: ce que décodent tous les navigateurs,
|
||||
décodeurs matériels des téléphones compris. VP9 matériel en profil 0 garde la négociation
|
||||
actuelle.
|
||||
3. **Repli sans surprise.** Sans greffon `va`, sans pilote, ou réglage « Encoder sur la carte
|
||||
graphique » décoché: VP9 passe par libvpx, H.264 retombe en VP8, et l'interface le dit
|
||||
(`hardware_fallback`). Une fois un partage ouvert, son codec ne change plus: une reprise après
|
||||
veille ou un changement de source qui ne retrouverait pas le même codec est refusé
|
||||
(`codec_lost`), les spectateurs ayant négocié celui-là.
|
||||
4. **Paquet Nix**: le greffon `va` et les pilotes VA-API de nixpkgs (Intel, Mesa) sont fournis par
|
||||
l'enrobage, un pilote du système liant des bibliothèques que la libva de Nix ne sait pas charger.
|
||||
|
||||
## Conséquences
|
||||
|
||||
- 1080p30 en H.264 matériel: 17 % d'un cœur pour tout l'hôte au lieu de 80 % en VP8 logiciel, et
|
||||
la meilleure latence mesurée (27 ms médiane). 1080p60 tient à 26-35 % (`docs/perf.md`).
|
||||
- Le critère de #57 « sous 5 % en 1080p30 » n'est pas atteint: l'image passe encore par une copie
|
||||
en mémoire et un envoi au GPU (4,6 ms de processeur par image). Le pas suivant est l'import
|
||||
DMA-BUF des tampons PipeWire, sans copie.
|
||||
- Une dépendance de plus à la compilation (GStreamer, LGPL, liée dynamiquement) et à l'exécution
|
||||
(greffon `va`, pilote). Sans elles, rien ne casse: libvpx encode.
|
||||
- Windows et macOS demanderont leur propre implémentation du même trait (Media Foundation,
|
||||
VideoToolbox), GStreamer n'étant pas là-bas un prérequis raisonnable.
|
||||
|
||||
## Alternatives écartées
|
||||
|
||||
- **libva directement**: le coût d'écriture et de maintenance des en-têtes, pour un gain de
|
||||
dépendance nul puisque PipeWire tire déjà GStreamer sur les bureaux visés.
|
||||
- **FFmpeg**: dépendance plus lourde, ABI instable, pour la même chose.
|
||||
- **x264 logiciel pour H.264**: plus lent que libvpx VP8 à qualité égale, et licence GPL
|
||||
incompatible avec Apache-2.0.
|
||||
|
||||
## Condition de réouverture
|
||||
|
||||
Si `vapostproc` ou les encodeurs `va` disparaissent de gst-plugins-bad, si l'import DMA-BUF exige
|
||||
de quitter GStreamer, ou si un encodeur AV1 matériel (#85) devient le meilleur choix par défaut.
|
||||
@@ -18,6 +18,7 @@ le 26 octobre 2026 (issue #2); les suivantes tranchent ce qui restait ouvert.
|
||||
| [0009](0009-capture-wayland-et-ecran-virtuel.md) | capture Linux et écran virtuel | PipeWire en feature, repli x11rb, type `VIRTUAL` du portail |
|
||||
| [0010](0010-jeton-usage-unique.md) | accès à la session | lien à usage unique, code court réutilisable, journal des refus |
|
||||
| [0011](0011-appareils-de-confiance.md) | appareils de confiance | clé Ed25519 signée en JavaScript, défi par connexion, révocation immédiate |
|
||||
| [0012](0012-encodage-materiel-gstreamer.md) | encodage matériel | VA-API par GStreamer, H.264 et VP9, repli sur libvpx |
|
||||
|
||||
Aucune décision structurante n'est ouverte à ce jour. Une nouvelle décision ouvre une issue, puis
|
||||
une ADR au même plan quand elle est tranchée.
|
||||
@@ -235,6 +235,37 @@ vise surtout Chrome.
|
||||
Coût d'une image 1080p dans le thread d'encodage (`examples/bench_stages.rs`): conversion 4,7 ms,
|
||||
encodage 3 ms, pour un budget de 16,7 ms à 60 i/s.
|
||||
|
||||
## 30 octobre 2026, encodage matériel VA-API (#57)
|
||||
|
||||
Même machine (i5-1335U, Iris Xe, pilote iHD 26.3 de nixpkgs), même banc
|
||||
(`scripts/bench-latency.sh`, Firefox sans écran, mire synthétique). Processeur de l'hôte en
|
||||
pourcentage d'un cœur, pour tout le processus: mire peinte, copie, encodage, réseau.
|
||||
|
||||
| 1920x1080 | Images affichées | Latence médiane / p95 | Processeur de l'hôte |
|
||||
| --- | --- | --- | --- |
|
||||
| VP8 logiciel, 30 i/s (`saver`) | 30 | 39 / 41 ms | 80 % |
|
||||
| **H.264 matériel**, 30 i/s | 30 | **27 / 29 ms** | **17 %** |
|
||||
| VP9 matériel, 30 i/s | 30 | 31 / 34 ms | 17 % |
|
||||
| VP9 logiciel, 60 i/s (`balanced`) | 60 | 33 / 49 ms | 112 % |
|
||||
| **H.264 matériel**, 60 i/s | 60 | 36 / 52 ms | **35 %** |
|
||||
| VP9 matériel, 60 i/s | 60 | 41 à 54 / 42 à 54 ms | 26 % |
|
||||
|
||||
L'encodeur seul (`examples/bench_hardware.rs`): un appel rend l'image encodée en 9,2 ms
|
||||
(médiane, p95 11,3 ms) en H.264 et 12,6 ms en VP9, pour 4,6 à 5,0 ms de processeur, surtout la
|
||||
copie de l'image (8 Mo) et son envoi au GPU. À 30 i/s, c'est 14 % d'un cœur: le critère « sous
|
||||
5 % » de #57 demande de passer les tampons PipeWire au GPU sans copie (DMA-BUF), non fait.
|
||||
|
||||
**Corrigé en chemin: la cadence adaptative divisait par deux pour de mauvaises raisons.** Elle
|
||||
partait de la durée de la toute première image, lente pour des raisons qui ne durent pas (pipeline
|
||||
GPU qui démarre, première image clé), passait à 30 i/s, et ne remontait qu'en dessous de la
|
||||
moitié d'une période (8,3 ms) que le GPU, à 9-13 ms, n'atteint jamais. Les dix premières images
|
||||
après l'ouverture ou un changement de taille ne comptent plus (`WARM_UP_FRAMES`). VP9 logiciel en
|
||||
profite aussi: 16 i/s avant, 60 après.
|
||||
|
||||
VP8 logiciel reste à 30 i/s en 1080p sur cette machine, alors que la mesure du 27 octobre en
|
||||
donnait 60 à 94-114 %: la marge de VP8 (7,7 ms par image) est juste sous le seuil de remontée.
|
||||
À reprendre avec #53.
|
||||
|
||||
## Ce qui reste à mesurer
|
||||
|
||||
- **Latence verre-à-verre.** La VM n'a pas d'écran et la mire n'a pas d'horloge commune avec le
|
||||
|
||||
@@ -76,6 +76,11 @@
|
||||
export VPX_LIB_DIR="${pkgs.callPackage ./nix/libvpx.nix { }}/lib"
|
||||
export VPX_INCLUDE_DIR="${pkgs.callPackage ./nix/libvpx.nix { }}/include"
|
||||
export VPX_VERSION="1.13.0"
|
||||
# Hardware encoding (#57): the `va` GStreamer plugin and a VA-API
|
||||
# driver from nixpkgs, since a system driver links system
|
||||
# libraries the Nix libva cannot load (Intel and AMD/Mesa here).
|
||||
export GST_PLUGIN_SYSTEM_PATH_1_0="${pkgs.gst_all_1.gstreamer.out}/lib/gstreamer-1.0:${pkgs.gst_all_1.gst-plugins-base}/lib/gstreamer-1.0:${pkgs.gst_all_1.gst-plugins-bad}/lib/gstreamer-1.0"
|
||||
export LIBVA_DRIVERS_PATH="${pkgs.intel-media-driver}/lib/dri:${pkgs.mesa}/lib/dri"
|
||||
'';
|
||||
};
|
||||
in
|
||||
|
||||
+9
-3
@@ -163,10 +163,13 @@
|
||||
"sharp": "Sharp"
|
||||
},
|
||||
"codec": "Video codec",
|
||||
"codecHelp": "VP9 keeps the same picture for less bitrate, but asks more computing from this machine.",
|
||||
"codecHelp": "VP9 keeps the same picture for less bitrate. H.264 and VP9 are encoded by the graphics card when it can, which frees the processor; H.264 falls back on VP8 without it.",
|
||||
"hardwareEncoding": "Encode on the graphics card when possible",
|
||||
"hardwareEncodingHelp": "VA-API (Intel, AMD). Off: everything is encoded by the processor.",
|
||||
"codecs": {
|
||||
"vp8": "VP8 (light, decoded everywhere)",
|
||||
"vp9": "VP9 (less bitrate)"
|
||||
"vp9": "VP9 (less bitrate)",
|
||||
"h264": "H.264 (on the graphics card)"
|
||||
},
|
||||
"theme": "Theme",
|
||||
"themes": {
|
||||
@@ -295,7 +298,10 @@
|
||||
"no_device_id": "This browser keeps no identifier: its name cannot be remembered.",
|
||||
"media_port_range": "The media range starts between {min} and {max}.",
|
||||
"media_port_overlap": "The media range must not contain port {port}.",
|
||||
"pending_media_port": "media ports: those of connected viewers stay open until the next share"
|
||||
"pending_media_port": "media ports: those of connected viewers stay open until the next share",
|
||||
"hardware_fallback": "Hardware encoding unavailable, {codec} is encoded by the processor: {detail}",
|
||||
"codec_lost": "The new capture cannot be encoded as {codec}: the share keeps its source.",
|
||||
"pending_hardware_encoding": "hardware encoding: the encoder of the current share stays until the next one"
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
-3
@@ -163,10 +163,13 @@
|
||||
"sharp": "Nette"
|
||||
},
|
||||
"codec": "Codec vidéo",
|
||||
"codecHelp": "VP9 garde la même image pour moins de débit, mais demande plus de calcul à cette machine.",
|
||||
"codecHelp": "VP9 garde la même image pour moins de débit. H.264 et VP9 sont encodés par la carte graphique quand elle sait le faire, ce qui libère le processeur ; sans elle, H.264 retombe en VP8.",
|
||||
"hardwareEncoding": "Encoder sur la carte graphique quand c’est possible",
|
||||
"hardwareEncodingHelp": "VA-API (Intel, AMD). Décoché : tout est encodé par le processeur.",
|
||||
"codecs": {
|
||||
"vp8": "VP8 (léger, décodé partout)",
|
||||
"vp9": "VP9 (moins de débit)"
|
||||
"vp9": "VP9 (moins de débit)",
|
||||
"h264": "H.264 (sur la carte graphique)"
|
||||
},
|
||||
"theme": "Thème",
|
||||
"themes": {
|
||||
@@ -295,7 +298,10 @@
|
||||
"no_device_id": "Ce navigateur ne garde pas d'identifiant : son nom ne peut pas être retenu.",
|
||||
"media_port_range": "La plage du média commence entre {min} et {max}.",
|
||||
"media_port_overlap": "La plage du média ne doit pas contenir le port {port}.",
|
||||
"pending_media_port": "ports du média : ceux des spectateurs connectés restent ouverts jusqu'au prochain partage"
|
||||
"pending_media_port": "ports du média : ceux des spectateurs connectés restent ouverts jusqu'au prochain partage",
|
||||
"hardware_fallback": "Encodage matériel indisponible, {codec} est encodé par le processeur : {detail}",
|
||||
"codec_lost": "La nouvelle capture ne peut pas être encodée en {codec} : le partage garde sa source.",
|
||||
"pending_hardware_encoding": "encodage matériel : l'encodeur du partage en cours reste jusqu'au suivant"
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
-1
@@ -30,6 +30,7 @@
|
||||
librsvg,
|
||||
libayatana-appindicator,
|
||||
pipewire,
|
||||
gst_all_1,
|
||||
cli,
|
||||
}:
|
||||
|
||||
@@ -125,7 +126,7 @@ let
|
||||
../apps/desktop/src-tauri/Cargo.lock
|
||||
];
|
||||
};
|
||||
cargoExtraArgs = "--locked --manifest-path apps/desktop/src-tauri/Cargo.toml --features pipewire";
|
||||
cargoExtraArgs = "--locked --manifest-path apps/desktop/src-tauri/Cargo.toml --features pipewire,vaapi";
|
||||
# The shell's lock file must sit next to its manifest, also in the
|
||||
# placeholder source crane builds the dependencies from (which keeps only
|
||||
# the root lock file).
|
||||
@@ -150,6 +151,11 @@ let
|
||||
glib-networking
|
||||
librsvg
|
||||
pipewire
|
||||
# Hardware encoding (#57): wrapGAppsHook puts the plugins on
|
||||
# GST_PLUGIN_SYSTEM_PATH_1_0.
|
||||
gst_all_1.gstreamer
|
||||
gst_all_1.gst-plugins-base
|
||||
gst_all_1.gst-plugins-bad
|
||||
];
|
||||
|
||||
env = {
|
||||
@@ -201,6 +207,12 @@ craneLib.buildPackage (
|
||||
gappsWrapperArgs+=(
|
||||
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ libayatana-appindicator ]}"
|
||||
--set-default RUSTSCREEN_VIEWER "${cli}/share/rustscreen/viewer"
|
||||
--set-default LIBVA_DRIVERS_PATH "${
|
||||
lib.makeSearchPath "lib/dri" [
|
||||
pkgs.intel-media-driver
|
||||
pkgs.mesa
|
||||
]
|
||||
}"
|
||||
)
|
||||
'';
|
||||
|
||||
|
||||
+26
-3
@@ -12,12 +12,23 @@
|
||||
makeWrapper,
|
||||
pkg-config,
|
||||
pipewire,
|
||||
gst_all_1,
|
||||
rustPlatform,
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (pkgs) callPackage;
|
||||
|
||||
gstPlugins = lib.makeSearchPath "lib/gstreamer-1.0" [
|
||||
gst_all_1.gstreamer.out
|
||||
gst_all_1.gst-plugins-base
|
||||
gst_all_1.gst-plugins-bad
|
||||
];
|
||||
vaDrivers = lib.makeSearchPath "lib/dri" [
|
||||
pkgs.intel-media-driver
|
||||
pkgs.mesa
|
||||
];
|
||||
|
||||
libvpx = callPackage ./libvpx.nix { };
|
||||
|
||||
# `npmDepsHash` is the only hash this flake cannot derive on its own: it
|
||||
@@ -81,9 +92,15 @@ craneLib.buildPackage {
|
||||
pkg-config
|
||||
rustPlatform.bindgenHook
|
||||
];
|
||||
buildInputs = [ pipewire ];
|
||||
# GStreamer: hardware encoding through VA-API (#57), `vaapi` feature. The
|
||||
# library is linked; the `va` plugin and the GPU driver are found at runtime.
|
||||
buildInputs = [
|
||||
pipewire
|
||||
gst_all_1.gstreamer
|
||||
gst_all_1.gst-plugins-base
|
||||
];
|
||||
|
||||
cargoExtraArgs = "--locked -p rs-session --features pipewire";
|
||||
cargoExtraArgs = "--locked -p rs-session --features pipewire,vaapi";
|
||||
|
||||
env = {
|
||||
VPX_LIB_DIR = "${libvpx}/lib";
|
||||
@@ -101,8 +118,14 @@ craneLib.buildPackage {
|
||||
# that removes references to the Rust toolchain fails.
|
||||
cp -r --no-preserve=mode ${viewer}/dist/. $out/share/rustscreen/viewer/
|
||||
|
||||
# Hardware encoding (#57): GStreamer's `va` plugin, and VA-API drivers
|
||||
# from nixpkgs (Intel, AMD/Mesa). A system driver links system libraries
|
||||
# this libva cannot load; NixOS users can point LIBVA_DRIVERS_PATH at
|
||||
# /run/opengl-driver/lib/dri instead. Without either, libvpx encodes.
|
||||
wrapProgram $out/bin/rustscreen-cli \
|
||||
--set-default RUSTSCREEN_VIEWER "$out/share/rustscreen/viewer"
|
||||
--set-default RUSTSCREEN_VIEWER "$out/share/rustscreen/viewer" \
|
||||
--prefix GST_PLUGIN_SYSTEM_PATH_1_0 : "${gstPlugins}" \
|
||||
--set-default LIBVA_DRIVERS_PATH "${vaDrivers}"
|
||||
'';
|
||||
|
||||
meta = {
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
# RUSTSCREEN_CLI binary to bench (default: target/release/rustscreen-cli)
|
||||
# FIREFOX_PROFILE profile directory (snap Firefox: under ~/snap/firefox/common)
|
||||
# BENCH_PORT host port (default 8199), MARIONETTE_PORT (default 2829)
|
||||
# BENCH_ARGS extra rustscreen-cli options (`--codec vp9`, `--software`)
|
||||
set -euo pipefail
|
||||
|
||||
size=${1:-1920x1080}
|
||||
@@ -40,7 +41,7 @@ PREFS
|
||||
|
||||
RUSTSCREEN_CONFIG="$work/settings.json" RUSTSCREEN_LOG_DIR="$work/logs" \
|
||||
RUSTSCREEN_VIEWER="${RUSTSCREEN_VIEWER:-$root/apps/viewer/dist}" \
|
||||
"$cli" --synthetic --size "$size" >"$work/host.log" 2>&1 &
|
||||
"$cli" --synthetic --size "$size" ${BENCH_ARGS:-} >"$work/host.log" 2>&1 &
|
||||
host_pid=$!
|
||||
firefox --headless --marionette --no-remote --profile "$profile" --window-size=1920,1200 about:blank \
|
||||
>"$work/firefox.log" 2>&1 &
|
||||
|
||||
@@ -90,7 +90,7 @@ export function accepted(expression) {
|
||||
function cargo(manifest) {
|
||||
const out = execFileSync(
|
||||
'cargo',
|
||||
['metadata', '--format-version', '1', '--locked', '--manifest-path', manifest],
|
||||
['metadata', '--format-version', '1', '--locked', '--all-features', '--manifest-path', manifest],
|
||||
{ cwd: root, maxBuffer: 256 * 1024 * 1024 },
|
||||
);
|
||||
const metadata = JSON.parse(out);
|
||||
|
||||
Reference in new issue
Block a user