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    /// #### `emit-signals`
24    ///  Enables the emission of signals such as [`buffer-consumed`][struct@crate::AggregatorPad#buffer-consumed]
25    ///
26    /// Readable | Writeable
27    /// <details><summary><h4>Pad</h4></summary>
28    ///
29    ///
30    /// #### `caps`
31    ///  Readable
32    ///
33    ///
34    /// #### `direction`
35    ///  Readable | Writeable | Construct Only
36    ///
37    ///
38    /// #### `offset`
39    ///  The offset that will be applied to the running time of the pad.
40    ///
41    /// Readable | Writeable
42    ///
43    ///
44    /// #### `template`
45    ///  Readable | Writeable
46    /// </details>
47    /// <details><summary><h4>Object</h4></summary>
48    ///
49    ///
50    /// #### `name`
51    ///  Readable | Writeable | Construct
52    ///
53    ///
54    /// #### `parent`
55    ///  The parent of the object. Please note, that when changing the 'parent'
56    /// property, we don't emit [`notify`][struct@crate::glib::Object#notify] and [`deep-notify`][struct@crate::gst::Object#deep-notify]
57    /// signals due to locking issues. In some cases one can use
58    /// `GstBin::element-added` or `GstBin::element-removed` signals on the parent to
59    /// achieve a similar effect.
60    ///
61    /// Readable | Writeable
62    /// </details>
63    ///
64    /// ## Signals
65    ///
66    ///
67    /// #### `buffer-consumed`
68    ///
69    /// <details><summary><h4>Pad</h4></summary>
70    ///
71    ///
72    /// #### `linked`
73    ///  Signals that a pad has been linked to the peer pad.
74    ///
75    ///
76    ///
77    ///
78    /// #### `unlinked`
79    ///  Signals that a pad has been unlinked from the peer pad.
80    ///
81    ///
82    /// </details>
83    /// <details><summary><h4>Object</h4></summary>
84    ///
85    ///
86    /// #### `deep-notify`
87    ///  The deep notify signal is used to be notified of property changes. It is
88    /// typically attached to the toplevel bin to receive notifications from all
89    /// the elements contained in that bin.
90    ///
91    /// Detailed
92    /// </details>
93    ///
94    /// # Implements
95    ///
96    /// [`AggregatorPadExt`][trait@crate::prelude::AggregatorPadExt], [`trait@gst::prelude::PadExt`], [`trait@gst::prelude::ObjectExt`], [`trait@glib::ObjectExt`], [`AggregatorPadExtManual`][trait@crate::prelude::AggregatorPadExtManual]
97    #[doc(alias = "GstAggregatorPad")]
98    pub struct AggregatorPad(Object<ffi::GstAggregatorPad, ffi::GstAggregatorPadClass>) @extends gst::Pad, gst::Object;
99
100    match fn {
101        type_ => || ffi::gst_aggregator_pad_get_type(),
102    }
103}
104
105impl AggregatorPad {
106    pub const NONE: Option<&'static AggregatorPad> = None;
107}
108
109unsafe impl Send for AggregatorPad {}
110unsafe impl Sync for AggregatorPad {}
111
112/// Trait containing all [`struct@AggregatorPad`] methods.
113///
114/// # Implementors
115///
116/// [`AggregatorPad`][struct@crate::AggregatorPad]
117pub trait AggregatorPadExt: IsA<AggregatorPad> + 'static {
118    /// Drop the buffer currently queued in `self`.
119    ///
120    /// # Returns
121    ///
122    /// TRUE if there was a buffer queued in `self`, or FALSE if not.
123    #[doc(alias = "gst_aggregator_pad_drop_buffer")]
124    fn drop_buffer(&self) -> bool {
125        unsafe {
126            from_glib(ffi::gst_aggregator_pad_drop_buffer(
127                self.as_ref().to_glib_none().0,
128            ))
129        }
130    }
131
132    /// This checks if a pad has a buffer available that will be returned by
133    /// a call to [`peek_buffer()`][Self::peek_buffer()] or
134    /// [`pop_buffer()`][Self::pop_buffer()].
135    ///
136    /// # Returns
137    ///
138    /// [`true`] if the pad has a buffer available as the next thing.
139    #[cfg(feature = "v1_14_1")]
140    #[cfg_attr(docsrs, doc(cfg(feature = "v1_14_1")))]
141    #[doc(alias = "gst_aggregator_pad_has_buffer")]
142    fn has_buffer(&self) -> bool {
143        unsafe {
144            from_glib(ffi::gst_aggregator_pad_has_buffer(
145                self.as_ref().to_glib_none().0,
146            ))
147        }
148    }
149
150    ///
151    /// # Returns
152    ///
153    /// [`true`] if the pad is EOS, otherwise [`false`].
154    #[doc(alias = "gst_aggregator_pad_is_eos")]
155    fn is_eos(&self) -> bool {
156        unsafe {
157            from_glib(ffi::gst_aggregator_pad_is_eos(
158                self.as_ref().to_glib_none().0,
159            ))
160        }
161    }
162
163    /// It is only valid to call this method from `GstAggregatorClass::aggregate()`
164    ///
165    /// # Returns
166    ///
167    /// [`true`] if the pad is inactive, [`false`] otherwise.
168    ///  See `gst_aggregator_ignore_inactive_pads()` for more info.
169    #[cfg(feature = "v1_20")]
170    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
171    #[doc(alias = "gst_aggregator_pad_is_inactive")]
172    fn is_inactive(&self) -> bool {
173        unsafe {
174            from_glib(ffi::gst_aggregator_pad_is_inactive(
175                self.as_ref().to_glib_none().0,
176            ))
177        }
178    }
179
180    ///
181    /// # Returns
182    ///
183    /// A reference to the buffer in `self` or
184    /// NULL if no buffer was queued. You should unref the buffer after
185    /// usage.
186    #[doc(alias = "gst_aggregator_pad_peek_buffer")]
187    fn peek_buffer(&self) -> Option<gst::Buffer> {
188        unsafe {
189            from_glib_full(ffi::gst_aggregator_pad_peek_buffer(
190                self.as_ref().to_glib_none().0,
191            ))
192        }
193    }
194
195    /// Steal the ref to the buffer currently queued in `self`.
196    ///
197    /// # Returns
198    ///
199    /// The buffer in `self` or NULL if no buffer was
200    ///  queued. You should unref the buffer after usage.
201    #[doc(alias = "gst_aggregator_pad_pop_buffer")]
202    fn pop_buffer(&self) -> Option<gst::Buffer> {
203        unsafe {
204            from_glib_full(ffi::gst_aggregator_pad_pop_buffer(
205                self.as_ref().to_glib_none().0,
206            ))
207        }
208    }
209
210    /// Enables the emission of signals such as [`buffer-consumed`][struct@crate::AggregatorPad#buffer-consumed]
211    #[cfg(feature = "v1_16")]
212    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
213    #[doc(alias = "emit-signals")]
214    fn emits_signals(&self) -> bool {
215        ObjectExt::property(self.as_ref(), "emit-signals")
216    }
217
218    /// Enables the emission of signals such as [`buffer-consumed`][struct@crate::AggregatorPad#buffer-consumed]
219    #[cfg(feature = "v1_16")]
220    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
221    #[doc(alias = "emit-signals")]
222    fn set_emit_signals(&self, emit_signals: bool) {
223        ObjectExt::set_property(self.as_ref(), "emit-signals", emit_signals)
224    }
225
226    #[doc(alias = "buffer-consumed")]
227    fn connect_buffer_consumed<F: Fn(&Self, &gst::Buffer) + Send + Sync + 'static>(
228        &self,
229        f: F,
230    ) -> SignalHandlerId {
231        unsafe extern "C" fn buffer_consumed_trampoline<
232            P: IsA<AggregatorPad>,
233            F: Fn(&P, &gst::Buffer) + Send + Sync + 'static,
234        >(
235            this: *mut ffi::GstAggregatorPad,
236            object: *mut gst::ffi::GstBuffer,
237            f: glib::ffi::gpointer,
238        ) {
239            let f: &F = &*(f as *const F);
240            f(
241                AggregatorPad::from_glib_borrow(this).unsafe_cast_ref(),
242                &from_glib_borrow(object),
243            )
244        }
245        unsafe {
246            let f: Box_<F> = Box_::new(f);
247            connect_raw(
248                self.as_ptr() as *mut _,
249                c"buffer-consumed".as_ptr() as *const _,
250                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
251                    buffer_consumed_trampoline::<Self, F> as *const (),
252                )),
253                Box_::into_raw(f),
254            )
255        }
256    }
257
258    #[cfg(feature = "v1_16")]
259    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
260    #[doc(alias = "emit-signals")]
261    fn connect_emit_signals_notify<F: Fn(&Self) + Send + Sync + 'static>(
262        &self,
263        f: F,
264    ) -> SignalHandlerId {
265        unsafe extern "C" fn notify_emit_signals_trampoline<
266            P: IsA<AggregatorPad>,
267            F: Fn(&P) + Send + Sync + 'static,
268        >(
269            this: *mut ffi::GstAggregatorPad,
270            _param_spec: glib::ffi::gpointer,
271            f: glib::ffi::gpointer,
272        ) {
273            let f: &F = &*(f as *const F);
274            f(AggregatorPad::from_glib_borrow(this).unsafe_cast_ref())
275        }
276        unsafe {
277            let f: Box_<F> = Box_::new(f);
278            connect_raw(
279                self.as_ptr() as *mut _,
280                c"notify::emit-signals".as_ptr() as *const _,
281                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
282                    notify_emit_signals_trampoline::<Self, F> as *const (),
283                )),
284                Box_::into_raw(f),
285            )
286        }
287    }
288}
289
290impl<O: IsA<AggregatorPad>> AggregatorPadExt for O {}