gstreamer_audio/auto/
audio_decoder.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, AudioInfo};
7use glib::{
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "GstAudioDecoder")]
16    pub struct AudioDecoder(Object<ffi::GstAudioDecoder, ffi::GstAudioDecoderClass>) @extends gst::Element, gst::Object;
17
18    match fn {
19        type_ => || ffi::gst_audio_decoder_get_type(),
20    }
21}
22
23impl AudioDecoder {
24    pub const NONE: Option<&'static AudioDecoder> = None;
25}
26
27unsafe impl Send for AudioDecoder {}
28unsafe impl Sync for AudioDecoder {}
29
30mod sealed {
31    pub trait Sealed {}
32    impl<T: super::IsA<super::AudioDecoder>> Sealed for T {}
33}
34
35pub trait AudioDecoderExt: IsA<AudioDecoder> + sealed::Sealed + 'static {
36    #[doc(alias = "gst_audio_decoder_allocate_output_buffer")]
37    fn allocate_output_buffer(&self, size: usize) -> gst::Buffer {
38        unsafe {
39            from_glib_full(ffi::gst_audio_decoder_allocate_output_buffer(
40                self.as_ref().to_glib_none().0,
41                size,
42            ))
43        }
44    }
45
46    #[doc(alias = "gst_audio_decoder_finish_frame")]
47    fn finish_frame(
48        &self,
49        buf: Option<gst::Buffer>,
50        frames: i32,
51    ) -> Result<gst::FlowSuccess, gst::FlowError> {
52        unsafe {
53            try_from_glib(ffi::gst_audio_decoder_finish_frame(
54                self.as_ref().to_glib_none().0,
55                buf.into_glib_ptr(),
56                frames,
57            ))
58        }
59    }
60
61    #[cfg(feature = "v1_16")]
62    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
63    #[doc(alias = "gst_audio_decoder_finish_subframe")]
64    fn finish_subframe(
65        &self,
66        buf: Option<gst::Buffer>,
67    ) -> Result<gst::FlowSuccess, gst::FlowError> {
68        unsafe {
69            try_from_glib(ffi::gst_audio_decoder_finish_subframe(
70                self.as_ref().to_glib_none().0,
71                buf.into_glib_ptr(),
72            ))
73        }
74    }
75
76    #[doc(alias = "gst_audio_decoder_get_audio_info")]
77    #[doc(alias = "get_audio_info")]
78    fn audio_info(&self) -> AudioInfo {
79        unsafe {
80            from_glib_none(ffi::gst_audio_decoder_get_audio_info(
81                self.as_ref().to_glib_none().0,
82            ))
83        }
84    }
85
86    #[doc(alias = "gst_audio_decoder_get_delay")]
87    #[doc(alias = "get_delay")]
88    fn delay(&self) -> i32 {
89        unsafe { ffi::gst_audio_decoder_get_delay(self.as_ref().to_glib_none().0) }
90    }
91
92    #[doc(alias = "gst_audio_decoder_get_drainable")]
93    #[doc(alias = "get_drainable")]
94    fn is_drainable(&self) -> bool {
95        unsafe {
96            from_glib(ffi::gst_audio_decoder_get_drainable(
97                self.as_ref().to_glib_none().0,
98            ))
99        }
100    }
101
102    #[doc(alias = "gst_audio_decoder_get_estimate_rate")]
103    #[doc(alias = "get_estimate_rate")]
104    fn estimate_rate(&self) -> i32 {
105        unsafe { ffi::gst_audio_decoder_get_estimate_rate(self.as_ref().to_glib_none().0) }
106    }
107
108    #[doc(alias = "gst_audio_decoder_get_latency")]
109    #[doc(alias = "get_latency")]
110    fn latency(&self) -> (gst::ClockTime, Option<gst::ClockTime>) {
111        unsafe {
112            let mut min = std::mem::MaybeUninit::uninit();
113            let mut max = std::mem::MaybeUninit::uninit();
114            ffi::gst_audio_decoder_get_latency(
115                self.as_ref().to_glib_none().0,
116                min.as_mut_ptr(),
117                max.as_mut_ptr(),
118            );
119            (
120                try_from_glib(min.assume_init()).expect("mandatory glib value is None"),
121                from_glib(max.assume_init()),
122            )
123        }
124    }
125
126    #[doc(alias = "gst_audio_decoder_get_max_errors")]
127    #[doc(alias = "get_max_errors")]
128    #[doc(alias = "max-errors")]
129    fn max_errors(&self) -> i32 {
130        unsafe { ffi::gst_audio_decoder_get_max_errors(self.as_ref().to_glib_none().0) }
131    }
132
133    #[doc(alias = "gst_audio_decoder_get_min_latency")]
134    #[doc(alias = "get_min_latency")]
135    #[doc(alias = "min-latency")]
136    fn min_latency(&self) -> gst::ClockTime {
137        unsafe {
138            try_from_glib(ffi::gst_audio_decoder_get_min_latency(
139                self.as_ref().to_glib_none().0,
140            ))
141            .expect("mandatory glib value is None")
142        }
143    }
144
145    #[doc(alias = "gst_audio_decoder_get_needs_format")]
146    #[doc(alias = "get_needs_format")]
147    fn needs_format(&self) -> bool {
148        unsafe {
149            from_glib(ffi::gst_audio_decoder_get_needs_format(
150                self.as_ref().to_glib_none().0,
151            ))
152        }
153    }
154
155    #[doc(alias = "gst_audio_decoder_get_parse_state")]
156    #[doc(alias = "get_parse_state")]
157    fn parse_state(&self) -> (bool, bool) {
158        unsafe {
159            let mut sync = std::mem::MaybeUninit::uninit();
160            let mut eos = std::mem::MaybeUninit::uninit();
161            ffi::gst_audio_decoder_get_parse_state(
162                self.as_ref().to_glib_none().0,
163                sync.as_mut_ptr(),
164                eos.as_mut_ptr(),
165            );
166            (from_glib(sync.assume_init()), from_glib(eos.assume_init()))
167        }
168    }
169
170    #[doc(alias = "gst_audio_decoder_get_plc")]
171    #[doc(alias = "get_plc")]
172    #[doc(alias = "plc")]
173    fn is_plc(&self) -> bool {
174        unsafe {
175            from_glib(ffi::gst_audio_decoder_get_plc(
176                self.as_ref().to_glib_none().0,
177            ))
178        }
179    }
180
181    #[doc(alias = "gst_audio_decoder_get_plc_aware")]
182    #[doc(alias = "get_plc_aware")]
183    fn plc_aware(&self) -> i32 {
184        unsafe { ffi::gst_audio_decoder_get_plc_aware(self.as_ref().to_glib_none().0) }
185    }
186
187    #[doc(alias = "gst_audio_decoder_get_tolerance")]
188    #[doc(alias = "get_tolerance")]
189    fn tolerance(&self) -> gst::ClockTime {
190        unsafe {
191            try_from_glib(ffi::gst_audio_decoder_get_tolerance(
192                self.as_ref().to_glib_none().0,
193            ))
194            .expect("mandatory glib value is None")
195        }
196    }
197
198    #[doc(alias = "gst_audio_decoder_merge_tags")]
199    fn merge_tags(&self, tags: Option<&gst::TagList>, mode: gst::TagMergeMode) {
200        unsafe {
201            ffi::gst_audio_decoder_merge_tags(
202                self.as_ref().to_glib_none().0,
203                tags.to_glib_none().0,
204                mode.into_glib(),
205            );
206        }
207    }
208
209    #[doc(alias = "gst_audio_decoder_proxy_getcaps")]
210    fn proxy_getcaps(&self, caps: Option<&gst::Caps>, filter: Option<&gst::Caps>) -> gst::Caps {
211        unsafe {
212            from_glib_full(ffi::gst_audio_decoder_proxy_getcaps(
213                self.as_ref().to_glib_none().0,
214                caps.to_glib_none().0,
215                filter.to_glib_none().0,
216            ))
217        }
218    }
219
220    #[doc(alias = "gst_audio_decoder_set_allocation_caps")]
221    fn set_allocation_caps(&self, allocation_caps: Option<&gst::Caps>) {
222        unsafe {
223            ffi::gst_audio_decoder_set_allocation_caps(
224                self.as_ref().to_glib_none().0,
225                allocation_caps.to_glib_none().0,
226            );
227        }
228    }
229
230    #[doc(alias = "gst_audio_decoder_set_drainable")]
231    fn set_drainable(&self, enabled: bool) {
232        unsafe {
233            ffi::gst_audio_decoder_set_drainable(
234                self.as_ref().to_glib_none().0,
235                enabled.into_glib(),
236            );
237        }
238    }
239
240    #[doc(alias = "gst_audio_decoder_set_estimate_rate")]
241    fn set_estimate_rate(&self, enabled: bool) {
242        unsafe {
243            ffi::gst_audio_decoder_set_estimate_rate(
244                self.as_ref().to_glib_none().0,
245                enabled.into_glib(),
246            );
247        }
248    }
249
250    #[doc(alias = "gst_audio_decoder_set_latency")]
251    fn set_latency(&self, min: gst::ClockTime, max: impl Into<Option<gst::ClockTime>>) {
252        unsafe {
253            ffi::gst_audio_decoder_set_latency(
254                self.as_ref().to_glib_none().0,
255                min.into_glib(),
256                max.into().into_glib(),
257            );
258        }
259    }
260
261    #[doc(alias = "gst_audio_decoder_set_max_errors")]
262    #[doc(alias = "max-errors")]
263    fn set_max_errors(&self, num: i32) {
264        unsafe {
265            ffi::gst_audio_decoder_set_max_errors(self.as_ref().to_glib_none().0, num);
266        }
267    }
268
269    #[doc(alias = "gst_audio_decoder_set_min_latency")]
270    #[doc(alias = "min-latency")]
271    fn set_min_latency(&self, num: gst::ClockTime) {
272        unsafe {
273            ffi::gst_audio_decoder_set_min_latency(self.as_ref().to_glib_none().0, num.into_glib());
274        }
275    }
276
277    #[doc(alias = "gst_audio_decoder_set_needs_format")]
278    fn set_needs_format(&self, enabled: bool) {
279        unsafe {
280            ffi::gst_audio_decoder_set_needs_format(
281                self.as_ref().to_glib_none().0,
282                enabled.into_glib(),
283            );
284        }
285    }
286
287    #[doc(alias = "gst_audio_decoder_set_plc")]
288    #[doc(alias = "plc")]
289    fn set_plc(&self, enabled: bool) {
290        unsafe {
291            ffi::gst_audio_decoder_set_plc(self.as_ref().to_glib_none().0, enabled.into_glib());
292        }
293    }
294
295    #[doc(alias = "gst_audio_decoder_set_plc_aware")]
296    fn set_plc_aware(&self, plc: bool) {
297        unsafe {
298            ffi::gst_audio_decoder_set_plc_aware(self.as_ref().to_glib_none().0, plc.into_glib());
299        }
300    }
301
302    #[doc(alias = "gst_audio_decoder_set_tolerance")]
303    #[doc(alias = "tolerance")]
304    fn set_tolerance(&self, tolerance: gst::ClockTime) {
305        unsafe {
306            ffi::gst_audio_decoder_set_tolerance(
307                self.as_ref().to_glib_none().0,
308                tolerance.into_glib(),
309            );
310        }
311    }
312
313    #[doc(alias = "gst_audio_decoder_set_use_default_pad_acceptcaps")]
314    fn set_use_default_pad_acceptcaps(&self, use_: bool) {
315        unsafe {
316            ffi::gst_audio_decoder_set_use_default_pad_acceptcaps(
317                self.as_ref().to_glib_none().0,
318                use_.into_glib(),
319            );
320        }
321    }
322
323    #[cfg(feature = "v1_18")]
324    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
325    #[doc(alias = "max-errors")]
326    fn connect_max_errors_notify<F: Fn(&Self) + Send + Sync + 'static>(
327        &self,
328        f: F,
329    ) -> SignalHandlerId {
330        unsafe extern "C" fn notify_max_errors_trampoline<
331            P: IsA<AudioDecoder>,
332            F: Fn(&P) + Send + Sync + 'static,
333        >(
334            this: *mut ffi::GstAudioDecoder,
335            _param_spec: glib::ffi::gpointer,
336            f: glib::ffi::gpointer,
337        ) {
338            let f: &F = &*(f as *const F);
339            f(AudioDecoder::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                b"notify::max-errors\0".as_ptr() as *const _,
346                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
347                    notify_max_errors_trampoline::<Self, F> as *const (),
348                )),
349                Box_::into_raw(f),
350            )
351        }
352    }
353
354    #[doc(alias = "min-latency")]
355    fn connect_min_latency_notify<F: Fn(&Self) + Send + Sync + 'static>(
356        &self,
357        f: F,
358    ) -> SignalHandlerId {
359        unsafe extern "C" fn notify_min_latency_trampoline<
360            P: IsA<AudioDecoder>,
361            F: Fn(&P) + Send + Sync + 'static,
362        >(
363            this: *mut ffi::GstAudioDecoder,
364            _param_spec: glib::ffi::gpointer,
365            f: glib::ffi::gpointer,
366        ) {
367            let f: &F = &*(f as *const F);
368            f(AudioDecoder::from_glib_borrow(this).unsafe_cast_ref())
369        }
370        unsafe {
371            let f: Box_<F> = Box_::new(f);
372            connect_raw(
373                self.as_ptr() as *mut _,
374                b"notify::min-latency\0".as_ptr() as *const _,
375                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
376                    notify_min_latency_trampoline::<Self, F> as *const (),
377                )),
378                Box_::into_raw(f),
379            )
380        }
381    }
382
383    #[doc(alias = "plc")]
384    fn connect_plc_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
385        unsafe extern "C" fn notify_plc_trampoline<
386            P: IsA<AudioDecoder>,
387            F: Fn(&P) + Send + Sync + 'static,
388        >(
389            this: *mut ffi::GstAudioDecoder,
390            _param_spec: glib::ffi::gpointer,
391            f: glib::ffi::gpointer,
392        ) {
393            let f: &F = &*(f as *const F);
394            f(AudioDecoder::from_glib_borrow(this).unsafe_cast_ref())
395        }
396        unsafe {
397            let f: Box_<F> = Box_::new(f);
398            connect_raw(
399                self.as_ptr() as *mut _,
400                b"notify::plc\0".as_ptr() as *const _,
401                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
402                    notify_plc_trampoline::<Self, F> as *const (),
403                )),
404                Box_::into_raw(f),
405            )
406        }
407    }
408
409    #[doc(alias = "tolerance")]
410    fn connect_tolerance_notify<F: Fn(&Self) + Send + Sync + 'static>(
411        &self,
412        f: F,
413    ) -> SignalHandlerId {
414        unsafe extern "C" fn notify_tolerance_trampoline<
415            P: IsA<AudioDecoder>,
416            F: Fn(&P) + Send + Sync + 'static,
417        >(
418            this: *mut ffi::GstAudioDecoder,
419            _param_spec: glib::ffi::gpointer,
420            f: glib::ffi::gpointer,
421        ) {
422            let f: &F = &*(f as *const F);
423            f(AudioDecoder::from_glib_borrow(this).unsafe_cast_ref())
424        }
425        unsafe {
426            let f: Box_<F> = Box_::new(f);
427            connect_raw(
428                self.as_ptr() as *mut _,
429                b"notify::tolerance\0".as_ptr() as *const _,
430                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
431                    notify_tolerance_trampoline::<Self, F> as *const (),
432                )),
433                Box_::into_raw(f),
434            )
435        }
436    }
437}
438
439impl<O: IsA<AudioDecoder>> AudioDecoderExt for O {}