mirror of
https://github.com/VallierDev/uu-remote-linux.git
synced 2026-11-16 16:50:41 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab137a1b20 | ||
|
|
092ea713f8 | ||
|
|
53d5f0e144 |
No files matched your search
Generated
+1
-1
@@ -2741,7 +2741,7 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "uu-remote-linux"
|
name = "uu-remote-linux"
|
||||||
version = "0.2.35"
|
version = "0.2.36"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "uu-remote-linux"
|
name = "uu-remote-linux"
|
||||||
version = "0.2.35"
|
version = "0.2.36"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
default-run = "uuremote-server"
|
default-run = "uuremote-server"
|
||||||
authors = ["uu-remote-linux contributors"]
|
authors = ["uu-remote-linux contributors"]
|
||||||
|
|||||||
+17
-2
@@ -56,6 +56,15 @@ static void track_injected_key(int keycode, int is_press) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* XShmAttach fails asynchronously (BadAccess when the X server cannot reach our segment, e.g. a
|
||||||
|
* server in another container); Xlib's default handler would exit the process before the XGetImage fallback. */
|
||||||
|
static volatile int g_shm_attach_failed = 0;
|
||||||
|
static int shm_attach_error(Display *display, XErrorEvent *event) {
|
||||||
|
(void)display; (void)event;
|
||||||
|
g_shm_attach_failed = 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void shm_open_image(void) {
|
static void shm_open_image(void) {
|
||||||
g_use_shm = 0;
|
g_use_shm = 0;
|
||||||
if (!XShmQueryExtension(g_display)) return;
|
if (!XShmQueryExtension(g_display)) return;
|
||||||
@@ -66,9 +75,15 @@ static void shm_open_image(void) {
|
|||||||
if (g_shminfo.shmid == -1) return;
|
if (g_shminfo.shmid == -1) return;
|
||||||
g_shminfo.shmaddr = g_shm_image->data = (char *)shmat(g_shminfo.shmid, 0, 0);
|
g_shminfo.shmaddr = g_shm_image->data = (char *)shmat(g_shminfo.shmid, 0, 0);
|
||||||
g_shminfo.readOnly = False;
|
g_shminfo.readOnly = False;
|
||||||
if (g_shminfo.shmaddr != (char *)-1 && XShmAttach(g_display, &g_shminfo)) {
|
if (g_shminfo.shmaddr != (char *)-1) {
|
||||||
XSync(g_display, False);
|
XSync(g_display, False);
|
||||||
g_use_shm = 1;
|
g_shm_attach_failed = 0;
|
||||||
|
int (*previous)(Display *, XErrorEvent *) = XSetErrorHandler(shm_attach_error);
|
||||||
|
Status attached = XShmAttach(g_display, &g_shminfo);
|
||||||
|
XSync(g_display, False);
|
||||||
|
XSetErrorHandler(previous);
|
||||||
|
if (attached && !g_shm_attach_failed) g_use_shm = 1;
|
||||||
|
else fprintf(stderr, "X11 shared-memory capture unavailable; using XGetImage\n");
|
||||||
}
|
}
|
||||||
shmctl(g_shminfo.shmid, IPC_RMID, 0); // 标记删除,进程退出时自动回收;失败时也不遗留段
|
shmctl(g_shminfo.shmid, IPC_RMID, 0); // 标记删除,进程退出时自动回收;失败时也不遗留段
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
修复 X11 共享内存被拒时主机直接退出,以及 Linux 控制端加入已有会话时可能永久黑屏。/ Fixes the host exiting when X11 refuses shared memory, and a possible black screen when the Linux viewer joins a host that already streams to another session.
|
||||||
|
|
||||||
|
### 修复 / Fixed
|
||||||
|
- **X11 MIT-SHM 被拒时直接退出**:X 服务器无法访问本程序的共享内存段时(例如 X 服务器在另一个容器里),`XShmAttach` 返回 BadAccess,Xlib 默认错误处理直接结束了进程,原有的 `XGetImage` 退路没有机会执行。现在捕获该错误并改用 `XGetImage` 抓屏。
|
||||||
|
When `XShmAttach` is refused (BadAccess, e.g. an X server in another container), the host now falls back to `XGetImage` instead of being terminated by Xlib's default error handler.
|
||||||
|
- **控制端加入已有会话时黑屏(#124,感谢 @shao-zhijie)**:Linux 控制端过去只在丢包或解码出错时请求关键帧;加入一条已在推流的干净 H.264 流时永远等不到 IDR。现在首帧显示前每 30 个访问单元请求一次关键帧(PLI),300 个仍无画面时日志给出提示。
|
||||||
|
The Linux viewer now requests key frames (PLI) every 30 access units until the first frame is shown, and logs a warning after 300.
|
||||||
|
|
||||||
|
### 验证范围 / Validation
|
||||||
|
单元测试与 CI。共享内存退路尚待在报告环境实机确认;#124 中官方 Mac 主机是否响应 PLI 尚未实测。
|
||||||
|
|
||||||
|
### 下载 / Download
|
||||||
|
`uu-remote-linux_0.2.36_<amd64|arm64>.deb`,或 `uu-remote-linux-v0.2.36-<x86_64|aarch64>-linux.tar.gz`(解压后运行 `./install.sh`),或 `docker pull ghcr.io/vallierdev/uu-remote-linux:v0.2.36`(x86_64)。
|
||||||
|
|
||||||
|
**非官方项目,与网易无关。** / **Unofficial, not affiliated with NetEase.**
|
||||||
+11
-1
@@ -11,8 +11,14 @@ pub trait Decoder { fn set_codec(&mut self,codec:super::media::Codec)->Result<()
|
|||||||
pub trait FrameSink { fn present(&mut self,frame:&Frame)->Result<(),String>; }
|
pub trait FrameSink { fn present(&mut self,frame:&Frame)->Result<(),String>; }
|
||||||
/// Counts only (access units, presented frames, decode errors) for the periodic stats line.
|
/// Counts only (access units, presented frames, decode errors) for the periodic stats line.
|
||||||
pub static STATS:[std::sync::atomic::AtomicU64;3]=[std::sync::atomic::AtomicU64::new(0),std::sync::atomic::AtomicU64::new(0),std::sync::atomic::AtomicU64::new(0)];
|
pub static STATS:[std::sync::atomic::AtomicU64;3]=[std::sync::atomic::AtomicU64::new(0),std::sync::atomic::AtomicU64::new(0),std::sync::atomic::AtomicU64::new(0)];
|
||||||
|
fn wants_key_frame(units:u64,presented:u64)->bool {presented==0 && units%30==0}
|
||||||
pub fn display(decoder:&mut dyn Decoder,sink:&mut dyn FrameSink,au:&[u8],codec:super::media::Codec,pli:&AtomicBool)->Result<(),String> {
|
pub fn display(decoder:&mut dyn Decoder,sink:&mut dyn FrameSink,au:&[u8],codec:super::media::Codec,pli:&AtomicBool)->Result<(),String> {
|
||||||
STATS[0].fetch_add(1,Ordering::Relaxed);
|
let units=STATS[0].fetch_add(1,Ordering::Relaxed)+1;
|
||||||
|
// A later session can join a clean stream with no IDR in flight (#124): keep asking until a frame shows.
|
||||||
|
if wants_key_frame(units,STATS[1].load(Ordering::Relaxed)) {
|
||||||
|
pli.store(true,Ordering::Release);
|
||||||
|
if units==300 { log::warn!("Viewer desktop: no decodable frame after {units} access units; requesting key frames (another session may hold the host)"); }
|
||||||
|
}
|
||||||
// Local diagnostic: UU_VIEWER_DUMP_H264=path appends the first 300 access units (owner's own stream).
|
// Local diagnostic: UU_VIEWER_DUMP_H264=path appends the first 300 access units (owner's own stream).
|
||||||
if codec==super::media::Codec::H264 && STATS[0].load(Ordering::Relaxed)<=300 { if let Some(path)=std::env::var_os("UU_VIEWER_DUMP_H264") {
|
if codec==super::media::Codec::H264 && STATS[0].load(Ordering::Relaxed)<=300 { if let Some(path)=std::env::var_os("UU_VIEWER_DUMP_H264") {
|
||||||
use std::io::Write; if let Ok(mut f)=std::fs::OpenOptions::new().create(true).append(true).open(path){let _=f.write_all(au);}
|
use std::io::Write; if let Ok(mut f)=std::fs::OpenOptions::new().create(true).append(true).open(path){let _=f.write_all(au);}
|
||||||
@@ -32,5 +38,9 @@ pub fn display(decoder:&mut dyn Decoder,sink:&mut dyn FrameSink,au:&[u8],codec:s
|
|||||||
use super::*;
|
use super::*;
|
||||||
struct Mock(bool);impl Decoder for Mock {fn set_codec(&mut self,_:crate::viewer::media::Codec)->Result<(),String>{Ok(())} fn decode(&mut self,_:&[u8])->Result<Vec<Frame>,String>{if self.0{Err("synthetic".into())}else{Ok(vec![Frame{width:1,height:1,rgb:vec![0;3],content:None}])}} fn reset(&mut self){self.0=false;}}
|
struct Mock(bool);impl Decoder for Mock {fn set_codec(&mut self,_:crate::viewer::media::Codec)->Result<(),String>{Ok(())} fn decode(&mut self,_:&[u8])->Result<Vec<Frame>,String>{if self.0{Err("synthetic".into())}else{Ok(vec![Frame{width:1,height:1,rgb:vec![0;3],content:None}])}} fn reset(&mut self){self.0=false;}}
|
||||||
struct Sink(usize);impl FrameSink for Sink{fn present(&mut self,f:&Frame)->Result<(),String>{assert_eq!(f.rgb.len(),3);self.0+=1;Ok(())}}
|
struct Sink(usize);impl FrameSink for Sink{fn present(&mut self,f:&Frame)->Result<(),String>{assert_eq!(f.rgb.len(),3);self.0+=1;Ok(())}}
|
||||||
|
#[test] fn requests_key_frames_until_the_first_frame(){
|
||||||
|
assert_eq!((1..=90).filter(|&n|wants_key_frame(n,0)).count(),3);
|
||||||
|
assert!(!(1..=90).any(|n|wants_key_frame(n,1)));
|
||||||
|
}
|
||||||
#[test] fn decode_error_requests_pli_and_recovers(){let mut d=Mock(true);let mut s=Sink(0);let p=AtomicBool::new(false);display(&mut d,&mut s,&[],crate::viewer::media::Codec::H264,&p).unwrap();assert!(p.load(Ordering::Acquire));display(&mut d,&mut s,&[],crate::viewer::media::Codec::H264,&p).unwrap();assert_eq!(s.0,1);}
|
#[test] fn decode_error_requests_pli_and_recovers(){let mut d=Mock(true);let mut s=Sink(0);let p=AtomicBool::new(false);display(&mut d,&mut s,&[],crate::viewer::media::Codec::H264,&p).unwrap();assert!(p.load(Ordering::Acquire));display(&mut d,&mut s,&[],crate::viewer::media::Codec::H264,&p).unwrap();assert_eq!(s.0,1);}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user