1use crate::ffi;
7#[cfg(feature = "v1_18")]
8#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
9use crate::{AggregatorPad, AggregatorStartTimeSelection};
10use glib::{
11 prelude::*,
12 signal::{connect_raw, SignalHandlerId},
13 translate::*,
14};
15use std::boxed::Box as Box_;
16
17glib::wrapper! {
18 #[doc(alias = "GstAggregator")]
19 pub struct Aggregator(Object<ffi::GstAggregator, ffi::GstAggregatorClass>) @extends gst::Element, gst::Object;
20
21 match fn {
22 type_ => || ffi::gst_aggregator_get_type(),
23 }
24}
25
26impl Aggregator {
27 pub const NONE: Option<&'static Aggregator> = None;
28}
29
30unsafe impl Send for Aggregator {}
31unsafe impl Sync for Aggregator {}
32
33pub trait AggregatorExt: IsA<Aggregator> + 'static {
34 #[doc(alias = "gst_aggregator_finish_buffer")]
35 fn finish_buffer(&self, buffer: gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError> {
36 unsafe {
37 try_from_glib(ffi::gst_aggregator_finish_buffer(
38 self.as_ref().to_glib_none().0,
39 buffer.into_glib_ptr(),
40 ))
41 }
42 }
43
44 #[cfg(feature = "v1_18")]
45 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
46 #[doc(alias = "gst_aggregator_finish_buffer_list")]
47 fn finish_buffer_list(
48 &self,
49 bufferlist: gst::BufferList,
50 ) -> Result<gst::FlowSuccess, gst::FlowError> {
51 unsafe {
52 try_from_glib(ffi::gst_aggregator_finish_buffer_list(
53 self.as_ref().to_glib_none().0,
54 bufferlist.into_glib_ptr(),
55 ))
56 }
57 }
58
59 #[doc(alias = "gst_aggregator_get_buffer_pool")]
60 #[doc(alias = "get_buffer_pool")]
61 fn buffer_pool(&self) -> Option<gst::BufferPool> {
62 unsafe {
63 from_glib_full(ffi::gst_aggregator_get_buffer_pool(
64 self.as_ref().to_glib_none().0,
65 ))
66 }
67 }
68
69 #[cfg(feature = "v1_22")]
70 #[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))]
71 #[doc(alias = "gst_aggregator_get_force_live")]
72 #[doc(alias = "get_force_live")]
73 fn is_force_live(&self) -> bool {
74 unsafe {
75 from_glib(ffi::gst_aggregator_get_force_live(
76 self.as_ref().to_glib_none().0,
77 ))
78 }
79 }
80
81 #[cfg(feature = "v1_20")]
82 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
83 #[doc(alias = "gst_aggregator_get_ignore_inactive_pads")]
84 #[doc(alias = "get_ignore_inactive_pads")]
85 fn ignores_inactive_pads(&self) -> bool {
86 unsafe {
87 from_glib(ffi::gst_aggregator_get_ignore_inactive_pads(
88 self.as_ref().to_glib_none().0,
89 ))
90 }
91 }
92
93 #[doc(alias = "gst_aggregator_get_latency")]
94 #[doc(alias = "get_latency")]
95 fn latency(&self) -> Option<gst::ClockTime> {
96 unsafe {
97 from_glib(ffi::gst_aggregator_get_latency(
98 self.as_ref().to_glib_none().0,
99 ))
100 }
101 }
102
103 #[cfg(feature = "v1_18")]
104 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
105 #[doc(alias = "gst_aggregator_negotiate")]
106 fn negotiate(&self) -> bool {
107 unsafe {
108 from_glib(ffi::gst_aggregator_negotiate(
109 self.as_ref().to_glib_none().0,
110 ))
111 }
112 }
113
114 #[cfg(feature = "v1_18")]
115 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
116 #[doc(alias = "gst_aggregator_peek_next_sample")]
117 fn peek_next_sample(&self, pad: &impl IsA<AggregatorPad>) -> Option<gst::Sample> {
118 unsafe {
119 from_glib_full(ffi::gst_aggregator_peek_next_sample(
120 self.as_ref().to_glib_none().0,
121 pad.as_ref().to_glib_none().0,
122 ))
123 }
124 }
125
126 #[cfg(feature = "v1_26")]
127 #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))]
128 #[doc(alias = "gst_aggregator_push_src_event")]
129 fn push_src_event(&self, event: gst::Event) -> bool {
130 unsafe {
131 from_glib(ffi::gst_aggregator_push_src_event(
132 self.as_ref().to_glib_none().0,
133 event.into_glib_ptr(),
134 ))
135 }
136 }
137
138 #[cfg(feature = "v1_22")]
139 #[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))]
140 #[doc(alias = "gst_aggregator_set_force_live")]
141 fn set_force_live(&self, force_live: bool) {
142 unsafe {
143 ffi::gst_aggregator_set_force_live(
144 self.as_ref().to_glib_none().0,
145 force_live.into_glib(),
146 );
147 }
148 }
149
150 #[cfg(feature = "v1_20")]
151 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
152 #[doc(alias = "gst_aggregator_set_ignore_inactive_pads")]
153 fn set_ignore_inactive_pads(&self, ignore: bool) {
154 unsafe {
155 ffi::gst_aggregator_set_ignore_inactive_pads(
156 self.as_ref().to_glib_none().0,
157 ignore.into_glib(),
158 );
159 }
160 }
161
162 #[doc(alias = "gst_aggregator_set_latency")]
163 #[doc(alias = "latency")]
164 fn set_latency(
165 &self,
166 min_latency: gst::ClockTime,
167 max_latency: impl Into<Option<gst::ClockTime>>,
168 ) {
169 unsafe {
170 ffi::gst_aggregator_set_latency(
171 self.as_ref().to_glib_none().0,
172 min_latency.into_glib(),
173 max_latency.into().into_glib(),
174 );
175 }
176 }
177
178 #[doc(alias = "gst_aggregator_set_src_caps")]
179 fn set_src_caps(&self, caps: &gst::Caps) {
180 unsafe {
181 ffi::gst_aggregator_set_src_caps(self.as_ref().to_glib_none().0, caps.to_glib_none().0);
182 }
183 }
184
185 #[cfg(feature = "v1_16")]
186 #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
187 #[doc(alias = "gst_aggregator_simple_get_next_time")]
188 fn simple_get_next_time(&self) -> Option<gst::ClockTime> {
189 unsafe {
190 from_glib(ffi::gst_aggregator_simple_get_next_time(
191 self.as_ref().to_glib_none().0,
192 ))
193 }
194 }
195
196 #[cfg(feature = "v1_18")]
197 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
198 #[doc(alias = "emit-signals")]
199 fn emits_signals(&self) -> bool {
200 ObjectExt::property(self.as_ref(), "emit-signals")
201 }
202
203 #[cfg(feature = "v1_18")]
204 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
205 #[doc(alias = "emit-signals")]
206 fn set_emit_signals(&self, emit_signals: bool) {
207 ObjectExt::set_property(self.as_ref(), "emit-signals", emit_signals)
208 }
209
210 #[doc(alias = "start-time")]
211 fn start_time(&self) -> u64 {
212 ObjectExt::property(self.as_ref(), "start-time")
213 }
214
215 #[doc(alias = "start-time")]
216 fn set_start_time(&self, start_time: u64) {
217 ObjectExt::set_property(self.as_ref(), "start-time", start_time)
218 }
219
220 #[cfg(feature = "v1_18")]
221 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
222 #[doc(alias = "start-time-selection")]
223 fn start_time_selection(&self) -> AggregatorStartTimeSelection {
224 ObjectExt::property(self.as_ref(), "start-time-selection")
225 }
226
227 #[cfg(feature = "v1_18")]
228 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
229 #[doc(alias = "start-time-selection")]
230 fn set_start_time_selection(&self, start_time_selection: AggregatorStartTimeSelection) {
231 ObjectExt::set_property(self.as_ref(), "start-time-selection", start_time_selection)
232 }
233
234 #[cfg(feature = "v1_18")]
235 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
236 #[doc(alias = "emit-signals")]
237 fn connect_emit_signals_notify<F: Fn(&Self) + Send + Sync + 'static>(
238 &self,
239 f: F,
240 ) -> SignalHandlerId {
241 unsafe extern "C" fn notify_emit_signals_trampoline<
242 P: IsA<Aggregator>,
243 F: Fn(&P) + Send + Sync + 'static,
244 >(
245 this: *mut ffi::GstAggregator,
246 _param_spec: glib::ffi::gpointer,
247 f: glib::ffi::gpointer,
248 ) {
249 let f: &F = &*(f as *const F);
250 f(Aggregator::from_glib_borrow(this).unsafe_cast_ref())
251 }
252 unsafe {
253 let f: Box_<F> = Box_::new(f);
254 connect_raw(
255 self.as_ptr() as *mut _,
256 c"notify::emit-signals".as_ptr() as *const _,
257 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
258 notify_emit_signals_trampoline::<Self, F> as *const (),
259 )),
260 Box_::into_raw(f),
261 )
262 }
263 }
264
265 #[doc(alias = "latency")]
266 fn connect_latency_notify<F: Fn(&Self) + Send + Sync + 'static>(
267 &self,
268 f: F,
269 ) -> SignalHandlerId {
270 unsafe extern "C" fn notify_latency_trampoline<
271 P: IsA<Aggregator>,
272 F: Fn(&P) + Send + Sync + 'static,
273 >(
274 this: *mut ffi::GstAggregator,
275 _param_spec: glib::ffi::gpointer,
276 f: glib::ffi::gpointer,
277 ) {
278 let f: &F = &*(f as *const F);
279 f(Aggregator::from_glib_borrow(this).unsafe_cast_ref())
280 }
281 unsafe {
282 let f: Box_<F> = Box_::new(f);
283 connect_raw(
284 self.as_ptr() as *mut _,
285 c"notify::latency".as_ptr() as *const _,
286 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
287 notify_latency_trampoline::<Self, F> as *const (),
288 )),
289 Box_::into_raw(f),
290 )
291 }
292 }
293
294 #[doc(alias = "start-time")]
295 fn connect_start_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
296 &self,
297 f: F,
298 ) -> SignalHandlerId {
299 unsafe extern "C" fn notify_start_time_trampoline<
300 P: IsA<Aggregator>,
301 F: Fn(&P) + Send + Sync + 'static,
302 >(
303 this: *mut ffi::GstAggregator,
304 _param_spec: glib::ffi::gpointer,
305 f: glib::ffi::gpointer,
306 ) {
307 let f: &F = &*(f as *const F);
308 f(Aggregator::from_glib_borrow(this).unsafe_cast_ref())
309 }
310 unsafe {
311 let f: Box_<F> = Box_::new(f);
312 connect_raw(
313 self.as_ptr() as *mut _,
314 c"notify::start-time".as_ptr() as *const _,
315 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
316 notify_start_time_trampoline::<Self, F> as *const (),
317 )),
318 Box_::into_raw(f),
319 )
320 }
321 }
322
323 #[cfg(feature = "v1_18")]
324 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
325 #[doc(alias = "start-time-selection")]
326 fn connect_start_time_selection_notify<F: Fn(&Self) + Send + Sync + 'static>(
327 &self,
328 f: F,
329 ) -> SignalHandlerId {
330 unsafe extern "C" fn notify_start_time_selection_trampoline<
331 P: IsA<Aggregator>,
332 F: Fn(&P) + Send + Sync + 'static,
333 >(
334 this: *mut ffi::GstAggregator,
335 _param_spec: glib::ffi::gpointer,
336 f: glib::ffi::gpointer,
337 ) {
338 let f: &F = &*(f as *const F);
339 f(Aggregator::from_glib_borrow(this).unsafe_cast_ref())
340 }
341 unsafe {
342 let f: Box_<F> = Box_::new(f);
343 connect_raw(
344 self.as_ptr() as *mut _,
345 c"notify::start-time-selection".as_ptr() as *const _,
346 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
347 notify_start_time_selection_trampoline::<Self, F> as *const (),
348 )),
349 Box_::into_raw(f),
350 )
351 }
352 }
353}
354
355impl<O: IsA<Aggregator>> AggregatorExt for O {}