From 0a6ed3c717fe996edf8e2044b6ca9aec0d9a904a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sat, 14 Jan 2023 19:18:03 +0200 Subject: [PATCH] utils: streamproducer: Add new `ConsumptionLink::disconnected()` constructor This allows constructing a new consumption link from an `appsrc` without having it connected from the very beginning. Part-of: --- gstreamer-utils/src/streamproducer.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gstreamer-utils/src/streamproducer.rs b/gstreamer-utils/src/streamproducer.rs index 4301c102b..5e648029d 100644 --- a/gstreamer-utils/src/streamproducer.rs +++ b/gstreamer-utils/src/streamproducer.rs @@ -53,6 +53,17 @@ pub struct ConsumptionLink { } impl ConsumptionLink { + /// Create a new disconnected `ConsumptionLink`. + pub fn disconnected(consumer: gst_app::AppSrc) -> ConsumptionLink { + ConsumptionLink { + consumer, + producer: None, + dropped: Arc::new(atomic::AtomicU64::new(0)), + pushed: Arc::new(atomic::AtomicU64::new(0)), + discard: Arc::new(atomic::AtomicBool::new(false)), + } + } + /// Replace the producer by a new one, keeping the existing consumer. pub fn change_producer( &mut self,