gstreamer_audio/auto/audio_base_sink.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;
7use glib::{
8 prelude::*,
9 signal::{connect_raw, SignalHandlerId},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 /// This is the base class for audio sinks. Subclasses need to implement the
16 /// ::create_ringbuffer vmethod. This base class will then take care of
17 /// writing samples to the ringbuffer, synchronisation, clipping and flushing.
18 ///
19 /// ## Properties
20 ///
21 ///
22 /// #### `alignment-threshold`
23 /// Readable | Writeable
24 ///
25 ///
26 /// #### `buffer-time`
27 /// Readable | Writeable
28 ///
29 ///
30 /// #### `can-activate-pull`
31 /// Readable | Writeable
32 ///
33 ///
34 /// #### `discont-wait`
35 /// A window of time in nanoseconds to wait before creating a discontinuity as
36 /// a result of breaching the drift-tolerance.
37 ///
38 /// Readable | Writeable
39 ///
40 ///
41 /// #### `drift-tolerance`
42 /// Controls the amount of time in microseconds that clocks are allowed
43 /// to drift before resynchronisation happens.
44 ///
45 /// Readable | Writeable
46 ///
47 ///
48 /// #### `latency-time`
49 /// Readable | Writeable
50 ///
51 ///
52 /// #### `provide-clock`
53 /// Readable | Writeable
54 ///
55 ///
56 /// #### `slave-method`
57 /// Readable | Writeable
58 /// <details><summary><h4>BaseSink</h4></summary>
59 ///
60 ///
61 /// #### `async`
62 /// If set to [`true`], the basesink will perform asynchronous state changes.
63 /// When set to [`false`], the sink will not signal the parent when it prerolls.
64 /// Use this option when dealing with sparse streams or when synchronisation is
65 /// not required.
66 ///
67 /// Readable | Writeable
68 ///
69 ///
70 /// #### `blocksize`
71 /// The amount of bytes to pull when operating in pull mode.
72 ///
73 /// Readable | Writeable
74 ///
75 ///
76 /// #### `enable-last-sample`
77 /// Enable the last-sample property. If [`false`], basesink doesn't keep a
78 /// reference to the last buffer arrived and the last-sample property is always
79 /// set to [`None`]. This can be useful if you need buffers to be released as soon
80 /// as possible, eg. if you're using a buffer pool.
81 ///
82 /// Readable | Writeable
83 ///
84 ///
85 /// #### `last-sample`
86 /// The last buffer that arrived in the sink and was used for preroll or for
87 /// rendering. This property can be used to generate thumbnails. This property
88 /// can be [`None`] when the sink has not yet received a buffer.
89 ///
90 /// Readable
91 ///
92 ///
93 /// #### `max-bitrate`
94 /// Control the maximum amount of bits that will be rendered per second.
95 /// Setting this property to a value bigger than 0 will make the sink delay
96 /// rendering of the buffers when it would exceed to max-bitrate.
97 ///
98 /// Readable | Writeable
99 ///
100 ///
101 /// #### `max-lateness`
102 /// Readable | Writeable
103 ///
104 ///
105 /// #### `processing-deadline`
106 /// Maximum amount of time (in nanoseconds) that the pipeline can take
107 /// for processing the buffer. This is added to the latency of live
108 /// pipelines.
109 ///
110 /// Readable | Writeable
111 ///
112 ///
113 /// #### `qos`
114 /// Readable | Writeable
115 ///
116 ///
117 /// #### `render-delay`
118 /// The additional delay between synchronisation and actual rendering of the
119 /// media. This property will add additional latency to the device in order to
120 /// make other sinks compensate for the delay.
121 ///
122 /// Readable | Writeable
123 ///
124 ///
125 /// #### `stats`
126 /// Various [`gst_base::BaseSink`][crate::gst_base::BaseSink] statistics. This property returns a `GstStructure`
127 /// with name `application/x-gst-base-sink-stats` with the following fields:
128 ///
129 /// - "average-rate" G_TYPE_DOUBLE average frame rate
130 /// - "dropped" G_TYPE_UINT64 Number of dropped frames
131 /// - "rendered" G_TYPE_UINT64 Number of rendered frames
132 ///
133 /// Readable
134 ///
135 ///
136 /// #### `sync`
137 /// Readable | Writeable
138 ///
139 ///
140 /// #### `throttle-time`
141 /// The time to insert between buffers. This property can be used to control
142 /// the maximum amount of buffers per second to render. Setting this property
143 /// to a value bigger than 0 will make the sink create THROTTLE QoS events.
144 ///
145 /// Readable | Writeable
146 ///
147 ///
148 /// #### `ts-offset`
149 /// Controls the final synchronisation, a negative value will render the buffer
150 /// earlier while a positive value delays playback. This property can be
151 /// used to fix synchronisation in bad files.
152 ///
153 /// Readable | Writeable
154 /// </details>
155 /// <details><summary><h4>Object</h4></summary>
156 ///
157 ///
158 /// #### `name`
159 /// Readable | Writeable | Construct
160 ///
161 ///
162 /// #### `parent`
163 /// The parent of the object. Please note, that when changing the 'parent'
164 /// property, we don't emit [`notify`][struct@crate::glib::Object#notify] and [`deep-notify`][struct@crate::gst::Object#deep-notify]
165 /// signals due to locking issues. In some cases one can use
166 /// `GstBin::element-added` or `GstBin::element-removed` signals on the parent to
167 /// achieve a similar effect.
168 ///
169 /// Readable | Writeable
170 /// </details>
171 ///
172 /// # Implements
173 ///
174 /// [`AudioBaseSinkExt`][trait@crate::prelude::AudioBaseSinkExt], [`trait@gst_base::prelude::BaseSinkExt`], [`trait@gst::prelude::ElementExt`], [`trait@gst::prelude::GstObjectExt`], [`trait@glib::ObjectExt`]
175 #[doc(alias = "GstAudioBaseSink")]
176 pub struct AudioBaseSink(Object<ffi::GstAudioBaseSink, ffi::GstAudioBaseSinkClass>) @extends gst_base::BaseSink, gst::Element, gst::Object;
177
178 match fn {
179 type_ => || ffi::gst_audio_base_sink_get_type(),
180 }
181}
182
183impl AudioBaseSink {
184 pub const NONE: Option<&'static AudioBaseSink> = None;
185}
186
187unsafe impl Send for AudioBaseSink {}
188unsafe impl Sync for AudioBaseSink {}
189
190mod sealed {
191 pub trait Sealed {}
192 impl<T: super::IsA<super::AudioBaseSink>> Sealed for T {}
193}
194
195/// Trait containing all [`struct@AudioBaseSink`] methods.
196///
197/// # Implementors
198///
199/// [`AudioBaseSink`][struct@crate::AudioBaseSink], [`AudioSink`][struct@crate::AudioSink]
200pub trait AudioBaseSinkExt: IsA<AudioBaseSink> + sealed::Sealed + 'static {
201 //#[doc(alias = "gst_audio_base_sink_create_ringbuffer")]
202 //fn create_ringbuffer(&self) -> /*Ignored*/Option<AudioRingBuffer> {
203 // unsafe { TODO: call ffi:gst_audio_base_sink_create_ringbuffer() }
204 //}
205
206 /// Get the current alignment threshold, in nanoseconds, used by `self`.
207 ///
208 /// # Returns
209 ///
210 /// The current alignment threshold used by `self`.
211 #[doc(alias = "gst_audio_base_sink_get_alignment_threshold")]
212 #[doc(alias = "get_alignment_threshold")]
213 #[doc(alias = "alignment-threshold")]
214 fn alignment_threshold(&self) -> gst::ClockTime {
215 unsafe {
216 try_from_glib(ffi::gst_audio_base_sink_get_alignment_threshold(
217 self.as_ref().to_glib_none().0,
218 ))
219 .expect("mandatory glib value is None")
220 }
221 }
222
223 /// Get the current discont wait, in nanoseconds, used by `self`.
224 ///
225 /// # Returns
226 ///
227 /// The current discont wait used by `self`.
228 #[doc(alias = "gst_audio_base_sink_get_discont_wait")]
229 #[doc(alias = "get_discont_wait")]
230 #[doc(alias = "discont-wait")]
231 fn discont_wait(&self) -> gst::ClockTime {
232 unsafe {
233 try_from_glib(ffi::gst_audio_base_sink_get_discont_wait(
234 self.as_ref().to_glib_none().0,
235 ))
236 .expect("mandatory glib value is None")
237 }
238 }
239
240 /// Get the current drift tolerance, in microseconds, used by `self`.
241 ///
242 /// # Returns
243 ///
244 /// The current drift tolerance used by `self`.
245 #[doc(alias = "gst_audio_base_sink_get_drift_tolerance")]
246 #[doc(alias = "get_drift_tolerance")]
247 #[doc(alias = "drift-tolerance")]
248 fn drift_tolerance(&self) -> i64 {
249 unsafe { ffi::gst_audio_base_sink_get_drift_tolerance(self.as_ref().to_glib_none().0) }
250 }
251
252 /// Queries whether `self` will provide a clock or not. See also
253 /// gst_audio_base_sink_set_provide_clock.
254 ///
255 /// # Returns
256 ///
257 /// [`true`] if `self` will provide a clock.
258 #[doc(alias = "gst_audio_base_sink_get_provide_clock")]
259 #[doc(alias = "get_provide_clock")]
260 #[doc(alias = "provide-clock")]
261 fn is_provide_clock(&self) -> bool {
262 unsafe {
263 from_glib(ffi::gst_audio_base_sink_get_provide_clock(
264 self.as_ref().to_glib_none().0,
265 ))
266 }
267 }
268
269 //#[doc(alias = "gst_audio_base_sink_get_slave_method")]
270 //#[doc(alias = "get_slave_method")]
271 //#[doc(alias = "slave-method")]
272 //fn slave_method(&self) -> /*Ignored*/AudioBaseSinkSlaveMethod {
273 // unsafe { TODO: call ffi:gst_audio_base_sink_get_slave_method() }
274 //}
275
276 /// Informs this base class that the audio output device has failed for
277 /// some reason, causing a discontinuity (for example, because the device
278 /// recovered from the error, but lost all contents of its ring buffer).
279 /// This function is typically called by derived classes, and is useful
280 /// for the custom slave method.
281 #[doc(alias = "gst_audio_base_sink_report_device_failure")]
282 fn report_device_failure(&self) {
283 unsafe {
284 ffi::gst_audio_base_sink_report_device_failure(self.as_ref().to_glib_none().0);
285 }
286 }
287
288 /// Controls the sink's alignment threshold.
289 /// ## `alignment_threshold`
290 /// the new alignment threshold in nanoseconds
291 #[doc(alias = "gst_audio_base_sink_set_alignment_threshold")]
292 #[doc(alias = "alignment-threshold")]
293 fn set_alignment_threshold(&self, alignment_threshold: gst::ClockTime) {
294 unsafe {
295 ffi::gst_audio_base_sink_set_alignment_threshold(
296 self.as_ref().to_glib_none().0,
297 alignment_threshold.into_glib(),
298 );
299 }
300 }
301
302 //#[doc(alias = "gst_audio_base_sink_set_custom_slaving_callback")]
303 //fn set_custom_slaving_callback(&self, callback: /*Unimplemented*/Fn(&AudioBaseSink, impl Into<Option<gst::ClockTime>>, impl Into<Option<gst::ClockTime>>, gst::ClockTimeDiff, /*Ignored*/AudioBaseSinkDiscontReason), user_data: /*Unimplemented*/Option<Basic: Pointer>) {
304 // unsafe { TODO: call ffi:gst_audio_base_sink_set_custom_slaving_callback() }
305 //}
306
307 /// Controls how long the sink will wait before creating a discontinuity.
308 /// ## `discont_wait`
309 /// the new discont wait in nanoseconds
310 #[doc(alias = "gst_audio_base_sink_set_discont_wait")]
311 #[doc(alias = "discont-wait")]
312 fn set_discont_wait(&self, discont_wait: gst::ClockTime) {
313 unsafe {
314 ffi::gst_audio_base_sink_set_discont_wait(
315 self.as_ref().to_glib_none().0,
316 discont_wait.into_glib(),
317 );
318 }
319 }
320
321 /// Controls the sink's drift tolerance.
322 /// ## `drift_tolerance`
323 /// the new drift tolerance in microseconds
324 #[doc(alias = "gst_audio_base_sink_set_drift_tolerance")]
325 #[doc(alias = "drift-tolerance")]
326 fn set_drift_tolerance(&self, drift_tolerance: i64) {
327 unsafe {
328 ffi::gst_audio_base_sink_set_drift_tolerance(
329 self.as_ref().to_glib_none().0,
330 drift_tolerance,
331 );
332 }
333 }
334
335 /// Controls whether `self` will provide a clock or not. If `provide` is [`true`],
336 /// [`ElementExtManual::provide_clock()`][crate::gst::prelude::ElementExtManual::provide_clock()] will return a clock that reflects the datarate
337 /// of `self`. If `provide` is [`false`], [`ElementExtManual::provide_clock()`][crate::gst::prelude::ElementExtManual::provide_clock()] will return
338 /// NULL.
339 /// ## `provide`
340 /// new state
341 #[doc(alias = "gst_audio_base_sink_set_provide_clock")]
342 #[doc(alias = "provide-clock")]
343 fn set_provide_clock(&self, provide: bool) {
344 unsafe {
345 ffi::gst_audio_base_sink_set_provide_clock(
346 self.as_ref().to_glib_none().0,
347 provide.into_glib(),
348 );
349 }
350 }
351
352 //#[doc(alias = "gst_audio_base_sink_set_slave_method")]
353 //#[doc(alias = "slave-method")]
354 //fn set_slave_method(&self, method: /*Ignored*/AudioBaseSinkSlaveMethod) {
355 // unsafe { TODO: call ffi:gst_audio_base_sink_set_slave_method() }
356 //}
357
358 #[doc(alias = "buffer-time")]
359 fn buffer_time(&self) -> i64 {
360 ObjectExt::property(self.as_ref(), "buffer-time")
361 }
362
363 #[doc(alias = "buffer-time")]
364 fn set_buffer_time(&self, buffer_time: i64) {
365 ObjectExt::set_property(self.as_ref(), "buffer-time", buffer_time)
366 }
367
368 #[doc(alias = "can-activate-pull")]
369 fn can_activate_pull(&self) -> bool {
370 ObjectExt::property(self.as_ref(), "can-activate-pull")
371 }
372
373 #[doc(alias = "can-activate-pull")]
374 fn set_can_activate_pull(&self, can_activate_pull: bool) {
375 ObjectExt::set_property(self.as_ref(), "can-activate-pull", can_activate_pull)
376 }
377
378 #[doc(alias = "latency-time")]
379 fn latency_time(&self) -> i64 {
380 ObjectExt::property(self.as_ref(), "latency-time")
381 }
382
383 #[doc(alias = "latency-time")]
384 fn set_latency_time(&self, latency_time: i64) {
385 ObjectExt::set_property(self.as_ref(), "latency-time", latency_time)
386 }
387
388 #[doc(alias = "alignment-threshold")]
389 fn connect_alignment_threshold_notify<F: Fn(&Self) + Send + Sync + 'static>(
390 &self,
391 f: F,
392 ) -> SignalHandlerId {
393 unsafe extern "C" fn notify_alignment_threshold_trampoline<
394 P: IsA<AudioBaseSink>,
395 F: Fn(&P) + Send + Sync + 'static,
396 >(
397 this: *mut ffi::GstAudioBaseSink,
398 _param_spec: glib::ffi::gpointer,
399 f: glib::ffi::gpointer,
400 ) {
401 let f: &F = &*(f as *const F);
402 f(AudioBaseSink::from_glib_borrow(this).unsafe_cast_ref())
403 }
404 unsafe {
405 let f: Box_<F> = Box_::new(f);
406 connect_raw(
407 self.as_ptr() as *mut _,
408 b"notify::alignment-threshold\0".as_ptr() as *const _,
409 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
410 notify_alignment_threshold_trampoline::<Self, F> as *const (),
411 )),
412 Box_::into_raw(f),
413 )
414 }
415 }
416
417 #[doc(alias = "buffer-time")]
418 fn connect_buffer_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
419 &self,
420 f: F,
421 ) -> SignalHandlerId {
422 unsafe extern "C" fn notify_buffer_time_trampoline<
423 P: IsA<AudioBaseSink>,
424 F: Fn(&P) + Send + Sync + 'static,
425 >(
426 this: *mut ffi::GstAudioBaseSink,
427 _param_spec: glib::ffi::gpointer,
428 f: glib::ffi::gpointer,
429 ) {
430 let f: &F = &*(f as *const F);
431 f(AudioBaseSink::from_glib_borrow(this).unsafe_cast_ref())
432 }
433 unsafe {
434 let f: Box_<F> = Box_::new(f);
435 connect_raw(
436 self.as_ptr() as *mut _,
437 b"notify::buffer-time\0".as_ptr() as *const _,
438 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
439 notify_buffer_time_trampoline::<Self, F> as *const (),
440 )),
441 Box_::into_raw(f),
442 )
443 }
444 }
445
446 #[doc(alias = "can-activate-pull")]
447 fn connect_can_activate_pull_notify<F: Fn(&Self) + Send + Sync + 'static>(
448 &self,
449 f: F,
450 ) -> SignalHandlerId {
451 unsafe extern "C" fn notify_can_activate_pull_trampoline<
452 P: IsA<AudioBaseSink>,
453 F: Fn(&P) + Send + Sync + 'static,
454 >(
455 this: *mut ffi::GstAudioBaseSink,
456 _param_spec: glib::ffi::gpointer,
457 f: glib::ffi::gpointer,
458 ) {
459 let f: &F = &*(f as *const F);
460 f(AudioBaseSink::from_glib_borrow(this).unsafe_cast_ref())
461 }
462 unsafe {
463 let f: Box_<F> = Box_::new(f);
464 connect_raw(
465 self.as_ptr() as *mut _,
466 b"notify::can-activate-pull\0".as_ptr() as *const _,
467 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
468 notify_can_activate_pull_trampoline::<Self, F> as *const (),
469 )),
470 Box_::into_raw(f),
471 )
472 }
473 }
474
475 #[doc(alias = "discont-wait")]
476 fn connect_discont_wait_notify<F: Fn(&Self) + Send + Sync + 'static>(
477 &self,
478 f: F,
479 ) -> SignalHandlerId {
480 unsafe extern "C" fn notify_discont_wait_trampoline<
481 P: IsA<AudioBaseSink>,
482 F: Fn(&P) + Send + Sync + 'static,
483 >(
484 this: *mut ffi::GstAudioBaseSink,
485 _param_spec: glib::ffi::gpointer,
486 f: glib::ffi::gpointer,
487 ) {
488 let f: &F = &*(f as *const F);
489 f(AudioBaseSink::from_glib_borrow(this).unsafe_cast_ref())
490 }
491 unsafe {
492 let f: Box_<F> = Box_::new(f);
493 connect_raw(
494 self.as_ptr() as *mut _,
495 b"notify::discont-wait\0".as_ptr() as *const _,
496 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
497 notify_discont_wait_trampoline::<Self, F> as *const (),
498 )),
499 Box_::into_raw(f),
500 )
501 }
502 }
503
504 #[doc(alias = "drift-tolerance")]
505 fn connect_drift_tolerance_notify<F: Fn(&Self) + Send + Sync + 'static>(
506 &self,
507 f: F,
508 ) -> SignalHandlerId {
509 unsafe extern "C" fn notify_drift_tolerance_trampoline<
510 P: IsA<AudioBaseSink>,
511 F: Fn(&P) + Send + Sync + 'static,
512 >(
513 this: *mut ffi::GstAudioBaseSink,
514 _param_spec: glib::ffi::gpointer,
515 f: glib::ffi::gpointer,
516 ) {
517 let f: &F = &*(f as *const F);
518 f(AudioBaseSink::from_glib_borrow(this).unsafe_cast_ref())
519 }
520 unsafe {
521 let f: Box_<F> = Box_::new(f);
522 connect_raw(
523 self.as_ptr() as *mut _,
524 b"notify::drift-tolerance\0".as_ptr() as *const _,
525 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
526 notify_drift_tolerance_trampoline::<Self, F> as *const (),
527 )),
528 Box_::into_raw(f),
529 )
530 }
531 }
532
533 #[doc(alias = "latency-time")]
534 fn connect_latency_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
535 &self,
536 f: F,
537 ) -> SignalHandlerId {
538 unsafe extern "C" fn notify_latency_time_trampoline<
539 P: IsA<AudioBaseSink>,
540 F: Fn(&P) + Send + Sync + 'static,
541 >(
542 this: *mut ffi::GstAudioBaseSink,
543 _param_spec: glib::ffi::gpointer,
544 f: glib::ffi::gpointer,
545 ) {
546 let f: &F = &*(f as *const F);
547 f(AudioBaseSink::from_glib_borrow(this).unsafe_cast_ref())
548 }
549 unsafe {
550 let f: Box_<F> = Box_::new(f);
551 connect_raw(
552 self.as_ptr() as *mut _,
553 b"notify::latency-time\0".as_ptr() as *const _,
554 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
555 notify_latency_time_trampoline::<Self, F> as *const (),
556 )),
557 Box_::into_raw(f),
558 )
559 }
560 }
561
562 #[doc(alias = "provide-clock")]
563 fn connect_provide_clock_notify<F: Fn(&Self) + Send + Sync + 'static>(
564 &self,
565 f: F,
566 ) -> SignalHandlerId {
567 unsafe extern "C" fn notify_provide_clock_trampoline<
568 P: IsA<AudioBaseSink>,
569 F: Fn(&P) + Send + Sync + 'static,
570 >(
571 this: *mut ffi::GstAudioBaseSink,
572 _param_spec: glib::ffi::gpointer,
573 f: glib::ffi::gpointer,
574 ) {
575 let f: &F = &*(f as *const F);
576 f(AudioBaseSink::from_glib_borrow(this).unsafe_cast_ref())
577 }
578 unsafe {
579 let f: Box_<F> = Box_::new(f);
580 connect_raw(
581 self.as_ptr() as *mut _,
582 b"notify::provide-clock\0".as_ptr() as *const _,
583 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
584 notify_provide_clock_trampoline::<Self, F> as *const (),
585 )),
586 Box_::into_raw(f),
587 )
588 }
589 }
590
591 #[doc(alias = "slave-method")]
592 fn connect_slave_method_notify<F: Fn(&Self) + Send + Sync + 'static>(
593 &self,
594 f: F,
595 ) -> SignalHandlerId {
596 unsafe extern "C" fn notify_slave_method_trampoline<
597 P: IsA<AudioBaseSink>,
598 F: Fn(&P) + Send + Sync + 'static,
599 >(
600 this: *mut ffi::GstAudioBaseSink,
601 _param_spec: glib::ffi::gpointer,
602 f: glib::ffi::gpointer,
603 ) {
604 let f: &F = &*(f as *const F);
605 f(AudioBaseSink::from_glib_borrow(this).unsafe_cast_ref())
606 }
607 unsafe {
608 let f: Box_<F> = Box_::new(f);
609 connect_raw(
610 self.as_ptr() as *mut _,
611 b"notify::slave-method\0".as_ptr() as *const _,
612 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
613 notify_slave_method_trampoline::<Self, F> as *const (),
614 )),
615 Box_::into_raw(f),
616 )
617 }
618 }
619}
620
621impl<O: IsA<AudioBaseSink>> AudioBaseSinkExt for O {}