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