From 7fcc6744406c4067552b3b6108c407aa8970668a Mon Sep 17 00:00:00 2001 From: VallierDev <24893073+VallierDev@users.noreply.github.com> Date: Sun, 18 Oct 2026 20:54:34 +0800 Subject: [PATCH] Release v0.2.10: official device_capability shape and sender_para_info (#49) The iPhone client ignored our flat forward_setting device_capability and kept quality and chroma locked. Send it nested under data.device_capability with type beside it, list the formats the encoder really produces (4:4:4 when available), and add sender_para_info, as the official Windows host does. Verified with the UU iPhone app 4.42.0. Co-Authored-By: Claude Opus 5.5 --- Cargo.lock | 2 +- Cargo.toml | 2 +- docker/Dockerfile | 2 +- docs/release-notes/v0.2.10.md | 18 ++++++++ src/capability.rs | 80 +++++++++++++++++++++++++---------- src/webrtc.rs | 19 ++++++++- 6 files changed, 97 insertions(+), 26 deletions(-) create mode 100644 docs/release-notes/v0.2.10.md diff --git a/Cargo.lock b/Cargo.lock index 183fc96..ffdf40a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2741,7 +2741,7 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uu-remote-linux" -version = "0.2.9" +version = "0.2.10" dependencies = [ "async-trait", "base64 0.22.1", diff --git a/Cargo.toml b/Cargo.toml index 8b0841b..6e03b68 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu-remote-linux" -version = "0.2.9" +version = "0.2.10" edition = "2021" default-run = "uuremote-server" authors = ["uu-remote-linux contributors"] diff --git a/docker/Dockerfile b/docker/Dockerfile index 082259a..6efc85a 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,7 +1,7 @@ # Unofficial UU Remote Linux host in a container, for NAS boxes (Synology DSM, etc.) without a desktop. # Headless mode: file transfer, terminal and port mapping; no remote desktop. Uses the published release binary. FROM ubuntu:24.04 -ARG VERSION=v0.2.9 +ARG VERSION=v0.2.10 LABEL org.opencontainers.image.source="https://github.com/VallierDev/uu-remote-linux" \ org.opencontainers.image.description="Unofficial UU Remote Linux host, headless (file transfer, terminal, port mapping)" \ org.opencontainers.image.licenses="GPL-3.0" diff --git a/docs/release-notes/v0.2.10.md b/docs/release-notes/v0.2.10.md new file mode 100644 index 0000000..e253674 --- /dev/null +++ b/docs/release-notes/v0.2.10.md @@ -0,0 +1,18 @@ +修复 iPhone 上「超清 / 原画」「常规 / 真彩」点不动。/ Fix iPhone quality and chroma choices being locked. + +### 修复 / Fixed +- **iPhone 无法切换画质与真彩**(#49,感谢 @RiverOnVenus 的细致排查):连接本项目主机时,iPhone 的「超清」「原画」 + 以及「常规 / 真彩」按钮点了没反应,只有帧率能改。原因是主机发出的设备能力消息(`forward_setting` 的 `device_capability`) + 格式与官方 Windows 被控端不一致,iPhone 无法识别,于是锁定在默认值。现在按官方格式发送设备能力(含 4:4:4 等真实支持的格式), + 并补发发送参数 `sender_para_info`。 + 已实测:iPhone(UU 远程 4.42.0)连接修复后的主机,可以切换画质(主机收到新的画质请求)。Mac 客户端不依赖这条消息,此前即正常。 +- Device capability is now sent in the official nested shape (and `sender_para_info` is added), so the iPhone client unlocks + quality and chroma choices. Verified with the UU iPhone app 4.42.0. + +### 其他 / Other +- 控制端窗口与主机使用同一图标,并新增控制端启动项 `contrib/desktop/uu-remote-linux-viewer.desktop`(#13)。 + +### 下载 / Download +`uu-remote-linux-v0.2.10-x86_64-linux.tar.gz`(主机 `uuremote-server` + 控制端 `uuremote-viewer`,附带 `contrib/`),或 `docker pull ghcr.io/vallierdev/uu-remote-linux:v0.2.10`。 + +**非官方项目,与网易无关。** / **Unofficial, not affiliated with NetEase.** diff --git a/src/capability.rs b/src/capability.rs index c30887c..7484034 100644 --- a/src/capability.rs +++ b/src/capability.rs @@ -27,21 +27,49 @@ pub fn h264_device_capability( fps: i32, codec_impl: i32, ) -> Value { - device_capability(client_id, ice_id, display_id, fps, codec_impl, false) + device_capability(client_id, ice_id, display_id, fps, codec_impl, false, false) } -pub fn device_capability(client_id: &str, ice_id: &str, display_id: i32, fps: i32, codec_impl: i32, hevc: bool) -> Value { - let mut codecs = vec![json!({"video_codec": VIDEO_CODEC_H264, "chroma_sampling": 1, - "codec_impl": codec_impl, "bit_depth": 8})]; - // Official VideoCodecCapability::SerializeJson uses the same fields for CodecType H265=2. - if hevc { codecs.push(json!({"video_codec": 2, "chroma_sampling": 1, "codec_impl": codec_impl, "bit_depth": 8})); } +/// Shape of the official Windows host's `forward_setting` (observed from a live 4.37 host): +/// `{client_id, data: {device_capability: {display_info, ice_id, video_codec_capability}, type}}`. +/// The payload sits under `data.device_capability` with `type` beside it. The earlier flat shape +/// (`type` at the top, fields directly in `data`) was not recognised by the iPhone client, which +/// then kept quality and chroma locked at their defaults (#49). Only 8-bit and the chroma formats +/// the encoder really produces are listed; the first entry carries the maximum size as officially. +pub fn device_capability(client_id: &str, ice_id: &str, display_id: i32, fps: i32, codec_impl: i32, hevc: bool, full_chroma: bool) -> Value { + let mut codecs = Vec::new(); + for codec in [VIDEO_CODEC_H264].into_iter().chain(hevc.then_some(2)) { + for chroma in [1].into_iter().chain(full_chroma.then_some(3)) { + let (width, height) = if codecs.is_empty() { (3840, 2160) } else { (0, 0) }; + codecs.push(json!({"video_codec": codec, "chroma_sampling": chroma, "codec_impl": codec_impl, + "bit_depth": 8, "width": width, "height": height})); + } + } json!({ "client_id": client_id, - "type": "device_capability", "data": { - "display_info": [{"id": display_id, "fps": fps, "type": 0, "hdr": 0}], - "video_codec_capability": codecs, - "ice_id": ice_id + "device_capability": { + "display_info": [{"id": display_id, "fps": fps, "type": 0, "hdr": -1}], + "video_codec_capability": codecs, + "ice_id": ice_id + }, + "type": "device_capability" + } + }) +} + +/// Official `sender_para_info` (capture and encoder names; the Windows host sends "DXGI" / +/// "NVIDIA NVENC") for the single video track. +pub fn sender_para_info(client_id: &str, ice_id: &str, capture_impl: &str, encoder_impl: &str) -> Value { + json!({ + "client_id": client_id, + "data": { + "sender_para_info": { + "capture_impl": capture_impl, "encoder_impl": encoder_impl, "ice_id": ice_id, + "sender_media_infos": [{"capture_impl": capture_impl, "encoder_impl": encoder_impl, "video_track_index": 0}], + "video_track_index": 0 + }, + "type": "sender_para_info" } }) } @@ -51,12 +79,20 @@ mod tests { use super::*; #[test] - fn hevc_capability_uses_official_codec_enum_and_420_only() { - let payload = device_capability("client-example", "ice-example", 0, 60, 5, true); - assert_eq!(payload["data"]["video_codec_capability"], json!([ - {"video_codec":1,"chroma_sampling":1,"codec_impl":5,"bit_depth":8}, - {"video_codec":2,"chroma_sampling":1,"codec_impl":5,"bit_depth":8}])); - assert_eq!(device_capability("c", "i", 0, 60, 5, false)["data"]["video_codec_capability"].as_array().unwrap().len(), 1); + fn capability_uses_the_official_nested_shape_and_real_formats() { + let payload = device_capability("client-example", "ice-example", 0, 60, 5, true, true); + assert_eq!(payload["data"]["type"], "device_capability"); + assert!(payload.get("type").is_none()); + let caps = &payload["data"]["device_capability"]["video_codec_capability"]; + assert_eq!(caps.as_array().unwrap().len(), 4); + assert_eq!(caps[0], json!({"video_codec":1,"chroma_sampling":1,"codec_impl":5,"bit_depth":8,"width":3840,"height":2160})); + assert_eq!(caps[3], json!({"video_codec":2,"chroma_sampling":3,"codec_impl":5,"bit_depth":8,"width":0,"height":0})); + assert_eq!(payload["data"]["device_capability"]["display_info"][0]["hdr"], -1); + let h264_420 = device_capability("c", "i", 0, 60, 5, false, false); + assert_eq!(h264_420["data"]["device_capability"]["video_codec_capability"].as_array().unwrap().len(), 1); + let sender = sender_para_info("c", "i", "X11", "NVIDIA NVENC"); + assert_eq!(sender["data"]["type"], "sender_para_info"); + assert_eq!(sender["data"]["sender_para_info"]["sender_media_infos"][0]["encoder_impl"], "NVIDIA NVENC"); } #[test] @@ -71,15 +107,15 @@ mod tests { #[test] fn device_capability_uses_object_data_and_string_ice_id() { let payload = h264_device_capability("client-example", "ice-example", 11, 60, 0); - assert_eq!(payload["type"], "device_capability"); - assert!(payload["data"].is_object()); - assert_eq!(payload["data"]["ice_id"], "ice-example"); - let display = &payload["data"]["display_info"][0]; + let capability = &payload["data"]["device_capability"]; + assert!(capability.is_object()); + assert_eq!(capability["ice_id"], "ice-example"); + let display = &capability["display_info"][0]; assert_eq!(display.as_object().unwrap().len(), 4); assert_eq!(display["id"], 11); assert_eq!(display["fps"], 60); - let codec = &payload["data"]["video_codec_capability"][0]; - assert_eq!(codec.as_object().unwrap().len(), 4); + let codec = &capability["video_codec_capability"][0]; + assert_eq!(codec.as_object().unwrap().len(), 6); assert_eq!(codec["video_codec"], 1); assert_eq!(codec["codec_impl"], 0); assert_eq!(codec["bit_depth"], 8); diff --git a/src/webrtc.rs b/src/webrtc.rs index dd2fb2b..f42ee83 100644 --- a/src/webrtc.rs +++ b/src/webrtc.rs @@ -177,10 +177,27 @@ impl WebRtcSession { tokio::spawn(async move { let ctx = ctx.lock().await.clone(); if let (Some(client), Some(ice)) = (&ctx.client_id, ctx.ice_id.as_ref().and_then(|v| v.as_str())) { - let payload = crate::capability::device_capability(client, ice, 0, crate::video::display_fps() as i32, 5, hevc); + let encoder = crate::video::Encoder::requested(); + let codec_impl = if encoder == crate::video::Encoder::Nvenc { crate::capability::CODEC_IMPL_NVENC } else { 5 }; + let payload = crate::capability::device_capability(client, ice, 0, crate::video::display_fps() as i32, codec_impl, + hevc, crate::video::full_chroma_available()); if let Err(e) = sig.emit_event(crate::capability::FORWARD_SETTING_EVENT, payload).await { log::error!("Device capability notification failed: {}", e); } + let capture_impl = match crate::desktop_backend::detect() { + Ok(crate::desktop_backend::DesktopBackend::Portal) => "PipeWire", + Ok(crate::desktop_backend::DesktopBackend::Wayland) => "Wayland", + _ => "X11", + }; + let encoder_impl = match encoder { + crate::video::Encoder::Nvenc => "NVIDIA NVENC", + crate::video::Encoder::Vaapi => "VAAPI", + crate::video::Encoder::Cpu => "Software", + }; + if let Err(e) = sig.emit_event(crate::capability::FORWARD_SETTING_EVENT, + crate::capability::sender_para_info(client, ice, capture_impl, encoder_impl)).await { + log::error!("Sender parameter notification failed: {}", e); + } if let Some(control) = ctx.app_control_id.as_ref().and_then(|v| v.as_str()) { if let Err(e) = sig.emit_event(crate::capability::ICE_FINISHED_EVENT, crate::capability::ice_finished(ice, control)).await {