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