mirror of
https://github.com/VallierDev/uu-remote-linux.git
synced 2026-11-16 08:50:40 +01:00
* Add the experimental native viewer (uuremote-viewer) A Linux viewer/controller for UU Remote hosts, built separately with --features native-viewer,viewer-sdl; the host build and behaviour are unchanged. - Cloud join by device and remote assistance by share ID + code (code via stdin only), WebRTC offer side, SDL desktop window with ffmpeg CLI H.264 decoding, Opus sound, keyboard/mouse, view-only mode, text clipboard on TEXT_DATA_CHANNEL. - Tools: file browser/transfer (zero- and one-based download blocks), terminal and terminal session list, port mapping (127.0.0.1 only), reboot/shutdown; tools reuse the desktop peer while one is open. - GTK launcher with device list and tool windows. - CI builds and tests the viewer; release tarballs include it. Logs carry field numbers, sizes and states only. Co-Authored-By: Claude Opus 5.5 <[email protected]> * ci: install the ffmpeg CLI for the viewer audio tests Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: VallierDev <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
37 lines
2.1 KiB
Rust
37 lines
2.1 KiB
Rust
//! Uses the same optional FFmpeg dependency as the host inproc-av feature.
|
|
use super::desktop::{Decoder,Frame};
|
|
use ffmpeg_next as av;
|
|
pub struct Ffmpeg { decoder:av::decoder::Video }
|
|
impl Ffmpeg {
|
|
pub fn new()->Result<Self,String> {
|
|
av::init().map_err(|_|"FFmpeg initialization failed")?;
|
|
// Library diagnostics can contain bitstream data; suppress them globally in this viewer process.
|
|
av::log::set_level(av::log::Level::Quiet);
|
|
let codec=av::decoder::find(av::codec::Id::H264).ok_or("H264 decoder unavailable")?;
|
|
let decoder=av::codec::context::Context::new().decoder().open_as(codec).and_then(|d|d.video()).map_err(|_|"H264 decoder initialization failed")?;
|
|
Ok(Self{decoder})
|
|
}
|
|
}
|
|
impl Decoder for Ffmpeg {
|
|
fn reset(&mut self){self.decoder.flush();}
|
|
fn decode(&mut self,au:&[u8])->Result<Vec<Frame>,String>{
|
|
self.decoder.send_packet(&av::Packet::copy(au)).map_err(|_|"H264 packet rejected")?;
|
|
let mut frames=Vec::new();let mut decoded=av::frame::Video::empty();
|
|
loop {
|
|
match self.decoder.receive_frame(&mut decoded) {
|
|
Ok(())=>{},
|
|
Err(av::Error::Other{errno}) if errno==libc::EAGAIN=>break,
|
|
Err(_)=>return Err("H264 decode failed".into()),
|
|
}
|
|
if decoded.is_corrupt(){return Err("Corrupt H264 frame".into())}
|
|
let (w,h)=(decoded.width(),decoded.height());
|
|
if w==0 || h==0 || w>8192 || h>8192 {return Err("Decoded dimensions exceed limit".into())}
|
|
let mut scaler=av::software::scaling::context::Context::get(decoded.format(),w,h,av::format::Pixel::RGB24,w,h,av::software::scaling::flag::Flags::BILINEAR).map_err(|_|"Frame conversion unavailable")?;
|
|
let mut rgb=av::frame::Video::empty();scaler.run(&decoded,&mut rgb).map_err(|_|"Frame conversion failed")?;
|
|
let mut data=Vec::with_capacity(w as usize*h as usize*3);
|
|
for row in 0..h as usize {let start=row*rgb.stride(0);data.extend_from_slice(&rgb.data(0)[start..start+w as usize*3]);}
|
|
frames.push(Frame{width:w,height:h,rgb:data});
|
|
} Ok(frames)
|
|
}
|
|
}
|