gstreamer_audio/auto/audio_decoder.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 decoders turning encoded data into
16 /// raw audio samples.
17 ///
18 /// GstAudioDecoder and subclass should cooperate as follows.
19 ///
20 /// ## Configuration
21 ///
22 /// * Initially, GstAudioDecoder calls `start` when the decoder element
23 /// is activated, which allows subclass to perform any global setup.
24 /// Base class (context) parameters can already be set according to subclass
25 /// capabilities (or possibly upon receive more information in subsequent
26 /// `set_format`).
27 /// * GstAudioDecoder calls `set_format` to inform subclass of the format
28 /// of input audio data that it is about to receive.
29 /// While unlikely, it might be called more than once, if changing input
30 /// parameters require reconfiguration.
31 /// * GstAudioDecoder calls `stop` at end of all processing.
32 ///
33 /// As of configuration stage, and throughout processing, GstAudioDecoder
34 /// provides various (context) parameters, e.g. describing the format of
35 /// output audio data (valid when output caps have been set) or current parsing state.
36 /// Conversely, subclass can and should configure context to inform
37 /// base class of its expectation w.r.t. buffer handling.
38 ///
39 /// ## Data processing
40 /// * Base class gathers input data, and optionally allows subclass
41 /// to parse this into subsequently manageable (as defined by subclass)
42 /// chunks. Such chunks are subsequently referred to as 'frames',
43 /// though they may or may not correspond to 1 (or more) audio format frame.
44 /// * Input frame is provided to subclass' `handle_frame`.
45 /// * If codec processing results in decoded data, subclass should call
46 /// [`AudioDecoderExt::finish_frame()`][crate::prelude::AudioDecoderExt::finish_frame()] to have decoded data pushed
47 /// downstream.
48 /// * Just prior to actually pushing a buffer downstream,
49 /// it is passed to `pre_push`. Subclass should either use this callback
50 /// to arrange for additional downstream pushing or otherwise ensure such
51 /// custom pushing occurs after at least a method call has finished since
52 /// setting src pad caps.
53 /// * During the parsing process GstAudioDecoderClass will handle both
54 /// srcpad and sinkpad events. Sink events will be passed to subclass
55 /// if `event` callback has been provided.
56 ///
57 /// ## Shutdown phase
58 ///
59 /// * GstAudioDecoder class calls `stop` to inform the subclass that data
60 /// parsing will be stopped.
61 ///
62 /// Subclass is responsible for providing pad template caps for
63 /// source and sink pads. The pads need to be named "sink" and "src". It also
64 /// needs to set the fixed caps on srcpad, when the format is ensured. This
65 /// is typically when base class calls subclass' `set_format` function, though
66 /// it might be delayed until calling [`AudioDecoderExt::finish_frame()`][crate::prelude::AudioDecoderExt::finish_frame()].
67 ///
68 /// In summary, above process should have subclass concentrating on
69 /// codec data processing while leaving other matters to base class,
70 /// such as most notably timestamp handling. While it may exert more control
71 /// in this area (see e.g. `pre_push`), it is very much not recommended.
72 ///
73 /// In particular, base class will try to arrange for perfect output timestamps
74 /// as much as possible while tracking upstream timestamps.
75 /// To this end, if deviation between the next ideal expected perfect timestamp
76 /// and upstream exceeds [`tolerance`][struct@crate::AudioDecoder#tolerance], then resync to upstream
77 /// occurs (which would happen always if the tolerance mechanism is disabled).
78 ///
79 /// In non-live pipelines, baseclass can also (configurably) arrange for
80 /// output buffer aggregation which may help to redue large(r) numbers of
81 /// small(er) buffers being pushed and processed downstream. Note that this
82 /// feature is only available if the buffer layout is interleaved. For planar
83 /// buffers, the decoder implementation is fully responsible for the output
84 /// buffer size.
85 ///
86 /// On the other hand, it should be noted that baseclass only provides limited
87 /// seeking support (upon explicit subclass request), as full-fledged support
88 /// should rather be left to upstream demuxer, parser or alike. This simple
89 /// approach caters for seeking and duration reporting using estimated input
90 /// bitrates.
91 ///
92 /// Things that subclass need to take care of:
93 ///
94 /// * Provide pad templates
95 /// * Set source pad caps when appropriate
96 /// * Set user-configurable properties to sane defaults for format and
97 /// implementing codec at hand, and convey some subclass capabilities and
98 /// expectations in context.
99 ///
100 /// * Accept data in `handle_frame` and provide encoded results to
101 /// [`AudioDecoderExt::finish_frame()`][crate::prelude::AudioDecoderExt::finish_frame()]. If it is prepared to perform
102 /// PLC, it should also accept NULL data in `handle_frame` and provide for
103 /// data for indicated duration.
104 ///
105 /// This is an Abstract Base Class, you cannot instantiate it.
106 ///
107 /// ## Properties
108 ///
109 ///
110 /// #### `max-errors`
111 /// Maximum number of tolerated consecutive decode errors. See
112 /// [`AudioDecoderExt::set_max_errors()`][crate::prelude::AudioDecoderExt::set_max_errors()] for more details.
113 ///
114 /// Readable | Writeable
115 ///
116 ///
117 /// #### `min-latency`
118 /// Readable | Writeable
119 ///
120 ///
121 /// #### `plc`
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 /// [`AudioDecoderExt`][trait@crate::prelude::AudioDecoderExt], [`trait@gst::prelude::ElementExt`], [`trait@gst::prelude::GstObjectExt`], [`trait@glib::ObjectExt`], [`AudioDecoderExtManual`][trait@crate::prelude::AudioDecoderExtManual]
147 #[doc(alias = "GstAudioDecoder")]
148 pub struct AudioDecoder(Object<ffi::GstAudioDecoder, ffi::GstAudioDecoderClass>) @extends gst::Element, gst::Object;
149
150 match fn {
151 type_ => || ffi::gst_audio_decoder_get_type(),
152 }
153}
154
155impl AudioDecoder {
156 pub const NONE: Option<&'static AudioDecoder> = None;
157}
158
159unsafe impl Send for AudioDecoder {}
160unsafe impl Sync for AudioDecoder {}
161
162mod sealed {
163 pub trait Sealed {}
164 impl<T: super::IsA<super::AudioDecoder>> Sealed for T {}
165}
166
167/// Trait containing all [`struct@AudioDecoder`] methods.
168///
169/// # Implementors
170///
171/// [`AudioDecoder`][struct@crate::AudioDecoder]
172pub trait AudioDecoderExt: IsA<AudioDecoder> + sealed::Sealed + 'static {
173 /// Helper function that allocates a buffer to hold an 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_decoder_allocate_output_buffer")]
182 fn allocate_output_buffer(&self, size: usize) -> gst::Buffer {
183 unsafe {
184 from_glib_full(ffi::gst_audio_decoder_allocate_output_buffer(
185 self.as_ref().to_glib_none().0,
186 size,
187 ))
188 }
189 }
190
191 /// Collects decoded data and pushes it downstream.
192 ///
193 /// `buf` may be NULL in which case the indicated number of frames
194 /// are discarded and considered to have produced no output
195 /// (e.g. lead-in or setup frames).
196 /// Otherwise, source pad caps must be set when it is called with valid
197 /// data in `buf`.
198 ///
199 /// Note that a frame received in `GstAudioDecoderClass.handle_frame()` may be
200 /// invalidated by a call to this function.
201 /// ## `buf`
202 /// decoded data
203 /// ## `frames`
204 /// number of decoded frames represented by decoded 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_decoder_finish_frame")]
210 fn finish_frame(
211 &self,
212 buf: Option<gst::Buffer>,
213 frames: i32,
214 ) -> Result<gst::FlowSuccess, gst::FlowError> {
215 unsafe {
216 try_from_glib(ffi::gst_audio_decoder_finish_frame(
217 self.as_ref().to_glib_none().0,
218 buf.into_glib_ptr(),
219 frames,
220 ))
221 }
222 }
223
224 /// Collects decoded data and pushes it downstream. This function may be called
225 /// multiple times for a given input frame.
226 ///
227 /// `buf` may be NULL in which case it is assumed that the current input frame is
228 /// finished. This is equivalent to calling [`finish_subframe()`][Self::finish_subframe()]
229 /// with a NULL buffer and frames=1 after having pushed out all decoded audio
230 /// subframes using this function.
231 ///
232 /// When called with valid data in `buf` the source pad caps must have been set
233 /// already.
234 ///
235 /// Note that a frame received in `GstAudioDecoderClass.handle_frame()` may be
236 /// invalidated by a call to this function.
237 /// ## `buf`
238 /// decoded data
239 ///
240 /// # Returns
241 ///
242 /// a [`gst::FlowReturn`][crate::gst::FlowReturn] that should be escalated to caller (of caller)
243 #[cfg(feature = "v1_16")]
244 #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
245 #[doc(alias = "gst_audio_decoder_finish_subframe")]
246 fn finish_subframe(
247 &self,
248 buf: Option<gst::Buffer>,
249 ) -> Result<gst::FlowSuccess, gst::FlowError> {
250 unsafe {
251 try_from_glib(ffi::gst_audio_decoder_finish_subframe(
252 self.as_ref().to_glib_none().0,
253 buf.into_glib_ptr(),
254 ))
255 }
256 }
257
258 ///
259 /// # Returns
260 ///
261 /// a [`AudioInfo`][crate::AudioInfo] describing the input audio format
262 #[doc(alias = "gst_audio_decoder_get_audio_info")]
263 #[doc(alias = "get_audio_info")]
264 fn audio_info(&self) -> AudioInfo {
265 unsafe {
266 from_glib_none(ffi::gst_audio_decoder_get_audio_info(
267 self.as_ref().to_glib_none().0,
268 ))
269 }
270 }
271
272 ///
273 /// # Returns
274 ///
275 /// currently configured decoder delay
276 #[doc(alias = "gst_audio_decoder_get_delay")]
277 #[doc(alias = "get_delay")]
278 fn delay(&self) -> i32 {
279 unsafe { ffi::gst_audio_decoder_get_delay(self.as_ref().to_glib_none().0) }
280 }
281
282 /// Queries decoder drain handling.
283 ///
284 /// # Returns
285 ///
286 /// TRUE if drainable handling is enabled.
287 ///
288 /// MT safe.
289 #[doc(alias = "gst_audio_decoder_get_drainable")]
290 #[doc(alias = "get_drainable")]
291 fn is_drainable(&self) -> bool {
292 unsafe {
293 from_glib(ffi::gst_audio_decoder_get_drainable(
294 self.as_ref().to_glib_none().0,
295 ))
296 }
297 }
298
299 ///
300 /// # Returns
301 ///
302 /// currently configured byte to time conversion setting
303 #[doc(alias = "gst_audio_decoder_get_estimate_rate")]
304 #[doc(alias = "get_estimate_rate")]
305 fn estimate_rate(&self) -> i32 {
306 unsafe { ffi::gst_audio_decoder_get_estimate_rate(self.as_ref().to_glib_none().0) }
307 }
308
309 /// Sets the variables pointed to by `min` and `max` to the currently configured
310 /// latency.
311 ///
312 /// # Returns
313 ///
314 ///
315 /// ## `min`
316 /// a pointer to storage to hold minimum latency
317 ///
318 /// ## `max`
319 /// a pointer to storage to hold maximum latency
320 #[doc(alias = "gst_audio_decoder_get_latency")]
321 #[doc(alias = "get_latency")]
322 fn latency(&self) -> (gst::ClockTime, Option<gst::ClockTime>) {
323 unsafe {
324 let mut min = std::mem::MaybeUninit::uninit();
325 let mut max = std::mem::MaybeUninit::uninit();
326 ffi::gst_audio_decoder_get_latency(
327 self.as_ref().to_glib_none().0,
328 min.as_mut_ptr(),
329 max.as_mut_ptr(),
330 );
331 (
332 try_from_glib(min.assume_init()).expect("mandatory glib value is None"),
333 from_glib(max.assume_init()),
334 )
335 }
336 }
337
338 ///
339 /// # Returns
340 ///
341 /// currently configured decoder tolerated error count.
342 #[doc(alias = "gst_audio_decoder_get_max_errors")]
343 #[doc(alias = "get_max_errors")]
344 #[doc(alias = "max-errors")]
345 fn max_errors(&self) -> i32 {
346 unsafe { ffi::gst_audio_decoder_get_max_errors(self.as_ref().to_glib_none().0) }
347 }
348
349 /// Queries decoder's latency aggregation.
350 ///
351 /// # Returns
352 ///
353 /// aggregation latency.
354 ///
355 /// MT safe.
356 #[doc(alias = "gst_audio_decoder_get_min_latency")]
357 #[doc(alias = "get_min_latency")]
358 #[doc(alias = "min-latency")]
359 fn min_latency(&self) -> gst::ClockTime {
360 unsafe {
361 try_from_glib(ffi::gst_audio_decoder_get_min_latency(
362 self.as_ref().to_glib_none().0,
363 ))
364 .expect("mandatory glib value is None")
365 }
366 }
367
368 /// Queries decoder required format handling.
369 ///
370 /// # Returns
371 ///
372 /// TRUE if required format handling is enabled.
373 ///
374 /// MT safe.
375 #[doc(alias = "gst_audio_decoder_get_needs_format")]
376 #[doc(alias = "get_needs_format")]
377 fn needs_format(&self) -> bool {
378 unsafe {
379 from_glib(ffi::gst_audio_decoder_get_needs_format(
380 self.as_ref().to_glib_none().0,
381 ))
382 }
383 }
384
385 /// Return current parsing (sync and eos) state.
386 ///
387 /// # Returns
388 ///
389 ///
390 /// ## `sync`
391 /// a pointer to a variable to hold the current sync state
392 ///
393 /// ## `eos`
394 /// a pointer to a variable to hold the current eos state
395 #[doc(alias = "gst_audio_decoder_get_parse_state")]
396 #[doc(alias = "get_parse_state")]
397 fn parse_state(&self) -> (bool, bool) {
398 unsafe {
399 let mut sync = std::mem::MaybeUninit::uninit();
400 let mut eos = std::mem::MaybeUninit::uninit();
401 ffi::gst_audio_decoder_get_parse_state(
402 self.as_ref().to_glib_none().0,
403 sync.as_mut_ptr(),
404 eos.as_mut_ptr(),
405 );
406 (from_glib(sync.assume_init()), from_glib(eos.assume_init()))
407 }
408 }
409
410 /// Queries decoder packet loss concealment handling.
411 ///
412 /// # Returns
413 ///
414 /// TRUE if packet loss concealment is enabled.
415 ///
416 /// MT safe.
417 #[doc(alias = "gst_audio_decoder_get_plc")]
418 #[doc(alias = "get_plc")]
419 #[doc(alias = "plc")]
420 fn is_plc(&self) -> bool {
421 unsafe {
422 from_glib(ffi::gst_audio_decoder_get_plc(
423 self.as_ref().to_glib_none().0,
424 ))
425 }
426 }
427
428 ///
429 /// # Returns
430 ///
431 /// currently configured plc handling
432 #[doc(alias = "gst_audio_decoder_get_plc_aware")]
433 #[doc(alias = "get_plc_aware")]
434 fn plc_aware(&self) -> i32 {
435 unsafe { ffi::gst_audio_decoder_get_plc_aware(self.as_ref().to_glib_none().0) }
436 }
437
438 /// Queries current audio jitter tolerance threshold.
439 ///
440 /// # Returns
441 ///
442 /// decoder audio jitter tolerance threshold.
443 ///
444 /// MT safe.
445 #[doc(alias = "gst_audio_decoder_get_tolerance")]
446 #[doc(alias = "get_tolerance")]
447 fn tolerance(&self) -> gst::ClockTime {
448 unsafe {
449 try_from_glib(ffi::gst_audio_decoder_get_tolerance(
450 self.as_ref().to_glib_none().0,
451 ))
452 .expect("mandatory glib value is None")
453 }
454 }
455
456 /// Sets the audio decoder tags and how they should be merged with any
457 /// upstream stream tags. This will override any tags previously-set
458 /// with [`merge_tags()`][Self::merge_tags()].
459 ///
460 /// Note that this is provided for convenience, and the subclass is
461 /// not required to use this and can still do tag handling on its own.
462 /// ## `tags`
463 /// a [`gst::TagList`][crate::gst::TagList] to merge, or NULL
464 /// ## `mode`
465 /// the [`gst::TagMergeMode`][crate::gst::TagMergeMode] to use, usually [`gst::TagMergeMode::Replace`][crate::gst::TagMergeMode::Replace]
466 #[doc(alias = "gst_audio_decoder_merge_tags")]
467 fn merge_tags(&self, tags: Option<&gst::TagList>, mode: gst::TagMergeMode) {
468 unsafe {
469 ffi::gst_audio_decoder_merge_tags(
470 self.as_ref().to_glib_none().0,
471 tags.to_glib_none().0,
472 mode.into_glib(),
473 );
474 }
475 }
476
477 /// Returns caps that express `caps` (or sink template caps if `caps` == NULL)
478 /// restricted to rate/channels/... combinations supported by downstream
479 /// elements.
480 /// ## `caps`
481 /// initial caps
482 /// ## `filter`
483 /// filter caps
484 ///
485 /// # Returns
486 ///
487 /// a [`gst::Caps`][crate::gst::Caps] owned by caller
488 #[doc(alias = "gst_audio_decoder_proxy_getcaps")]
489 fn proxy_getcaps(&self, caps: Option<&gst::Caps>, filter: Option<&gst::Caps>) -> gst::Caps {
490 unsafe {
491 from_glib_full(ffi::gst_audio_decoder_proxy_getcaps(
492 self.as_ref().to_glib_none().0,
493 caps.to_glib_none().0,
494 filter.to_glib_none().0,
495 ))
496 }
497 }
498
499 /// Sets a caps in allocation query which are different from the set
500 /// pad's caps. Use this function before calling
501 /// [`AudioDecoderExtManual::negotiate()`][crate::prelude::AudioDecoderExtManual::negotiate()]. Setting to [`None`] the allocation
502 /// query will use the caps from the pad.
503 /// ## `allocation_caps`
504 /// a [`gst::Caps`][crate::gst::Caps] or [`None`]
505 #[doc(alias = "gst_audio_decoder_set_allocation_caps")]
506 fn set_allocation_caps(&self, allocation_caps: Option<&gst::Caps>) {
507 unsafe {
508 ffi::gst_audio_decoder_set_allocation_caps(
509 self.as_ref().to_glib_none().0,
510 allocation_caps.to_glib_none().0,
511 );
512 }
513 }
514
515 /// Configures decoder drain handling. If drainable, subclass might
516 /// be handed a NULL buffer to have it return any leftover decoded data.
517 /// Otherwise, it is not considered so capable and will only ever be passed
518 /// real data.
519 ///
520 /// MT safe.
521 /// ## `enabled`
522 /// new state
523 #[doc(alias = "gst_audio_decoder_set_drainable")]
524 fn set_drainable(&self, enabled: bool) {
525 unsafe {
526 ffi::gst_audio_decoder_set_drainable(
527 self.as_ref().to_glib_none().0,
528 enabled.into_glib(),
529 );
530 }
531 }
532
533 /// Allows baseclass to perform byte to time estimated conversion.
534 /// ## `enabled`
535 /// whether to enable byte to time conversion
536 #[doc(alias = "gst_audio_decoder_set_estimate_rate")]
537 fn set_estimate_rate(&self, enabled: bool) {
538 unsafe {
539 ffi::gst_audio_decoder_set_estimate_rate(
540 self.as_ref().to_glib_none().0,
541 enabled.into_glib(),
542 );
543 }
544 }
545
546 /// Sets decoder latency. If the provided values changed from
547 /// previously provided ones, this will also post a LATENCY message on the bus
548 /// so the pipeline can reconfigure its global latency.
549 /// ## `min`
550 /// minimum latency
551 /// ## `max`
552 /// maximum latency
553 #[doc(alias = "gst_audio_decoder_set_latency")]
554 fn set_latency(&self, min: gst::ClockTime, max: impl Into<Option<gst::ClockTime>>) {
555 unsafe {
556 ffi::gst_audio_decoder_set_latency(
557 self.as_ref().to_glib_none().0,
558 min.into_glib(),
559 max.into().into_glib(),
560 );
561 }
562 }
563
564 /// Sets numbers of tolerated decoder errors, where a tolerated one is then only
565 /// warned about, but more than tolerated will lead to fatal error. You can set
566 /// -1 for never returning fatal errors. Default is set to
567 /// GST_AUDIO_DECODER_MAX_ERRORS.
568 /// ## `num`
569 /// max tolerated errors
570 #[doc(alias = "gst_audio_decoder_set_max_errors")]
571 #[doc(alias = "max-errors")]
572 fn set_max_errors(&self, num: i32) {
573 unsafe {
574 ffi::gst_audio_decoder_set_max_errors(self.as_ref().to_glib_none().0, num);
575 }
576 }
577
578 /// Sets decoder minimum aggregation latency.
579 ///
580 /// MT safe.
581 /// ## `num`
582 /// new minimum latency
583 #[doc(alias = "gst_audio_decoder_set_min_latency")]
584 #[doc(alias = "min-latency")]
585 fn set_min_latency(&self, num: gst::ClockTime) {
586 unsafe {
587 ffi::gst_audio_decoder_set_min_latency(self.as_ref().to_glib_none().0, num.into_glib());
588 }
589 }
590
591 /// Configures decoder format needs. If enabled, subclass needs to be
592 /// negotiated with format caps before it can process any data. It will then
593 /// never be handed any data before it has been configured.
594 /// Otherwise, it might be handed data without having been configured and
595 /// is then expected being able to do so either by default
596 /// or based on the input data.
597 ///
598 /// MT safe.
599 /// ## `enabled`
600 /// new state
601 #[doc(alias = "gst_audio_decoder_set_needs_format")]
602 fn set_needs_format(&self, enabled: bool) {
603 unsafe {
604 ffi::gst_audio_decoder_set_needs_format(
605 self.as_ref().to_glib_none().0,
606 enabled.into_glib(),
607 );
608 }
609 }
610
611 /// Enable or disable decoder packet loss concealment, provided subclass
612 /// and codec are capable and allow handling plc.
613 ///
614 /// MT safe.
615 /// ## `enabled`
616 /// new state
617 #[doc(alias = "gst_audio_decoder_set_plc")]
618 #[doc(alias = "plc")]
619 fn set_plc(&self, enabled: bool) {
620 unsafe {
621 ffi::gst_audio_decoder_set_plc(self.as_ref().to_glib_none().0, enabled.into_glib());
622 }
623 }
624
625 /// Indicates whether or not subclass handles packet loss concealment (plc).
626 /// ## `plc`
627 /// new plc state
628 #[doc(alias = "gst_audio_decoder_set_plc_aware")]
629 fn set_plc_aware(&self, plc: bool) {
630 unsafe {
631 ffi::gst_audio_decoder_set_plc_aware(self.as_ref().to_glib_none().0, plc.into_glib());
632 }
633 }
634
635 /// Configures decoder audio jitter tolerance threshold.
636 ///
637 /// MT safe.
638 /// ## `tolerance`
639 /// new tolerance
640 #[doc(alias = "gst_audio_decoder_set_tolerance")]
641 #[doc(alias = "tolerance")]
642 fn set_tolerance(&self, tolerance: gst::ClockTime) {
643 unsafe {
644 ffi::gst_audio_decoder_set_tolerance(
645 self.as_ref().to_glib_none().0,
646 tolerance.into_glib(),
647 );
648 }
649 }
650
651 /// Lets [`AudioDecoder`][crate::AudioDecoder] sub-classes decide if they want the sink pad
652 /// to use the default pad query handler to reply to accept-caps queries.
653 ///
654 /// By setting this to true it is possible to further customize the default
655 /// handler with `GST_PAD_SET_ACCEPT_INTERSECT` and
656 /// `GST_PAD_SET_ACCEPT_TEMPLATE`
657 /// ## `use_`
658 /// if the default pad accept-caps query handling should be used
659 #[doc(alias = "gst_audio_decoder_set_use_default_pad_acceptcaps")]
660 fn set_use_default_pad_acceptcaps(&self, use_: bool) {
661 unsafe {
662 ffi::gst_audio_decoder_set_use_default_pad_acceptcaps(
663 self.as_ref().to_glib_none().0,
664 use_.into_glib(),
665 );
666 }
667 }
668
669 #[cfg(feature = "v1_18")]
670 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
671 #[doc(alias = "max-errors")]
672 fn connect_max_errors_notify<F: Fn(&Self) + Send + Sync + 'static>(
673 &self,
674 f: F,
675 ) -> SignalHandlerId {
676 unsafe extern "C" fn notify_max_errors_trampoline<
677 P: IsA<AudioDecoder>,
678 F: Fn(&P) + Send + Sync + 'static,
679 >(
680 this: *mut ffi::GstAudioDecoder,
681 _param_spec: glib::ffi::gpointer,
682 f: glib::ffi::gpointer,
683 ) {
684 let f: &F = &*(f as *const F);
685 f(AudioDecoder::from_glib_borrow(this).unsafe_cast_ref())
686 }
687 unsafe {
688 let f: Box_<F> = Box_::new(f);
689 connect_raw(
690 self.as_ptr() as *mut _,
691 b"notify::max-errors\0".as_ptr() as *const _,
692 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
693 notify_max_errors_trampoline::<Self, F> as *const (),
694 )),
695 Box_::into_raw(f),
696 )
697 }
698 }
699
700 #[doc(alias = "min-latency")]
701 fn connect_min_latency_notify<F: Fn(&Self) + Send + Sync + 'static>(
702 &self,
703 f: F,
704 ) -> SignalHandlerId {
705 unsafe extern "C" fn notify_min_latency_trampoline<
706 P: IsA<AudioDecoder>,
707 F: Fn(&P) + Send + Sync + 'static,
708 >(
709 this: *mut ffi::GstAudioDecoder,
710 _param_spec: glib::ffi::gpointer,
711 f: glib::ffi::gpointer,
712 ) {
713 let f: &F = &*(f as *const F);
714 f(AudioDecoder::from_glib_borrow(this).unsafe_cast_ref())
715 }
716 unsafe {
717 let f: Box_<F> = Box_::new(f);
718 connect_raw(
719 self.as_ptr() as *mut _,
720 b"notify::min-latency\0".as_ptr() as *const _,
721 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
722 notify_min_latency_trampoline::<Self, F> as *const (),
723 )),
724 Box_::into_raw(f),
725 )
726 }
727 }
728
729 #[doc(alias = "plc")]
730 fn connect_plc_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
731 unsafe extern "C" fn notify_plc_trampoline<
732 P: IsA<AudioDecoder>,
733 F: Fn(&P) + Send + Sync + 'static,
734 >(
735 this: *mut ffi::GstAudioDecoder,
736 _param_spec: glib::ffi::gpointer,
737 f: glib::ffi::gpointer,
738 ) {
739 let f: &F = &*(f as *const F);
740 f(AudioDecoder::from_glib_borrow(this).unsafe_cast_ref())
741 }
742 unsafe {
743 let f: Box_<F> = Box_::new(f);
744 connect_raw(
745 self.as_ptr() as *mut _,
746 b"notify::plc\0".as_ptr() as *const _,
747 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
748 notify_plc_trampoline::<Self, F> as *const (),
749 )),
750 Box_::into_raw(f),
751 )
752 }
753 }
754
755 #[doc(alias = "tolerance")]
756 fn connect_tolerance_notify<F: Fn(&Self) + Send + Sync + 'static>(
757 &self,
758 f: F,
759 ) -> SignalHandlerId {
760 unsafe extern "C" fn notify_tolerance_trampoline<
761 P: IsA<AudioDecoder>,
762 F: Fn(&P) + Send + Sync + 'static,
763 >(
764 this: *mut ffi::GstAudioDecoder,
765 _param_spec: glib::ffi::gpointer,
766 f: glib::ffi::gpointer,
767 ) {
768 let f: &F = &*(f as *const F);
769 f(AudioDecoder::from_glib_borrow(this).unsafe_cast_ref())
770 }
771 unsafe {
772 let f: Box_<F> = Box_::new(f);
773 connect_raw(
774 self.as_ptr() as *mut _,
775 b"notify::tolerance\0".as_ptr() as *const _,
776 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
777 notify_tolerance_trampoline::<Self, F> as *const (),
778 )),
779 Box_::into_raw(f),
780 )
781 }
782 }
783}
784
785impl<O: IsA<AudioDecoder>> AudioDecoderExt for O {}