removed queue from appsink

This commit is contained in:
Nickiel12 2024-06-03 11:09:31 -07:00
parent e9a125500e
commit b9969f746c

View file

@ -16,7 +16,6 @@ pub struct WebcamPipeline {
pub queue_app: Element, pub queue_app: Element,
pub sink_paintable: Element, pub sink_paintable: Element,
pub queue: Element,
pub resize: Element, pub resize: Element,
pub sink_frame: Arc<Mutex<AppSink>>, pub sink_frame: Arc<Mutex<AppSink>>,
} }
@ -47,9 +46,14 @@ impl WebcamPipeline {
.build() .build()
.context(BuildSnafu { element: "tee" })?; .context(BuildSnafu { element: "tee" })?;
let queue_app = ElementFactory::make("queue").build().context(BuildSnafu { let queue_app = ElementFactory::make("queue")
element: "paintable 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") let sink_paintable = ElementFactory::make("gtk4paintablesink")
.name("gtk4_output") .name("gtk4_output")
.build() .build()
@ -57,9 +61,9 @@ impl WebcamPipeline {
element: "gtkpaintablesink", element: "gtkpaintablesink",
})?; })?;
let queue = ElementFactory::make("queue").build().context(BuildSnafu { // queue.connect_closure("overrun", false, glib::closure!(|queue: Element| {
element: "appsink queue", // println!("The queue is full!");
})?; // }));
let resize = ElementFactory::make("videoscale") let resize = ElementFactory::make("videoscale")
.build() .build()
@ -67,7 +71,7 @@ impl WebcamPipeline {
element: "videoscale", 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 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 { let appsrc_caps = gstreamer::Caps::from_str(caps_string).context(BuildSnafu {
element: "appsink caps", element: "appsink caps",
@ -76,7 +80,7 @@ impl WebcamPipeline {
let sink_frame = AppSink::builder() let sink_frame = AppSink::builder()
.name("frame_output") .name("frame_output")
.sync(false) .sync(false)
.max_buffers(1u32) .max_buffers(3u32)
.drop(true) .drop(true)
.caps(&appsrc_caps) .caps(&appsrc_caps)
.build(); .build();
@ -92,7 +96,6 @@ impl WebcamPipeline {
&queue_app, &queue_app,
&sink_paintable, &sink_paintable,
&resize, &resize,
&queue,
&sink_frame.upcast_ref(), &sink_frame.upcast_ref(),
]) ])
.context(LinkSnafu { .context(LinkSnafu {
@ -147,23 +150,19 @@ impl WebcamPipeline {
.ok_or(PipelineError::PadRequestError { .ok_or(PipelineError::PadRequestError {
element: "tee pad 2".to_string(), element: "tee pad 2".to_string(),
})?; })?;
let appsink_queue_sinkpad = let appsink_resize_sinkpad =
queue resize
.static_pad("sink") .static_pad("sink")
.ok_or(PipelineError::PadRequestError { .ok_or(PipelineError::PadRequestError {
element: "appsink queue".to_string(), element: "appsink queue".to_string(),
})?; })?;
tee_src_2 tee_src_2
.link(&appsink_queue_sinkpad) .link(&appsink_resize_sinkpad)
.context(PadLinkSnafu { .context(PadLinkSnafu {
from: "tee src pad 2", from: "tee src pad 2",
to: "appsink queue sinkpad", to: "appsink queue sinkpad",
})?; })?;
queue.link(&resize).context(LinkSnafu {
from: "appsink queue",
to: "videoscale",
})?;
resize.link(&sink_frame).context(LinkSnafu { resize.link(&sink_frame).context(LinkSnafu {
from: "videoscale", from: "videoscale",
to: "appsink", to: "appsink",
@ -177,7 +176,6 @@ impl WebcamPipeline {
queue_app, queue_app,
sink_paintable, sink_paintable,
resize, resize,
queue,
sink_frame: Arc::new(Mutex::new(sink_frame)), sink_frame: Arc::new(Mutex::new(sink_frame)),
}) })
} }