From 246febcc80226db290d4d1fd9505c7dbd00fa33b Mon Sep 17 00:00:00 2001 From: Mitchell R Date: Sun, 10 May 2026 20:51:29 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20filter=20rtspsrc=20pads=20=E2=80=94=20on?= =?UTF-8?q?ly=20link=20video=20to=20decodebin,=20skip=20audio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kiosk/src/pipeline.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/kiosk/src/pipeline.rs b/kiosk/src/pipeline.rs index 1e4a197..b53a58e 100644 --- a/kiosk/src/pipeline.rs +++ b/kiosk/src/pipeline.rs @@ -38,12 +38,22 @@ pub fn create_camera_pipeline(name: &str, rtsp_uri: &str) -> Option<(Pipeline, E let decode_weak = decode.downgrade(); let pn = pipeline_name.clone(); src.connect_pad_added(move |_src, pad| { - info!("[{pn}] rtspsrc pad added: {}", pad.name()); + let name = pad.name().to_string(); + info!("[{pn}] rtspsrc pad added: {name}"); + + // Only link video pads — check caps for application/x-rtp with video media + let caps = pad.current_caps().unwrap_or_else(|| pad.query_caps(None)); + let caps_str = caps.to_string(); + if !caps_str.contains("media=(string)video") && !caps_str.contains("encoding-name=(string)H26") { + info!("[{pn}] skipping non-video pad: {caps_str}"); + return; + } + let Some(decode) = decode_weak.upgrade() else { return }; let sink_pad = decode.static_pad("sink").unwrap(); if !sink_pad.is_linked() { match pad.link(&sink_pad) { - Ok(_) => info!("[{pn}] rtspsrc→decodebin linked"), + Ok(_) => info!("[{pn}] rtspsrc→decodebin linked (video)"), Err(e) => error!("[{pn}] rtspsrc→decodebin link failed: {e:?}"), } } @@ -76,7 +86,7 @@ pub fn create_camera_pipeline(name: &str, rtsp_uri: &str) -> Option<(Pipeline, E // Watch bus for errors let pn3 = pipeline_name.clone(); let bus = pipeline.bus().unwrap(); - bus.add_watch_local(move |_bus, msg| { + let _guard = bus.add_watch_local(move |_bus, msg| { use gst::MessageView; match msg.view() { MessageView::Error(err) => { @@ -96,6 +106,9 @@ pub fn create_camera_pipeline(name: &str, rtsp_uri: &str) -> Option<(Pipeline, E }) .ok()?; + // Leak the guard so it lives as long as the pipeline + std::mem::forget(_guard); + info!("[{pipeline_name}] pipeline created for {rtsp_uri}"); Some((pipeline, sink)) }