From 45987c7ff54826b7c6a699103507999a5c45651b Mon Sep 17 00:00:00 2001 From: Brad Stein Date: Wed, 25 Jun 2025 12:31:48 -0500 Subject: [PATCH] updates --- client/src/app.rs | 2 +- client/src/output/video.rs | 4 ++-- scripts/install-server.sh | 12 ------------ server/src/main.rs | 32 +++++++++++++++++++------------- 4 files changed, 22 insertions(+), 28 deletions(-) diff --git a/client/src/app.rs b/client/src/app.rs index fce197f..dca81e7 100644 --- a/client/src/app.rs +++ b/client/src/app.rs @@ -10,7 +10,7 @@ use tonic::Request; use tracing::{debug, error, info, warn}; use winit::{ event_loop::EventLoopBuilder, - platform::x11::EventLoopBuilderExtX11, + // platform::x11::EventLoopBuilderExtX11, platform::wayland::EventLoopBuilderExtWayland, event::Event, }; diff --git a/client/src/output/video.rs b/client/src/output/video.rs index 9daf19b..639083c 100644 --- a/client/src/output/video.rs +++ b/client/src/output/video.rs @@ -26,8 +26,8 @@ impl MonitorWindow { // appsrc -> decode -> convert -> waylandsink let desc = "appsrc name=src is-live=true format=time do-timestamp=true ! \ - queue ! h264parse ! avdec_h264 ! videoconvert ! \ - waylandsink name=sink sync=false"; + queue ! h264parse ! decodebin ! videoconvert ! \ + waylandsink name=sink sync=false"; let pipeline = gst::parse::launch(desc)? .downcast::() diff --git a/scripts/install-server.sh b/scripts/install-server.sh index 380ed58..243113e 100755 --- a/scripts/install-server.sh +++ b/scripts/install-server.sh @@ -18,18 +18,6 @@ options uvcvideo quirks=0x200 timeout=10000 EOF echo "==> 2b. Predictable /dev names for each capture card" -# sudo tee /etc/udev/rules.d/85-gc311.rules >/dev/null <<'RULES' -# # RIGHT eye (video index 0) -# SUBSYSTEM=="video4linux", ATTRS{idVendor}=="07ca", ATTRS{idProduct}=="3311", \ -# ATTRS{serial}=="5313550401897", ATTR{index}=="0", \ -# SYMLINK+="lesavka_r_eye" - -# # LEFT eye (video index 0) -# SUBSYSTEM=="video4linux", ATTRS{idVendor}=="07ca", ATTRS{idProduct}=="3311", \ -# ATTRS{serial}=="1200655409098", ATTR{index}=="0", \ -# SYMLINK+="lesavka_l_eye" -# RULES - # probe all v4l2 devices, keep only the two GC311 capture cards mapfile -t GC_VIDEOS < <( sudo v4l2-ctl --list-devices | diff --git a/server/src/main.rs b/server/src/main.rs index eb1461c..2d9ea76 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -81,6 +81,7 @@ struct Handler { impl Handler { async fn make(gadget: UsbGadget) -> anyhow::Result { + gadget.cycle().ok(); let kb = OpenOptions::new().write(true).open("/dev/hidg0").await?; let ms = OpenOptions::new().write(true) .custom_flags(libc::O_NONBLOCK) @@ -101,7 +102,7 @@ impl Relay for Handler { &self, req: Request>, ) -> Result, Status> { - self.gadget.cycle().map_err(|e| Status::internal(e.to_string()))?; + // self.gadget.cycle().map_err(|e| Status::internal(e.to_string()))?; let (tx, rx) = tokio::sync::mpsc::channel(32); let kb = self.kb.clone(); @@ -155,17 +156,24 @@ impl Relay for Handler { ) -> Result, Status> { let r = req.into_inner(); - let devs = loop { - let list = list_gc311_devices() - .map_err(|e| Status::internal(format!("enum v4l2: {e}")))?; - if !list.is_empty() { break list; } - tokio::time::sleep(Duration::from_secs(1)).await; - }; + // let devs = loop { + // let list = list_gc311_devices() + // .map_err(|e| Status::internal(format!("enum v4l2: {e}")))?; + // if !list.is_empty() { break list; } + // tokio::time::sleep(Duration::from_secs(1)).await; + // }; - let dev = devs - .get(r.id as usize) - .ok_or_else(|| Status::invalid_argument(format!("monitor id {} absent", r.id)))? - .to_owned(); + // let dev = devs + // .get(r.id as usize) + // .ok_or_else(|| Status::invalid_argument(format!("monitor id {} absent", r.id)))? + // .to_owned(); + + let dev = match r.id { + 0 => "/dev/lesavka_l_eye", + 1 => "/dev/lesavka_r_eye", + _ => return Err(Status::invalid_argument("monitor id must be 0 or 1")), + } + .to_string(); info!("🎥 streaming {dev} at ≤{} kb/s", r.max_bitrate); @@ -191,8 +199,6 @@ async fn main() -> anyhow::Result<()> { // tokio::spawn(async { monitor_gc311_disconnect().await.ok(); }); let gadget = UsbGadget::new("lesavka"); - gadget.cycle().ok(); - let handler = Handler::make(gadget.clone()).await?; // tokio::spawn({