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
112mod sealed {
113 pub trait Sealed {}
114 impl<T: super::IsA<super::AggregatorPad>> Sealed for T {}
115}
116
117/// Trait containing all [`struct@AggregatorPad`] methods.
118///
119/// # Implementors
120///
121/// [`AggregatorPad`][struct@crate::AggregatorPad]
122pub trait AggregatorPadExt: IsA<AggregatorPad> + sealed::Sealed + 'static {
123 /// Drop the buffer currently queued in `self`.
124 ///
125 /// # Returns
126 ///
127 /// TRUE if there was a buffer queued in `self`, or FALSE if not.
128 #[doc(alias = "gst_aggregator_pad_drop_buffer")]
129 fn drop_buffer(&self) -> bool {
130 unsafe {
131 from_glib(ffi::gst_aggregator_pad_drop_buffer(
132 self.as_ref().to_glib_none().0,
133 ))
134 }
135 }
136
137 /// This checks if a pad has a buffer available that will be returned by
138 /// a call to [`peek_buffer()`][Self::peek_buffer()] or
139 /// [`pop_buffer()`][Self::pop_buffer()].
140 ///
141 /// # Returns
142 ///
143 /// [`true`] if the pad has a buffer available as the next thing.
144 #[cfg(feature = "v1_14_1")]
145 #[cfg_attr(docsrs, doc(cfg(feature = "v1_14_1")))]
146 #[doc(alias = "gst_aggregator_pad_has_buffer")]
147 fn has_buffer(&self) -> bool {
148 unsafe {
149 from_glib(ffi::gst_aggregator_pad_has_buffer(
150 self.as_ref().to_glib_none().0,
151 ))
152 }
153 }
154
155 ///
156 /// # Returns
157 ///
158 /// [`true`] if the pad is EOS, otherwise [`false`].
159 #[doc(alias = "gst_aggregator_pad_is_eos")]
160 fn is_eos(&self) -> bool {
161 unsafe {
162 from_glib(ffi::gst_aggregator_pad_is_eos(
163 self.as_ref().to_glib_none().0,
164 ))
165 }
166 }
167
168 /// It is only valid to call this method from `GstAggregatorClass::aggregate()`
169 ///
170 /// # Returns
171 ///
172 /// [`true`] if the pad is inactive, [`false`] otherwise.
173 /// See `gst_aggregator_ignore_inactive_pads()` for more info.
174 #[cfg(feature = "v1_20")]
175 #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
176 #[doc(alias = "gst_aggregator_pad_is_inactive")]
177 fn is_inactive(&self) -> bool {
178 unsafe {
179 from_glib(ffi::gst_aggregator_pad_is_inactive(
180 self.as_ref().to_glib_none().0,
181 ))
182 }
183 }
184
185 ///
186 /// # Returns
187 ///
188 /// A reference to the buffer in `self` or
189 /// NULL if no buffer was queued. You should unref the buffer after
190 /// usage.
191 #[doc(alias = "gst_aggregator_pad_peek_buffer")]
192 fn peek_buffer(&self) -> Option<gst::Buffer> {
193 unsafe {
194 from_glib_full(ffi::gst_aggregator_pad_peek_buffer(
195 self.as_ref().to_glib_none().0,
196 ))
197 }
198 }
199
200 /// Steal the ref to the buffer currently queued in `self`.
201 ///
202 /// # Returns
203 ///
204 /// The buffer in `self` or NULL if no buffer was
205 /// queued. You should unref the buffer after usage.
206 #[doc(alias = "gst_aggregator_pad_pop_buffer")]
207 fn pop_buffer(&self) -> Option<gst::Buffer> {
208 unsafe {
209 from_glib_full(ffi::gst_aggregator_pad_pop_buffer(
210 self.as_ref().to_glib_none().0,
211 ))
212 }
213 }
214
215 /// Enables the emission of signals such as [`buffer-consumed`][struct@crate::AggregatorPad#buffer-consumed]
216 #[cfg(feature = "v1_16")]
217 #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
218 #[doc(alias = "emit-signals")]
219 fn emits_signals(&self) -> bool {
220 ObjectExt::property(self.as_ref(), "emit-signals")
221 }
222
223 /// Enables the emission of signals such as [`buffer-consumed`][struct@crate::AggregatorPad#buffer-consumed]
224 #[cfg(feature = "v1_16")]
225 #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
226 #[doc(alias = "emit-signals")]
227 fn set_emit_signals(&self, emit_signals: bool) {
228 ObjectExt::set_property(self.as_ref(), "emit-signals", emit_signals)
229 }
230
231 #[doc(alias = "buffer-consumed")]
232 fn connect_buffer_consumed<F: Fn(&Self, &gst::Buffer) + Send + Sync + 'static>(
233 &self,
234 f: F,
235 ) -> SignalHandlerId {
236 unsafe extern "C" fn buffer_consumed_trampoline<
237 P: IsA<AggregatorPad>,
238 F: Fn(&P, &gst::Buffer) + Send + Sync + 'static,
239 >(
240 this: *mut ffi::GstAggregatorPad,
241 object: *mut gst::ffi::GstBuffer,
242 f: glib::ffi::gpointer,
243 ) {
244 let f: &F = &*(f as *const F);
245 f(
246 AggregatorPad::from_glib_borrow(this).unsafe_cast_ref(),
247 &from_glib_borrow(object),
248 )
249 }
250 unsafe {
251 let f: Box_<F> = Box_::new(f);
252 connect_raw(
253 self.as_ptr() as *mut _,
254 b"buffer-consumed\0".as_ptr() as *const _,
255 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
256 buffer_consumed_trampoline::<Self, F> as *const (),
257 )),
258 Box_::into_raw(f),
259 )
260 }
261 }
262
263 #[cfg(feature = "v1_16")]
264 #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
265 #[doc(alias = "emit-signals")]
266 fn connect_emit_signals_notify<F: Fn(&Self) + Send + Sync + 'static>(
267 &self,
268 f: F,
269 ) -> SignalHandlerId {
270 unsafe extern "C" fn notify_emit_signals_trampoline<
271 P: IsA<AggregatorPad>,
272 F: Fn(&P) + Send + Sync + 'static,
273 >(
274 this: *mut ffi::GstAggregatorPad,
275 _param_spec: glib::ffi::gpointer,
276 f: glib::ffi::gpointer,
277 ) {
278 let f: &F = &*(f as *const F);
279 f(AggregatorPad::from_glib_borrow(this).unsafe_cast_ref())
280 }
281 unsafe {
282 let f: Box_<F> = Box_::new(f);
283 connect_raw(
284 self.as_ptr() as *mut _,
285 b"notify::emit-signals\0".as_ptr() as *const _,
286 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
287 notify_emit_signals_trampoline::<Self, F> as *const (),
288 )),
289 Box_::into_raw(f),
290 )
291 }
292 }
293}
294
295impl<O: IsA<AggregatorPad>> AggregatorPadExt for O {}