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::{ffi, AudioInfo}; |
7 | use glib::{ |
8 | prelude::*, |
9 | signal::{connect_raw, SignalHandlerId}, |
10 | translate::*, |
11 | }; |
12 | use std::boxed::Box as Box_; |
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 | #[doc (alias = "hard-resync" )] |
112 | fn is_hard_resync(&self) -> bool { |
113 | unsafe { |
114 | from_glib(ffi::gst_audio_encoder_get_hard_resync( |
115 | self.as_ref().to_glib_none().0, |
116 | )) |
117 | } |
118 | } |
119 | |
120 | #[doc (alias = "gst_audio_encoder_get_latency" )] |
121 | #[doc (alias = "get_latency" )] |
122 | fn latency(&self) -> (gst::ClockTime, Option<gst::ClockTime>) { |
123 | unsafe { |
124 | let mut min = std::mem::MaybeUninit::uninit(); |
125 | let mut max = std::mem::MaybeUninit::uninit(); |
126 | ffi::gst_audio_encoder_get_latency( |
127 | self.as_ref().to_glib_none().0, |
128 | min.as_mut_ptr(), |
129 | max.as_mut_ptr(), |
130 | ); |
131 | ( |
132 | try_from_glib(min.assume_init()).expect("mandatory glib value is None" ), |
133 | from_glib(max.assume_init()), |
134 | ) |
135 | } |
136 | } |
137 | |
138 | #[doc (alias = "gst_audio_encoder_get_lookahead" )] |
139 | #[doc (alias = "get_lookahead" )] |
140 | fn lookahead(&self) -> i32 { |
141 | unsafe { ffi::gst_audio_encoder_get_lookahead(self.as_ref().to_glib_none().0) } |
142 | } |
143 | |
144 | #[doc (alias = "gst_audio_encoder_get_mark_granule" )] |
145 | #[doc (alias = "get_mark_granule" )] |
146 | #[doc (alias = "mark-granule" )] |
147 | fn is_mark_granule(&self) -> bool { |
148 | unsafe { |
149 | from_glib(ffi::gst_audio_encoder_get_mark_granule( |
150 | self.as_ref().to_glib_none().0, |
151 | )) |
152 | } |
153 | } |
154 | |
155 | #[doc (alias = "gst_audio_encoder_get_perfect_timestamp" )] |
156 | #[doc (alias = "get_perfect_timestamp" )] |
157 | #[doc (alias = "perfect-timestamp" )] |
158 | fn is_perfect_timestamp(&self) -> bool { |
159 | unsafe { |
160 | from_glib(ffi::gst_audio_encoder_get_perfect_timestamp( |
161 | self.as_ref().to_glib_none().0, |
162 | )) |
163 | } |
164 | } |
165 | |
166 | #[doc (alias = "gst_audio_encoder_get_tolerance" )] |
167 | #[doc (alias = "get_tolerance" )] |
168 | fn tolerance(&self) -> gst::ClockTime { |
169 | unsafe { |
170 | try_from_glib(ffi::gst_audio_encoder_get_tolerance( |
171 | self.as_ref().to_glib_none().0, |
172 | )) |
173 | .expect("mandatory glib value is None" ) |
174 | } |
175 | } |
176 | |
177 | #[doc (alias = "gst_audio_encoder_merge_tags" )] |
178 | fn merge_tags(&self, tags: Option<&gst::TagList>, mode: gst::TagMergeMode) { |
179 | unsafe { |
180 | ffi::gst_audio_encoder_merge_tags( |
181 | self.as_ref().to_glib_none().0, |
182 | tags.to_glib_none().0, |
183 | mode.into_glib(), |
184 | ); |
185 | } |
186 | } |
187 | |
188 | #[doc (alias = "gst_audio_encoder_proxy_getcaps" )] |
189 | fn proxy_getcaps(&self, caps: Option<&gst::Caps>, filter: Option<&gst::Caps>) -> gst::Caps { |
190 | unsafe { |
191 | from_glib_full(ffi::gst_audio_encoder_proxy_getcaps( |
192 | self.as_ref().to_glib_none().0, |
193 | caps.to_glib_none().0, |
194 | filter.to_glib_none().0, |
195 | )) |
196 | } |
197 | } |
198 | |
199 | #[doc (alias = "gst_audio_encoder_set_allocation_caps" )] |
200 | fn set_allocation_caps(&self, allocation_caps: Option<&gst::Caps>) { |
201 | unsafe { |
202 | ffi::gst_audio_encoder_set_allocation_caps( |
203 | self.as_ref().to_glib_none().0, |
204 | allocation_caps.to_glib_none().0, |
205 | ); |
206 | } |
207 | } |
208 | |
209 | #[doc (alias = "gst_audio_encoder_set_drainable" )] |
210 | fn set_drainable(&self, enabled: bool) { |
211 | unsafe { |
212 | ffi::gst_audio_encoder_set_drainable( |
213 | self.as_ref().to_glib_none().0, |
214 | enabled.into_glib(), |
215 | ); |
216 | } |
217 | } |
218 | |
219 | #[doc (alias = "gst_audio_encoder_set_frame_max" )] |
220 | fn set_frame_max(&self, num: i32) { |
221 | unsafe { |
222 | ffi::gst_audio_encoder_set_frame_max(self.as_ref().to_glib_none().0, num); |
223 | } |
224 | } |
225 | |
226 | #[doc (alias = "gst_audio_encoder_set_frame_samples_max" )] |
227 | fn set_frame_samples_max(&self, num: i32) { |
228 | unsafe { |
229 | ffi::gst_audio_encoder_set_frame_samples_max(self.as_ref().to_glib_none().0, num); |
230 | } |
231 | } |
232 | |
233 | #[doc (alias = "gst_audio_encoder_set_frame_samples_min" )] |
234 | fn set_frame_samples_min(&self, num: i32) { |
235 | unsafe { |
236 | ffi::gst_audio_encoder_set_frame_samples_min(self.as_ref().to_glib_none().0, num); |
237 | } |
238 | } |
239 | |
240 | #[doc (alias = "gst_audio_encoder_set_hard_min" )] |
241 | fn set_hard_min(&self, enabled: bool) { |
242 | unsafe { |
243 | ffi::gst_audio_encoder_set_hard_min( |
244 | self.as_ref().to_glib_none().0, |
245 | enabled.into_glib(), |
246 | ); |
247 | } |
248 | } |
249 | |
250 | #[doc (alias = "gst_audio_encoder_set_hard_resync" )] |
251 | #[doc (alias = "hard-resync" )] |
252 | fn set_hard_resync(&self, enabled: bool) { |
253 | unsafe { |
254 | ffi::gst_audio_encoder_set_hard_resync( |
255 | self.as_ref().to_glib_none().0, |
256 | enabled.into_glib(), |
257 | ); |
258 | } |
259 | } |
260 | |
261 | #[doc (alias = "gst_audio_encoder_set_latency" )] |
262 | fn set_latency(&self, min: gst::ClockTime, max: impl Into<Option<gst::ClockTime>>) { |
263 | unsafe { |
264 | ffi::gst_audio_encoder_set_latency( |
265 | self.as_ref().to_glib_none().0, |
266 | min.into_glib(), |
267 | max.into().into_glib(), |
268 | ); |
269 | } |
270 | } |
271 | |
272 | #[doc (alias = "gst_audio_encoder_set_lookahead" )] |
273 | fn set_lookahead(&self, num: i32) { |
274 | unsafe { |
275 | ffi::gst_audio_encoder_set_lookahead(self.as_ref().to_glib_none().0, num); |
276 | } |
277 | } |
278 | |
279 | #[doc (alias = "gst_audio_encoder_set_mark_granule" )] |
280 | fn set_mark_granule(&self, enabled: bool) { |
281 | unsafe { |
282 | ffi::gst_audio_encoder_set_mark_granule( |
283 | self.as_ref().to_glib_none().0, |
284 | enabled.into_glib(), |
285 | ); |
286 | } |
287 | } |
288 | |
289 | #[doc (alias = "gst_audio_encoder_set_perfect_timestamp" )] |
290 | #[doc (alias = "perfect-timestamp" )] |
291 | fn set_perfect_timestamp(&self, enabled: bool) { |
292 | unsafe { |
293 | ffi::gst_audio_encoder_set_perfect_timestamp( |
294 | self.as_ref().to_glib_none().0, |
295 | enabled.into_glib(), |
296 | ); |
297 | } |
298 | } |
299 | |
300 | #[doc (alias = "gst_audio_encoder_set_tolerance" )] |
301 | #[doc (alias = "tolerance" )] |
302 | fn set_tolerance(&self, tolerance: gst::ClockTime) { |
303 | unsafe { |
304 | ffi::gst_audio_encoder_set_tolerance( |
305 | self.as_ref().to_glib_none().0, |
306 | tolerance.into_glib(), |
307 | ); |
308 | } |
309 | } |
310 | |
311 | #[doc (alias = "hard-resync" )] |
312 | fn connect_hard_resync_notify<F: Fn(&Self) + Send + Sync + 'static>( |
313 | &self, |
314 | f: F, |
315 | ) -> SignalHandlerId { |
316 | unsafe extern "C" fn notify_hard_resync_trampoline< |
317 | P: IsA<AudioEncoder>, |
318 | F: Fn(&P) + Send + Sync + 'static, |
319 | >( |
320 | this: *mut ffi::GstAudioEncoder, |
321 | _param_spec: glib::ffi::gpointer, |
322 | f: glib::ffi::gpointer, |
323 | ) { |
324 | let f: &F = &*(f as *const F); |
325 | f(AudioEncoder::from_glib_borrow(this).unsafe_cast_ref()) |
326 | } |
327 | unsafe { |
328 | let f: Box_<F> = Box_::new(f); |
329 | connect_raw( |
330 | self.as_ptr() as *mut _, |
331 | b"notify::hard-resync \0" .as_ptr() as *const _, |
332 | Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( |
333 | notify_hard_resync_trampoline::<Self, F> as *const (), |
334 | )), |
335 | Box_::into_raw(f), |
336 | ) |
337 | } |
338 | } |
339 | |
340 | #[doc (alias = "mark-granule" )] |
341 | fn connect_mark_granule_notify<F: Fn(&Self) + Send + Sync + 'static>( |
342 | &self, |
343 | f: F, |
344 | ) -> SignalHandlerId { |
345 | unsafe extern "C" fn notify_mark_granule_trampoline< |
346 | P: IsA<AudioEncoder>, |
347 | F: Fn(&P) + Send + Sync + 'static, |
348 | >( |
349 | this: *mut ffi::GstAudioEncoder, |
350 | _param_spec: glib::ffi::gpointer, |
351 | f: glib::ffi::gpointer, |
352 | ) { |
353 | let f: &F = &*(f as *const F); |
354 | f(AudioEncoder::from_glib_borrow(this).unsafe_cast_ref()) |
355 | } |
356 | unsafe { |
357 | let f: Box_<F> = Box_::new(f); |
358 | connect_raw( |
359 | self.as_ptr() as *mut _, |
360 | b"notify::mark-granule \0" .as_ptr() as *const _, |
361 | Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( |
362 | notify_mark_granule_trampoline::<Self, F> as *const (), |
363 | )), |
364 | Box_::into_raw(f), |
365 | ) |
366 | } |
367 | } |
368 | |
369 | #[doc (alias = "perfect-timestamp" )] |
370 | fn connect_perfect_timestamp_notify<F: Fn(&Self) + Send + Sync + 'static>( |
371 | &self, |
372 | f: F, |
373 | ) -> SignalHandlerId { |
374 | unsafe extern "C" fn notify_perfect_timestamp_trampoline< |
375 | P: IsA<AudioEncoder>, |
376 | F: Fn(&P) + Send + Sync + 'static, |
377 | >( |
378 | this: *mut ffi::GstAudioEncoder, |
379 | _param_spec: glib::ffi::gpointer, |
380 | f: glib::ffi::gpointer, |
381 | ) { |
382 | let f: &F = &*(f as *const F); |
383 | f(AudioEncoder::from_glib_borrow(this).unsafe_cast_ref()) |
384 | } |
385 | unsafe { |
386 | let f: Box_<F> = Box_::new(f); |
387 | connect_raw( |
388 | self.as_ptr() as *mut _, |
389 | b"notify::perfect-timestamp \0" .as_ptr() as *const _, |
390 | Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( |
391 | notify_perfect_timestamp_trampoline::<Self, F> as *const (), |
392 | )), |
393 | Box_::into_raw(f), |
394 | ) |
395 | } |
396 | } |
397 | |
398 | #[doc (alias = "tolerance" )] |
399 | fn connect_tolerance_notify<F: Fn(&Self) + Send + Sync + 'static>( |
400 | &self, |
401 | f: F, |
402 | ) -> SignalHandlerId { |
403 | unsafe extern "C" fn notify_tolerance_trampoline< |
404 | P: IsA<AudioEncoder>, |
405 | F: Fn(&P) + Send + Sync + 'static, |
406 | >( |
407 | this: *mut ffi::GstAudioEncoder, |
408 | _param_spec: glib::ffi::gpointer, |
409 | f: glib::ffi::gpointer, |
410 | ) { |
411 | let f: &F = &*(f as *const F); |
412 | f(AudioEncoder::from_glib_borrow(this).unsafe_cast_ref()) |
413 | } |
414 | unsafe { |
415 | let f: Box_<F> = Box_::new(f); |
416 | connect_raw( |
417 | self.as_ptr() as *mut _, |
418 | b"notify::tolerance \0" .as_ptr() as *const _, |
419 | Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( |
420 | notify_tolerance_trampoline::<Self, F> as *const (), |
421 | )), |
422 | Box_::into_raw(f), |
423 | ) |
424 | } |
425 | } |
426 | } |
427 | |
428 | impl<O: IsA<AudioEncoder>> AudioEncoderExt for O {} |
429 | |