Skip to main content

gstreamer_base/auto/
aggregator_pad.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
4// DO NOT EDIT
5
6use crate::ffi;
7use glib::{
8    object::ObjectType as _,
9    prelude::*,
10    signal::{SignalHandlerId, connect_raw},
11    translate::*,
12};
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16    /// Pads managed by a [`Aggregator`][crate::Aggregator] subclass.
17    ///
18    /// This class used to live in gst-plugins-bad and was moved to core.
19    ///
20    /// ## Properties
21    ///
22    ///
23    /// #### `current-level-buffers`
24    ///  The number of currently queued buffers inside this pad
25    ///
26    /// Readable
27    ///
28    ///
29    /// #### `current-level-bytes`
30    ///  The number of currently queued bytes inside this pad
31    ///
32    /// Readable
33    ///
34    ///
35    /// #### `current-level-time`
36    ///  The amount of currently queued time inside this pad
37    ///
38    /// Readable
39    ///
40    ///
41    /// #### `emit-signals`
42    ///  Enables the emission of signals such as [`buffer-consumed`][struct@crate::AggregatorPad#buffer-consumed]
43    ///
44    /// Readable | Writeable
45    /// <details><summary><h4>Pad</h4></summary>
46    ///
47    ///
48    /// #### `caps`
49    ///  Readable
50    ///
51    ///
52    /// #### `direction`
53    ///  Readable | Writeable | Construct Only
54    ///
55    ///
56    /// #### `offset`
57    ///  The offset that will be applied to the running time of the pad.
58    ///
59    /// Readable | Writeable
60    ///
61    ///
62    /// #### `template`
63    ///  Readable | Writeable
64    /// </details>
65    /// <details><summary><h4>Object</h4></summary>
66    ///
67    ///
68    /// #### `name`
69    ///  Readable | Writeable | Construct
70    ///
71    ///
72    /// #### `parent`
73    ///  The parent of the object. Please note, that when changing the 'parent'
74    /// property, we don't emit [`notify`][struct@crate::glib::Object#notify] and [`deep-notify`][struct@crate::gst::Object#deep-notify]
75    /// signals due to locking issues. In some cases one can use
76    /// `GstBin::element-added` or `GstBin::element-removed` signals on the parent to
77    /// achieve a similar effect.
78    ///
79    /// Readable | Writeable
80    /// </details>
81    ///
82    /// ## Signals
83    ///
84    ///
85    /// #### `buffer-consumed`
86    ///
87    /// <details><summary><h4>Pad</h4></summary>
88    ///
89    ///
90    /// #### `linked`
91    ///  Signals that a pad has been linked to the peer pad.
92    ///
93    ///
94    ///
95    ///
96    /// #### `unlinked`
97    ///  Signals that a pad has been unlinked from the peer pad.
98    ///
99    ///
100    /// </details>
101    /// <details><summary><h4>Object</h4></summary>
102    ///
103    ///
104    /// #### `deep-notify`
105    ///  The deep notify signal is used to be notified of property changes. It is
106    /// typically attached to the toplevel bin to receive notifications from all
107    /// the elements contained in that bin.
108    ///
109    /// Detailed
110    /// </details>
111    ///
112    /// # Implements
113    ///
114    /// [`AggregatorPadExt`][trait@crate::prelude::AggregatorPadExt], [`trait@gst::prelude::PadExt`], [`trait@gst::prelude::ObjectExt`], [`trait@glib::ObjectExt`], [`AggregatorPadExtManual`][trait@crate::prelude::AggregatorPadExtManual]
115    #[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
130/// Trait containing all [`struct@AggregatorPad`] methods.
131///
132/// # Implementors
133///
134/// [`AggregatorPad`][struct@crate::AggregatorPad]
135pub trait AggregatorPadExt: IsA<AggregatorPad> + 'static {
136    /// Drop the buffer currently queued in `self`.
137    ///
138    /// # Returns
139    ///
140    /// TRUE if there was a buffer queued in `self`, or FALSE if not.
141    #[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    /// This checks if a pad has a buffer available that will be returned by
151    /// a call to [`peek_buffer()`][Self::peek_buffer()] or
152    /// [`pop_buffer()`][Self::pop_buffer()].
153    ///
154    /// # Returns
155    ///
156    /// [`true`] if the pad has a buffer available as the next thing.
157    #[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    ///
169    /// # Returns
170    ///
171    /// [`true`] if the pad is EOS, otherwise [`false`].
172    #[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    /// It is only valid to call this method from `GstAggregatorClass::aggregate()`
182    ///
183    /// # Returns
184    ///
185    /// [`true`] if the pad is inactive, [`false`] otherwise.
186    ///  See `gst_aggregator_ignore_inactive_pads()` for more info.
187    #[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    ///
199    /// # Returns
200    ///
201    /// A reference to the buffer in `self` or
202    /// NULL if no buffer was queued. You should unref the buffer after
203    /// usage.
204    #[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    /// Steal the ref to the buffer currently queued in `self`.
214    ///
215    /// # Returns
216    ///
217    /// The buffer in `self` or NULL if no buffer was
218    ///  queued. You should unref the buffer after usage.
219    #[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    /// The number of currently queued buffers inside this pad
229    #[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    /// The number of currently queued bytes inside this pad
237    #[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    /// Enables the emission of signals such as [`buffer-consumed`][struct@crate::AggregatorPad#buffer-consumed]
245    #[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    /// Enables the emission of signals such as [`buffer-consumed`][struct@crate::AggregatorPad#buffer-consumed]
253    #[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            unsafe {
274                let f: &F = &*(f as *const F);
275                f(
276                    AggregatorPad::from_glib_borrow(this).unsafe_cast_ref(),
277                    &from_glib_borrow(object),
278                )
279            }
280        }
281        unsafe {
282            let f: Box_<F> = Box_::new(f);
283            connect_raw(
284                self.as_ptr() as *mut _,
285                c"buffer-consumed".as_ptr(),
286                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
287                    buffer_consumed_trampoline::<Self, F> as *const (),
288                )),
289                Box_::into_raw(f),
290            )
291        }
292    }
293
294    #[cfg(feature = "v1_28")]
295    #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
296    #[doc(alias = "current-level-buffers")]
297    fn connect_current_level_buffers_notify<F: Fn(&Self) + Send + Sync + 'static>(
298        &self,
299        f: F,
300    ) -> SignalHandlerId {
301        unsafe extern "C" fn notify_current_level_buffers_trampoline<
302            P: IsA<AggregatorPad>,
303            F: Fn(&P) + Send + Sync + 'static,
304        >(
305            this: *mut ffi::GstAggregatorPad,
306            _param_spec: glib::ffi::gpointer,
307            f: glib::ffi::gpointer,
308        ) {
309            unsafe {
310                let f: &F = &*(f as *const F);
311                f(AggregatorPad::from_glib_borrow(this).unsafe_cast_ref())
312            }
313        }
314        unsafe {
315            let f: Box_<F> = Box_::new(f);
316            connect_raw(
317                self.as_ptr() as *mut _,
318                c"notify::current-level-buffers".as_ptr(),
319                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
320                    notify_current_level_buffers_trampoline::<Self, F> as *const (),
321                )),
322                Box_::into_raw(f),
323            )
324        }
325    }
326
327    #[cfg(feature = "v1_28")]
328    #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
329    #[doc(alias = "current-level-bytes")]
330    fn connect_current_level_bytes_notify<F: Fn(&Self) + Send + Sync + 'static>(
331        &self,
332        f: F,
333    ) -> SignalHandlerId {
334        unsafe extern "C" fn notify_current_level_bytes_trampoline<
335            P: IsA<AggregatorPad>,
336            F: Fn(&P) + Send + Sync + 'static,
337        >(
338            this: *mut ffi::GstAggregatorPad,
339            _param_spec: glib::ffi::gpointer,
340            f: glib::ffi::gpointer,
341        ) {
342            unsafe {
343                let f: &F = &*(f as *const F);
344                f(AggregatorPad::from_glib_borrow(this).unsafe_cast_ref())
345            }
346        }
347        unsafe {
348            let f: Box_<F> = Box_::new(f);
349            connect_raw(
350                self.as_ptr() as *mut _,
351                c"notify::current-level-bytes".as_ptr(),
352                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
353                    notify_current_level_bytes_trampoline::<Self, F> as *const (),
354                )),
355                Box_::into_raw(f),
356            )
357        }
358    }
359
360    #[cfg(feature = "v1_16")]
361    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
362    #[doc(alias = "emit-signals")]
363    fn connect_emit_signals_notify<F: Fn(&Self) + Send + Sync + 'static>(
364        &self,
365        f: F,
366    ) -> SignalHandlerId {
367        unsafe extern "C" fn notify_emit_signals_trampoline<
368            P: IsA<AggregatorPad>,
369            F: Fn(&P) + Send + Sync + 'static,
370        >(
371            this: *mut ffi::GstAggregatorPad,
372            _param_spec: glib::ffi::gpointer,
373            f: glib::ffi::gpointer,
374        ) {
375            unsafe {
376                let f: &F = &*(f as *const F);
377                f(AggregatorPad::from_glib_borrow(this).unsafe_cast_ref())
378            }
379        }
380        unsafe {
381            let f: Box_<F> = Box_::new(f);
382            connect_raw(
383                self.as_ptr() as *mut _,
384                c"notify::emit-signals".as_ptr(),
385                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
386                    notify_emit_signals_trampoline::<Self, F> as *const (),
387                )),
388                Box_::into_raw(f),
389            )
390        }
391    }
392}
393
394impl<O: IsA<AggregatorPad>> AggregatorPadExt for O {}