diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5882027..bea6a9f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -106,7 +106,8 @@ jobs: run: | sudo apt-get update sudo apt-get install -y build-essential pkg-config \ - libx11-dev libxext-dev libxtst-dev libxfixes-dev libgtk-3-dev + libx11-dev libxext-dev libxtst-dev libxfixes-dev libgtk-3-dev \ + libwayland-dev libwayland-bin libxkbcommon-dev libglib2.0-dev libpipewire-0.3-dev libei-dev - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 - run: cargo test --locked @@ -114,3 +115,8 @@ jobs: run: | cargo build --locked --release --bin uuremote-server file target/release/uuremote-server + # The aarch64 release package ships both engine plugins. + - name: Release feature set + run: | + cargo build --locked --features wayland,portal,engine-plugins --bin uuremote-server + for lib in libuu-wayland.so libuu-portal.so; do test -f "target/debug/$lib"; done diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 46660fb..735e1fc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,7 +12,12 @@ jobs: # GNOME/KDE Wayland engine: libei >= 1.1 first ships in Ubuntu 24.04, so this plugin needs # glibc >= 2.39. It is only loaded on portal sessions; X11 and wlroots hosts never open it. portal-plugin: - runs-on: ubuntu-24.04 + strategy: + matrix: + include: + - { arch: x86_64, runner: ubuntu-24.04 } + - { arch: aarch64, runner: ubuntu-24.04-arm } + runs-on: ${{ matrix.runner }} steps: - uses: actions/checkout@v4 - name: Install build dependencies @@ -24,13 +29,18 @@ jobs: - run: UU_NO_GTK=1 cargo build --release --locked --features portal,engine-plugins --bin uuremote-server - uses: actions/upload-artifact@v4 with: - name: libuu-portal + name: libuu-portal-${{ matrix.arch }} path: target/release/libuu-portal.so - release: + build: needs: portal-plugin + strategy: + matrix: + include: + - { arch: x86_64, runner: ubuntu-22.04 } + - { arch: aarch64, runner: ubuntu-22.04-arm } # Built on 22.04 so the binary also runs on Ubuntu 22.04/24.04 and newer Debian (glibc >= 2.35). - runs-on: ubuntu-22.04 + runs-on: ${{ matrix.runner }} steps: - uses: actions/checkout@v4 - name: Install build dependencies @@ -46,19 +56,34 @@ jobs: - run: cargo build --release --locked --features wayland,portal,engine-plugins - uses: actions/download-artifact@v4 with: - name: libuu-portal + name: libuu-portal-${{ matrix.arch }} path: target/release # Experimental viewer; built after the host so uuremote-server keeps the release features. - run: cargo build --release --locked --features native-viewer,viewer-sdl --bin uuremote-viewer - name: Package run: | - name=uu-remote-linux-${GITHUB_REF_NAME}-x86_64-linux + name=uu-remote-linux-${GITHUB_REF_NAME}-${{ matrix.arch }}-linux mkdir -p "$name" cp target/release/uuremote-server target/release/uuremote-viewer target/release/libuu-wayland.so target/release/libuu-portal.so \ LICENSE README.md README.en.md config.example.json "$name/" cp -r contrib "$name/" tar czf "$name.tar.gz" "$name" sha256sum "$name.tar.gz" > "$name.tar.gz.sha256" + - uses: actions/upload-artifact@v4 + with: + name: package-${{ matrix.arch }} + path: uu-remote-linux-*.tar.gz* + + # One publisher, so the matrix legs never race to create the release. + release: + needs: build + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + with: + pattern: package-* + merge-multiple: true - uses: softprops/action-gh-release@v2 with: body_path: docs/release-notes/${{ github.ref_name }}.md diff --git a/README.en.md b/README.en.md index f8b6c9f..eeeb56a 100644 --- a/README.en.md +++ b/README.en.md @@ -128,9 +128,9 @@ Switching reuses one video track and pauses input until the new source sends a f ## Installation -### 0. Prebuilt release package (recommended, x86_64) +### 0. Prebuilt release package (recommended, x86_64 / aarch64) -Download `uu-remote-linux--x86_64-linux.tar.gz` from [Releases](../../releases/latest), extract it, then: +Download `uu-remote-linux--x86_64-linux.tar.gz` (ARM64: `aarch64-linux`) from [Releases](../../releases/latest), extract it, then: ```sh install -Dm755 uuremote-server ~/.local/bin/uuremote-server @@ -148,7 +148,7 @@ running session at startup, and the matching `libuu-*.so` is loaded only on Wayl Plugins are found next to `uuremote-server`, in `../lib/uu-remote-linux/`, `~/.local/lib/uu-remote-linux/` or `/usr/lib/uu-remote-linux/` (`UU_ENGINE_DIR` overrides); a missing library or too old glibc is reported in the log. -Continue with step 3 (login). Other architectures (ARM): build from source below. +Continue with step 3 (login). Other architectures: build from source below. ### 1. Dependencies (Ubuntu / Debian) @@ -383,7 +383,7 @@ Released under the [GPL-3.0](LICENSE): you may use, modify and redistribute it, ### H.265 / HEVC -When both sides support H.265 the host uses it (as the official host does: the host picks the codec from both +When both sides support H.265 and the host has a hardware encoder (NVENC / explicit VAAPI), the host uses it (as the official host does: the host picks the codec from both capability lists; the official Mac viewer lists H265 first in its SDP). The first desktop connection probes a synthetic frame and announces encoder support with CodecNegotiation. `hevc_nvenc`, `libx265` and explicit `UU_VIDEO_ENCODER=vaapi` (`hevc_vaapi`); hardware failure falls back to software HEVC, then to H.264. @@ -391,6 +391,9 @@ synthetic frame and announces encoder support with CodecNegotiation. `hevc_nvenc Verified with the official Mac viewer on an RTX 3090 (hevc_nvenc, including 4:4:4) and with the official Android viewer on Intel Alder Lake-P (iHD): 2560x1440 fully hardware-encoded, 58 fps decoded at about 10 ms. libx265 is still not verified against a real viewer. +With CPU-only encoding the default is H.264: libx265 is about ten times slower than libx264 (measured ~15 vs ~155 fps +at 1080p on a 4-core ARM host, #59); `UU_VIDEO_CODEC=h265` forces H.265. The applied frame rate comes from the viewer's +quality/fps menu; `UU_DISPLAY_FPS` only changes the reported display refresh rate. HEVC access units are split on RFC 7798 picture boundaries instead of AUDs: `hevc_vaapi` with `-aud 1` writes an AUD only at IRAPs and drops every other picture from the bitstream, so an AUD-based reader turns a whole GOP into diff --git a/README.md b/README.md index e281690..743dcd2 100644 --- a/README.md +++ b/README.md @@ -115,9 +115,9 @@ GNOME Portal 的控制通道不再等待授权窗口或第一帧画面:先通 ## 安装 -### 0. 直接用 Release 预编译包(推荐,x86_64) +### 0. 直接用 Release 预编译包(推荐,x86_64 / aarch64) -从 [Releases](../../releases/latest) 下载 `uu-remote-linux-<版本>-x86_64-linux.tar.gz`,解压后: +从 [Releases](../../releases/latest) 下载 `uu-remote-linux-<版本>-x86_64-linux.tar.gz`(ARM64 选 `aarch64-linux`),解压后: ```sh install -Dm755 uuremote-server ~/.local/bin/uuremote-server @@ -134,7 +134,7 @@ install -Dm644 libuu-wayland.so libuu-portal.so -t ~/.local/lib/uu-remote-linux/ | GNOME / KDE Wayland | glibc ≥ 2.39(Ubuntu 24.04、Fedora 40、Debian 13 及更新),以及 libei ≥ 1.1、PipeWire | 插件放在 `uuremote-server` 同目录、`../lib/uu-remote-linux/`、`~/.local/lib/uu-remote-linux/` 或 `/usr/lib/uu-remote-linux/` 都能找到 -(`UU_ENGINE_DIR` 可指定)。缺库或版本太旧时日志会写明原因。之后从第 3 步「登录」继续;ARM 等其他架构请按下面源码编译。 +(`UU_ENGINE_DIR` 可指定)。缺库或版本太旧时日志会写明原因。之后从第 3 步「登录」继续;其他架构请按下面源码编译。 ### 1. 依赖(Ubuntu / Debian) @@ -346,8 +346,9 @@ flowchart LR ### H.265 / HEVC -控制端和主机都支持 H.265 时,主机自动使用 H.265(与官方主机一致,由主机按双方能力选择;官方 Mac 客户端在 SDP -中优先列出 H.265)。首次桌面连接会用合成帧探测实际编码能力,并通过 CodecNegotiation 告知客户端。支持 `hevc_nvenc`、 +控制端和主机都支持 H.265、且主机使用硬件编码器(NVENC / 显式 VAAPI)时,主机自动使用 H.265(与官方主机一致,由主机按双方能力选择;官方 Mac 客户端在 SDP +中优先列出 H.265)。**只有 CPU 编码时默认用 H.264**:libx265 比 libx264 慢约 10 倍(4 核 ARM 上 1080p 实测约 15 帧对 155 帧,#59), +可用 `UU_VIDEO_CODEC=h265` 强制 H.265。实际帧率由控制端的「画质/帧率」菜单决定;`UU_DISPLAY_FPS` 只改上报的显示器刷新率。首次桌面连接会用合成帧探测实际编码能力,并通过 CodecNegotiation 告知客户端。支持 `hevc_nvenc`、 `libx265`、显式 `UU_VIDEO_ENCODER=vaapi` 的 `hevc_vaapi`;硬件失败先回落软件 HEVC,再回落 H.264。 `UU_VIDEO_CODEC=h264` 强制使用 H.264。8-bit;真彩 4:4:4 使用 hevc_nvenc `rext` / libx265 `main444-8`。 已用官方 Mac 客户端在 RTX 3090(hevc_nvenc,含 4:4:4)实机验收;`hevc_vaapi` 配官方 Android 客户端也已实机验收 diff --git a/src/capture_setting.rs b/src/capture_setting.rs index bfc6937..2606570 100644 --- a/src/capture_setting.rs +++ b/src/capture_setting.rs @@ -117,10 +117,16 @@ pub fn handle_rpc(rpc: &[WireField], settings: &watch::Sender, na } /// Initial codec once the m-line is negotiated: H.265 when both sides support it (the Mac viewer -/// lists H265 first in its offer), unless UU_VIDEO_CODEC=h264. +/// lists H265 first in its offer) and a hardware encoder is selected. Software libx265 is about ten +/// times slower than libx264 (measured 15 vs 155 fps at 1080p on a 4-core ARM host, #59), so CPU +/// hosts default to H.264. UU_VIDEO_CODEC=h264 / h265 overrides. pub fn preferred_codec(h264: bool, h265: bool) -> VideoCodec { - let forced_h264 = std::env::var("UU_VIDEO_CODEC").is_ok_and(|v| v.eq_ignore_ascii_case("h264")); - if h265 && !(forced_h264 && h264) { VideoCodec::H265 } else { VideoCodec::H264 } + let forced = std::env::var("UU_VIDEO_CODEC").ok().map(|v| v.to_ascii_lowercase()); + pick_codec(h264, h265, forced.as_deref(), crate::video::Encoder::requested() != crate::video::Encoder::Cpu) +} +fn pick_codec(h264: bool, h265: bool, forced: Option<&str>, hardware: bool) -> VideoCodec { + let wants_h265 = match forced { Some("h264") => false, Some("h265" | "hevc") => true, _ => hardware }; + if h265 && (wants_h265 || !h264) { VideoCodec::H265 } else { VideoCodec::H264 } } pub fn handle_rpc_with_codecs(rpc: &[WireField], settings: &watch::Sender, native: (u32, u32), h264: bool, h265: bool) -> Option> { @@ -499,6 +505,16 @@ mod codec_tests { assert_eq!(rx.borrow().codec, VideoCodec::H265); assert_eq!(preferred_codec(true, false), VideoCodec::H264); } + #[test] + fn software_hosts_default_to_h264_unless_forced() { + assert_eq!(pick_codec(true, true, None, true), VideoCodec::H265); + assert_eq!(pick_codec(true, true, None, false), VideoCodec::H264); + assert_eq!(pick_codec(true, true, Some("h265"), false), VideoCodec::H265); + assert_eq!(pick_codec(true, true, Some("h264"), true), VideoCodec::H264); + // Only one codec bound in the SDP: use it whatever the preference. + assert_eq!(pick_codec(false, true, None, false), VideoCodec::H265); + assert_eq!(pick_codec(true, false, Some("h265"), true), VideoCodec::H264); + } } #[cfg(test)]