From b9969f746ce7d1155b6d97ad97cb604f2a90d109 Mon Sep 17 00:00:00 2001 From: Nickiel12 <35903114+Nickiel12@users.noreply.github.com> Date: Mon, 3 Jun 2024 11:09:31 -0700 Subject: [PATCH] removed queue from appsink --- src/gstreamer_pipeline.rs | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/gstreamer_pipeline.rs b/src/gstreamer_pipeline.rs index ab37ee5..3dd7442 100644 --- a/src/gstreamer_pipeline.rs +++ b/src/gstreamer_pipeline.rs @@ -16,7 +16,6 @@ pub struct WebcamPipeline { pub queue_app: Element, pub sink_paintable: Element, - pub queue: Element, pub resize: Element, pub sink_frame: Arc>, } @@ -47,9 +46,14 @@ impl WebcamPipeline { .build() .context(BuildSnafu { element: "tee" })?; - let queue_app = ElementFactory::make("queue").build().context(BuildSnafu { - element: "paintable queue", - })?; + let queue_app = ElementFactory::make("queue") + .property("max-size-time", 1u64) + .property("max-size-buffers", 0u32) + .property("max-size-bytes", 0u32) + .build() + .context(BuildSnafu { + element: "paintable queue", + })?; let sink_paintable = ElementFactory::make("gtk4paintablesink") .name("gtk4_output") .build() @@ -57,9 +61,9 @@ impl WebcamPipeline { element: "gtkpaintablesink", })?; - let queue = ElementFactory::make("queue").build().context(BuildSnafu { - element: "appsink queue", - })?; + // queue.connect_closure("overrun", false, glib::closure!(|queue: Element| { + // println!("The queue is full!"); + // })); let resize = ElementFactory::make("videoscale") .build() @@ -67,7 +71,7 @@ impl WebcamPipeline { element: "videoscale", })?; - let caps_string = "video/x-raw,format=RGB,width=640,height=480,max-buffers=1,drop=true"; + let caps_string = "video/x-raw,format=RGB,width=640,height=480"; // let caps_string = String::from("video/x-raw,format=RGB,max-buffers=1,drop=true"); let appsrc_caps = gstreamer::Caps::from_str(caps_string).context(BuildSnafu { element: "appsink caps", @@ -76,7 +80,7 @@ impl WebcamPipeline { let sink_frame = AppSink::builder() .name("frame_output") .sync(false) - .max_buffers(1u32) + .max_buffers(3u32) .drop(true) .caps(&appsrc_caps) .build(); @@ -92,7 +96,6 @@ impl WebcamPipeline { &queue_app, &sink_paintable, &resize, - &queue, &sink_frame.upcast_ref(), ]) .context(LinkSnafu { @@ -147,23 +150,19 @@ impl WebcamPipeline { .ok_or(PipelineError::PadRequestError { element: "tee pad 2".to_string(), })?; - let appsink_queue_sinkpad = - queue + let appsink_resize_sinkpad = + resize .static_pad("sink") .ok_or(PipelineError::PadRequestError { element: "appsink queue".to_string(), })?; tee_src_2 - .link(&appsink_queue_sinkpad) + .link(&appsink_resize_sinkpad) .context(PadLinkSnafu { from: "tee src pad 2", to: "appsink queue sinkpad", })?; - queue.link(&resize).context(LinkSnafu { - from: "appsink queue", - to: "videoscale", - })?; resize.link(&sink_frame).context(LinkSnafu { from: "videoscale", to: "appsink", @@ -177,7 +176,6 @@ impl WebcamPipeline { queue_app, sink_paintable, resize, - queue, sink_frame: Arc::new(Mutex::new(sink_frame)), }) }