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: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1189>
This commit is contained in:
Sebastian Dröge 2023-01-14 19:18:03 +02:00
parent dd284a80ea
commit 0a6ed3c717

View file

@ -53,6 +53,17 @@ pub struct ConsumptionLink {
} }
impl 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. /// Replace the producer by a new one, keeping the existing consumer.
pub fn change_producer( pub fn change_producer(
&mut self, &mut self,