From 14dadf4c6267e0afb8f31145f7502c1be4486ad3 Mon Sep 17 00:00:00 2001 From: Jimmi Holst Christensen Date: Wed, 24 Nov 2021 10:44:04 +0100 Subject: [PATCH] aggregator: Implement set_position --- gstreamer-base/src/aggregator.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/gstreamer-base/src/aggregator.rs b/gstreamer-base/src/aggregator.rs index db6a37caa..9204713a5 100644 --- a/gstreamer-base/src/aggregator.rs +++ b/gstreamer-base/src/aggregator.rs @@ -6,6 +6,7 @@ use glib::prelude::*; #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))] use glib::signal::{connect_raw, SignalHandlerId}; use glib::translate::*; +use gst::FormattedValue; #[cfg(any(feature = "v1_16", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))] use std::boxed::Box as Box_; @@ -54,6 +55,8 @@ pub trait AggregatorExtManual: 'static { #[doc(alias = "gst_aggregator_update_segment")] fn update_segment(&self, segment: &gst::FormattedSegment); + fn set_position(&self, position: V); + #[cfg(any(feature = "v1_18", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))] #[doc(alias = "gst_aggregator_selected_samples")] @@ -165,6 +168,21 @@ impl> AggregatorExtManual for O { } } + fn set_position(&self, position: V) { + unsafe { + let ptr: *mut ffi::GstAggregator = self.as_ref().to_glib_none().0; + let ptr = &mut *ptr; + let _guard = crate::utils::MutexGuard::lock(&ptr.parent.object.lock); + + // gstaggregator.c asserts that the src pad is always of type GST_TYPE_AGGREGATOR_PAD, + // so the pointer cast here should be safe. + let srcpad = &mut *(ptr.srcpad as *mut ffi::GstAggregatorPad); + + assert_eq!(srcpad.segment.format, position.format().into_glib()); + srcpad.segment.position = position.into_raw_value() as u64; + } + } + #[cfg(any(feature = "v1_18", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))] fn selected_samples(