1use crate::ffi;
7use glib::{
8 object::ObjectType as _,
9 prelude::*,
10 signal::{connect_raw, SignalHandlerId},
11 translate::*,
12};
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16 #[doc(alias = "GstAggregatorPad")]
116 pub struct AggregatorPad(Object<ffi::GstAggregatorPad, ffi::GstAggregatorPadClass>) @extends gst::Pad, gst::Object;
117
118 match fn {
119 type_ => || ffi::gst_aggregator_pad_get_type(),
120 }
121}
122
123impl AggregatorPad {
124 pub const NONE: Option<&'static AggregatorPad> = None;
125}
126
127unsafe impl Send for AggregatorPad {}
128unsafe impl Sync for AggregatorPad {}
129
130pub trait AggregatorPadExt: IsA<AggregatorPad> + 'static {
136 #[doc(alias = "gst_aggregator_pad_drop_buffer")]
142 fn drop_buffer(&self) -> bool {
143 unsafe {
144 from_glib(ffi::gst_aggregator_pad_drop_buffer(
145 self.as_ref().to_glib_none().0,
146 ))
147 }
148 }
149
150 #[cfg(feature = "v1_14_1")]
158 #[cfg_attr(docsrs, doc(cfg(feature = "v1_14_1")))]
159 #[doc(alias = "gst_aggregator_pad_has_buffer")]
160 fn has_buffer(&self) -> bool {
161 unsafe {
162 from_glib(ffi::gst_aggregator_pad_has_buffer(
163 self.as_ref().to_glib_none().0,
164 ))
165 }
166 }
167
168 #[doc(alias = "gst_aggregator_pad_is_eos")]
173 fn is_eos(&self) -> bool {
174 unsafe {
175 from_glib(ffi::gst_aggregator_pad_is_eos(
176 self.as_ref().to_glib_none().0,
177 ))
178 }
179 }
180
181 #[cfg(feature = "v1_20")]
188 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
189 #[doc(alias = "gst_aggregator_pad_is_inactive")]
190 fn is_inactive(&self) -> bool {
191 unsafe {
192 from_glib(ffi::gst_aggregator_pad_is_inactive(
193 self.as_ref().to_glib_none().0,
194 ))
195 }
196 }
197
198 #[doc(alias = "gst_aggregator_pad_peek_buffer")]
205 fn peek_buffer(&self) -> Option<gst::Buffer> {
206 unsafe {
207 from_glib_full(ffi::gst_aggregator_pad_peek_buffer(
208 self.as_ref().to_glib_none().0,
209 ))
210 }
211 }
212
213 #[doc(alias = "gst_aggregator_pad_pop_buffer")]
220 fn pop_buffer(&self) -> Option<gst::Buffer> {
221 unsafe {
222 from_glib_full(ffi::gst_aggregator_pad_pop_buffer(
223 self.as_ref().to_glib_none().0,
224 ))
225 }
226 }
227
228 #[cfg(feature = "v1_28")]
230 #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
231 #[doc(alias = "current-level-buffers")]
232 fn current_level_buffers(&self) -> u64 {
233 ObjectExt::property(self.as_ref(), "current-level-buffers")
234 }
235
236 #[cfg(feature = "v1_28")]
238 #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
239 #[doc(alias = "current-level-bytes")]
240 fn current_level_bytes(&self) -> u64 {
241 ObjectExt::property(self.as_ref(), "current-level-bytes")
242 }
243
244 #[cfg(feature = "v1_16")]
246 #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
247 #[doc(alias = "emit-signals")]
248 fn emits_signals(&self) -> bool {
249 ObjectExt::property(self.as_ref(), "emit-signals")
250 }
251
252 #[cfg(feature = "v1_16")]
254 #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
255 #[doc(alias = "emit-signals")]
256 fn set_emit_signals(&self, emit_signals: bool) {
257 ObjectExt::set_property(self.as_ref(), "emit-signals", emit_signals)
258 }
259
260 #[doc(alias = "buffer-consumed")]
261 fn connect_buffer_consumed<F: Fn(&Self, &gst::Buffer) + Send + Sync + 'static>(
262 &self,
263 f: F,
264 ) -> SignalHandlerId {
265 unsafe extern "C" fn buffer_consumed_trampoline<
266 P: IsA<AggregatorPad>,
267 F: Fn(&P, &gst::Buffer) + Send + Sync + 'static,
268 >(
269 this: *mut ffi::GstAggregatorPad,
270 object: *mut gst::ffi::GstBuffer,
271 f: glib::ffi::gpointer,
272 ) {
273 let f: &F = &*(f as *const F);
274 f(
275 AggregatorPad::from_glib_borrow(this).unsafe_cast_ref(),
276 &from_glib_borrow(object),
277 )
278 }
279 unsafe {
280 let f: Box_<F> = Box_::new(f);
281 connect_raw(
282 self.as_ptr() as *mut _,
283 c"buffer-consumed".as_ptr() as *const _,
284 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
285 buffer_consumed_trampoline::<Self, F> as *const (),
286 )),
287 Box_::into_raw(f),
288 )
289 }
290 }
291
292 #[cfg(feature = "v1_28")]
293 #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
294 #[doc(alias = "current-level-buffers")]
295 fn connect_current_level_buffers_notify<F: Fn(&Self) + Send + Sync + 'static>(
296 &self,
297 f: F,
298 ) -> SignalHandlerId {
299 unsafe extern "C" fn notify_current_level_buffers_trampoline<
300 P: IsA<AggregatorPad>,
301 F: Fn(&P) + Send + Sync + 'static,
302 >(
303 this: *mut ffi::GstAggregatorPad,
304 _param_spec: glib::ffi::gpointer,
305 f: glib::ffi::gpointer,
306 ) {
307 let f: &F = &*(f as *const F);
308 f(AggregatorPad::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::current-level-buffers".as_ptr() as *const _,
315 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
316 notify_current_level_buffers_trampoline::<Self, F> as *const (),
317 )),
318 Box_::into_raw(f),
319 )
320 }
321 }
322
323 #[cfg(feature = "v1_28")]
324 #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
325 #[doc(alias = "current-level-bytes")]
326 fn connect_current_level_bytes_notify<F: Fn(&Self) + Send + Sync + 'static>(
327 &self,
328 f: F,
329 ) -> SignalHandlerId {
330 unsafe extern "C" fn notify_current_level_bytes_trampoline<
331 P: IsA<AggregatorPad>,
332 F: Fn(&P) + Send + Sync + 'static,
333 >(
334 this: *mut ffi::GstAggregatorPad,
335 _param_spec: glib::ffi::gpointer,
336 f: glib::ffi::gpointer,
337 ) {
338 let f: &F = &*(f as *const F);
339 f(AggregatorPad::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::current-level-bytes".as_ptr() as *const _,
346 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
347 notify_current_level_bytes_trampoline::<Self, F> as *const (),
348 )),
349 Box_::into_raw(f),
350 )
351 }
352 }
353
354 #[cfg(feature = "v1_16")]
355 #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
356 #[doc(alias = "emit-signals")]
357 fn connect_emit_signals_notify<F: Fn(&Self) + Send + Sync + 'static>(
358 &self,
359 f: F,
360 ) -> SignalHandlerId {
361 unsafe extern "C" fn notify_emit_signals_trampoline<
362 P: IsA<AggregatorPad>,
363 F: Fn(&P) + Send + Sync + 'static,
364 >(
365 this: *mut ffi::GstAggregatorPad,
366 _param_spec: glib::ffi::gpointer,
367 f: glib::ffi::gpointer,
368 ) {
369 let f: &F = &*(f as *const F);
370 f(AggregatorPad::from_glib_borrow(this).unsafe_cast_ref())
371 }
372 unsafe {
373 let f: Box_<F> = Box_::new(f);
374 connect_raw(
375 self.as_ptr() as *mut _,
376 c"notify::emit-signals".as_ptr() as *const _,
377 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
378 notify_emit_signals_trampoline::<Self, F> as *const (),
379 )),
380 Box_::into_raw(f),
381 )
382 }
383 }
384}
385
386impl<O: IsA<AggregatorPad>> AggregatorPadExt for O {}