Skip to main content

gstreamer_audio/auto/
audio_encoder.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::{AudioInfo, ffi};
7use glib::{
8    prelude::*,
9    signal::{SignalHandlerId, connect_raw},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "GstAudioEncoder")]
16    pub struct AudioEncoder(Object<ffi::GstAudioEncoder, ffi::GstAudioEncoderClass>) @extends gst::Element, gst::Object;
17
18    match fn {
19        type_ => || ffi::gst_audio_encoder_get_type(),
20    }
21}
22
23impl AudioEncoder {
24    pub const NONE: Option<&'static AudioEncoder> = None;
25}
26
27unsafe impl Send for AudioEncoder {}
28unsafe impl Sync for AudioEncoder {}
29
30pub trait AudioEncoderExt: IsA<AudioEncoder> + 'static {
31    #[doc(alias = "gst_audio_encoder_allocate_output_buffer")]
32    fn allocate_output_buffer(&self, size: usize) -> gst::Buffer {
33        unsafe {
34            from_glib_full(ffi::gst_audio_encoder_allocate_output_buffer(
35                self.as_ref().to_glib_none().0,
36                size,
37            ))
38        }
39    }
40
41    #[doc(alias = "gst_audio_encoder_finish_frame")]
42    fn finish_frame(
43        &self,
44        buffer: Option<gst::Buffer>,
45        samples: i32,
46    ) -> Result<gst::FlowSuccess, gst::FlowError> {
47        unsafe {
48            try_from_glib(ffi::gst_audio_encoder_finish_frame(
49                self.as_ref().to_glib_none().0,
50                buffer.into_glib_ptr(),
51                samples,
52            ))
53        }
54    }
55
56    #[doc(alias = "gst_audio_encoder_get_audio_info")]
57    #[doc(alias = "get_audio_info")]
58    fn audio_info(&self) -> AudioInfo {
59        unsafe {
60            from_glib_none(ffi::gst_audio_encoder_get_audio_info(
61                self.as_ref().to_glib_none().0,
62            ))
63        }
64    }
65
66    #[doc(alias = "gst_audio_encoder_get_drainable")]
67    #[doc(alias = "get_drainable")]
68    fn is_drainable(&self) -> bool {
69        unsafe {
70            from_glib(ffi::gst_audio_encoder_get_drainable(
71                self.as_ref().to_glib_none().0,
72            ))
73        }
74    }
75
76    #[doc(alias = "gst_audio_encoder_get_frame_max")]
77    #[doc(alias = "get_frame_max")]
78    fn frame_max(&self) -> i32 {
79        unsafe { ffi::gst_audio_encoder_get_frame_max(self.as_ref().to_glib_none().0) }
80    }
81
82    #[doc(alias = "gst_audio_encoder_get_frame_samples_max")]
83    #[doc(alias = "get_frame_samples_max")]
84    fn frame_samples_max(&self) -> i32 {
85        unsafe { ffi::gst_audio_encoder_get_frame_samples_max(self.as_ref().to_glib_none().0) }
86    }
87
88    #[doc(alias = "gst_audio_encoder_get_frame_samples_min")]
89    #[doc(alias = "get_frame_samples_min")]
90    fn frame_samples_min(&self) -> i32 {
91        unsafe { ffi::gst_audio_encoder_get_frame_samples_min(self.as_ref().to_glib_none().0) }
92    }
93
94    #[doc(alias = "gst_audio_encoder_get_hard_min")]
95    #[doc(alias = "get_hard_min")]
96    fn is_hard_min(&self) -> bool {
97        unsafe {
98            from_glib(ffi::gst_audio_encoder_get_hard_min(
99                self.as_ref().to_glib_none().0,
100            ))
101        }
102    }
103
104    #[doc(alias = "gst_audio_encoder_get_hard_resync")]
105    #[doc(alias = "get_hard_resync")]
106    #[doc(alias = "hard-resync")]
107    fn is_hard_resync(&self) -> bool {
108        unsafe {
109            from_glib(ffi::gst_audio_encoder_get_hard_resync(
110                self.as_ref().to_glib_none().0,
111            ))
112        }
113    }
114
115    #[doc(alias = "gst_audio_encoder_get_latency")]
116    #[doc(alias = "get_latency")]
117    fn latency(&self) -> (gst::ClockTime, Option<gst::ClockTime>) {
118        unsafe {
119            let mut min = std::mem::MaybeUninit::uninit();
120            let mut max = std::mem::MaybeUninit::uninit();
121            ffi::gst_audio_encoder_get_latency(
122                self.as_ref().to_glib_none().0,
123                min.as_mut_ptr(),
124                max.as_mut_ptr(),
125            );
126            (
127                try_from_glib(min.assume_init()).expect("mandatory glib value is None"),
128                from_glib(max.assume_init()),
129            )
130        }
131    }
132
133    #[doc(alias = "gst_audio_encoder_get_lookahead")]
134    #[doc(alias = "get_lookahead")]
135    fn lookahead(&self) -> i32 {
136        unsafe { ffi::gst_audio_encoder_get_lookahead(self.as_ref().to_glib_none().0) }
137    }
138
139    #[doc(alias = "gst_audio_encoder_get_mark_granule")]
140    #[doc(alias = "get_mark_granule")]
141    #[doc(alias = "mark-granule")]
142    fn is_mark_granule(&self) -> bool {
143        unsafe {
144            from_glib(ffi::gst_audio_encoder_get_mark_granule(
145                self.as_ref().to_glib_none().0,
146            ))
147        }
148    }
149
150    #[doc(alias = "gst_audio_encoder_get_perfect_timestamp")]
151    #[doc(alias = "get_perfect_timestamp")]
152    #[doc(alias = "perfect-timestamp")]
153    fn is_perfect_timestamp(&self) -> bool {
154        unsafe {
155            from_glib(ffi::gst_audio_encoder_get_perfect_timestamp(
156                self.as_ref().to_glib_none().0,
157            ))
158        }
159    }
160
161    #[doc(alias = "gst_audio_encoder_get_tolerance")]
162    #[doc(alias = "get_tolerance")]
163    fn tolerance(&self) -> gst::ClockTime {
164        unsafe {
165            try_from_glib(ffi::gst_audio_encoder_get_tolerance(
166                self.as_ref().to_glib_none().0,
167            ))
168            .expect("mandatory glib value is None")
169        }
170    }
171
172    #[doc(alias = "gst_audio_encoder_merge_tags")]
173    fn merge_tags(&self, tags: Option<&gst::TagList>, mode: gst::TagMergeMode) {
174        unsafe {
175            ffi::gst_audio_encoder_merge_tags(
176                self.as_ref().to_glib_none().0,
177                tags.to_glib_none().0,
178                mode.into_glib(),
179            );
180        }
181    }
182
183    #[doc(alias = "gst_audio_encoder_proxy_getcaps")]
184    fn proxy_getcaps(&self, caps: Option<&gst::Caps>, filter: Option<&gst::Caps>) -> gst::Caps {
185        unsafe {
186            from_glib_full(ffi::gst_audio_encoder_proxy_getcaps(
187                self.as_ref().to_glib_none().0,
188                caps.to_glib_none().0,
189                filter.to_glib_none().0,
190            ))
191        }
192    }
193
194    #[doc(alias = "gst_audio_encoder_set_allocation_caps")]
195    fn set_allocation_caps(&self, allocation_caps: Option<&gst::Caps>) {
196        unsafe {
197            ffi::gst_audio_encoder_set_allocation_caps(
198                self.as_ref().to_glib_none().0,
199                allocation_caps.to_glib_none().0,
200            );
201        }
202    }
203
204    #[doc(alias = "gst_audio_encoder_set_drainable")]
205    fn set_drainable(&self, enabled: bool) {
206        unsafe {
207            ffi::gst_audio_encoder_set_drainable(
208                self.as_ref().to_glib_none().0,
209                enabled.into_glib(),
210            );
211        }
212    }
213
214    #[doc(alias = "gst_audio_encoder_set_frame_max")]
215    fn set_frame_max(&self, num: i32) {
216        unsafe {
217            ffi::gst_audio_encoder_set_frame_max(self.as_ref().to_glib_none().0, num);
218        }
219    }
220
221    #[doc(alias = "gst_audio_encoder_set_frame_samples_max")]
222    fn set_frame_samples_max(&self, num: i32) {
223        unsafe {
224            ffi::gst_audio_encoder_set_frame_samples_max(self.as_ref().to_glib_none().0, num);
225        }
226    }
227
228    #[doc(alias = "gst_audio_encoder_set_frame_samples_min")]
229    fn set_frame_samples_min(&self, num: i32) {
230        unsafe {
231            ffi::gst_audio_encoder_set_frame_samples_min(self.as_ref().to_glib_none().0, num);
232        }
233    }
234
235    #[doc(alias = "gst_audio_encoder_set_hard_min")]
236    fn set_hard_min(&self, enabled: bool) {
237        unsafe {
238            ffi::gst_audio_encoder_set_hard_min(
239                self.as_ref().to_glib_none().0,
240                enabled.into_glib(),
241            );
242        }
243    }
244
245    #[doc(alias = "gst_audio_encoder_set_hard_resync")]
246    #[doc(alias = "hard-resync")]
247    fn set_hard_resync(&self, enabled: bool) {
248        unsafe {
249            ffi::gst_audio_encoder_set_hard_resync(
250                self.as_ref().to_glib_none().0,
251                enabled.into_glib(),
252            );
253        }
254    }
255
256    #[doc(alias = "gst_audio_encoder_set_latency")]
257    fn set_latency(&self, min: gst::ClockTime, max: impl Into<Option<gst::ClockTime>>) {
258        unsafe {
259            ffi::gst_audio_encoder_set_latency(
260                self.as_ref().to_glib_none().0,
261                min.into_glib(),
262                max.into().into_glib(),
263            );
264        }
265    }
266
267    #[doc(alias = "gst_audio_encoder_set_lookahead")]
268    fn set_lookahead(&self, num: i32) {
269        unsafe {
270            ffi::gst_audio_encoder_set_lookahead(self.as_ref().to_glib_none().0, num);
271        }
272    }
273
274    #[doc(alias = "gst_audio_encoder_set_mark_granule")]
275    fn set_mark_granule(&self, enabled: bool) {
276        unsafe {
277            ffi::gst_audio_encoder_set_mark_granule(
278                self.as_ref().to_glib_none().0,
279                enabled.into_glib(),
280            );
281        }
282    }
283
284    #[doc(alias = "gst_audio_encoder_set_perfect_timestamp")]
285    #[doc(alias = "perfect-timestamp")]
286    fn set_perfect_timestamp(&self, enabled: bool) {
287        unsafe {
288            ffi::gst_audio_encoder_set_perfect_timestamp(
289                self.as_ref().to_glib_none().0,
290                enabled.into_glib(),
291            );
292        }
293    }
294
295    #[doc(alias = "gst_audio_encoder_set_tolerance")]
296    #[doc(alias = "tolerance")]
297    fn set_tolerance(&self, tolerance: gst::ClockTime) {
298        unsafe {
299            ffi::gst_audio_encoder_set_tolerance(
300                self.as_ref().to_glib_none().0,
301                tolerance.into_glib(),
302            );
303        }
304    }
305
306    #[doc(alias = "hard-resync")]
307    fn connect_hard_resync_notify<F: Fn(&Self) + Send + Sync + 'static>(
308        &self,
309        f: F,
310    ) -> SignalHandlerId {
311        unsafe extern "C" fn notify_hard_resync_trampoline<
312            P: IsA<AudioEncoder>,
313            F: Fn(&P) + Send + Sync + 'static,
314        >(
315            this: *mut ffi::GstAudioEncoder,
316            _param_spec: glib::ffi::gpointer,
317            f: glib::ffi::gpointer,
318        ) {
319            unsafe {
320                let f: &F = &*(f as *const F);
321                f(AudioEncoder::from_glib_borrow(this).unsafe_cast_ref())
322            }
323        }
324        unsafe {
325            let f: Box_<F> = Box_::new(f);
326            connect_raw(
327                self.as_ptr() as *mut _,
328                c"notify::hard-resync".as_ptr(),
329                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
330                    notify_hard_resync_trampoline::<Self, F> as *const (),
331                )),
332                Box_::into_raw(f),
333            )
334        }
335    }
336
337    #[doc(alias = "mark-granule")]
338    fn connect_mark_granule_notify<F: Fn(&Self) + Send + Sync + 'static>(
339        &self,
340        f: F,
341    ) -> SignalHandlerId {
342        unsafe extern "C" fn notify_mark_granule_trampoline<
343            P: IsA<AudioEncoder>,
344            F: Fn(&P) + Send + Sync + 'static,
345        >(
346            this: *mut ffi::GstAudioEncoder,
347            _param_spec: glib::ffi::gpointer,
348            f: glib::ffi::gpointer,
349        ) {
350            unsafe {
351                let f: &F = &*(f as *const F);
352                f(AudioEncoder::from_glib_borrow(this).unsafe_cast_ref())
353            }
354        }
355        unsafe {
356            let f: Box_<F> = Box_::new(f);
357            connect_raw(
358                self.as_ptr() as *mut _,
359                c"notify::mark-granule".as_ptr(),
360                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
361                    notify_mark_granule_trampoline::<Self, F> as *const (),
362                )),
363                Box_::into_raw(f),
364            )
365        }
366    }
367
368    #[doc(alias = "perfect-timestamp")]
369    fn connect_perfect_timestamp_notify<F: Fn(&Self) + Send + Sync + 'static>(
370        &self,
371        f: F,
372    ) -> SignalHandlerId {
373        unsafe extern "C" fn notify_perfect_timestamp_trampoline<
374            P: IsA<AudioEncoder>,
375            F: Fn(&P) + Send + Sync + 'static,
376        >(
377            this: *mut ffi::GstAudioEncoder,
378            _param_spec: glib::ffi::gpointer,
379            f: glib::ffi::gpointer,
380        ) {
381            unsafe {
382                let f: &F = &*(f as *const F);
383                f(AudioEncoder::from_glib_borrow(this).unsafe_cast_ref())
384            }
385        }
386        unsafe {
387            let f: Box_<F> = Box_::new(f);
388            connect_raw(
389                self.as_ptr() as *mut _,
390                c"notify::perfect-timestamp".as_ptr(),
391                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
392                    notify_perfect_timestamp_trampoline::<Self, F> as *const (),
393                )),
394                Box_::into_raw(f),
395            )
396        }
397    }
398
399    #[doc(alias = "tolerance")]
400    fn connect_tolerance_notify<F: Fn(&Self) + Send + Sync + 'static>(
401        &self,
402        f: F,
403    ) -> SignalHandlerId {
404        unsafe extern "C" fn notify_tolerance_trampoline<
405            P: IsA<AudioEncoder>,
406            F: Fn(&P) + Send + Sync + 'static,
407        >(
408            this: *mut ffi::GstAudioEncoder,
409            _param_spec: glib::ffi::gpointer,
410            f: glib::ffi::gpointer,
411        ) {
412            unsafe {
413                let f: &F = &*(f as *const F);
414                f(AudioEncoder::from_glib_borrow(this).unsafe_cast_ref())
415            }
416        }
417        unsafe {
418            let f: Box_<F> = Box_::new(f);
419            connect_raw(
420                self.as_ptr() as *mut _,
421                c"notify::tolerance".as_ptr(),
422                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
423                    notify_tolerance_trampoline::<Self, F> as *const (),
424                )),
425                Box_::into_raw(f),
426            )
427        }
428    }
429}
430
431impl<O: IsA<AudioEncoder>> AudioEncoderExt for O {}