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