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 | |
6 | use crate::AudioInfo; |
7 | use glib::{ |
8 | prelude::*, |
9 | signal::{connect_raw, SignalHandlerId}, |
10 | translate::*, |
11 | }; |
12 | use std::{boxed::Box as Box_, mem, mem::transmute}; |
13 | |
14 | glib::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 | |
23 | impl AudioDecoder { |
24 | pub const NONE: Option<&'static AudioDecoder> = None; |
25 | } |
26 | |
27 | unsafe impl Send for AudioDecoder {} |
28 | unsafe impl Sync for AudioDecoder {} |
29 | |
30 | mod sealed { |
31 | pub trait Sealed {} |
32 | impl<T: super::IsA<super::AudioDecoder>> Sealed for T {} |
33 | } |
34 | |
35 | pub 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 = mem::MaybeUninit::uninit(); |
113 | let mut max = 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 | fn max_errors(&self) -> i32 { |
129 | unsafe { ffi::gst_audio_decoder_get_max_errors(self.as_ref().to_glib_none().0) } |
130 | } |
131 | |
132 | #[doc (alias = "gst_audio_decoder_get_min_latency" )] |
133 | #[doc (alias = "get_min_latency" )] |
134 | fn min_latency(&self) -> gst::ClockTime { |
135 | unsafe { |
136 | try_from_glib(ffi::gst_audio_decoder_get_min_latency( |
137 | self.as_ref().to_glib_none().0, |
138 | )) |
139 | .expect("mandatory glib value is None" ) |
140 | } |
141 | } |
142 | |
143 | #[doc (alias = "gst_audio_decoder_get_needs_format" )] |
144 | #[doc (alias = "get_needs_format" )] |
145 | fn needs_format(&self) -> bool { |
146 | unsafe { |
147 | from_glib(ffi::gst_audio_decoder_get_needs_format( |
148 | self.as_ref().to_glib_none().0, |
149 | )) |
150 | } |
151 | } |
152 | |
153 | #[doc (alias = "gst_audio_decoder_get_parse_state" )] |
154 | #[doc (alias = "get_parse_state" )] |
155 | fn parse_state(&self) -> (bool, bool) { |
156 | unsafe { |
157 | let mut sync = mem::MaybeUninit::uninit(); |
158 | let mut eos = mem::MaybeUninit::uninit(); |
159 | ffi::gst_audio_decoder_get_parse_state( |
160 | self.as_ref().to_glib_none().0, |
161 | sync.as_mut_ptr(), |
162 | eos.as_mut_ptr(), |
163 | ); |
164 | (from_glib(sync.assume_init()), from_glib(eos.assume_init())) |
165 | } |
166 | } |
167 | |
168 | #[doc (alias = "gst_audio_decoder_get_plc" )] |
169 | #[doc (alias = "get_plc" )] |
170 | fn is_plc(&self) -> bool { |
171 | unsafe { |
172 | from_glib(ffi::gst_audio_decoder_get_plc( |
173 | self.as_ref().to_glib_none().0, |
174 | )) |
175 | } |
176 | } |
177 | |
178 | #[doc (alias = "gst_audio_decoder_get_plc_aware" )] |
179 | #[doc (alias = "get_plc_aware" )] |
180 | fn plc_aware(&self) -> i32 { |
181 | unsafe { ffi::gst_audio_decoder_get_plc_aware(self.as_ref().to_glib_none().0) } |
182 | } |
183 | |
184 | #[doc (alias = "gst_audio_decoder_get_tolerance" )] |
185 | #[doc (alias = "get_tolerance" )] |
186 | fn tolerance(&self) -> gst::ClockTime { |
187 | unsafe { |
188 | try_from_glib(ffi::gst_audio_decoder_get_tolerance( |
189 | self.as_ref().to_glib_none().0, |
190 | )) |
191 | .expect("mandatory glib value is None" ) |
192 | } |
193 | } |
194 | |
195 | #[doc (alias = "gst_audio_decoder_merge_tags" )] |
196 | fn merge_tags(&self, tags: Option<&gst::TagList>, mode: gst::TagMergeMode) { |
197 | unsafe { |
198 | ffi::gst_audio_decoder_merge_tags( |
199 | self.as_ref().to_glib_none().0, |
200 | tags.to_glib_none().0, |
201 | mode.into_glib(), |
202 | ); |
203 | } |
204 | } |
205 | |
206 | #[doc (alias = "gst_audio_decoder_proxy_getcaps" )] |
207 | fn proxy_getcaps(&self, caps: Option<&gst::Caps>, filter: Option<&gst::Caps>) -> gst::Caps { |
208 | unsafe { |
209 | from_glib_full(ffi::gst_audio_decoder_proxy_getcaps( |
210 | self.as_ref().to_glib_none().0, |
211 | caps.to_glib_none().0, |
212 | filter.to_glib_none().0, |
213 | )) |
214 | } |
215 | } |
216 | |
217 | #[doc (alias = "gst_audio_decoder_set_allocation_caps" )] |
218 | fn set_allocation_caps(&self, allocation_caps: Option<&gst::Caps>) { |
219 | unsafe { |
220 | ffi::gst_audio_decoder_set_allocation_caps( |
221 | self.as_ref().to_glib_none().0, |
222 | allocation_caps.to_glib_none().0, |
223 | ); |
224 | } |
225 | } |
226 | |
227 | #[doc (alias = "gst_audio_decoder_set_drainable" )] |
228 | fn set_drainable(&self, enabled: bool) { |
229 | unsafe { |
230 | ffi::gst_audio_decoder_set_drainable( |
231 | self.as_ref().to_glib_none().0, |
232 | enabled.into_glib(), |
233 | ); |
234 | } |
235 | } |
236 | |
237 | #[doc (alias = "gst_audio_decoder_set_estimate_rate" )] |
238 | fn set_estimate_rate(&self, enabled: bool) { |
239 | unsafe { |
240 | ffi::gst_audio_decoder_set_estimate_rate( |
241 | self.as_ref().to_glib_none().0, |
242 | enabled.into_glib(), |
243 | ); |
244 | } |
245 | } |
246 | |
247 | #[doc (alias = "gst_audio_decoder_set_latency" )] |
248 | fn set_latency(&self, min: gst::ClockTime, max: impl Into<Option<gst::ClockTime>>) { |
249 | unsafe { |
250 | ffi::gst_audio_decoder_set_latency( |
251 | self.as_ref().to_glib_none().0, |
252 | min.into_glib(), |
253 | max.into().into_glib(), |
254 | ); |
255 | } |
256 | } |
257 | |
258 | #[doc (alias = "gst_audio_decoder_set_max_errors" )] |
259 | fn set_max_errors(&self, num: i32) { |
260 | unsafe { |
261 | ffi::gst_audio_decoder_set_max_errors(self.as_ref().to_glib_none().0, num); |
262 | } |
263 | } |
264 | |
265 | #[doc (alias = "gst_audio_decoder_set_min_latency" )] |
266 | fn set_min_latency(&self, num: gst::ClockTime) { |
267 | unsafe { |
268 | ffi::gst_audio_decoder_set_min_latency(self.as_ref().to_glib_none().0, num.into_glib()); |
269 | } |
270 | } |
271 | |
272 | #[doc (alias = "gst_audio_decoder_set_needs_format" )] |
273 | fn set_needs_format(&self, enabled: bool) { |
274 | unsafe { |
275 | ffi::gst_audio_decoder_set_needs_format( |
276 | self.as_ref().to_glib_none().0, |
277 | enabled.into_glib(), |
278 | ); |
279 | } |
280 | } |
281 | |
282 | #[doc (alias = "gst_audio_decoder_set_plc" )] |
283 | fn set_plc(&self, enabled: bool) { |
284 | unsafe { |
285 | ffi::gst_audio_decoder_set_plc(self.as_ref().to_glib_none().0, enabled.into_glib()); |
286 | } |
287 | } |
288 | |
289 | #[doc (alias = "gst_audio_decoder_set_plc_aware" )] |
290 | fn set_plc_aware(&self, plc: bool) { |
291 | unsafe { |
292 | ffi::gst_audio_decoder_set_plc_aware(self.as_ref().to_glib_none().0, plc.into_glib()); |
293 | } |
294 | } |
295 | |
296 | #[doc (alias = "gst_audio_decoder_set_tolerance" )] |
297 | fn set_tolerance(&self, tolerance: gst::ClockTime) { |
298 | unsafe { |
299 | ffi::gst_audio_decoder_set_tolerance( |
300 | self.as_ref().to_glib_none().0, |
301 | tolerance.into_glib(), |
302 | ); |
303 | } |
304 | } |
305 | |
306 | #[doc (alias = "gst_audio_decoder_set_use_default_pad_acceptcaps" )] |
307 | fn set_use_default_pad_acceptcaps(&self, use_: bool) { |
308 | unsafe { |
309 | ffi::gst_audio_decoder_set_use_default_pad_acceptcaps( |
310 | self.as_ref().to_glib_none().0, |
311 | use_.into_glib(), |
312 | ); |
313 | } |
314 | } |
315 | |
316 | #[cfg (feature = "v1_18" )] |
317 | #[cfg_attr (docsrs, doc(cfg(feature = "v1_18" )))] |
318 | #[doc (alias = "max-errors" )] |
319 | fn connect_max_errors_notify<F: Fn(&Self) + Send + Sync + 'static>( |
320 | &self, |
321 | f: F, |
322 | ) -> SignalHandlerId { |
323 | unsafe extern "C" fn notify_max_errors_trampoline< |
324 | P: IsA<AudioDecoder>, |
325 | F: Fn(&P) + Send + Sync + 'static, |
326 | >( |
327 | this: *mut ffi::GstAudioDecoder, |
328 | _param_spec: glib::ffi::gpointer, |
329 | f: glib::ffi::gpointer, |
330 | ) { |
331 | let f: &F = &*(f as *const F); |
332 | f(AudioDecoder::from_glib_borrow(this).unsafe_cast_ref()) |
333 | } |
334 | unsafe { |
335 | let f: Box_<F> = Box_::new(f); |
336 | connect_raw( |
337 | self.as_ptr() as *mut _, |
338 | b"notify::max-errors \0" .as_ptr() as *const _, |
339 | Some(transmute::<_, unsafe extern "C" fn()>( |
340 | notify_max_errors_trampoline::<Self, F> as *const (), |
341 | )), |
342 | Box_::into_raw(f), |
343 | ) |
344 | } |
345 | } |
346 | |
347 | #[doc (alias = "min-latency" )] |
348 | fn connect_min_latency_notify<F: Fn(&Self) + Send + Sync + 'static>( |
349 | &self, |
350 | f: F, |
351 | ) -> SignalHandlerId { |
352 | unsafe extern "C" fn notify_min_latency_trampoline< |
353 | P: IsA<AudioDecoder>, |
354 | F: Fn(&P) + Send + Sync + 'static, |
355 | >( |
356 | this: *mut ffi::GstAudioDecoder, |
357 | _param_spec: glib::ffi::gpointer, |
358 | f: glib::ffi::gpointer, |
359 | ) { |
360 | let f: &F = &*(f as *const F); |
361 | f(AudioDecoder::from_glib_borrow(this).unsafe_cast_ref()) |
362 | } |
363 | unsafe { |
364 | let f: Box_<F> = Box_::new(f); |
365 | connect_raw( |
366 | self.as_ptr() as *mut _, |
367 | b"notify::min-latency \0" .as_ptr() as *const _, |
368 | Some(transmute::<_, unsafe extern "C" fn()>( |
369 | notify_min_latency_trampoline::<Self, F> as *const (), |
370 | )), |
371 | Box_::into_raw(f), |
372 | ) |
373 | } |
374 | } |
375 | |
376 | #[doc (alias = "plc" )] |
377 | fn connect_plc_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId { |
378 | unsafe extern "C" fn notify_plc_trampoline< |
379 | P: IsA<AudioDecoder>, |
380 | F: Fn(&P) + Send + Sync + 'static, |
381 | >( |
382 | this: *mut ffi::GstAudioDecoder, |
383 | _param_spec: glib::ffi::gpointer, |
384 | f: glib::ffi::gpointer, |
385 | ) { |
386 | let f: &F = &*(f as *const F); |
387 | f(AudioDecoder::from_glib_borrow(this).unsafe_cast_ref()) |
388 | } |
389 | unsafe { |
390 | let f: Box_<F> = Box_::new(f); |
391 | connect_raw( |
392 | self.as_ptr() as *mut _, |
393 | b"notify::plc \0" .as_ptr() as *const _, |
394 | Some(transmute::<_, unsafe extern "C" fn()>( |
395 | notify_plc_trampoline::<Self, F> as *const (), |
396 | )), |
397 | Box_::into_raw(f), |
398 | ) |
399 | } |
400 | } |
401 | |
402 | #[doc (alias = "tolerance" )] |
403 | fn connect_tolerance_notify<F: Fn(&Self) + Send + Sync + 'static>( |
404 | &self, |
405 | f: F, |
406 | ) -> SignalHandlerId { |
407 | unsafe extern "C" fn notify_tolerance_trampoline< |
408 | P: IsA<AudioDecoder>, |
409 | F: Fn(&P) + Send + Sync + 'static, |
410 | >( |
411 | this: *mut ffi::GstAudioDecoder, |
412 | _param_spec: glib::ffi::gpointer, |
413 | f: glib::ffi::gpointer, |
414 | ) { |
415 | let f: &F = &*(f as *const F); |
416 | f(AudioDecoder::from_glib_borrow(this).unsafe_cast_ref()) |
417 | } |
418 | unsafe { |
419 | let f: Box_<F> = Box_::new(f); |
420 | connect_raw( |
421 | self.as_ptr() as *mut _, |
422 | b"notify::tolerance \0" .as_ptr() as *const _, |
423 | Some(transmute::<_, unsafe extern "C" fn()>( |
424 | notify_tolerance_trampoline::<Self, F> as *const (), |
425 | )), |
426 | Box_::into_raw(f), |
427 | ) |
428 | } |
429 | } |
430 | } |
431 | |
432 | impl<O: IsA<AudioDecoder>> AudioDecoderExt for O {} |
433 | |