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>
139 lines
4.2 KiB
Nix
139 lines
4.2 KiB
Nix
# The rustscreen command line package: one binary, its viewer, and nothing else.
|
|
#
|
|
# The viewer is built separately (npm) then installed next to the binary; the
|
|
# binary finds it through `RUSTSCREEN_VIEWER`, set by a wrapper. A package that
|
|
# relied on a path hardcoded in the code would break the first time /nix/store
|
|
# moved.
|
|
{
|
|
lib,
|
|
craneLib,
|
|
pkgs,
|
|
stdenv,
|
|
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
|
|
# depends on the exact npm dependency tree. To get it:
|
|
#
|
|
# nix build .#rustscreen 2>&1 | grep "got:" # prints the expected hash
|
|
#
|
|
# then replace the value below. crane handles the Rust side without any hash
|
|
# being copied.
|
|
viewer = pkgs.buildNpmPackage {
|
|
pname = "rustscreen-viewer";
|
|
version = "0.5.0";
|
|
src = ../apps/viewer;
|
|
|
|
npmDepsHash = "sha256-LBgtO4fU8EEye11o+o+B/POwl+bdFvHuzB69r6iZQZI=";
|
|
|
|
nativeBuildInputs = [ pkgs.nodejs_22 ];
|
|
|
|
buildPhase = ''
|
|
runHook preBuild
|
|
npm run build
|
|
runHook postBuild
|
|
'';
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
mkdir -p $out/dist
|
|
cp -r dist/. $out/dist/
|
|
runHook postInstall
|
|
'';
|
|
|
|
meta = {
|
|
description = "rustscreen web viewer";
|
|
license = lib.licenses.asl20;
|
|
};
|
|
};
|
|
in
|
|
craneLib.buildPackage {
|
|
pname = "rustscreen-cli";
|
|
version = "0.5.0";
|
|
|
|
# `cleanCargoSource` strips from the source what has no business in a Rust
|
|
# build: targets, node_modules, the viewer bundle. Without it, changing the
|
|
# viewer's CSS would invalidate the Rust build.
|
|
# The embedded pages (`include_str!` of host.html, demo.html) and the
|
|
# translations (`locales/*.json`, embedded by rs-signaling) must survive the
|
|
# filter, which otherwise keeps only Rust and Cargo files.
|
|
src = lib.cleanSourceWith {
|
|
src = ../.;
|
|
filter =
|
|
path: type:
|
|
(lib.hasSuffix ".html" path)
|
|
|| (lib.hasInfix "/locales" path)
|
|
|| (craneLib.filterCargoSources path type);
|
|
};
|
|
|
|
# PipeWire: Wayland capture (ADR 0009). bindgenHook provides libclang and its
|
|
# headers to the `pipewire-sys` build, with no manual setup.
|
|
nativeBuildInputs = [
|
|
makeWrapper
|
|
pkg-config
|
|
rustPlatform.bindgenHook
|
|
];
|
|
# 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,vaapi";
|
|
|
|
env = {
|
|
VPX_LIB_DIR = "${libvpx}/lib";
|
|
VPX_INCLUDE_DIR = "${libvpx}/include";
|
|
VPX_VERSION = "1.13.0";
|
|
};
|
|
|
|
# The protocol tests write the TypeScript types into `apps/viewer`: the Nix
|
|
# store is read-only, and producing them is not the build's job.
|
|
cargoTestExtraArgs = "-- --skip export_bindings";
|
|
|
|
postInstall = ''
|
|
install -d $out/share/rustscreen/viewer
|
|
# Store files are read-only: without `--no-preserve=mode`, the crane pass
|
|
# 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" \
|
|
--prefix GST_PLUGIN_SYSTEM_PATH_1_0 : "${gstPlugins}" \
|
|
--set-default LIBVA_DRIVERS_PATH "${vaDrivers}"
|
|
'';
|
|
|
|
meta = {
|
|
description = "Screen sharing over the local network, watched from a browser";
|
|
homepage = "https://gitea-nubo.hopledge.com/heap/rustscreen";
|
|
license = lib.licenses.asl20;
|
|
mainProgram = "rustscreen-cli";
|
|
platforms = lib.platforms.unix;
|
|
};
|
|
}
|