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    /// 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 | Writable
115    ///
116    ///
117    /// #### `mark-granule`
118    ///  Readable
119    ///
120    ///
121    /// #### `perfect-timestamp`
122    ///  Readable | Writable
123    ///
124    ///
125    /// #### `tolerance`
126    ///  Readable | Writable
127    /// <details><summary><h4>Object</h4></summary>
128    ///
129    ///
130    /// #### `name`
131    ///  Readable | Writable | 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 | Writable
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    ///  0, then best estimate is all samples provided to encoder
187    /// (subclass) so far. `buf` may be NULL, in which case next number of `samples`
188    /// are considered discarded, e.g. as a result of discontinuous transmission,
189    /// and a discontinuity is marked.
190    ///
191    /// Note that samples received in `GstAudioEncoderClass.handle_frame()`
192    /// may be invalidated by a call to this function.
193    /// ## `buffer`
194    /// encoded data
195    /// ## `samples`
196    /// number of samples (per channel) represented by encoded data
197    ///
198    /// # Returns
199    ///
200    /// a [`gst::FlowReturn`][crate::gst::FlowReturn] that should be escalated to caller (of caller)
201    #[doc(alias = "gst_audio_encoder_finish_frame")]
202    fn finish_frame(
203        &self,
204        buffer: Option<gst::Buffer>,
205        samples: i32,
206    ) -> Result<gst::FlowSuccess, gst::FlowError> {
207        unsafe {
208            try_from_glib(ffi::gst_audio_encoder_finish_frame(
209                self.as_ref().to_glib_none().0,
210                buffer.into_glib_ptr(),
211                samples,
212            ))
213        }
214    }
215
216    ///
217    /// # Returns
218    ///
219    /// a [`AudioInfo`][crate::AudioInfo] describing the input audio format
220    #[doc(alias = "gst_audio_encoder_get_audio_info")]
221    #[doc(alias = "get_audio_info")]
222    fn audio_info(&self) -> AudioInfo {
223        unsafe {
224            from_glib_none(ffi::gst_audio_encoder_get_audio_info(
225                self.as_ref().to_glib_none().0,
226            ))
227        }
228    }
229
230    /// Queries encoder drain handling.
231    ///
232    /// # Returns
233    ///
234    /// TRUE if drainable handling is enabled.
235    ///
236    /// MT safe.
237    #[doc(alias = "gst_audio_encoder_get_drainable")]
238    #[doc(alias = "get_drainable")]
239    fn is_drainable(&self) -> bool {
240        unsafe {
241            from_glib(ffi::gst_audio_encoder_get_drainable(
242                self.as_ref().to_glib_none().0,
243            ))
244        }
245    }
246
247    ///
248    /// # Returns
249    ///
250    /// currently configured maximum handled frames
251    #[doc(alias = "gst_audio_encoder_get_frame_max")]
252    #[doc(alias = "get_frame_max")]
253    fn frame_max(&self) -> i32 {
254        unsafe { ffi::gst_audio_encoder_get_frame_max(self.as_ref().to_glib_none().0) }
255    }
256
257    ///
258    /// # Returns
259    ///
260    /// currently maximum requested samples per frame
261    #[doc(alias = "gst_audio_encoder_get_frame_samples_max")]
262    #[doc(alias = "get_frame_samples_max")]
263    fn frame_samples_max(&self) -> i32 {
264        unsafe { ffi::gst_audio_encoder_get_frame_samples_max(self.as_ref().to_glib_none().0) }
265    }
266
267    ///
268    /// # Returns
269    ///
270    /// currently minimum requested samples per frame
271    #[doc(alias = "gst_audio_encoder_get_frame_samples_min")]
272    #[doc(alias = "get_frame_samples_min")]
273    fn frame_samples_min(&self) -> i32 {
274        unsafe { ffi::gst_audio_encoder_get_frame_samples_min(self.as_ref().to_glib_none().0) }
275    }
276
277    /// Queries encoder hard minimum handling.
278    ///
279    /// # Returns
280    ///
281    /// TRUE if hard minimum handling is enabled.
282    ///
283    /// MT safe.
284    #[doc(alias = "gst_audio_encoder_get_hard_min")]
285    #[doc(alias = "get_hard_min")]
286    fn is_hard_min(&self) -> bool {
287        unsafe {
288            from_glib(ffi::gst_audio_encoder_get_hard_min(
289                self.as_ref().to_glib_none().0,
290            ))
291        }
292    }
293
294    #[doc(alias = "gst_audio_encoder_get_hard_resync")]
295    #[doc(alias = "get_hard_resync")]
296    #[doc(alias = "hard-resync")]
297    fn is_hard_resync(&self) -> bool {
298        unsafe {
299            from_glib(ffi::gst_audio_encoder_get_hard_resync(
300                self.as_ref().to_glib_none().0,
301            ))
302        }
303    }
304
305    /// Sets the variables pointed to by `min` and `max` to the currently configured
306    /// latency.
307    ///
308    /// # Returns
309    ///
310    ///
311    /// ## `min`
312    /// a pointer to storage to hold minimum latency
313    ///
314    /// ## `max`
315    /// a pointer to storage to hold maximum latency
316    #[doc(alias = "gst_audio_encoder_get_latency")]
317    #[doc(alias = "get_latency")]
318    fn latency(&self) -> (gst::ClockTime, Option<gst::ClockTime>) {
319        unsafe {
320            let mut min = std::mem::MaybeUninit::uninit();
321            let mut max = std::mem::MaybeUninit::uninit();
322            ffi::gst_audio_encoder_get_latency(
323                self.as_ref().to_glib_none().0,
324                min.as_mut_ptr(),
325                max.as_mut_ptr(),
326            );
327            (
328                try_from_glib(min.assume_init()).expect("mandatory glib value is None"),
329                from_glib(max.assume_init()),
330            )
331        }
332    }
333
334    ///
335    /// # Returns
336    ///
337    /// currently configured encoder lookahead
338    #[doc(alias = "gst_audio_encoder_get_lookahead")]
339    #[doc(alias = "get_lookahead")]
340    fn lookahead(&self) -> i32 {
341        unsafe { ffi::gst_audio_encoder_get_lookahead(self.as_ref().to_glib_none().0) }
342    }
343
344    /// Queries if the encoder will handle granule marking.
345    ///
346    /// # Returns
347    ///
348    /// TRUE if granule marking is enabled.
349    ///
350    /// MT safe.
351    #[doc(alias = "gst_audio_encoder_get_mark_granule")]
352    #[doc(alias = "get_mark_granule")]
353    #[doc(alias = "mark-granule")]
354    fn is_mark_granule(&self) -> bool {
355        unsafe {
356            from_glib(ffi::gst_audio_encoder_get_mark_granule(
357                self.as_ref().to_glib_none().0,
358            ))
359        }
360    }
361
362    /// Queries encoder perfect timestamp behaviour.
363    ///
364    /// # Returns
365    ///
366    /// TRUE if perfect timestamp setting enabled.
367    ///
368    /// MT safe.
369    #[doc(alias = "gst_audio_encoder_get_perfect_timestamp")]
370    #[doc(alias = "get_perfect_timestamp")]
371    #[doc(alias = "perfect-timestamp")]
372    fn is_perfect_timestamp(&self) -> bool {
373        unsafe {
374            from_glib(ffi::gst_audio_encoder_get_perfect_timestamp(
375                self.as_ref().to_glib_none().0,
376            ))
377        }
378    }
379
380    /// Queries current audio jitter tolerance threshold.
381    ///
382    /// # Returns
383    ///
384    /// encoder audio jitter tolerance threshold.
385    ///
386    /// MT safe.
387    #[doc(alias = "gst_audio_encoder_get_tolerance")]
388    #[doc(alias = "get_tolerance")]
389    fn tolerance(&self) -> gst::ClockTime {
390        unsafe {
391            try_from_glib(ffi::gst_audio_encoder_get_tolerance(
392                self.as_ref().to_glib_none().0,
393            ))
394            .expect("mandatory glib value is None")
395        }
396    }
397
398    /// Sets the audio encoder tags and how they should be merged with any
399    /// upstream stream tags. This will override any tags previously-set
400    /// with [`merge_tags()`][Self::merge_tags()].
401    ///
402    /// Note that this is provided for convenience, and the subclass is
403    /// not required to use this and can still do tag handling on its own.
404    ///
405    /// MT safe.
406    /// ## `tags`
407    /// a [`gst::TagList`][crate::gst::TagList] to merge, or NULL to unset
408    ///  previously-set tags
409    /// ## `mode`
410    /// the [`gst::TagMergeMode`][crate::gst::TagMergeMode] to use, usually [`gst::TagMergeMode::Replace`][crate::gst::TagMergeMode::Replace]
411    #[doc(alias = "gst_audio_encoder_merge_tags")]
412    fn merge_tags(&self, tags: Option<&gst::TagList>, mode: gst::TagMergeMode) {
413        unsafe {
414            ffi::gst_audio_encoder_merge_tags(
415                self.as_ref().to_glib_none().0,
416                tags.to_glib_none().0,
417                mode.into_glib(),
418            );
419        }
420    }
421
422    /// Returns caps that express `caps` (or sink template caps if `caps` == NULL)
423    /// restricted to channel/rate combinations supported by downstream elements
424    /// (e.g. muxers).
425    /// ## `caps`
426    /// initial caps
427    /// ## `filter`
428    /// filter caps
429    ///
430    /// # Returns
431    ///
432    /// a [`gst::Caps`][crate::gst::Caps] owned by caller
433    #[doc(alias = "gst_audio_encoder_proxy_getcaps")]
434    fn proxy_getcaps(&self, caps: Option<&gst::Caps>, filter: Option<&gst::Caps>) -> gst::Caps {
435        unsafe {
436            from_glib_full(ffi::gst_audio_encoder_proxy_getcaps(
437                self.as_ref().to_glib_none().0,
438                caps.to_glib_none().0,
439                filter.to_glib_none().0,
440            ))
441        }
442    }
443
444    /// Sets a caps in allocation query which are different from the set
445    /// pad's caps. Use this function before calling
446    /// [`AudioEncoderExtManual::negotiate()`][crate::prelude::AudioEncoderExtManual::negotiate()]. Setting to [`None`] the allocation
447    /// query will use the caps from the pad.
448    /// ## `allocation_caps`
449    /// a [`gst::Caps`][crate::gst::Caps] or [`None`]
450    #[doc(alias = "gst_audio_encoder_set_allocation_caps")]
451    fn set_allocation_caps(&self, allocation_caps: Option<&gst::Caps>) {
452        unsafe {
453            ffi::gst_audio_encoder_set_allocation_caps(
454                self.as_ref().to_glib_none().0,
455                allocation_caps.to_glib_none().0,
456            );
457        }
458    }
459
460    /// Allows [`AudioEncoder`][crate::AudioEncoder] sub-classes to set the memory `allocator` and
461    /// its `params`.
462    /// ## `allocator`
463    /// the [`gst::Allocator`][crate::gst::Allocator]
464    /// ## `params`
465    /// the [`gst::AllocationParams`][crate::gst::AllocationParams] of `allocator`
466    #[cfg(feature = "v1_30")]
467    #[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
468    #[doc(alias = "gst_audio_encoder_set_allocator")]
469    fn set_allocator(
470        &self,
471        allocator: Option<impl IsA<gst::Allocator>>,
472        params: Option<&gst::AllocationParams>,
473    ) {
474        unsafe {
475            ffi::gst_audio_encoder_set_allocator(
476                self.as_ref().to_glib_none().0,
477                allocator.map(|p| p.upcast()).into_glib_ptr(),
478                params.to_glib_none().0,
479            );
480        }
481    }
482
483    /// Configures encoder drain handling. If drainable, subclass might
484    /// be handed a NULL buffer to have it return any leftover encoded data.
485    /// Otherwise, it is not considered so capable and will only ever be passed
486    /// real data.
487    ///
488    /// MT safe.
489    /// ## `enabled`
490    /// new state
491    #[doc(alias = "gst_audio_encoder_set_drainable")]
492    fn set_drainable(&self, enabled: bool) {
493        unsafe {
494            ffi::gst_audio_encoder_set_drainable(
495                self.as_ref().to_glib_none().0,
496                enabled.into_glib(),
497            );
498        }
499    }
500
501    /// Sets max number of frames accepted at once (assumed minimally 1).
502    /// Requires `frame_samples_min` and `frame_samples_max` to be the equal.
503    ///
504    /// Note: This value will be reset to 0 every time before
505    /// `GstAudioEncoderClass.set_format()` is called.
506    /// ## `num`
507    /// number of frames
508    #[doc(alias = "gst_audio_encoder_set_frame_max")]
509    fn set_frame_max(&self, num: i32) {
510        unsafe {
511            ffi::gst_audio_encoder_set_frame_max(self.as_ref().to_glib_none().0, num);
512        }
513    }
514
515    /// Sets number of samples (per channel) subclass needs to be handed,
516    /// at most or will be handed all available if 0.
517    ///
518    /// If an exact number of samples is required, [`set_frame_samples_min()`][Self::set_frame_samples_min()]
519    /// must be called with the same number.
520    ///
521    /// Note: This value will be reset to 0 every time before
522    /// `GstAudioEncoderClass.set_format()` is called.
523    /// ## `num`
524    /// number of samples per frame
525    #[doc(alias = "gst_audio_encoder_set_frame_samples_max")]
526    fn set_frame_samples_max(&self, num: i32) {
527        unsafe {
528            ffi::gst_audio_encoder_set_frame_samples_max(self.as_ref().to_glib_none().0, num);
529        }
530    }
531
532    /// Sets number of samples (per channel) subclass needs to be handed,
533    /// at least or will be handed all available if 0.
534    ///
535    /// If an exact number of samples is required, [`set_frame_samples_max()`][Self::set_frame_samples_max()]
536    /// must be called with the same number.
537    ///
538    /// Note: This value will be reset to 0 every time before
539    /// `GstAudioEncoderClass.set_format()` is called.
540    /// ## `num`
541    /// number of samples per frame
542    #[doc(alias = "gst_audio_encoder_set_frame_samples_min")]
543    fn set_frame_samples_min(&self, num: i32) {
544        unsafe {
545            ffi::gst_audio_encoder_set_frame_samples_min(self.as_ref().to_glib_none().0, num);
546        }
547    }
548
549    /// Configures encoder hard minimum handling. If enabled, subclass
550    /// will never be handed less samples than it configured, which otherwise
551    /// might occur near end-of-data handling. Instead, the leftover samples
552    /// will simply be discarded.
553    ///
554    /// MT safe.
555    /// ## `enabled`
556    /// new state
557    #[doc(alias = "gst_audio_encoder_set_hard_min")]
558    fn set_hard_min(&self, enabled: bool) {
559        unsafe {
560            ffi::gst_audio_encoder_set_hard_min(
561                self.as_ref().to_glib_none().0,
562                enabled.into_glib(),
563            );
564        }
565    }
566
567    #[doc(alias = "gst_audio_encoder_set_hard_resync")]
568    #[doc(alias = "hard-resync")]
569    fn set_hard_resync(&self, enabled: bool) {
570        unsafe {
571            ffi::gst_audio_encoder_set_hard_resync(
572                self.as_ref().to_glib_none().0,
573                enabled.into_glib(),
574            );
575        }
576    }
577
578    /// Sets encoder latency. If the provided values changed from
579    /// previously provided ones, this will also post a LATENCY message on the bus
580    /// so the pipeline can reconfigure its global latency.
581    /// ## `min`
582    /// minimum latency
583    /// ## `max`
584    /// maximum latency
585    #[doc(alias = "gst_audio_encoder_set_latency")]
586    fn set_latency(&self, min: gst::ClockTime, max: impl Into<Option<gst::ClockTime>>) {
587        unsafe {
588            ffi::gst_audio_encoder_set_latency(
589                self.as_ref().to_glib_none().0,
590                min.into_glib(),
591                max.into().into_glib(),
592            );
593        }
594    }
595
596    /// Sets encoder lookahead (in units of input rate samples)
597    ///
598    /// Note: This value will be reset to 0 every time before
599    /// `GstAudioEncoderClass.set_format()` is called.
600    /// ## `num`
601    /// lookahead
602    #[doc(alias = "gst_audio_encoder_set_lookahead")]
603    fn set_lookahead(&self, num: i32) {
604        unsafe {
605            ffi::gst_audio_encoder_set_lookahead(self.as_ref().to_glib_none().0, num);
606        }
607    }
608
609    /// Enable or disable encoder granule handling.
610    ///
611    /// MT safe.
612    /// ## `enabled`
613    /// new state
614    #[doc(alias = "gst_audio_encoder_set_mark_granule")]
615    fn set_mark_granule(&self, enabled: bool) {
616        unsafe {
617            ffi::gst_audio_encoder_set_mark_granule(
618                self.as_ref().to_glib_none().0,
619                enabled.into_glib(),
620            );
621        }
622    }
623
624    /// Enable or disable encoder perfect output timestamp preference.
625    ///
626    /// MT safe.
627    /// ## `enabled`
628    /// new state
629    #[doc(alias = "gst_audio_encoder_set_perfect_timestamp")]
630    #[doc(alias = "perfect-timestamp")]
631    fn set_perfect_timestamp(&self, enabled: bool) {
632        unsafe {
633            ffi::gst_audio_encoder_set_perfect_timestamp(
634                self.as_ref().to_glib_none().0,
635                enabled.into_glib(),
636            );
637        }
638    }
639
640    /// Configures encoder audio jitter tolerance threshold.
641    ///
642    /// MT safe.
643    /// ## `tolerance`
644    /// new tolerance
645    #[doc(alias = "gst_audio_encoder_set_tolerance")]
646    #[doc(alias = "tolerance")]
647    fn set_tolerance(&self, tolerance: gst::ClockTime) {
648        unsafe {
649            ffi::gst_audio_encoder_set_tolerance(
650                self.as_ref().to_glib_none().0,
651                tolerance.into_glib(),
652            );
653        }
654    }
655
656    #[doc(alias = "hard-resync")]
657    fn connect_hard_resync_notify<F: Fn(&Self) + Send + Sync + 'static>(
658        &self,
659        f: F,
660    ) -> SignalHandlerId {
661        unsafe extern "C" fn notify_hard_resync_trampoline<
662            P: IsA<AudioEncoder>,
663            F: Fn(&P) + Send + Sync + 'static,
664        >(
665            this: *mut ffi::GstAudioEncoder,
666            _param_spec: glib::ffi::gpointer,
667            f: glib::ffi::gpointer,
668        ) {
669            unsafe {
670                let f: &F = &*(f as *const F);
671                f(AudioEncoder::from_glib_borrow(this).unsafe_cast_ref())
672            }
673        }
674        unsafe {
675            let f: Box_<F> = Box_::new(f);
676            connect_raw(
677                self.as_ptr() as *mut _,
678                c"notify::hard-resync".as_ptr(),
679                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
680                    notify_hard_resync_trampoline::<Self, F> as *const (),
681                )),
682                Box_::into_raw(f),
683            )
684        }
685    }
686
687    #[doc(alias = "mark-granule")]
688    fn connect_mark_granule_notify<F: Fn(&Self) + Send + Sync + 'static>(
689        &self,
690        f: F,
691    ) -> SignalHandlerId {
692        unsafe extern "C" fn notify_mark_granule_trampoline<
693            P: IsA<AudioEncoder>,
694            F: Fn(&P) + Send + Sync + 'static,
695        >(
696            this: *mut ffi::GstAudioEncoder,
697            _param_spec: glib::ffi::gpointer,
698            f: glib::ffi::gpointer,
699        ) {
700            unsafe {
701                let f: &F = &*(f as *const F);
702                f(AudioEncoder::from_glib_borrow(this).unsafe_cast_ref())
703            }
704        }
705        unsafe {
706            let f: Box_<F> = Box_::new(f);
707            connect_raw(
708                self.as_ptr() as *mut _,
709                c"notify::mark-granule".as_ptr(),
710                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
711                    notify_mark_granule_trampoline::<Self, F> as *const (),
712                )),
713                Box_::into_raw(f),
714            )
715        }
716    }
717
718    #[doc(alias = "perfect-timestamp")]
719    fn connect_perfect_timestamp_notify<F: Fn(&Self) + Send + Sync + 'static>(
720        &self,
721        f: F,
722    ) -> SignalHandlerId {
723        unsafe extern "C" fn notify_perfect_timestamp_trampoline<
724            P: IsA<AudioEncoder>,
725            F: Fn(&P) + Send + Sync + 'static,
726        >(
727            this: *mut ffi::GstAudioEncoder,
728            _param_spec: glib::ffi::gpointer,
729            f: glib::ffi::gpointer,
730        ) {
731            unsafe {
732                let f: &F = &*(f as *const F);
733                f(AudioEncoder::from_glib_borrow(this).unsafe_cast_ref())
734            }
735        }
736        unsafe {
737            let f: Box_<F> = Box_::new(f);
738            connect_raw(
739                self.as_ptr() as *mut _,
740                c"notify::perfect-timestamp".as_ptr(),
741                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
742                    notify_perfect_timestamp_trampoline::<Self, F> as *const (),
743                )),
744                Box_::into_raw(f),
745            )
746        }
747    }
748
749    #[doc(alias = "tolerance")]
750    fn connect_tolerance_notify<F: Fn(&Self) + Send + Sync + 'static>(
751        &self,
752        f: F,
753    ) -> SignalHandlerId {
754        unsafe extern "C" fn notify_tolerance_trampoline<
755            P: IsA<AudioEncoder>,
756            F: Fn(&P) + Send + Sync + 'static,
757        >(
758            this: *mut ffi::GstAudioEncoder,
759            _param_spec: glib::ffi::gpointer,
760            f: glib::ffi::gpointer,
761        ) {
762            unsafe {
763                let f: &F = &*(f as *const F);
764                f(AudioEncoder::from_glib_borrow(this).unsafe_cast_ref())
765            }
766        }
767        unsafe {
768            let f: Box_<F> = Box_::new(f);
769            connect_raw(
770                self.as_ptr() as *mut _,
771                c"notify::tolerance".as_ptr(),
772                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
773                    notify_tolerance_trampoline::<Self, F> as *const (),
774                )),
775                Box_::into_raw(f),
776            )
777        }
778    }
779}
780
781impl<O: IsA<AudioEncoder>> AudioEncoderExt for O {}