Skip to main content

gstreamer_base/auto/
base_transform.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    prelude::*,
9    signal::{SignalHandlerId, connect_raw},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    /// = input buffer size
16    /// * If the always_in_place flag is set, non-writable buffers will be copied
17    ///  and passed to the transform_ip function, otherwise a new buffer will be
18    ///  created and the transform function called.
19    ///
20    /// * Incoming writable buffers will be passed to the transform_ip function
21    ///  immediately.
22    /// * only implementing transform_ip and not transform implies always_in_place = [`true`]
23    ///
24    ///  * Example elements:
25    ///  * Volume
26    ///  * Audioconvert in certain modes (signed/unsigned conversion)
27    ///  * videoconvert in certain modes (endianness swapping)
28    ///
29    /// ## Modifications only to the caps/metadata of a buffer
30    ///
31    /// * The element does not require writable data, but non-writable buffers
32    ///  should be subbuffered so that the meta-information can be replaced.
33    ///
34    /// * Elements wishing to operate in this mode should replace the
35    ///  prepare_output_buffer method to create subbuffers of the input buffer
36    ///  and set always_in_place to [`true`]
37    ///
38    /// * Example elements
39    ///  * Capsfilter when setting caps on outgoing buffers that have
40    ///  none.
41    ///  * identity when it is going to re-timestamp buffers by
42    ///  datarate.
43    ///
44    /// ## Normal mode
45    ///  * always_in_place flag is not set, or there is no transform_ip function
46    ///  * Element will receive an input buffer and output buffer to operate on.
47    ///  * Output buffer is allocated by calling the prepare_output_buffer function.
48    ///  * Example elements:
49    ///  * Videoscale, videoconvert, audioconvert when doing
50    ///  scaling/conversions
51    ///
52    /// ## Special output buffer allocations
53    ///  * Elements which need to do special allocation of their output buffers
54    ///  beyond allocating output buffers via the negotiated allocator or
55    ///  buffer pool should implement the prepare_output_buffer method.
56    ///
57    ///  * Example elements:
58    ///  * efence
59    ///
60    /// # Sub-class settable flags on GstBaseTransform
61    ///
62    /// * passthrough
63    ///
64    ///  * Implies that in the current configuration, the sub-class is not interested in modifying the buffers.
65    ///  * Elements which are always in passthrough mode whenever the same caps has been negotiated on both pads can set the class variable passthrough_on_same_caps to have this behaviour automatically.
66    ///
67    /// * always_in_place
68    ///  * Determines whether a non-writable buffer will be copied before passing
69    ///  to the transform_ip function.
70    ///
71    ///  * Implied [`true`] if no transform function is implemented.
72    ///  * Implied [`false`] if ONLY transform function is implemented.
73    ///
74    /// This is an Abstract Base Class, you cannot instantiate it.
75    ///
76    /// ## Properties
77    ///
78    ///
79    /// #### `qos`
80    ///  Readable | Writable
81    /// <details><summary><h4>Object</h4></summary>
82    ///
83    ///
84    /// #### `name`
85    ///  Readable | Writable | Construct
86    ///
87    ///
88    /// #### `parent`
89    ///  The parent of the object. Please note, that when changing the 'parent'
90    /// property, we don't emit [`notify`][struct@crate::glib::Object#notify] and [`deep-notify`][struct@crate::gst::Object#deep-notify]
91    /// signals due to locking issues. In some cases one can use
92    /// `GstBin::element-added` or `GstBin::element-removed` signals on the parent to
93    /// achieve a similar effect.
94    ///
95    /// Readable | Writable
96    /// </details>
97    ///
98    /// # Implements
99    ///
100    /// [`BaseTransformExt`][trait@crate::prelude::BaseTransformExt], [`trait@gst::prelude::ElementExt`], [`trait@gst::prelude::ObjectExt`], [`trait@glib::ObjectExt`], [`BaseTransformExtManual`][trait@crate::prelude::BaseTransformExtManual]
101    #[doc(alias = "GstBaseTransform")]
102    pub struct BaseTransform(Object<ffi::GstBaseTransform, ffi::GstBaseTransformClass>) @extends gst::Element, gst::Object;
103
104    match fn {
105        type_ => || ffi::gst_base_transform_get_type(),
106    }
107}
108
109impl BaseTransform {
110    pub const NONE: Option<&'static BaseTransform> = None;
111}
112
113unsafe impl Send for BaseTransform {}
114unsafe impl Sync for BaseTransform {}
115
116/// Trait containing all [`struct@BaseTransform`] methods.
117///
118/// # Implementors
119///
120/// [`BaseTransform`][struct@crate::BaseTransform]
121pub trait BaseTransformExt: IsA<BaseTransform> + 'static {
122    ///
123    /// # Returns
124    ///
125    /// the instance of the [`gst::BufferPool`][crate::gst::BufferPool] used
126    /// by `self`; free it after use
127    #[doc(alias = "gst_base_transform_get_buffer_pool")]
128    #[doc(alias = "get_buffer_pool")]
129    fn buffer_pool(&self) -> Option<gst::BufferPool> {
130        unsafe {
131            from_glib_full(ffi::gst_base_transform_get_buffer_pool(
132                self.as_ref().to_glib_none().0,
133            ))
134        }
135    }
136
137    /// See if `self` is configured as a in_place transform.
138    ///
139    /// # Returns
140    ///
141    /// [`true`] if the transform is configured in in_place mode.
142    ///
143    /// MT safe.
144    #[doc(alias = "gst_base_transform_is_in_place")]
145    fn is_in_place(&self) -> bool {
146        unsafe {
147            from_glib(ffi::gst_base_transform_is_in_place(
148                self.as_ref().to_glib_none().0,
149            ))
150        }
151    }
152
153    /// See if `self` is configured as a passthrough transform.
154    ///
155    /// # Returns
156    ///
157    /// [`true`] if the transform is configured in passthrough mode.
158    ///
159    /// MT safe.
160    #[doc(alias = "gst_base_transform_is_passthrough")]
161    fn is_passthrough(&self) -> bool {
162        unsafe {
163            from_glib(ffi::gst_base_transform_is_passthrough(
164                self.as_ref().to_glib_none().0,
165            ))
166        }
167    }
168
169    /// Negotiates src pad caps with downstream elements if the source pad is
170    /// marked as needing reconfiguring. Unmarks GST_PAD_FLAG_NEED_RECONFIGURE in
171    /// any case. But marks it again if negotiation fails.
172    ///
173    /// Do not call this in the `GstBaseTransformClass::transform` or
174    /// `GstBaseTransformClass::transform_ip` vmethod. Call this in
175    /// `GstBaseTransformClass::submit_input_buffer`,
176    /// `GstBaseTransformClass::prepare_output_buffer` or in
177    /// `GstBaseTransformClass::generate_output` _before_ any output buffer is
178    /// allocated.
179    ///
180    /// It will be default be called when handling an ALLOCATION query or at the
181    /// very beginning of the default `GstBaseTransformClass::submit_input_buffer`
182    /// implementation.
183    ///
184    /// # Returns
185    ///
186    /// [`true`] if the negotiation succeeded, else [`false`].
187    #[cfg(feature = "v1_18")]
188    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
189    #[doc(alias = "gst_base_transform_reconfigure")]
190    fn reconfigure(&self) -> bool {
191        unsafe {
192            from_glib(ffi::gst_base_transform_reconfigure(
193                self.as_ref().to_glib_none().0,
194            ))
195        }
196    }
197
198    /// Instructs `self` to request renegotiation upstream. This function is
199    /// typically called after properties on the transform were set that
200    /// influence the input format.
201    #[doc(alias = "gst_base_transform_reconfigure_sink")]
202    fn reconfigure_sink(&self) {
203        unsafe {
204            ffi::gst_base_transform_reconfigure_sink(self.as_ref().to_glib_none().0);
205        }
206    }
207
208    /// Instructs `self` to renegotiate a new downstream transform on the next
209    /// buffer. This function is typically called after properties on the transform
210    /// were set that influence the output format.
211    #[doc(alias = "gst_base_transform_reconfigure_src")]
212    fn reconfigure_src(&self) {
213        unsafe {
214            ffi::gst_base_transform_reconfigure_src(self.as_ref().to_glib_none().0);
215        }
216    }
217
218    /// If `gap_aware` is [`false`] (the default), output buffers will have the
219    /// [`gst::BufferFlags::GAP`][crate::gst::BufferFlags::GAP] flag unset.
220    ///
221    /// If set to [`true`], the element must handle output buffers with this flag set
222    /// correctly, i.e. it can assume that the buffer contains neutral data but must
223    /// unset the flag if the output is no neutral data.
224    ///
225    /// MT safe.
226    /// ## `gap_aware`
227    /// New state
228    #[doc(alias = "gst_base_transform_set_gap_aware")]
229    fn set_gap_aware(&self, gap_aware: bool) {
230        unsafe {
231            ffi::gst_base_transform_set_gap_aware(
232                self.as_ref().to_glib_none().0,
233                gap_aware.into_glib(),
234            );
235        }
236    }
237
238    /// Determines whether a non-writable buffer will be copied before passing
239    /// to the transform_ip function.
240    ///
241    ///  * Always [`true`] if no transform function is implemented.
242    ///  * Always [`false`] if ONLY transform function is implemented.
243    ///
244    /// MT safe.
245    /// ## `in_place`
246    /// Boolean value indicating that we would like to operate
247    /// on in_place buffers.
248    #[doc(alias = "gst_base_transform_set_in_place")]
249    fn set_in_place(&self, in_place: bool) {
250        unsafe {
251            ffi::gst_base_transform_set_in_place(
252                self.as_ref().to_glib_none().0,
253                in_place.into_glib(),
254            );
255        }
256    }
257
258    /// Set passthrough mode for this filter by default. This is mostly
259    /// useful for filters that do not care about negotiation.
260    ///
261    /// Always [`true`] for filters which don't implement either a transform
262    /// or transform_ip or generate_output method.
263    ///
264    /// MT safe.
265    /// ## `passthrough`
266    /// boolean indicating passthrough mode.
267    #[doc(alias = "gst_base_transform_set_passthrough")]
268    fn set_passthrough(&self, passthrough: bool) {
269        unsafe {
270            ffi::gst_base_transform_set_passthrough(
271                self.as_ref().to_glib_none().0,
272                passthrough.into_glib(),
273            );
274        }
275    }
276
277    /// If `prefer_passthrough` is [`true`] (the default), `self` will check and
278    /// prefer passthrough caps from the list of caps returned by the
279    /// transform_caps vmethod.
280    ///
281    /// If set to [`false`], the element must order the caps returned from the
282    /// transform_caps function in such a way that the preferred format is
283    /// first in the list. This can be interesting for transforms that can do
284    /// passthrough transforms but prefer to do something else, like a
285    /// capsfilter.
286    ///
287    /// MT safe.
288    /// ## `prefer_passthrough`
289    /// New state
290    #[doc(alias = "gst_base_transform_set_prefer_passthrough")]
291    fn set_prefer_passthrough(&self, prefer_passthrough: bool) {
292        unsafe {
293            ffi::gst_base_transform_set_prefer_passthrough(
294                self.as_ref().to_glib_none().0,
295                prefer_passthrough.into_glib(),
296            );
297        }
298    }
299
300    /// Set the QoS parameters in the transform. This function is called internally
301    /// when a QOS event is received but subclasses can provide custom information
302    /// when needed.
303    ///
304    /// MT safe.
305    /// ## `proportion`
306    /// the proportion
307    /// ## `diff`
308    /// the diff against the clock
309    /// ## `timestamp`
310    /// the timestamp of the buffer generating the QoS expressed in
311    /// running_time.
312    #[doc(alias = "gst_base_transform_update_qos")]
313    fn update_qos(&self, proportion: f64, diff: gst::ClockTimeDiff, timestamp: gst::ClockTime) {
314        unsafe {
315            ffi::gst_base_transform_update_qos(
316                self.as_ref().to_glib_none().0,
317                proportion,
318                diff,
319                timestamp.into_glib(),
320            );
321        }
322    }
323
324    /// Updates the srcpad caps and sends the caps downstream. This function
325    /// can be used by subclasses when they have already negotiated their caps
326    /// but found a change in them (or computed new information). This way,
327    /// they can notify downstream about that change without losing any
328    /// buffer.
329    /// ## `updated_caps`
330    /// An updated version of the srcpad caps to be pushed
331    /// downstream
332    ///
333    /// # Returns
334    ///
335    /// [`true`] if the caps could be sent downstream [`false`] otherwise
336    #[doc(alias = "gst_base_transform_update_src_caps")]
337    fn update_src_caps(&self, updated_caps: &gst::Caps) -> Result<(), glib::error::BoolError> {
338        unsafe {
339            glib::result_from_gboolean!(
340                ffi::gst_base_transform_update_src_caps(
341                    self.as_ref().to_glib_none().0,
342                    updated_caps.to_glib_none().0
343                ),
344                "Failed to update src caps"
345            )
346        }
347    }
348
349    fn is_qos(&self) -> bool {
350        ObjectExt::property(self.as_ref(), "qos")
351    }
352
353    fn set_qos(&self, qos: bool) {
354        ObjectExt::set_property(self.as_ref(), "qos", qos)
355    }
356
357    #[doc(alias = "qos")]
358    fn connect_qos_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
359        unsafe extern "C" fn notify_qos_trampoline<
360            P: IsA<BaseTransform>,
361            F: Fn(&P) + Send + Sync + 'static,
362        >(
363            this: *mut ffi::GstBaseTransform,
364            _param_spec: glib::ffi::gpointer,
365            f: glib::ffi::gpointer,
366        ) {
367            unsafe {
368                let f: &F = &*(f as *const F);
369                f(BaseTransform::from_glib_borrow(this).unsafe_cast_ref())
370            }
371        }
372        unsafe {
373            let f: Box_<F> = Box_::new(f);
374            connect_raw(
375                self.as_ptr() as *mut _,
376                c"notify::qos".as_ptr(),
377                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
378                    notify_qos_trampoline::<Self, F> as *const (),
379                )),
380                Box_::into_raw(f),
381            )
382        }
383    }
384}
385
386impl<O: IsA<BaseTransform>> BaseTransformExt for O {}