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::{SignalHandlerId, connect_raw},
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 unsafe {
250 let f: &F = &*(f as *const F);
251 f(Aggregator::from_glib_borrow(this).unsafe_cast_ref())
252 }
253 }
254 unsafe {
255 let f: Box_<F> = Box_::new(f);
256 connect_raw(
257 self.as_ptr() as *mut _,
258 c"notify::emit-signals".as_ptr(),
259 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
260 notify_emit_signals_trampoline::<Self, F> as *const (),
261 )),
262 Box_::into_raw(f),
263 )
264 }
265 }
266
267 #[doc(alias = "latency")]
268 fn connect_latency_notify<F: Fn(&Self) + Send + Sync + 'static>(
269 &self,
270 f: F,
271 ) -> SignalHandlerId {
272 unsafe extern "C" fn notify_latency_trampoline<
273 P: IsA<Aggregator>,
274 F: Fn(&P) + Send + Sync + 'static,
275 >(
276 this: *mut ffi::GstAggregator,
277 _param_spec: glib::ffi::gpointer,
278 f: glib::ffi::gpointer,
279 ) {
280 unsafe {
281 let f: &F = &*(f as *const F);
282 f(Aggregator::from_glib_borrow(this).unsafe_cast_ref())
283 }
284 }
285 unsafe {
286 let f: Box_<F> = Box_::new(f);
287 connect_raw(
288 self.as_ptr() as *mut _,
289 c"notify::latency".as_ptr(),
290 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
291 notify_latency_trampoline::<Self, F> as *const (),
292 )),
293 Box_::into_raw(f),
294 )
295 }
296 }
297
298 #[doc(alias = "start-time")]
299 fn connect_start_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
300 &self,
301 f: F,
302 ) -> SignalHandlerId {
303 unsafe extern "C" fn notify_start_time_trampoline<
304 P: IsA<Aggregator>,
305 F: Fn(&P) + Send + Sync + 'static,
306 >(
307 this: *mut ffi::GstAggregator,
308 _param_spec: glib::ffi::gpointer,
309 f: glib::ffi::gpointer,
310 ) {
311 unsafe {
312 let f: &F = &*(f as *const F);
313 f(Aggregator::from_glib_borrow(this).unsafe_cast_ref())
314 }
315 }
316 unsafe {
317 let f: Box_<F> = Box_::new(f);
318 connect_raw(
319 self.as_ptr() as *mut _,
320 c"notify::start-time".as_ptr(),
321 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
322 notify_start_time_trampoline::<Self, F> as *const (),
323 )),
324 Box_::into_raw(f),
325 )
326 }
327 }
328
329 #[cfg(feature = "v1_18")]
330 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
331 #[doc(alias = "start-time-selection")]
332 fn connect_start_time_selection_notify<F: Fn(&Self) + Send + Sync + 'static>(
333 &self,
334 f: F,
335 ) -> SignalHandlerId {
336 unsafe extern "C" fn notify_start_time_selection_trampoline<
337 P: IsA<Aggregator>,
338 F: Fn(&P) + Send + Sync + 'static,
339 >(
340 this: *mut ffi::GstAggregator,
341 _param_spec: glib::ffi::gpointer,
342 f: glib::ffi::gpointer,
343 ) {
344 unsafe {
345 let f: &F = &*(f as *const F);
346 f(Aggregator::from_glib_borrow(this).unsafe_cast_ref())
347 }
348 }
349 unsafe {
350 let f: Box_<F> = Box_::new(f);
351 connect_raw(
352 self.as_ptr() as *mut _,
353 c"notify::start-time-selection".as_ptr(),
354 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
355 notify_start_time_selection_trampoline::<Self, F> as *const (),
356 )),
357 Box_::into_raw(f),
358 )
359 }
360 }
361}
362
363impl<O: IsA<Aggregator>> AggregatorExt for O {}