video update

This commit is contained in:
Brad Stein 2025-06-28 00:05:13 -05:00
parent 8da4f36dc3
commit 3000871947
5 changed files with 32 additions and 13 deletions

View File

@ -88,7 +88,12 @@ impl LesavkaClientApp {
let win1 = MonitorWindow::new(1, &el).expect("win1");
let _ = el.run(move |_: Event<()>, _| {
static CNT: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0);
while let Ok(pkt) = video_rx.try_recv() {
CNT.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
if CNT.load(std::sync::atomic::Ordering::Relaxed) % 300 == 0 {
tracing::debug!("🎥 received {} video packets", CNT.load(std::sync::atomic::Ordering::Relaxed));
}
match pkt.id {
0 => win0.push_packet(pkt),
1 => win1.push_packet(pkt),

View File

@ -29,7 +29,7 @@ impl MonitorWindow {
let window = el
.create_window(
WindowAttributes::default()
.with_title(format!("Lesavkamonitor{id}"))
.with_title(format!("Lesavka-eye-{id}"))
.with_decorations(true),
)?;
@ -39,15 +39,22 @@ impl MonitorWindow {
.field("alignment", &"au")
.build();
let pipeline = gst::parse::launch(DESC)?
.downcast::<gst::Pipeline>()
.expect("pipeline downcast");
// let pipeline = gst::parse::launch(DESC)?
// .downcast::<gst::Pipeline>()
// .expect("pipeline downcast");
let pipeline: gst::Pipeline = gst::parse::launch(DESC)?
.downcast()
.expect("pipeline");
let src = pipeline
.by_name("src")
.expect("appsrc element not found")
.downcast::<gst_app::AppSrc>()
.expect("appsrc downcast");
// let src = pipeline
// .by_name("src")
// .expect("appsrc element not found")
// .downcast::<gst_app::AppSrc>()
// .expect("appsrc downcast");
let src: gst_app::AppSrc = pipeline.by_name("src")
.expect("appsrc")
.downcast()
.expect("appsrc");
src.set_caps(Some(&caps));
src.set_format(gst::Format::Time); // downstream clock
@ -65,7 +72,11 @@ impl MonitorWindow {
pub fn push_packet(&self, pkt: VideoPacket) {
// Mutable so we can set the PTS:
let mut buf = gst::Buffer::from_slice(pkt.data);
if let Some(ref mut b) = buf.get_mut() {
// if let Some(ref mut b) = buf.get_mut() {
// b.set_pts(Some(gst::ClockTime::from_useconds(pkt.pts)));
// }
{
let b = buf.get_mut().unwrap();
b.set_pts(Some(gst::ClockTime::from_useconds(pkt.pts)));
}
let _ = self.src.push_buffer(buf); // ignore Eos / flushing

View File

@ -6,6 +6,7 @@ ORIG_USER=${SUDO_USER:-$(id -un)}
# 1. packages (Arch)
sudo pacman -Syq --needed --noconfirm git rustup protobuf gcc evtest gstreamer gst-plugins-base gst-plugins-good gst-plugins-bad gst-plugins-ugly gst-libav
yay -S --noconfirm grpcurl-bin
# 2. Rust tool-chain for both root & user
sudo rustup default stable

View File

@ -11,7 +11,7 @@ if ! command -v yay >/dev/null 2>&1; then
cd /tmp && git clone --depth 1 https://aur.archlinux.org/yay.git &&
cd yay && makepkg -si --noconfirm'
fi
yay -S --noconfirm grpcurl-bin
# yay -S --noconfirm grpcurl-bin
echo "==> 2a. Kerneldriver tweaks"
cat <<'EOF' | sudo tee /etc/modprobe.d/gc311-stream.conf >/dev/null
@ -105,7 +105,7 @@ After=network.target lesavka-core.service
[Service]
ExecStart=/usr/local/bin/lesavka-server
Restart=always
Environment=RUST_LOG=lesavka_server=debug,lesavka_server::video=trace,lesavka_server::usb_gadget=info
Environment=RUST_LOG=lesavka_server=info,lesavka_server::video=trace,lesavka_server::usb_gadget=info
Environment=RUST_BACKTRACE=1
Restart=always
RestartSec=5

View File

@ -50,7 +50,8 @@ pub async fn eye_ball(
std::sync::atomic::AtomicU64::new(0);
let n = FRAME.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
if n % 120 == 0 {
trace!("eye{id}: delivered {n} frames");
// trace!("eye{id}: delivered {n} frames");
trace!(target: "lesavka_server::video", "eye{id}: delivered {n} frames");
}
/* -------- map once, reuse ----- */
@ -58,6 +59,7 @@ pub async fn eye_ball(
// write first IDR to disk (quick sanity check)
if n == 0 {
// let map = buffer.map_readable().map_err(|_| gst::FlowError::Error)?;
std::fs::write(format!("/tmp/eye{id}-idr.h264"), map.as_slice()).ok();
}