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::{connect_raw, SignalHandlerId},
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            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 {}