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 | 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 /// Allows [`AudioEncoder`][crate::AudioEncoder] sub-classes to set the memory `allocator` and
464 /// its `params`.
465 /// ## `allocator`
466 /// the [`gst::Allocator`][crate::gst::Allocator]
467 /// ## `params`
468 /// the [`gst::AllocationParams`][crate::gst::AllocationParams] of `allocator`
469 #[cfg(feature = "v1_30")]
470 #[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
471 #[doc(alias = "gst_audio_encoder_set_allocator")]
472 fn set_allocator(
473 &self,
474 allocator: Option<impl IsA<gst::Allocator>>,
475 params: Option<&gst::AllocationParams>,
476 ) {
477 unsafe {
478 ffi::gst_audio_encoder_set_allocator(
479 self.as_ref().to_glib_none().0,
480 allocator.map(|p| p.upcast()).into_glib_ptr(),
481 params.to_glib_none().0,
482 );
483 }
484 }
485
486 /// Configures encoder drain handling. If drainable, subclass might
487 /// be handed a NULL buffer to have it return any leftover encoded data.
488 /// Otherwise, it is not considered so capable and will only ever be passed
489 /// real data.
490 ///
491 /// MT safe.
492 /// ## `enabled`
493 /// new state
494 #[doc(alias = "gst_audio_encoder_set_drainable")]
495 fn set_drainable(&self, enabled: bool) {
496 unsafe {
497 ffi::gst_audio_encoder_set_drainable(
498 self.as_ref().to_glib_none().0,
499 enabled.into_glib(),
500 );
501 }
502 }
503
504 /// Sets max number of frames accepted at once (assumed minimally 1).
505 /// Requires `frame_samples_min` and `frame_samples_max` to be the equal.
506 ///
507 /// Note: This value will be reset to 0 every time before
508 /// `GstAudioEncoderClass.set_format()` is called.
509 /// ## `num`
510 /// number of frames
511 #[doc(alias = "gst_audio_encoder_set_frame_max")]
512 fn set_frame_max(&self, num: i32) {
513 unsafe {
514 ffi::gst_audio_encoder_set_frame_max(self.as_ref().to_glib_none().0, num);
515 }
516 }
517
518 /// Sets number of samples (per channel) subclass needs to be handed,
519 /// at most or will be handed all available if 0.
520 ///
521 /// If an exact number of samples is required, [`set_frame_samples_min()`][Self::set_frame_samples_min()]
522 /// must be called with the same number.
523 ///
524 /// Note: This value will be reset to 0 every time before
525 /// `GstAudioEncoderClass.set_format()` is called.
526 /// ## `num`
527 /// number of samples per frame
528 #[doc(alias = "gst_audio_encoder_set_frame_samples_max")]
529 fn set_frame_samples_max(&self, num: i32) {
530 unsafe {
531 ffi::gst_audio_encoder_set_frame_samples_max(self.as_ref().to_glib_none().0, num);
532 }
533 }
534
535 /// Sets number of samples (per channel) subclass needs to be handed,
536 /// at least or will be handed all available if 0.
537 ///
538 /// If an exact number of samples is required, [`set_frame_samples_max()`][Self::set_frame_samples_max()]
539 /// must be called with the same number.
540 ///
541 /// Note: This value will be reset to 0 every time before
542 /// `GstAudioEncoderClass.set_format()` is called.
543 /// ## `num`
544 /// number of samples per frame
545 #[doc(alias = "gst_audio_encoder_set_frame_samples_min")]
546 fn set_frame_samples_min(&self, num: i32) {
547 unsafe {
548 ffi::gst_audio_encoder_set_frame_samples_min(self.as_ref().to_glib_none().0, num);
549 }
550 }
551
552 /// Configures encoder hard minimum handling. If enabled, subclass
553 /// will never be handed less samples than it configured, which otherwise
554 /// might occur near end-of-data handling. Instead, the leftover samples
555 /// will simply be discarded.
556 ///
557 /// MT safe.
558 /// ## `enabled`
559 /// new state
560 #[doc(alias = "gst_audio_encoder_set_hard_min")]
561 fn set_hard_min(&self, enabled: bool) {
562 unsafe {
563 ffi::gst_audio_encoder_set_hard_min(
564 self.as_ref().to_glib_none().0,
565 enabled.into_glib(),
566 );
567 }
568 }
569
570 #[doc(alias = "gst_audio_encoder_set_hard_resync")]
571 #[doc(alias = "hard-resync")]
572 fn set_hard_resync(&self, enabled: bool) {
573 unsafe {
574 ffi::gst_audio_encoder_set_hard_resync(
575 self.as_ref().to_glib_none().0,
576 enabled.into_glib(),
577 );
578 }
579 }
580
581 /// Sets encoder latency. If the provided values changed from
582 /// previously provided ones, this will also post a LATENCY message on the bus
583 /// so the pipeline can reconfigure its global latency.
584 /// ## `min`
585 /// minimum latency
586 /// ## `max`
587 /// maximum latency
588 #[doc(alias = "gst_audio_encoder_set_latency")]
589 fn set_latency(&self, min: gst::ClockTime, max: impl Into<Option<gst::ClockTime>>) {
590 unsafe {
591 ffi::gst_audio_encoder_set_latency(
592 self.as_ref().to_glib_none().0,
593 min.into_glib(),
594 max.into().into_glib(),
595 );
596 }
597 }
598
599 /// Sets encoder lookahead (in units of input rate samples)
600 ///
601 /// Note: This value will be reset to 0 every time before
602 /// `GstAudioEncoderClass.set_format()` is called.
603 /// ## `num`
604 /// lookahead
605 #[doc(alias = "gst_audio_encoder_set_lookahead")]
606 fn set_lookahead(&self, num: i32) {
607 unsafe {
608 ffi::gst_audio_encoder_set_lookahead(self.as_ref().to_glib_none().0, num);
609 }
610 }
611
612 /// Enable or disable encoder granule handling.
613 ///
614 /// MT safe.
615 /// ## `enabled`
616 /// new state
617 #[doc(alias = "gst_audio_encoder_set_mark_granule")]
618 fn set_mark_granule(&self, enabled: bool) {
619 unsafe {
620 ffi::gst_audio_encoder_set_mark_granule(
621 self.as_ref().to_glib_none().0,
622 enabled.into_glib(),
623 );
624 }
625 }
626
627 /// Enable or disable encoder perfect output timestamp preference.
628 ///
629 /// MT safe.
630 /// ## `enabled`
631 /// new state
632 #[doc(alias = "gst_audio_encoder_set_perfect_timestamp")]
633 #[doc(alias = "perfect-timestamp")]
634 fn set_perfect_timestamp(&self, enabled: bool) {
635 unsafe {
636 ffi::gst_audio_encoder_set_perfect_timestamp(
637 self.as_ref().to_glib_none().0,
638 enabled.into_glib(),
639 );
640 }
641 }
642
643 /// Configures encoder audio jitter tolerance threshold.
644 ///
645 /// MT safe.
646 /// ## `tolerance`
647 /// new tolerance
648 #[doc(alias = "gst_audio_encoder_set_tolerance")]
649 #[doc(alias = "tolerance")]
650 fn set_tolerance(&self, tolerance: gst::ClockTime) {
651 unsafe {
652 ffi::gst_audio_encoder_set_tolerance(
653 self.as_ref().to_glib_none().0,
654 tolerance.into_glib(),
655 );
656 }
657 }
658
659 #[doc(alias = "hard-resync")]
660 fn connect_hard_resync_notify<F: Fn(&Self) + Send + Sync + 'static>(
661 &self,
662 f: F,
663 ) -> SignalHandlerId {
664 unsafe extern "C" fn notify_hard_resync_trampoline<
665 P: IsA<AudioEncoder>,
666 F: Fn(&P) + Send + Sync + 'static,
667 >(
668 this: *mut ffi::GstAudioEncoder,
669 _param_spec: glib::ffi::gpointer,
670 f: glib::ffi::gpointer,
671 ) {
672 unsafe {
673 let f: &F = &*(f as *const F);
674 f(AudioEncoder::from_glib_borrow(this).unsafe_cast_ref())
675 }
676 }
677 unsafe {
678 let f: Box_<F> = Box_::new(f);
679 connect_raw(
680 self.as_ptr() as *mut _,
681 c"notify::hard-resync".as_ptr(),
682 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
683 notify_hard_resync_trampoline::<Self, F> as *const (),
684 )),
685 Box_::into_raw(f),
686 )
687 }
688 }
689
690 #[doc(alias = "mark-granule")]
691 fn connect_mark_granule_notify<F: Fn(&Self) + Send + Sync + 'static>(
692 &self,
693 f: F,
694 ) -> SignalHandlerId {
695 unsafe extern "C" fn notify_mark_granule_trampoline<
696 P: IsA<AudioEncoder>,
697 F: Fn(&P) + Send + Sync + 'static,
698 >(
699 this: *mut ffi::GstAudioEncoder,
700 _param_spec: glib::ffi::gpointer,
701 f: glib::ffi::gpointer,
702 ) {
703 unsafe {
704 let f: &F = &*(f as *const F);
705 f(AudioEncoder::from_glib_borrow(this).unsafe_cast_ref())
706 }
707 }
708 unsafe {
709 let f: Box_<F> = Box_::new(f);
710 connect_raw(
711 self.as_ptr() as *mut _,
712 c"notify::mark-granule".as_ptr(),
713 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
714 notify_mark_granule_trampoline::<Self, F> as *const (),
715 )),
716 Box_::into_raw(f),
717 )
718 }
719 }
720
721 #[doc(alias = "perfect-timestamp")]
722 fn connect_perfect_timestamp_notify<F: Fn(&Self) + Send + Sync + 'static>(
723 &self,
724 f: F,
725 ) -> SignalHandlerId {
726 unsafe extern "C" fn notify_perfect_timestamp_trampoline<
727 P: IsA<AudioEncoder>,
728 F: Fn(&P) + Send + Sync + 'static,
729 >(
730 this: *mut ffi::GstAudioEncoder,
731 _param_spec: glib::ffi::gpointer,
732 f: glib::ffi::gpointer,
733 ) {
734 unsafe {
735 let f: &F = &*(f as *const F);
736 f(AudioEncoder::from_glib_borrow(this).unsafe_cast_ref())
737 }
738 }
739 unsafe {
740 let f: Box_<F> = Box_::new(f);
741 connect_raw(
742 self.as_ptr() as *mut _,
743 c"notify::perfect-timestamp".as_ptr(),
744 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
745 notify_perfect_timestamp_trampoline::<Self, F> as *const (),
746 )),
747 Box_::into_raw(f),
748 )
749 }
750 }
751
752 #[doc(alias = "tolerance")]
753 fn connect_tolerance_notify<F: Fn(&Self) + Send + Sync + 'static>(
754 &self,
755 f: F,
756 ) -> SignalHandlerId {
757 unsafe extern "C" fn notify_tolerance_trampoline<
758 P: IsA<AudioEncoder>,
759 F: Fn(&P) + Send + Sync + 'static,
760 >(
761 this: *mut ffi::GstAudioEncoder,
762 _param_spec: glib::ffi::gpointer,
763 f: glib::ffi::gpointer,
764 ) {
765 unsafe {
766 let f: &F = &*(f as *const F);
767 f(AudioEncoder::from_glib_borrow(this).unsafe_cast_ref())
768 }
769 }
770 unsafe {
771 let f: Box_<F> = Box_::new(f);
772 connect_raw(
773 self.as_ptr() as *mut _,
774 c"notify::tolerance".as_ptr(),
775 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
776 notify_tolerance_trampoline::<Self, F> as *const (),
777 )),
778 Box_::into_raw(f),
779 )
780 }
781 }
782}
783
784impl<O: IsA<AudioEncoder>> AudioEncoderExt for O {}