diff --git a/Cargo.lock b/Cargo.lock index bdf46f0..c2a1cc9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2741,7 +2741,7 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uu-remote-linux" -version = "0.2.3" +version = "0.2.4" dependencies = [ "async-trait", "base64 0.22.1", diff --git a/Cargo.toml b/Cargo.toml index 6e33cfc..da884cf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "uu-remote-linux" -version = "0.2.3" +version = "0.2.4" edition = "2021" default-run = "uuremote-server" authors = ["uu-remote-linux contributors"] diff --git a/docs/release-notes/v0.2.4.md b/docs/release-notes/v0.2.4.md new file mode 100644 index 0000000..f6561be --- /dev/null +++ b/docs/release-notes/v0.2.4.md @@ -0,0 +1,22 @@ +控制端:修复 FFmpeg 9 下没有画面;新增「删除设备」。/ Viewer: fix no video with FFmpeg 9; add device removal. + +### 控制端修复 / Viewer — fixed +- **FFmpeg 9 下桌面没有画面**(v0.2.2、v0.2.3 的回归):为兼容 FFmpeg 4.4 改用的 `-vsync 0` 已被 FFmpeg 9 删除,解码进程一启动就退出, + 所有帧都解码失败。现在启动时探测当前 ffmpeg 支持的参数:新版本用 `-fps_mode passthrough`,旧版本(如 Ubuntu 22.04 的 4.4)用 `-vsync 0`。 + 已在 FFmpeg 9.0.2 上连接官方 Mac 被控端实测:0 解码错误。 + Fixed: with FFmpeg 9 every frame failed to decode (`-vsync` was removed). Verified against the official Mac host on FFmpeg 9.0.2. + +### 控制端新增 / Viewer — added +- **删除设备**:启动窗口「更多工具 → 删除设备」(带确认),或命令行 `uuremote-viewer unbind DEVICE`,把设备从账号中移除, + 与官方客户端的「删除设备」相同。命令行方式已对一台测试设备实测删除成功;⚠️ 启动窗口里的按钮尚未实机点击验收; + 分享给你的设备(`--shared`)只有字符串依据,未实测。 + Remove a device from the account (CLI verified live on a test device; launcher button and `--shared` not yet verified). + +### 已知问题 / Known issues +- 剪贴板只在控制端窗口获得焦点时同步;控制端 → 官方 Windows 被控端的剪贴板仍在排查。 +- Clipboard syncs only while the viewer window is focused; viewer → official Windows host clipboard is still unresolved. + +### 下载 / Download +`uu-remote-linux-v0.2.4-x86_64-linux.tar.gz`:主机 `uuremote-server`(X11 版)与控制端 `uuremote-viewer`(x86_64,glibc ≥ 2.35;控制端需 SDL2、GTK3、ffmpeg),附带 `contrib/`。主机端与 v0.2.3 相同。 + +**非官方项目,与网易无关。** / **Unofficial, not affiliated with NetEase.** diff --git a/src/viewer/decoder_cli.rs b/src/viewer/decoder_cli.rs index 1852ad6..c17df78 100644 --- a/src/viewer/decoder_cli.rs +++ b/src/viewer/decoder_cli.rs @@ -21,14 +21,14 @@ impl Cli { fn with_codec(codec:Codec,width:u32,height:u32)->Result { let ffmpeg=std::env::var("UU_VIEWER_FFMPEG").unwrap_or_else(|_|"ffmpeg".into()); let filter=format!("scale={width}:{height}:force_original_aspect_ratio=decrease,pad={width}:{height}:(ow-iw)/2:(oh-ih)/2"); - let mut child=Command::new(ffmpeg) + let passthrough=passthrough_args(&ffmpeg); + let mut child=Command::new(&ffmpeg) .args(["-hide_banner","-loglevel","error","-nostdin","-threads","1","-probesize","32","-analyzeduration","0", "-fflags","nobuffer","-flags","low_delay","-f",codec.demuxer(),"-i","pipe:0","-an","-vf",&filter, "-pix_fmt","rgb24", // Raw H.264/H.265 carries no timestamps; constant-rate output dropped almost every frame of // the official Mac host's stream (270 → 2). Pass frames through unchanged. - // -vsync 0 also supports Ubuntu 22.04's FFmpeg 4.4, which lacks -fps_mode. - "-vsync","0","-f","rawvideo","pipe:1"]) + passthrough.0,passthrough.1,"-f","rawvideo","pipe:1"]) .stdin(Stdio::piped()).stdout(Stdio::piped()).stderr(Stdio::null()) .spawn().map_err(|e|format!("Start ffmpeg decoder: {e}"))?; let input=child.stdin.take().ok_or("ffmpeg stdin missing")?; @@ -47,6 +47,23 @@ impl Cli { } } +/// FFmpeg ≥ 5.1 has `-fps_mode`; FFmpeg 8+ removed `-vsync`, and Ubuntu 22.04's 4.4 lacks `-fps_mode`. +/// Probe once per binary with a one-frame null run instead of parsing version strings. +fn passthrough_args(ffmpeg:&str)->(&'static str,&'static str) { + static CACHE:std::sync::Mutex>=std::sync::Mutex::new(Vec::new()); + let mut cache=CACHE.lock().unwrap_or_else(|e|e.into_inner()); + let fps_mode=match cache.iter().find(|(name,_)|name==ffmpeg) { + Some(&(_,known))=>known, + None=>{ + let ok=Command::new(ffmpeg).args(["-hide_banner","-loglevel","quiet","-nostdin","-f","lavfi","-i","color=s=16x16:d=0.04", + "-fps_mode","passthrough","-f","null","-"]).stdin(Stdio::null()).stdout(Stdio::null()).stderr(Stdio::null()) + .status().is_ok_and(|s|s.success()); + cache.push((ffmpeg.into(),ok));ok + } + }; + if fps_mode {("-fps_mode","passthrough")} else {("-vsync","0")} +} + impl Decoder for Cli { fn set_codec(&mut self,codec:Codec)->Result<(),String>{ if self.codec!=codec {*self=Self::with_codec(codec,self.width,self.height)?;}Ok(()) @@ -72,6 +89,16 @@ impl Drop for Cli { fn drop(&mut self) { let _=self.child.kill(); let _=self.chi #[cfg(test)] mod tests { use super::*; // Six synthetic red IDRs per fixture; no captured desktop or external encoder dependency. + #[cfg(unix)] #[test] fn passthrough_follows_ffmpeg_option_support(){ + use std::os::unix::fs::PermissionsExt; + let dir=std::env::temp_dir().join(format!("uu-ffprobe-{}",std::process::id()));std::fs::create_dir_all(&dir).unwrap(); + for (name,script,expected) in [("new","exit 0",("-fps_mode","passthrough")),("old","case \"$*\" in *-fps_mode*) exit 1;; esac",("-vsync","0"))]{ + let path=dir.join(name);std::fs::write(&path,format!("#!/bin/sh\n{script}\n")).unwrap(); + std::fs::set_permissions(&path,std::fs::Permissions::from_mode(0o755)).unwrap(); + assert_eq!(super::passthrough_args(path.to_str().unwrap()),expected); + } + std::fs::remove_dir_all(dir).unwrap(); + } #[test] fn ffmpeg_decodes_h264_and_hevc_420_and_444_to_rgb24(){ match Command::new("ffmpeg").arg("-version").stdout(Stdio::null()).stderr(Stdio::null()).status(){ Err(e) if e.kind()==std::io::ErrorKind::NotFound=>{eprintln!("skip: ffmpeg is not on PATH");return},