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::{ffi, AudioInfo};
7use glib::{
8 prelude::*,
9 signal::{connect_raw, SignalHandlerId},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 /// This base class is for audio encoders turning raw audio samples into
16 /// encoded audio data.
17 ///
18 /// GstAudioEncoder and subclass should cooperate as follows.
19 ///
20 /// ## Configuration
21 ///
22 /// * Initially, GstAudioEncoder calls `start` when the encoder element
23 /// is activated, which allows subclass to perform any global setup.
24 ///
25 /// * GstAudioEncoder calls `set_format` to inform subclass of the format
26 /// of input audio data that it is about to receive. Subclass should
27 /// setup for encoding and configure various base class parameters
28 /// appropriately, notably those directing desired input data handling.
29 /// While unlikely, it might be called more than once, if changing input
30 /// parameters require reconfiguration.
31 ///
32 /// * GstAudioEncoder calls `stop` at end of all processing.
33 ///
34 /// As of configuration stage, and throughout processing, GstAudioEncoder
35 /// maintains various parameters that provide required context,
36 /// e.g. describing the format of input audio data.
37 /// Conversely, subclass can and should configure these context parameters
38 /// to inform base class of its expectation w.r.t. buffer handling.
39 ///
40 /// ## Data processing
41 ///
42 /// * Base class gathers input sample data (as directed by the context's
43 /// frame_samples and frame_max) and provides this to subclass' `handle_frame`.
44 /// * If codec processing results in encoded data, subclass should call
45 /// [`AudioEncoderExt::finish_frame()`][crate::prelude::AudioEncoderExt::finish_frame()] to have encoded data pushed
46 /// downstream. Alternatively, it might also call
47 /// [`AudioEncoderExt::finish_frame()`][crate::prelude::AudioEncoderExt::finish_frame()] (with a NULL buffer and some number of
48 /// dropped samples) to indicate dropped (non-encoded) samples.
49 /// * Just prior to actually pushing a buffer downstream,
50 /// it is passed to `pre_push`.
51 /// * During the parsing process GstAudioEncoderClass will handle both
52 /// srcpad and sinkpad events. Sink events will be passed to subclass
53 /// if `event` callback has been provided.
54 ///
55 /// ## Shutdown phase
56 ///
57 /// * GstAudioEncoder class calls `stop` to inform the subclass that data
58 /// parsing will be stopped.
59 ///
60 /// Subclass is responsible for providing pad template caps for
61 /// source and sink pads. The pads need to be named "sink" and "src". It also
62 /// needs to set the fixed caps on srcpad, when the format is ensured. This
63 /// is typically when base class calls subclass' `set_format` function, though
64 /// it might be delayed until calling [`AudioEncoderExt::finish_frame()`][crate::prelude::AudioEncoderExt::finish_frame()].
65 ///
66 /// In summary, above process should have subclass concentrating on
67 /// codec data processing while leaving other matters to base class,
68 /// such as most notably timestamp handling. While it may exert more control
69 /// in this area (see e.g. `pre_push`), it is very much not recommended.
70 ///
71 /// In particular, base class will either favor tracking upstream timestamps
72 /// (at the possible expense of jitter) or aim to arrange for a perfect stream of
73 /// output timestamps, depending on [`perfect-timestamp`][struct@crate::AudioEncoder#perfect-timestamp].
74 /// However, in the latter case, the input may not be so perfect or ideal, which
75 /// is handled as follows. An input timestamp is compared with the expected
76 /// timestamp as dictated by input sample stream and if the deviation is less
77 /// than [`tolerance`][struct@crate::AudioEncoder#tolerance], the deviation is discarded.
78 /// Otherwise, it is considered a discontuinity and subsequent output timestamp
79 /// is resynced to the new position after performing configured discontinuity
80 /// processing. In the non-perfect-timestamp case, an upstream variation
81 /// exceeding tolerance only leads to marking DISCONT on subsequent outgoing
82 /// (while timestamps are adjusted to upstream regardless of variation).
83 /// While DISCONT is also marked in the perfect-timestamp case, this one
84 /// optionally (see [`hard-resync`][struct@crate::AudioEncoder#hard-resync])
85 /// performs some additional steps, such as clipping of (early) input samples
86 /// or draining all currently remaining input data, depending on the direction
87 /// of the discontuinity.
88 ///
89 /// If perfect timestamps are arranged, it is also possible to request baseclass
90 /// (usually set by subclass) to provide additional buffer metadata (in OFFSET
91 /// and OFFSET_END) fields according to granule defined semantics currently
92 /// needed by oggmux. Specifically, OFFSET is set to granulepos (= sample count
93 /// including buffer) and OFFSET_END to corresponding timestamp (as determined
94 /// by same sample count and sample rate).
95 ///
96 /// Things that subclass need to take care of:
97 ///
98 /// * Provide pad templates
99 /// * Set source pad caps when appropriate
100 /// * Inform base class of buffer processing needs using context's
101 /// frame_samples and frame_bytes.
102 /// * Set user-configurable properties to sane defaults for format and
103 /// implementing codec at hand, e.g. those controlling timestamp behaviour
104 /// and discontinuity processing.
105 /// * Accept data in `handle_frame` and provide encoded results to
106 /// [`AudioEncoderExt::finish_frame()`][crate::prelude::AudioEncoderExt::finish_frame()].
107 ///
108 /// This is an Abstract Base Class, you cannot instantiate it.
109 ///
110 /// ## Properties
111 ///
112 ///
113 /// #### `hard-resync`
114 /// Readable | Writeable
115 ///
116 ///
117 /// #### `mark-granule`
118 /// Readable
119 ///
120 ///
121 /// #### `perfect-timestamp`
122 /// Readable | Writeable
123 ///
124 ///
125 /// #### `tolerance`
126 /// Readable | Writeable
127 /// <details><summary><h4>Object</h4></summary>
128 ///
129 ///
130 /// #### `name`
131 /// Readable | Writeable | Construct
132 ///
133 ///
134 /// #### `parent`
135 /// The parent of the object. Please note, that when changing the 'parent'
136 /// property, we don't emit [`notify`][struct@crate::glib::Object#notify] and [`deep-notify`][struct@crate::gst::Object#deep-notify]
137 /// signals due to locking issues. In some cases one can use
138 /// `GstBin::element-added` or `GstBin::element-removed` signals on the parent to
139 /// achieve a similar effect.
140 ///
141 /// Readable | Writeable
142 /// </details>
143 ///
144 /// # Implements
145 ///
146 /// [`AudioEncoderExt`][trait@crate::prelude::AudioEncoderExt], [`trait@gst::prelude::ElementExt`], [`trait@gst::prelude::GstObjectExt`], [`trait@glib::ObjectExt`], [`AudioEncoderExtManual`][trait@crate::prelude::AudioEncoderExtManual]
147 #[doc(alias = "GstAudioEncoder")]
148 pub struct AudioEncoder(Object<ffi::GstAudioEncoder, ffi::GstAudioEncoderClass>) @extends gst::Element, gst::Object;
149
150 match fn {
151 type_ => || ffi::gst_audio_encoder_get_type(),
152 }
153}
154
155impl AudioEncoder {
156 pub const NONE: Option<&'static AudioEncoder> = None;
157}
158
159unsafe impl Send for AudioEncoder {}
160unsafe impl Sync for AudioEncoder {}
161
162/// Trait containing all [`struct@AudioEncoder`] methods.
163///
164/// # Implementors
165///
166/// [`AudioEncoder`][struct@crate::AudioEncoder]
167pub trait AudioEncoderExt: IsA<AudioEncoder> + 'static {
168 /// Helper function that allocates a buffer to hold an encoded audio frame
169 /// for `self`'s current output format.
170 /// ## `size`
171 /// size of the buffer
172 ///
173 /// # Returns
174 ///
175 /// allocated buffer
176 #[doc(alias = "gst_audio_encoder_allocate_output_buffer")]
177 fn allocate_output_buffer(&self, size: usize) -> gst::Buffer {
178 unsafe {
179 from_glib_full(ffi::gst_audio_encoder_allocate_output_buffer(
180 self.as_ref().to_glib_none().0,
181 size,
182 ))
183 }
184 }
185
186 /// Collects encoded data and pushes encoded data downstream.
187 /// Source pad caps must be set when this is called.
188 ///
189 /// If `samples` < 0, then best estimate is all samples provided to encoder
190 /// (subclass) so far. `buf` may be NULL, in which case next number of `samples`
191 /// are considered discarded, e.g. as a result of discontinuous transmission,
192 /// and a discontinuity is marked.
193 ///
194 /// Note that samples received in `GstAudioEncoderClass.handle_frame()`
195 /// may be invalidated by a call to this function.
196 /// ## `buffer`
197 /// encoded data
198 /// ## `samples`
199 /// number of samples (per channel) represented by encoded data
200 ///
201 /// # Returns
202 ///
203 /// a [`gst::FlowReturn`][crate::gst::FlowReturn] that should be escalated to caller (of caller)
204 #[doc(alias = "gst_audio_encoder_finish_frame")]
205 fn finish_frame(
206 &self,
207 buffer: Option<gst::Buffer>,
208 samples: i32,
209 ) -> Result<gst::FlowSuccess, gst::FlowError> {
210 unsafe {
211 try_from_glib(ffi::gst_audio_encoder_finish_frame(
212 self.as_ref().to_glib_none().0,
213 buffer.into_glib_ptr(),
214 samples,
215 ))
216 }
217 }
218
219 ///
220 /// # Returns
221 ///
222 /// a [`AudioInfo`][crate::AudioInfo] describing the input audio format
223 #[doc(alias = "gst_audio_encoder_get_audio_info")]
224 #[doc(alias = "get_audio_info")]
225 fn audio_info(&self) -> AudioInfo {
226 unsafe {
227 from_glib_none(ffi::gst_audio_encoder_get_audio_info(
228 self.as_ref().to_glib_none().0,
229 ))
230 }
231 }
232
233 /// Queries encoder drain handling.
234 ///
235 /// # Returns
236 ///
237 /// TRUE if drainable handling is enabled.
238 ///
239 /// MT safe.
240 #[doc(alias = "gst_audio_encoder_get_drainable")]
241 #[doc(alias = "get_drainable")]
242 fn is_drainable(&self) -> bool {
243 unsafe {
244 from_glib(ffi::gst_audio_encoder_get_drainable(
245 self.as_ref().to_glib_none().0,
246 ))
247 }
248 }
249
250 ///
251 /// # Returns
252 ///
253 /// currently configured maximum handled frames
254 #[doc(alias = "gst_audio_encoder_get_frame_max")]
255 #[doc(alias = "get_frame_max")]
256 fn frame_max(&self) -> i32 {
257 unsafe { ffi::gst_audio_encoder_get_frame_max(self.as_ref().to_glib_none().0) }
258 }
259
260 ///
261 /// # Returns
262 ///
263 /// currently maximum requested samples per frame
264 #[doc(alias = "gst_audio_encoder_get_frame_samples_max")]
265 #[doc(alias = "get_frame_samples_max")]
266 fn frame_samples_max(&self) -> i32 {
267 unsafe { ffi::gst_audio_encoder_get_frame_samples_max(self.as_ref().to_glib_none().0) }
268 }
269
270 ///
271 /// # Returns
272 ///
273 /// currently minimum requested samples per frame
274 #[doc(alias = "gst_audio_encoder_get_frame_samples_min")]
275 #[doc(alias = "get_frame_samples_min")]
276 fn frame_samples_min(&self) -> i32 {
277 unsafe { ffi::gst_audio_encoder_get_frame_samples_min(self.as_ref().to_glib_none().0) }
278 }
279
280 /// Queries encoder hard minimum handling.
281 ///
282 /// # Returns
283 ///
284 /// TRUE if hard minimum handling is enabled.
285 ///
286 /// MT safe.
287 #[doc(alias = "gst_audio_encoder_get_hard_min")]
288 #[doc(alias = "get_hard_min")]
289 fn is_hard_min(&self) -> bool {
290 unsafe {
291 from_glib(ffi::gst_audio_encoder_get_hard_min(
292 self.as_ref().to_glib_none().0,
293 ))
294 }
295 }
296
297 #[doc(alias = "gst_audio_encoder_get_hard_resync")]
298 #[doc(alias = "get_hard_resync")]
299 #[doc(alias = "hard-resync")]
300 fn is_hard_resync(&self) -> bool {
301 unsafe {
302 from_glib(ffi::gst_audio_encoder_get_hard_resync(
303 self.as_ref().to_glib_none().0,
304 ))
305 }
306 }
307
308 /// Sets the variables pointed to by `min` and `max` to the currently configured
309 /// latency.
310 ///
311 /// # Returns
312 ///
313 ///
314 /// ## `min`
315 /// a pointer to storage to hold minimum latency
316 ///
317 /// ## `max`
318 /// a pointer to storage to hold maximum latency
319 #[doc(alias = "gst_audio_encoder_get_latency")]
320 #[doc(alias = "get_latency")]
321 fn latency(&self) -> (gst::ClockTime, Option<gst::ClockTime>) {
322 unsafe {
323 let mut min = std::mem::MaybeUninit::uninit();
324 let mut max = std::mem::MaybeUninit::uninit();
325 ffi::gst_audio_encoder_get_latency(
326 self.as_ref().to_glib_none().0,
327 min.as_mut_ptr(),
328 max.as_mut_ptr(),
329 );
330 (
331 try_from_glib(min.assume_init()).expect("mandatory glib value is None"),
332 from_glib(max.assume_init()),
333 )
334 }
335 }
336
337 ///
338 /// # Returns
339 ///
340 /// currently configured encoder lookahead
341 #[doc(alias = "gst_audio_encoder_get_lookahead")]
342 #[doc(alias = "get_lookahead")]
343 fn lookahead(&self) -> i32 {
344 unsafe { ffi::gst_audio_encoder_get_lookahead(self.as_ref().to_glib_none().0) }
345 }
346
347 /// Queries if the encoder will handle granule marking.
348 ///
349 /// # Returns
350 ///
351 /// TRUE if granule marking is enabled.
352 ///
353 /// MT safe.
354 #[doc(alias = "gst_audio_encoder_get_mark_granule")]
355 #[doc(alias = "get_mark_granule")]
356 #[doc(alias = "mark-granule")]
357 fn is_mark_granule(&self) -> bool {
358 unsafe {
359 from_glib(ffi::gst_audio_encoder_get_mark_granule(
360 self.as_ref().to_glib_none().0,
361 ))
362 }
363 }
364
365 /// Queries encoder perfect timestamp behaviour.
366 ///
367 /// # Returns
368 ///
369 /// TRUE if perfect timestamp setting enabled.
370 ///
371 /// MT safe.
372 #[doc(alias = "gst_audio_encoder_get_perfect_timestamp")]
373 #[doc(alias = "get_perfect_timestamp")]
374 #[doc(alias = "perfect-timestamp")]
375 fn is_perfect_timestamp(&self) -> bool {
376 unsafe {
377 from_glib(ffi::gst_audio_encoder_get_perfect_timestamp(
378 self.as_ref().to_glib_none().0,
379 ))
380 }
381 }
382
383 /// Queries current audio jitter tolerance threshold.
384 ///
385 /// # Returns
386 ///
387 /// encoder audio jitter tolerance threshold.
388 ///
389 /// MT safe.
390 #[doc(alias = "gst_audio_encoder_get_tolerance")]
391 #[doc(alias = "get_tolerance")]
392 fn tolerance(&self) -> gst::ClockTime {
393 unsafe {
394 try_from_glib(ffi::gst_audio_encoder_get_tolerance(
395 self.as_ref().to_glib_none().0,
396 ))
397 .expect("mandatory glib value is None")
398 }
399 }
400
401 /// Sets the audio encoder tags and how they should be merged with any
402 /// upstream stream tags. This will override any tags previously-set
403 /// with [`merge_tags()`][Self::merge_tags()].
404 ///
405 /// Note that this is provided for convenience, and the subclass is
406 /// not required to use this and can still do tag handling on its own.
407 ///
408 /// MT safe.
409 /// ## `tags`
410 /// a [`gst::TagList`][crate::gst::TagList] to merge, or NULL to unset
411 /// previously-set tags
412 /// ## `mode`
413 /// the [`gst::TagMergeMode`][crate::gst::TagMergeMode] to use, usually [`gst::TagMergeMode::Replace`][crate::gst::TagMergeMode::Replace]
414 #[doc(alias = "gst_audio_encoder_merge_tags")]
415 fn merge_tags(&self, tags: Option<&gst::TagList>, mode: gst::TagMergeMode) {
416 unsafe {
417 ffi::gst_audio_encoder_merge_tags(
418 self.as_ref().to_glib_none().0,
419 tags.to_glib_none().0,
420 mode.into_glib(),
421 );
422 }
423 }
424
425 /// Returns caps that express `caps` (or sink template caps if `caps` == NULL)
426 /// restricted to channel/rate combinations supported by downstream elements
427 /// (e.g. muxers).
428 /// ## `caps`
429 /// initial caps
430 /// ## `filter`
431 /// filter caps
432 ///
433 /// # Returns
434 ///
435 /// a [`gst::Caps`][crate::gst::Caps] owned by caller
436 #[doc(alias = "gst_audio_encoder_proxy_getcaps")]
437 fn proxy_getcaps(&self, caps: Option<&gst::Caps>, filter: Option<&gst::Caps>) -> gst::Caps {
438 unsafe {
439 from_glib_full(ffi::gst_audio_encoder_proxy_getcaps(
440 self.as_ref().to_glib_none().0,
441 caps.to_glib_none().0,
442 filter.to_glib_none().0,
443 ))
444 }
445 }
446
447 /// Sets a caps in allocation query which are different from the set
448 /// pad's caps. Use this function before calling
449 /// [`AudioEncoderExtManual::negotiate()`][crate::prelude::AudioEncoderExtManual::negotiate()]. Setting to [`None`] the allocation
450 /// query will use the caps from the pad.
451 /// ## `allocation_caps`
452 /// a [`gst::Caps`][crate::gst::Caps] or [`None`]
453 #[doc(alias = "gst_audio_encoder_set_allocation_caps")]
454 fn set_allocation_caps(&self, allocation_caps: Option<&gst::Caps>) {
455 unsafe {
456 ffi::gst_audio_encoder_set_allocation_caps(
457 self.as_ref().to_glib_none().0,
458 allocation_caps.to_glib_none().0,
459 );
460 }
461 }
462
463 /// Configures encoder drain handling. If drainable, subclass might
464 /// be handed a NULL buffer to have it return any leftover encoded data.
465 /// Otherwise, it is not considered so capable and will only ever be passed
466 /// real data.
467 ///
468 /// MT safe.
469 /// ## `enabled`
470 /// new state
471 #[doc(alias = "gst_audio_encoder_set_drainable")]
472 fn set_drainable(&self, enabled: bool) {
473 unsafe {
474 ffi::gst_audio_encoder_set_drainable(
475 self.as_ref().to_glib_none().0,
476 enabled.into_glib(),
477 );
478 }
479 }
480
481 /// Sets max number of frames accepted at once (assumed minimally 1).
482 /// Requires `frame_samples_min` and `frame_samples_max` to be the equal.
483 ///
484 /// Note: This value will be reset to 0 every time before
485 /// `GstAudioEncoderClass.set_format()` is called.
486 /// ## `num`
487 /// number of frames
488 #[doc(alias = "gst_audio_encoder_set_frame_max")]
489 fn set_frame_max(&self, num: i32) {
490 unsafe {
491 ffi::gst_audio_encoder_set_frame_max(self.as_ref().to_glib_none().0, num);
492 }
493 }
494
495 /// Sets number of samples (per channel) subclass needs to be handed,
496 /// at most or will be handed all available if 0.
497 ///
498 /// If an exact number of samples is required, [`set_frame_samples_min()`][Self::set_frame_samples_min()]
499 /// must be called with the same number.
500 ///
501 /// Note: This value will be reset to 0 every time before
502 /// `GstAudioEncoderClass.set_format()` is called.
503 /// ## `num`
504 /// number of samples per frame
505 #[doc(alias = "gst_audio_encoder_set_frame_samples_max")]
506 fn set_frame_samples_max(&self, num: i32) {
507 unsafe {
508 ffi::gst_audio_encoder_set_frame_samples_max(self.as_ref().to_glib_none().0, num);
509 }
510 }
511
512 /// Sets number of samples (per channel) subclass needs to be handed,
513 /// at least or will be handed all available if 0.
514 ///
515 /// If an exact number of samples is required, [`set_frame_samples_max()`][Self::set_frame_samples_max()]
516 /// must be called with the same number.
517 ///
518 /// Note: This value will be reset to 0 every time before
519 /// `GstAudioEncoderClass.set_format()` is called.
520 /// ## `num`
521 /// number of samples per frame
522 #[doc(alias = "gst_audio_encoder_set_frame_samples_min")]
523 fn set_frame_samples_min(&self, num: i32) {
524 unsafe {
525 ffi::gst_audio_encoder_set_frame_samples_min(self.as_ref().to_glib_none().0, num);
526 }
527 }
528
529 /// Configures encoder hard minimum handling. If enabled, subclass
530 /// will never be handed less samples than it configured, which otherwise
531 /// might occur near end-of-data handling. Instead, the leftover samples
532 /// will simply be discarded.
533 ///
534 /// MT safe.
535 /// ## `enabled`
536 /// new state
537 #[doc(alias = "gst_audio_encoder_set_hard_min")]
538 fn set_hard_min(&self, enabled: bool) {
539 unsafe {
540 ffi::gst_audio_encoder_set_hard_min(
541 self.as_ref().to_glib_none().0,
542 enabled.into_glib(),
543 );
544 }
545 }
546
547 #[doc(alias = "gst_audio_encoder_set_hard_resync")]
548 #[doc(alias = "hard-resync")]
549 fn set_hard_resync(&self, enabled: bool) {
550 unsafe {
551 ffi::gst_audio_encoder_set_hard_resync(
552 self.as_ref().to_glib_none().0,
553 enabled.into_glib(),
554 );
555 }
556 }
557
558 /// Sets encoder latency. If the provided values changed from
559 /// previously provided ones, this will also post a LATENCY message on the bus
560 /// so the pipeline can reconfigure its global latency.
561 /// ## `min`
562 /// minimum latency
563 /// ## `max`
564 /// maximum latency
565 #[doc(alias = "gst_audio_encoder_set_latency")]
566 fn set_latency(&self, min: gst::ClockTime, max: impl Into<Option<gst::ClockTime>>) {
567 unsafe {
568 ffi::gst_audio_encoder_set_latency(
569 self.as_ref().to_glib_none().0,
570 min.into_glib(),
571 max.into().into_glib(),
572 );
573 }
574 }
575
576 /// Sets encoder lookahead (in units of input rate samples)
577 ///
578 /// Note: This value will be reset to 0 every time before
579 /// `GstAudioEncoderClass.set_format()` is called.
580 /// ## `num`
581 /// lookahead
582 #[doc(alias = "gst_audio_encoder_set_lookahead")]
583 fn set_lookahead(&self, num: i32) {
584 unsafe {
585 ffi::gst_audio_encoder_set_lookahead(self.as_ref().to_glib_none().0, num);
586 }
587 }
588
589 /// Enable or disable encoder granule handling.
590 ///
591 /// MT safe.
592 /// ## `enabled`
593 /// new state
594 #[doc(alias = "gst_audio_encoder_set_mark_granule")]
595 fn set_mark_granule(&self, enabled: bool) {
596 unsafe {
597 ffi::gst_audio_encoder_set_mark_granule(
598 self.as_ref().to_glib_none().0,
599 enabled.into_glib(),
600 );
601 }
602 }
603
604 /// Enable or disable encoder perfect output timestamp preference.
605 ///
606 /// MT safe.
607 /// ## `enabled`
608 /// new state
609 #[doc(alias = "gst_audio_encoder_set_perfect_timestamp")]
610 #[doc(alias = "perfect-timestamp")]
611 fn set_perfect_timestamp(&self, enabled: bool) {
612 unsafe {
613 ffi::gst_audio_encoder_set_perfect_timestamp(
614 self.as_ref().to_glib_none().0,
615 enabled.into_glib(),
616 );
617 }
618 }
619
620 /// Configures encoder audio jitter tolerance threshold.
621 ///
622 /// MT safe.
623 /// ## `tolerance`
624 /// new tolerance
625 #[doc(alias = "gst_audio_encoder_set_tolerance")]
626 #[doc(alias = "tolerance")]
627 fn set_tolerance(&self, tolerance: gst::ClockTime) {
628 unsafe {
629 ffi::gst_audio_encoder_set_tolerance(
630 self.as_ref().to_glib_none().0,
631 tolerance.into_glib(),
632 );
633 }
634 }
635
636 #[doc(alias = "hard-resync")]
637 fn connect_hard_resync_notify<F: Fn(&Self) + Send + Sync + 'static>(
638 &self,
639 f: F,
640 ) -> SignalHandlerId {
641 unsafe extern "C" fn notify_hard_resync_trampoline<
642 P: IsA<AudioEncoder>,
643 F: Fn(&P) + Send + Sync + 'static,
644 >(
645 this: *mut ffi::GstAudioEncoder,
646 _param_spec: glib::ffi::gpointer,
647 f: glib::ffi::gpointer,
648 ) {
649 let f: &F = &*(f as *const F);
650 f(AudioEncoder::from_glib_borrow(this).unsafe_cast_ref())
651 }
652 unsafe {
653 let f: Box_<F> = Box_::new(f);
654 connect_raw(
655 self.as_ptr() as *mut _,
656 c"notify::hard-resync".as_ptr() as *const _,
657 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
658 notify_hard_resync_trampoline::<Self, F> as *const (),
659 )),
660 Box_::into_raw(f),
661 )
662 }
663 }
664
665 #[doc(alias = "mark-granule")]
666 fn connect_mark_granule_notify<F: Fn(&Self) + Send + Sync + 'static>(
667 &self,
668 f: F,
669 ) -> SignalHandlerId {
670 unsafe extern "C" fn notify_mark_granule_trampoline<
671 P: IsA<AudioEncoder>,
672 F: Fn(&P) + Send + Sync + 'static,
673 >(
674 this: *mut ffi::GstAudioEncoder,
675 _param_spec: glib::ffi::gpointer,
676 f: glib::ffi::gpointer,
677 ) {
678 let f: &F = &*(f as *const F);
679 f(AudioEncoder::from_glib_borrow(this).unsafe_cast_ref())
680 }
681 unsafe {
682 let f: Box_<F> = Box_::new(f);
683 connect_raw(
684 self.as_ptr() as *mut _,
685 c"notify::mark-granule".as_ptr() as *const _,
686 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
687 notify_mark_granule_trampoline::<Self, F> as *const (),
688 )),
689 Box_::into_raw(f),
690 )
691 }
692 }
693
694 #[doc(alias = "perfect-timestamp")]
695 fn connect_perfect_timestamp_notify<F: Fn(&Self) + Send + Sync + 'static>(
696 &self,
697 f: F,
698 ) -> SignalHandlerId {
699 unsafe extern "C" fn notify_perfect_timestamp_trampoline<
700 P: IsA<AudioEncoder>,
701 F: Fn(&P) + Send + Sync + 'static,
702 >(
703 this: *mut ffi::GstAudioEncoder,
704 _param_spec: glib::ffi::gpointer,
705 f: glib::ffi::gpointer,
706 ) {
707 let f: &F = &*(f as *const F);
708 f(AudioEncoder::from_glib_borrow(this).unsafe_cast_ref())
709 }
710 unsafe {
711 let f: Box_<F> = Box_::new(f);
712 connect_raw(
713 self.as_ptr() as *mut _,
714 c"notify::perfect-timestamp".as_ptr() as *const _,
715 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
716 notify_perfect_timestamp_trampoline::<Self, F> as *const (),
717 )),
718 Box_::into_raw(f),
719 )
720 }
721 }
722
723 #[doc(alias = "tolerance")]
724 fn connect_tolerance_notify<F: Fn(&Self) + Send + Sync + 'static>(
725 &self,
726 f: F,
727 ) -> SignalHandlerId {
728 unsafe extern "C" fn notify_tolerance_trampoline<
729 P: IsA<AudioEncoder>,
730 F: Fn(&P) + Send + Sync + 'static,
731 >(
732 this: *mut ffi::GstAudioEncoder,
733 _param_spec: glib::ffi::gpointer,
734 f: glib::ffi::gpointer,
735 ) {
736 let f: &F = &*(f as *const F);
737 f(AudioEncoder::from_glib_borrow(this).unsafe_cast_ref())
738 }
739 unsafe {
740 let f: Box_<F> = Box_::new(f);
741 connect_raw(
742 self.as_ptr() as *mut _,
743 c"notify::tolerance".as_ptr() as *const _,
744 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
745 notify_tolerance_trampoline::<Self, F> as *const (),
746 )),
747 Box_::into_raw(f),
748 )
749 }
750 }
751}
752
753impl<O: IsA<AudioEncoder>> AudioEncoderExt for O {}