From ac187fe39e703104a23d8dd8a8ff38d2848953ea Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 4 Oct 2026 22:12:17 +0000 Subject: [PATCH] packages: every codec backend, and the libraries the app needs voelin-media builds dav1d (AV1 decoding) by default, like every other codec backend: Linux images already had libdav1d-dev; Windows CI takes it from vcpkg next to libvpx and the MinGW image builds it static (dav1d 1.5.4, pinned commit; checked to cross-compile). Windows packages ship FFmpeg's LGPL DLLs (BtbN's 8.1 shared build, checked against the release's checksums by scripts/fetch-ffmpeg-windows.sh) next to voelin.exe, where the app looks first, with their license and a note on the build and its source; the installer installs and removes them. The Linux .tar.gz carries libvpx and libdav1d in lib/ (RUNPATH $ORIGIN/../lib, set with patchelf), whose sonames differ between distributions, and bin/voelin-install-deps, which installs FFmpeg, VA-API drivers, PipeWire, the desktop portal and a keyring with apt, dnf, pacman or zypper. The .deb recommends those packages. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01VZBWxxMsxUzp4PSTKVzbZN --- .github/actions/system-deps/action.yml | 29 +++++++++--- .github/workflows/release.yml | 11 ++++- crates/voelin-core/Cargo.toml | 6 +-- crates/voelin-media/Cargo.toml | 7 ++- docker/linux.Dockerfile | 4 +- docker/windows.Dockerfile | 45 +++++++++++++++--- docs/building.md | 18 +++++--- docs/media.md | 22 ++++++--- packaging/linux/voelin-install-deps | 42 +++++++++++++++++ packaging/windows/README.md | 20 ++++++-- packaging/windows/installer.nsi | 10 ++++ scripts/fetch-ffmpeg-windows.sh | 63 ++++++++++++++++++++++++++ scripts/package.sh | 45 ++++++++++++++++-- 13 files changed, 280 insertions(+), 42 deletions(-) create mode 100755 packaging/linux/voelin-install-deps create mode 100755 scripts/fetch-ffmpeg-windows.sh diff --git a/.github/actions/system-deps/action.yml b/.github/actions/system-deps/action.yml index bb10f50..1767ab4 100644 --- a/.github/actions/system-deps/action.yml +++ b/.github/actions/system-deps/action.yml @@ -1,12 +1,13 @@ name: System dependencies description: > Native libraries and tools the workspace builds against: apt packages on - Linux; NASM and libvpx (vcpkg, cached) on Windows, exporting VPX_LIB_DIR, - VPX_INCLUDE_DIR, VPX_VERSION and VPX_STATIC for libvpx-native-sys. + Linux; NASM, libvpx and dav1d (vcpkg, cached) on Windows, exporting + VPX_LIB_DIR, VPX_INCLUDE_DIR, VPX_VERSION and VPX_STATIC for + libvpx-native-sys and SYSTEM_DEPS_DAV1D_* for dav1d-sys. inputs: vpx-triplet: - description: vcpkg triplet for libvpx on Windows (static library, dynamic CRT like Rust's default) + description: vcpkg triplet for libvpx and dav1d on Windows (static libraries, dynamic CRT like Rust's default) default: x64-windows-static-md runs: @@ -47,8 +48,8 @@ runs: uses: actions/cache@v4 with: path: ${{ runner.temp }}\vcpkg-archives - key: vcpkg-libvpx-${{ inputs.vpx-triplet }}-${{ steps.vcpkg.outputs.commit }} - restore-keys: vcpkg-libvpx-${{ inputs.vpx-triplet }}- + key: vcpkg-libvpx-dav1d-${{ inputs.vpx-triplet }}-${{ steps.vcpkg.outputs.commit }} + restore-keys: vcpkg-libvpx-dav1d-${{ inputs.vpx-triplet }}- - name: libvpx if: runner.os == 'Windows' @@ -60,7 +61,7 @@ runs: $ErrorActionPreference = 'Stop' $vcpkg = Join-Path $env:VCPKG_INSTALLATION_ROOT 'vcpkg.exe' New-Item -ItemType Directory -Force (Join-Path $env:RUNNER_TEMP 'vcpkg-archives') | Out-Null - & $vcpkg install "libvpx:$env:TRIPLET" + & $vcpkg install "libvpx:$env:TRIPLET" "dav1d:$env:TRIPLET" if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } # "libvpx:x64-windows-static-md 1.15.2#1 The reference ..." @@ -85,3 +86,19 @@ runs: "VPX_VERSION=$version" >> $env:GITHUB_ENV "VPX_STATIC=1" >> $env:GITHUB_ENV Write-Host "libvpx $version from $libdir" + + # dav1d-sys (AV1 decoding) through system-deps, without pkg-config: + # the static library, linked as dav1d.lib. + $davdir = Join-Path $root 'lib' + if (-not (Test-Path (Join-Path $davdir 'dav1d.lib'))) { + $lib = Get-ChildItem $davdir -Filter '*dav1d*.lib' | Select-Object -First 1 + if (-not $lib) { Get-ChildItem $davdir; throw "no dav1d library in $davdir" } + $davdir = Join-Path $env:RUNNER_TEMP 'dav1d-lib' + New-Item -ItemType Directory -Force $davdir | Out-Null + Copy-Item $lib.FullName (Join-Path $davdir 'dav1d.lib') + } + "SYSTEM_DEPS_DAV1D_NO_PKG_CONFIG=1" >> $env:GITHUB_ENV + "SYSTEM_DEPS_DAV1D_SEARCH_NATIVE=$davdir" >> $env:GITHUB_ENV + "SYSTEM_DEPS_DAV1D_LIB=dav1d" >> $env:GITHUB_ENV + "SYSTEM_DEPS_DAV1D_LINK=static" >> $env:GITHUB_ENV + Write-Host "dav1d from $davdir" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c10b6b3..ed52189 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -35,10 +35,11 @@ jobs: key: release - name: Build run: cargo build --release --locked -p voelin-ui -p voelin-gateway - # dpkg-shlibdeps works out the .deb's dependencies. + # dpkg-shlibdeps works out the .deb's dependencies; patchelf points + # the .tar.gz's binary at the libraries it carries. - name: Package (.tar.gz, .deb) run: | - sudo apt-get install -y --no-install-recommends dpkg-dev + sudo apt-get install -y --no-install-recommends dpkg-dev patchelf scripts/package.sh linux dist - uses: actions/upload-artifact@v4 with: @@ -70,6 +71,12 @@ jobs: if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } } "MAKENSIS=$($makensis.Replace('\', '/'))" >> $env:GITHUB_ENV + # FFmpeg's LGPL DLLs, shipped next to voelin.exe. + - name: FFmpeg + shell: bash + run: | + scripts/fetch-ffmpeg-windows.sh "$RUNNER_TEMP/ffmpeg" + echo "FFMPEG_DLL_DIR=$RUNNER_TEMP/ffmpeg" >> "$GITHUB_ENV" - name: Package (.zip, installer) shell: bash run: scripts/package.sh windows dist diff --git a/crates/voelin-core/Cargo.toml b/crates/voelin-core/Cargo.toml index 571c60f..254f67b 100644 --- a/crates/voelin-core/Cargo.toml +++ b/crates/voelin-core/Cargo.toml @@ -16,9 +16,9 @@ audio-device = ["voelin-audio/device"] # voelin-media backends are enabled (e.g. MediaCodec and a registered capture # source on Android). media = ["dep:voelin-media"] -# `media` with voelin-media's desktop backends: libvpx, OpenH264 loaded at -# runtime, X11 and PipeWire on Linux. Not for Android (libvpx does not -# cross-compile there). +# `media` with voelin-media's desktop backends: libvpx, dav1d, OpenH264 and +# FFmpeg loaded at runtime, X11 and PipeWire on Linux. Not for Android +# (libvpx does not cross-compile there). media-desktop = ["media", "voelin-media/default"] [dependencies] diff --git a/crates/voelin-media/Cargo.toml b/crates/voelin-media/Cargo.toml index 6e1c23f..318fcae 100644 --- a/crates/voelin-media/Cargo.toml +++ b/crates/voelin-media/Cargo.toml @@ -9,7 +9,8 @@ repository.workspace = true publish.workspace = true [features] -default = ["vpx", "openh264", "openh264-download", "ffmpeg", "x11", "pipewire", "wlroots", "segment"] +# Every codec backend: desktop builds have all encoders and decoders. +default = ["vpx", "openh264", "openh264-download", "ffmpeg", "av1", "x11", "pipewire", "wlroots", "segment"] # VP8 and VP9 through the system libvpx (pkg-config `vpx`). vpx = ["dep:libvpx-native-sys"] # H.264 through Cisco's prebuilt OpenH264 library, loaded at runtime. The @@ -21,7 +22,9 @@ openh264-download = ["openh264", "dep:reqwest", "dep:bzip2", "dep:sha2"] # VA-API, NVENC, Quick Sync, AMF, Media Foundation, VideoToolbox, x264, # SVT-AV1, ... whatever the installed FFmpeg has (see docs/media.md). ffmpeg = ["dep:libloading", "dep:rustix"] -# AV1 decoding through the system libdav1d (pkg-config `dav1d` >= 1.3). +# AV1 decoding through libdav1d (pkg-config `dav1d` >= 1.3; on Windows +# vcpkg's or our MinGW build, see .github/actions/system-deps and +# docker/windows.Dockerfile). av1 = ["dep:dav1d"] # X11 screen capture (Linux). x11 = ["dep:x11rb", "dep:memmap2", "dep:rustix"] diff --git a/docker/linux.Dockerfile b/docker/linux.Dockerfile index efb3e92..3f31168 100644 --- a/docker/linux.Dockerfile +++ b/docker/linux.Dockerfile @@ -13,9 +13,9 @@ FROM ubuntu:24.04 AS toolchain ARG DEBIAN_FRONTEND=noninteractive # The same libraries as CI (.github/actions/system-deps), plus dpkg-dev for -# the .deb's dependencies. +# the .deb's dependencies and patchelf for the .tar.gz's bundled libraries. RUN apt-get update && apt-get install -y --no-install-recommends \ - build-essential ca-certificates cmake curl dpkg-dev pkg-config \ + build-essential ca-certificates cmake curl dpkg-dev patchelf pkg-config \ libasound2-dev libfontconfig1-dev libxkbcommon-dev \ libvpx-dev libdav1d-dev libpipewire-0.3-dev libspa-0.2-dev libclang-dev \ && rm -rf /var/lib/apt/lists/* diff --git a/docker/windows.Dockerfile b/docker/windows.Dockerfile index 3233179..8aafc86 100644 --- a/docker/windows.Dockerfile +++ b/docker/windows.Dockerfile @@ -12,10 +12,12 @@ FROM ubuntu:24.04 AS toolchain ARG DEBIAN_FRONTEND=noninteractive -# mingw-w64 (C compiler and linker), NASM (aws-lc and libvpx assembly), CMake -# (the bundled libopus, aws-lc), NSIS (the installer), zip. +# mingw-w64 (C compiler and linker), NASM (aws-lc, libvpx and dav1d +# assembly), CMake (the bundled libopus, aws-lc), Meson and Ninja (dav1d), +# NSIS (the installer), zip and unzip. RUN apt-get update && apt-get install -y --no-install-recommends \ - build-essential ca-certificates cmake curl git mingw-w64 nasm nsis perl pkg-config zip \ + build-essential ca-certificates cmake curl git meson mingw-w64 nasm ninja-build nsis perl \ + pkg-config unzip zip \ && rm -rf /var/lib/apt/lists/* \ && update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix \ && update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix @@ -51,18 +53,49 @@ RUN git clone --quiet --depth 1 --branch "v$LIBVPX_VERSION" \ && make -j"$(nproc)" && make install \ && rm -rf /tmp/libvpx +# dav1d (AV1 decoding) as a static mingw library (CI's Windows jobs take it +# from vcpkg), from upstream's git at a pinned commit. +FROM toolchain AS dav1d +ARG DAV1D_VERSION=1.5.4 +ARG DAV1D_COMMIT=54706fc6bc0cdecab7e9593974a4039cc038fca7 +RUN git clone --quiet --depth 1 --branch "$DAV1D_VERSION" \ + https://code.videolan.org/videolan/dav1d.git /tmp/dav1d \ + && test "$(git -C /tmp/dav1d rev-parse HEAD)" = "$DAV1D_COMMIT" \ + && printf '%s\n' \ + "[binaries]" \ + "c = 'x86_64-w64-mingw32-gcc'" \ + "ar = 'x86_64-w64-mingw32-ar'" \ + "strip = 'x86_64-w64-mingw32-strip'" \ + "windres = 'x86_64-w64-mingw32-windres'" \ + "[host_machine]" \ + "system = 'windows'" \ + "cpu_family = 'x86_64'" \ + "cpu = 'x86_64'" \ + "endian = 'little'" >/tmp/mingw.ini \ + && meson setup /tmp/dav1d/build /tmp/dav1d --cross-file /tmp/mingw.ini \ + --prefix=/opt/dav1d --libdir=lib --buildtype=release -Ddefault_library=static \ + -Denable_tools=false -Denable_tests=false -Denable_examples=false \ + && ninja -C /tmp/dav1d/build install \ + && rm -rf /tmp/dav1d + FROM toolchain AS build COPY --from=libvpx /opt/libvpx /opt/libvpx +COPY --from=dav1d /opt/dav1d /opt/dav1d ARG LIBVPX_VERSION=1.15.2 -# libvpx-native-sys: the library above, linked statically. +# libvpx-native-sys: the library above, linked statically; dav1d-sys +# through system-deps, without pkg-config. ENV VPX_LIB_DIR=/opt/libvpx/lib VPX_INCLUDE_DIR=/opt/libvpx/include \ - VPX_VERSION=$LIBVPX_VERSION VPX_STATIC=1 + VPX_VERSION=$LIBVPX_VERSION VPX_STATIC=1 \ + SYSTEM_DEPS_DAV1D_NO_PKG_CONFIG=1 SYSTEM_DEPS_DAV1D_SEARCH_NATIVE=/opt/dav1d/lib \ + SYSTEM_DEPS_DAV1D_LIB=dav1d SYSTEM_DEPS_DAV1D_LINK=static WORKDIR /src COPY . . +# FFmpeg's LGPL DLLs go into the packages (scripts/fetch-ffmpeg-windows.sh). RUN --mount=type=cache,id=voelin-cargo-registry,target=/usr/local/cargo/registry \ --mount=type=cache,id=voelin-target-windows,target=/src/target \ cargo build --release --locked --target x86_64-pc-windows-gnu -p voelin-ui \ - && WINDOWS_TARGET=x86_64-pc-windows-gnu scripts/package.sh windows /out + && scripts/fetch-ffmpeg-windows.sh /tmp/ffmpeg \ + && FFMPEG_DLL_DIR=/tmp/ffmpeg WINDOWS_TARGET=x86_64-pc-windows-gnu scripts/package.sh windows /out FROM scratch AS artifacts COPY --from=build /out / diff --git a/docs/building.md b/docs/building.md index b441864..576a31b 100644 --- a/docs/building.md +++ b/docs/building.md @@ -12,13 +12,13 @@ in no package (`cargo run -p voelinctl`). | Platform | Files | Install | |---|---|---| -| Linux x86_64 | `voelin--linux-x86_64.tar.gz` | unpack; `bin/voelin` plus desktop file and icon (prefix layout: `tar -xzf … --strip-components=1 -C ~/.local`) | -| | `voelin__amd64.deb` | `sudo apt install ./voelin__amd64.deb` (Ubuntu 24.04+, Debian 13+) | +| Linux x86_64 | `voelin--linux-x86_64.tar.gz` | unpack; `bin/voelin` plus desktop file and icon (prefix layout: `tar -xzf … --strip-components=1 -C ~/.local`), libvpx and libdav1d in `lib/`; `bin/voelin-install-deps` installs what comes from the system (FFmpeg, VA-API drivers, PipeWire, the desktop portal, a keyring) with apt, dnf, pacman or zypper | +| | `voelin__amd64.deb` | `sudo apt install ./voelin__amd64.deb` (Ubuntu 24.04+, Debian 13+); apt installs the libraries it links and, by default, the recommended FFmpeg, VA-API, PipeWire, portal and keyring packages | | | `voelin.flatpak` (release workflow only) | `flatpak install --user voelin.flatpak` | | Linux server | `tsgw__amd64.deb` | `sudo apt install ./tsgw__amd64.deb`, then configure and start it ([gateway-admin.md](gateway-admin.md#install)) | | | `tsgw--linux-x86_64.tar.gz` | unpack; `bin/tsgw`, the systemd unit and the example config | | | `tsgw-image.tar.gz` (release workflow only) | `docker load -i tsgw-image.tar.gz` | -| Windows x86_64 | `voelin--windows-x86_64.zip` | unpack; `voelin.exe` | +| Windows x86_64 | `voelin--windows-x86_64.zip` | unpack; `voelin.exe` with FFmpeg's LGPL DLLs next to it (libvpx and dav1d are linked in) | | | `voelin--setup.exe` | run it (per-machine install, uninstaller in Settings → Apps) | | Android | `voelin--android-debug.apk` | `adb install …` or open it on the phone (arm64-v8a and x86_64) | | | `voelin--android-release.apk` | only with signing configured ([release.md](release.md#android-apk-signing)) | @@ -57,7 +57,9 @@ gh run list --workflow release.yml --limit 3 gh run download --dir dist ``` -The Windows packages use the MSVC toolchain and libvpx from vcpkg. The +The Windows packages use the MSVC toolchain, libvpx and dav1d from vcpkg, and +FFmpeg's LGPL shared build from BtbN/FFmpeg-Builds +(`scripts/fetch-ffmpeg-windows.sh`, checked against the release's checksums). The Android job builds a signed release APK only when the repository has the signing secrets (`ANDROID_KEYSTORE_BASE64`, `VOELIN_SIGNING_STORE_PASSWORD`, `VOELIN_SIGNING_KEY_ALIAS`, `VOELIN_SIGNING_KEY_PASSWORD`). @@ -85,7 +87,7 @@ BuildKit cache mounts (`docker builder prune` frees them). | Dockerfile | Builds | Notes | |---|---|---| | `docker/linux.Dockerfile` | the app's and the gateway's `.tar.gz` and `.deb` on Ubuntu 24.04 | the binaries need glibc 2.39+ and the libraries the `.deb` lists | -| `docker/windows.Dockerfile` | `.zip` and the NSIS installer | cross-compiled for `x86_64-pc-windows-gnu` with mingw-w64 and a static libvpx; works on Windows 10 and 11 | +| `docker/windows.Dockerfile` | `.zip` and the NSIS installer | cross-compiled for `x86_64-pc-windows-gnu` with mingw-w64 and static libvpx and dav1d, FFmpeg's LGPL DLLs alongside; works on Windows 10 and 11 | | `docker/android.Dockerfile` | debug APK | SDK, NDK and cargo-ndk as in CI; `--build-arg ABIS=arm64-v8a,x86_64,armeabi-v7a` picks the ABIs | Options go after the platform, straight to `docker build`: @@ -108,11 +110,13 @@ the proxy is on localhost. If the proxy inspects TLS, set ## Locally without Docker - **Linux:** the packages from the table above need - `sudo apt install libasound2-dev libfontconfig1-dev libxkbcommon-dev libvpx-dev libdav1d-dev libpipewire-0.3-dev libspa-0.2-dev libclang-dev cmake dpkg-dev`, + `sudo apt install libasound2-dev libfontconfig1-dev libxkbcommon-dev libvpx-dev libdav1d-dev libpipewire-0.3-dev libspa-0.2-dev libclang-dev cmake dpkg-dev patchelf`, then `cargo build --release --locked -p voelin-ui -p voelin-gateway` and `scripts/package.sh linux`. - **Windows:** [packaging/windows/README.md](../packaging/windows/README.md) - (MSVC, vcpkg libvpx, NSIS), then `bash scripts/package.sh windows` from Git Bash. + (MSVC, vcpkg libvpx and dav1d, NSIS), then + `bash scripts/fetch-ffmpeg-windows.sh ffmpeg && FFMPEG_DLL_DIR=ffmpeg bash scripts/package.sh windows` + from Git Bash. - **Android:** [android.md](android.md) (SDK, NDK, cargo-ndk), then `cd android && ./gradlew assembleDebug` and `scripts/package.sh android`. - **Flatpak:** [packaging/README.md](../packaging/README.md#flatpak). diff --git a/docs/media.md b/docs/media.md index 74baae0..f15ad08 100644 --- a/docs/media.md +++ b/docs/media.md @@ -384,7 +384,7 @@ off), the automatic order after it. |---|---|---|---|---| | libvpx | `vpx` (default) | VP8, VP9 | VP8, VP9 | system libvpx (1.14 tested), dynamically linked; bindings from `libvpx-native-sys` (pre-generated, no bindgen) | | OpenH264 | `openh264` (default) | H.264 Constrained High / Baseline | H.264 | Cisco's prebuilt binary, loaded at runtime | -| dav1d | `av1` | – | AV1 | system libdav1d >= 1.3 (1.4.1 tested) | +| dav1d | `av1` (default) | – | AV1 | system libdav1d >= 1.3 (1.4.1 tested); static from vcpkg (MSVC) and built in `docker/windows.Dockerfile` (MinGW) on Windows | | FFmpeg | `ffmpeg` (default; off on Android) | H.264, HEVC, AV1, VP9, VP8 in hardware; H.264 (x264, OpenH264), AV1 (SVT-AV1, libaom, rav1e) in software | AV1, HEVC, VP9, H.264, VP8 in hardware (VA-API, NVDEC, D3D11VA, DXVA2, VideoToolbox) and in software (dav1d, libaom, FFmpeg's own) | the system's (or `VOELIN_FFMPEG_DIR`'s) libavcodec / libavutil, any major version, loaded at runtime; see below | | MediaCodec (Android) | – | H.264, VP8, VP9 | VP8, VP9, H.264, AV1 | the device's default codec per type through the NDK (`ndk` crate); an encoder factory named `mediacodec` | @@ -397,8 +397,10 @@ every build has). ### FFmpeg encoders, loaded at runtime `crate::ffmpeg` (feature `ffmpeg`) uses whatever FFmpeg is installed; it is -never linked or shipped. Without it, or when a backend fails its self-test, -the software encoders above are used as before. +never linked. The Windows packages ship FFmpeg's LGPL DLLs next to +`voelin.exe`; on Linux the packages depend on (or install, see +`voelin-install-deps`) the distribution's. Without it, or when a backend +fails its self-test, the software encoders above are used as before. - Finding it: `VOELIN_FFMPEG_DIR` (only that directory; its libavutil and libswresample are loaded first so libavcodec's dependencies resolve @@ -652,7 +654,11 @@ on (`Video::set_decoder_preference`); a running watch keeps its decoder. thread before the first comes out), `threads` up to 8 in software and 1 in hardware, dav1d's `max_frame_delay` 1 (`framethreads` 1 before FFmpeg 5.0). Every frame's picture comes out of the call that decoded it, except - what B-frames reorder. + what B-frames reorder. VP8 decodes on one thread and dav1d on a quarter + of the cores (1 to 4): + FFmpeg's VP8 slice threads work on the token partitions and wait on each + other, so our 4- and 8-partition streams decoded 40-80 % slower on four + threads than on one ([research/stream-fps.md](research/stream-fps.md)). - The self-test (`ffmpeg::decoder::probe()`, once per process, every decoder on a thread of its own, at the same time as the encoders' probe in `Codecs::new()`): each decoder decodes a three-frame clip of its codec @@ -1329,8 +1335,10 @@ voelin-media, str0m, x11rb-protocol, pipewire, wayland-client, ...) with Linux (Debian/Ubuntu packages): `libvpx-dev` (feature `vpx`), `libpipewire-0.3-dev libspa-0.2-dev libclang-dev` (feature `pipewire`; the -PipeWire bindings run bindgen), `pkg-config`, and `libdav1d-dev` for -`--features av1`. X11 capture is pure Rust (x11rb) and needs no packages. +PipeWire bindings run bindgen), `pkg-config`, and `libdav1d-dev` (feature +`av1`, on by default like every other codec backend: desktop builds always +have every encoder and decoder voelin-media has). X11 capture is pure Rust +(x11rb) and needs no packages. Tests of X11 capture need an X server: `xvfb`, run with `xvfb-run -a cargo test -p voelin-media` (skipped without `DISPLAY`). FFmpeg needs nothing at build time (feature `ffmpeg` only adds `libloading`); its tests run with the @@ -1364,7 +1372,7 @@ has not run on Windows yet. | `zune-jpeg`, `zune-core` | MIT OR Apache-2.0 OR Zlib | the studio's MJPEG cameras (`pipewire`) | | `tract-onnx`; PP-HumanSeg (ONNX model) | MIT OR Apache-2.0; Apache-2.0 | the studio's person segmentation (`segment`); the model is bundled | | `windows-capture`, `wasapi`, `windows` | MIT (`windows`: MIT OR Apache-2.0) | Windows only | -| FFmpeg (libavcodec, libavutil, libavformat) | LGPL-2.1+ (GPL-2+ in builds with x264 and other GPL parts) | the user's installed libraries, loaded at runtime; never linked or shipped | +| FFmpeg (libavcodec, libavutil, libavformat) | LGPL-2.1+ (GPL-2+ in builds with x264 and other GPL parts) | loaded at runtime, never linked: on Linux the distribution's libraries (the `.deb` recommends them, the `.tar.gz` has `voelin-install-deps`, the Flatpak runtime has its own); the Windows packages ship BtbN's LGPL shared build next to `voelin.exe` with its license and source pointer (`scripts/fetch-ffmpeg-windows.sh`) | | libva | MIT | the user's `libva.so.2` (the one FFmpeg's VA-API support uses), loaded at runtime for the GPU colour conversion; never linked or shipped | | `libloading` | ISC | opens FFmpeg (and OpenH264, through the `openh264` crate) | | `bzip2` / `libbz2-rs-sys` | MIT OR Apache-2.0 / bzip2-1.0.6 | unpacks the OpenH264 download; `bzip2-1.0.6` is allowed in `deny.toml` | diff --git a/packaging/linux/voelin-install-deps b/packaging/linux/voelin-install-deps new file mode 100755 index 0000000..4ef3166 --- /dev/null +++ b/packaging/linux/voelin-install-deps @@ -0,0 +1,42 @@ +#!/bin/sh +# Install what Voelin loads at run time from the system, for the .tar.gz +# (the .deb and the Flatpak get them on their own): FFmpeg (hardware and +# extra encoders and decoders), VA-API drivers, PipeWire and the desktop +# portal (screen sharing, push-to-talk on Wayland), the Secret Service +# (saved passwords). libvpx and libdav1d come with the archive (lib/). +# +# voelin-install-deps [--dry-run] +# +# Uses apt, dnf, pacman or zypper through sudo (unless run as root). +set -eu + +dry= +[ "${1:-}" = "--dry-run" ] && dry=echo +sudo= +[ "$(id -u)" -eq 0 ] || sudo=sudo + +run() { + echo "+ $*" + [ -n "$dry" ] || $sudo "$@" +} + +if command -v apt-get >/dev/null 2>&1; then + # ffmpeg pulls in the libav* libraries of the release. + run apt-get update + run apt-get install -y ffmpeg libva2 libva-drm2 mesa-va-drivers pipewire xdg-desktop-portal \ + gnome-keyring libegl1 libxkbcommon-x11-0 +elif command -v dnf >/dev/null 2>&1; then + # Fedora's ffmpeg-free; RPM Fusion's ffmpeg adds H.264/HEVC encoders. + run dnf install -y ffmpeg-free libva mesa-va-drivers pipewire xdg-desktop-portal gnome-keyring \ + libxkbcommon-x11 +elif command -v pacman >/dev/null 2>&1; then + run pacman -S --needed --noconfirm ffmpeg libva mesa pipewire xdg-desktop-portal gnome-keyring \ + libxkbcommon-x11 +elif command -v zypper >/dev/null 2>&1; then + run zypper --non-interactive install ffmpeg libva2 Mesa-dri pipewire xdg-desktop-portal \ + gnome-keyring libxkbcommon-x11-0 +else + echo "No apt, dnf, pacman or zypper: install FFmpeg (libavcodec), VA-API drivers," >&2 + echo "PipeWire, xdg-desktop-portal and a Secret Service keyring with your package manager." >&2 + exit 1 +fi diff --git a/packaging/windows/README.md b/packaging/windows/README.md index 2782f44..b381226 100644 --- a/packaging/windows/README.md +++ b/packaging/windows/README.md @@ -11,22 +11,36 @@ is for servers and packaged for Linux only. ## Build Needs the MSVC build tools, CMake (bundled libopus), NASM (assembly of -`aws-lc-sys`, used by the WebRTC stack) and libvpx (video, `voelin-media`): +`aws-lc-sys`, used by the WebRTC stack), libvpx (VP8/VP9) and dav1d (AV1 +decoding), both for `voelin-media`: ```powershell winget install NASM.NASM Kitware.CMake NSIS.NSIS -vcpkg install libvpx:x64-windows-static-md +vcpkg install libvpx:x64-windows-static-md dav1d:x64-windows-static-md $vpx = "$env:VCPKG_ROOT\installed\x64-windows-static-md" $env:VPX_LIB_DIR = "$vpx\lib" $env:VPX_INCLUDE_DIR = "$vpx\include" $env:VPX_VERSION = "1.15.2" # what `vcpkg list libvpx` shows $env:VPX_STATIC = "1" +# dav1d-sys through system-deps, without pkg-config. +$env:SYSTEM_DEPS_DAV1D_NO_PKG_CONFIG = "1" +$env:SYSTEM_DEPS_DAV1D_SEARCH_NATIVE = "$vpx\lib" +$env:SYSTEM_DEPS_DAV1D_LIB = "dav1d" +$env:SYSTEM_DEPS_DAV1D_LINK = "static" cargo build --release --locked -p voelin-ui -makensis /DVERSION=0.1.0 packaging\windows\installer.nsi +bash scripts/fetch-ffmpeg-windows.sh ffmpeg +makensis /DVERSION=0.1.0 /DFFMPEG=..\..\ffmpeg packaging\windows\installer.nsi ``` +FFmpeg (hardware encoders and decoders, H.265, more AV1 decoders) is not +linked: the app loads `avcodec-*.dll` and `avutil-*.dll` from its own +directory, then `PATH`. The packages carry BtbN's LGPL build of FFmpeg 8.1 +(`scripts/fetch-ffmpeg-windows.sh`, with `FFMPEG-LICENSE.txt` and +`FFMPEG-README.txt` naming the build and its source); replacing the DLLs +with another build of the same major versions works. + This gives `target\release\voelin.exe` and `packaging\windows\voelin-0.1.0-setup.exe`. The installer puts the app in `Program Files\Voelin`, adds a Start menu shortcut and an uninstaller; user diff --git a/packaging/windows/installer.nsi b/packaging/windows/installer.nsi index 2919b5d..1040aad 100644 --- a/packaging/windows/installer.nsi +++ b/packaging/windows/installer.nsi @@ -7,6 +7,8 @@ ; for the numeric file version (default: VERSION) ; BINARY the executable (default ..\..\target\release\voelin.exe) ; OUTDIR where the installer goes (default: next to this file) +; FFMPEG a directory with FFmpeg's DLLs and FFMPEG-*.txt +; (scripts/fetch-ffmpeg-windows.sh), installed next to the app ; SIGN a signing command; "%1" is replaced by the file to sign, e.g. ; /DSIGN="signtool sign /fd SHA256 /tr http://timestamp.digicert.com /td SHA256 /a %1" ; @@ -67,6 +69,11 @@ Section "Install" File "/oname=${EXE}" "${BINARY}" ; Also shown in the app's About page. File "/oname=THIRD_PARTY_NOTICES.md" "..\..\THIRD_PARTY_NOTICES.md" +!ifdef FFMPEG + ; FFmpeg's DLLs, loaded from the app's directory, and their license. + File "${FFMPEG}\*.dll" + File "${FFMPEG}\FFMPEG-*.txt" +!endif WriteUninstaller "$INSTDIR\uninstall.exe" CreateShortcut "$SMPROGRAMS\${APP_NAME}.lnk" "$INSTDIR\${EXE}" @@ -86,6 +93,9 @@ Section "Uninstall" ; User data in %APPDATA%\voelin (identities, bookmarks, history) is kept. Delete "$INSTDIR\${EXE}" Delete "$INSTDIR\THIRD_PARTY_NOTICES.md" + Delete "$INSTDIR\av*.dll" + Delete "$INSTDIR\sw*.dll" + Delete "$INSTDIR\FFMPEG-*.txt" Delete "$INSTDIR\uninstall.exe" RMDir "$INSTDIR" Delete "$SMPROGRAMS\${APP_NAME}.lnk" diff --git a/scripts/fetch-ffmpeg-windows.sh b/scripts/fetch-ffmpeg-windows.sh new file mode 100755 index 0000000..102c2aa --- /dev/null +++ b/scripts/fetch-ffmpeg-windows.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash +# FFmpeg's shared libraries for the Windows packages: BtbN's LGPL build +# (no GPL parts: no x264, x265), whose DLLs the app loads at run time from +# its own directory (crates/voelin-media/src/ffmpeg/sys.rs). Without them a +# Windows install has no FFmpeg, so no hardware encoders and decoders. +# +# scripts/fetch-ffmpeg-windows.sh +# +# Puts avcodec, avformat, avutil, swresample and swscale DLLs, FFmpeg's +# LICENSE.txt as FFMPEG-LICENSE.txt and FFMPEG-README.txt (version, source) +# into ; scripts/package.sh windows ships them with FFMPEG_DLL_DIR. +# The archive is checked against the release's checksums. +# +# Environment: +# FFMPEG_BRANCH FFmpeg release branch (default 8.1: libavcodec 62, which +# voelin-media's loader and struct layouts support) +# FFMPEG_TAG BtbN release tag (default latest, rebuilt daily; set an +# autobuild-YYYY-MM-DD-HH-MM tag to pin a build) +set -euo pipefail + +out=${1:?usage: $0 } +branch=${FFMPEG_BRANCH:-8.1} +tag=${FFMPEG_TAG:-latest} +name=ffmpeg-n$branch-latest-win64-lgpl-shared-$branch +base=https://github.com/BtbN/FFmpeg-Builds/releases/download/$tag + +tmp=$(mktemp -d) +trap 'rm -rf "$tmp"' EXIT +curl -sSfL --retry 4 -o "$tmp/$name.zip" "$base/$name.zip" +curl -sSfL --retry 4 -o "$tmp/checksums.sha256" "$base/checksums.sha256" +expected=$(awk -v file="$name.zip" '$2 == file { print $1 }' "$tmp/checksums.sha256") +[[ -n $expected ]] || { echo "$name.zip is not in the release's checksums" >&2; exit 1; } +actual=$(sha256sum "$tmp/$name.zip" | cut -d' ' -f1) +[[ $actual == "$expected" ]] || { echo "checksum mismatch for $name.zip" >&2; exit 1; } + +mkdir -p "$out" +# unzip, else 7-Zip or Python (Windows runners' Git Bash may lack unzip). +if command -v unzip >/dev/null; then + (cd "$tmp" && unzip -q "$name.zip") +elif command -v 7z >/dev/null; then + (cd "$tmp" && 7z x -bso0 "$name.zip") +else + (cd "$tmp" && "$(command -v python3 || command -v python)" -m zipfile -e "$name.zip" .) +fi +dlls=() +for lib in avcodec avformat avutil swresample swscale; do + found=("$tmp/$name/bin/$lib"-*.dll) + [[ -e ${found[0]} ]] || { echo "no $lib DLL in $name.zip" >&2; exit 1; } + cp "${found[@]}" "$out/" + dlls+=("$(basename "${found[0]}")") +done +cp "$tmp/$name/LICENSE.txt" "$out/FFMPEG-LICENSE.txt" +cat >"$out/FFMPEG-README.txt" < whose sonames differ between distributions (libvpx 7 +# to 11, libdav1d 6 and 7), copied into ; then finds them there +# (RUNPATH $ORIGIN/../lib) and the system's other libraries as usual. +bundle_libs() { + local exe=$1 dir=$2 lib path + if ! command -v patchelf >/dev/null; then + echo "patchelf not found: the .tar.gz uses the system's libvpx and libdav1d" >&2 + return + fi + mkdir -p "$dir" + while read -r lib path; do + case $lib in + libvpx.so.* | libdav1d.so.*) install -m644 "$path" "$dir/$lib" ;; + esac + done < <(ldd "$exe" | awk '$2 == "=>" && $3 ~ /^\// { print $1, $3 }') + # shellcheck disable=SC2016 # $ORIGIN is for the dynamic linker. + patchelf --set-rpath '$ORIGIN/../lib' "$exe" +} + package_linux() { local bin=$target_dir/release arch name stage root gw_version arch=$(uname -m) @@ -92,11 +118,12 @@ package_linux() { # `tar -xzf … --strip-components=1 -C ~/.local`. name=voelin-$version-linux-$arch stage=$tmp/$name - install -Dm755 "$bin/voelin" -t "$stage/bin" + install -Dm755 "$bin/voelin" packaging/linux/voelin-install-deps -t "$stage/bin" install -Dm644 packaging/linux/$app_id.desktop -t "$stage/share/applications" install -Dm644 packaging/linux/$app_id.metainfo.xml -t "$stage/share/metainfo" install -Dm644 packaging/linux/$app_id.svg -t "$stage/share/icons/hicolor/scalable/apps" install -Dm644 THIRD_PARTY_NOTICES.md -t "$stage/share/doc/voelin" + bundle_libs "$stage/bin/voelin" "$stage/lib" tar -C "$tmp" -czf "$out/$name.tar.gz" "$name" files+=("$name.tar.gz") @@ -118,8 +145,10 @@ package_linux() { install -Dm644 packaging/linux/$app_id.svg -t "$root/usr/share/icons/hicolor/scalable/apps" install -Dm644 THIRD_PARTY_NOTICES.md -t "$root/usr/share/doc/voelin" # libxkbcommon, Wayland/X11 and EGL are loaded at run time (dlopen), so - # dpkg-shlibdeps cannot see them. - deb_extra="Recommends: libwayland-client0, libwayland-cursor0, libxkbcommon-x11-0, libx11-xcb1, libxcursor1, libxi6, libxrandr2, libegl1" \ + # dpkg-shlibdeps cannot see them; neither FFmpeg (hardware and extra + # encoders and decoders) and libva (GPU colour conversion), nor what + # screen sharing, Wayland hotkeys and saved passwords talk to. + deb_extra="Recommends: libwayland-client0, libwayland-cursor0, libxkbcommon-x11-0, libx11-xcb1, libxcursor1, libxi6, libxrandr2, libegl1, libavcodec61 | libavcodec60 | libavcodec59 | libavcodec-extra, libavformat61 | libavformat60 | libavformat59, libva2, libva-drm2, mesa-va-drivers | va-driver-all | intel-media-va-driver, pipewire, xdg-desktop-portal, gnome-keyring | kwalletmanager | keepassxc" \ make_deb voelin "$version" libxkbcommon0 \ "Voelin, a TeamSpeak 3 and 6 client" \ "Desktop client for TeamSpeak 3 and TeamSpeak 6 servers: voice, chat," \ @@ -149,6 +178,14 @@ package_windows() { stage=$tmp/$name mkdir -p "$stage" cp "$bin/voelin.exe" THIRD_PARTY_NOTICES.md "$stage/" + # FFmpeg's DLLs next to voelin.exe, where the app looks for them first. + local ffmpeg=() + if [[ -n ${FFMPEG_DLL_DIR:-} ]]; then + cp "$FFMPEG_DLL_DIR"/*.dll "$FFMPEG_DLL_DIR"/FFMPEG-*.txt "$stage/" + ffmpeg=(-DFFMPEG="$(native_path "$(cd "$FFMPEG_DLL_DIR" && pwd)")") + else + echo "FFMPEG_DLL_DIR not set: the Windows packages have no FFmpeg" >&2 + fi if command -v zip >/dev/null; then (cd "$tmp" && zip -qr "$out/$name.zip" "$name") elif command -v 7z >/dev/null; then @@ -169,7 +206,7 @@ package_windows() { fi # Absolute paths: makensis changes into the script's directory. "$makensis" -V2 -DVERSION="$version" -DVERSION_NUMERIC="${version%%-*}" \ - -DOUTDIR="$(native_path "$out")" \ + -DOUTDIR="$(native_path "$out")" "${ffmpeg[@]}" \ -DBINARY="$(native_path "$(cd "$bin" && pwd)/voelin.exe")" packaging/windows/installer.nsi files+=("voelin-$version-setup.exe") }