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
190/// Trait containing all [`struct@AudioBaseSink`] methods.
191///
192/// # Implementors
193///
194/// [`AudioBaseSink`][struct@crate::AudioBaseSink], [`AudioSink`][struct@crate::AudioSink]
195pub trait AudioBaseSinkExt: IsA<AudioBaseSink> + 'static {
196 //#[doc(alias = "gst_audio_base_sink_create_ringbuffer")]
197 //fn create_ringbuffer(&self) -> /*Ignored*/Option<AudioRingBuffer> {
198 // unsafe { TODO: call ffi:gst_audio_base_sink_create_ringbuffer() }
199 //}
200
201 /// Get the current alignment threshold, in nanoseconds, used by `self`.
202 ///
203 /// # Returns
204 ///
205 /// The current alignment threshold used by `self`.
206 #[doc(alias = "gst_audio_base_sink_get_alignment_threshold")]
207 #[doc(alias = "get_alignment_threshold")]
208 #[doc(alias = "alignment-threshold")]
209 fn alignment_threshold(&self) -> gst::ClockTime {
210 unsafe {
211 try_from_glib(ffi::gst_audio_base_sink_get_alignment_threshold(
212 self.as_ref().to_glib_none().0,
213 ))
214 .expect("mandatory glib value is None")
215 }
216 }
217
218 /// Get the current discont wait, in nanoseconds, used by `self`.
219 ///
220 /// # Returns
221 ///
222 /// The current discont wait used by `self`.
223 #[doc(alias = "gst_audio_base_sink_get_discont_wait")]
224 #[doc(alias = "get_discont_wait")]
225 #[doc(alias = "discont-wait")]
226 fn discont_wait(&self) -> gst::ClockTime {
227 unsafe {
228 try_from_glib(ffi::gst_audio_base_sink_get_discont_wait(
229 self.as_ref().to_glib_none().0,
230 ))
231 .expect("mandatory glib value is None")
232 }
233 }
234
235 /// Get the current drift tolerance, in microseconds, used by `self`.
236 ///
237 /// # Returns
238 ///
239 /// The current drift tolerance used by `self`.
240 #[doc(alias = "gst_audio_base_sink_get_drift_tolerance")]
241 #[doc(alias = "get_drift_tolerance")]
242 #[doc(alias = "drift-tolerance")]
243 fn drift_tolerance(&self) -> i64 {
244 unsafe { ffi::gst_audio_base_sink_get_drift_tolerance(self.as_ref().to_glib_none().0) }
245 }
246
247 /// Queries whether `self` will provide a clock or not. See also
248 /// gst_audio_base_sink_set_provide_clock.
249 ///
250 /// # Returns
251 ///
252 /// [`true`] if `self` will provide a clock.
253 #[doc(alias = "gst_audio_base_sink_get_provide_clock")]
254 #[doc(alias = "get_provide_clock")]
255 #[doc(alias = "provide-clock")]
256 fn is_provide_clock(&self) -> bool {
257 unsafe {
258 from_glib(ffi::gst_audio_base_sink_get_provide_clock(
259 self.as_ref().to_glib_none().0,
260 ))
261 }
262 }
263
264 //#[doc(alias = "gst_audio_base_sink_get_slave_method")]
265 //#[doc(alias = "get_slave_method")]
266 //#[doc(alias = "slave-method")]
267 //fn slave_method(&self) -> /*Ignored*/AudioBaseSinkSlaveMethod {
268 // unsafe { TODO: call ffi:gst_audio_base_sink_get_slave_method() }
269 //}
270
271 /// Informs this base class that the audio output device has failed for
272 /// some reason, causing a discontinuity (for example, because the device
273 /// recovered from the error, but lost all contents of its ring buffer).
274 /// This function is typically called by derived classes, and is useful
275 /// for the custom slave method.
276 #[doc(alias = "gst_audio_base_sink_report_device_failure")]
277 fn report_device_failure(&self) {
278 unsafe {
279 ffi::gst_audio_base_sink_report_device_failure(self.as_ref().to_glib_none().0);
280 }
281 }
282
283 /// Controls the sink's alignment threshold.
284 /// ## `alignment_threshold`
285 /// the new alignment threshold in nanoseconds
286 #[doc(alias = "gst_audio_base_sink_set_alignment_threshold")]
287 #[doc(alias = "alignment-threshold")]
288 fn set_alignment_threshold(&self, alignment_threshold: gst::ClockTime) {
289 unsafe {
290 ffi::gst_audio_base_sink_set_alignment_threshold(
291 self.as_ref().to_glib_none().0,
292 alignment_threshold.into_glib(),
293 );
294 }
295 }
296
297 //#[doc(alias = "gst_audio_base_sink_set_custom_slaving_callback")]
298 //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>) {
299 // unsafe { TODO: call ffi:gst_audio_base_sink_set_custom_slaving_callback() }
300 //}
301
302 /// Controls how long the sink will wait before creating a discontinuity.
303 /// ## `discont_wait`
304 /// the new discont wait in nanoseconds
305 #[doc(alias = "gst_audio_base_sink_set_discont_wait")]
306 #[doc(alias = "discont-wait")]
307 fn set_discont_wait(&self, discont_wait: gst::ClockTime) {
308 unsafe {
309 ffi::gst_audio_base_sink_set_discont_wait(
310 self.as_ref().to_glib_none().0,
311 discont_wait.into_glib(),
312 );
313 }
314 }
315
316 /// Controls the sink's drift tolerance.
317 /// ## `drift_tolerance`
318 /// the new drift tolerance in microseconds
319 #[doc(alias = "gst_audio_base_sink_set_drift_tolerance")]
320 #[doc(alias = "drift-tolerance")]
321 fn set_drift_tolerance(&self, drift_tolerance: i64) {
322 unsafe {
323 ffi::gst_audio_base_sink_set_drift_tolerance(
324 self.as_ref().to_glib_none().0,
325 drift_tolerance,
326 );
327 }
328 }
329
330 /// Controls whether `self` will provide a clock or not. If `provide` is [`true`],
331 /// [`ElementExtManual::provide_clock()`][crate::gst::prelude::ElementExtManual::provide_clock()] will return a clock that reflects the datarate
332 /// of `self`. If `provide` is [`false`], [`ElementExtManual::provide_clock()`][crate::gst::prelude::ElementExtManual::provide_clock()] will return
333 /// NULL.
334 /// ## `provide`
335 /// new state
336 #[doc(alias = "gst_audio_base_sink_set_provide_clock")]
337 #[doc(alias = "provide-clock")]
338 fn set_provide_clock(&self, provide: bool) {
339 unsafe {
340 ffi::gst_audio_base_sink_set_provide_clock(
341 self.as_ref().to_glib_none().0,
342 provide.into_glib(),
343 );
344 }
345 }
346
347 //#[doc(alias = "gst_audio_base_sink_set_slave_method")]
348 //#[doc(alias = "slave-method")]
349 //fn set_slave_method(&self, method: /*Ignored*/AudioBaseSinkSlaveMethod) {
350 // unsafe { TODO: call ffi:gst_audio_base_sink_set_slave_method() }
351 //}
352
353 #[doc(alias = "buffer-time")]
354 fn buffer_time(&self) -> i64 {
355 ObjectExt::property(self.as_ref(), "buffer-time")
356 }
357
358 #[doc(alias = "buffer-time")]
359 fn set_buffer_time(&self, buffer_time: i64) {
360 ObjectExt::set_property(self.as_ref(), "buffer-time", buffer_time)
361 }
362
363 #[doc(alias = "can-activate-pull")]
364 fn can_activate_pull(&self) -> bool {
365 ObjectExt::property(self.as_ref(), "can-activate-pull")
366 }
367
368 #[doc(alias = "can-activate-pull")]
369 fn set_can_activate_pull(&self, can_activate_pull: bool) {
370 ObjectExt::set_property(self.as_ref(), "can-activate-pull", can_activate_pull)
371 }
372
373 #[doc(alias = "latency-time")]
374 fn latency_time(&self) -> i64 {
375 ObjectExt::property(self.as_ref(), "latency-time")
376 }
377
378 #[doc(alias = "latency-time")]
379 fn set_latency_time(&self, latency_time: i64) {
380 ObjectExt::set_property(self.as_ref(), "latency-time", latency_time)
381 }
382
383 #[doc(alias = "alignment-threshold")]
384 fn connect_alignment_threshold_notify<F: Fn(&Self) + Send + Sync + 'static>(
385 &self,
386 f: F,
387 ) -> SignalHandlerId {
388 unsafe extern "C" fn notify_alignment_threshold_trampoline<
389 P: IsA<AudioBaseSink>,
390 F: Fn(&P) + Send + Sync + 'static,
391 >(
392 this: *mut ffi::GstAudioBaseSink,
393 _param_spec: glib::ffi::gpointer,
394 f: glib::ffi::gpointer,
395 ) {
396 let f: &F = &*(f as *const F);
397 f(AudioBaseSink::from_glib_borrow(this).unsafe_cast_ref())
398 }
399 unsafe {
400 let f: Box_<F> = Box_::new(f);
401 connect_raw(
402 self.as_ptr() as *mut _,
403 c"notify::alignment-threshold".as_ptr() as *const _,
404 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
405 notify_alignment_threshold_trampoline::<Self, F> as *const (),
406 )),
407 Box_::into_raw(f),
408 )
409 }
410 }
411
412 #[doc(alias = "buffer-time")]
413 fn connect_buffer_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
414 &self,
415 f: F,
416 ) -> SignalHandlerId {
417 unsafe extern "C" fn notify_buffer_time_trampoline<
418 P: IsA<AudioBaseSink>,
419 F: Fn(&P) + Send + Sync + 'static,
420 >(
421 this: *mut ffi::GstAudioBaseSink,
422 _param_spec: glib::ffi::gpointer,
423 f: glib::ffi::gpointer,
424 ) {
425 let f: &F = &*(f as *const F);
426 f(AudioBaseSink::from_glib_borrow(this).unsafe_cast_ref())
427 }
428 unsafe {
429 let f: Box_<F> = Box_::new(f);
430 connect_raw(
431 self.as_ptr() as *mut _,
432 c"notify::buffer-time".as_ptr() as *const _,
433 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
434 notify_buffer_time_trampoline::<Self, F> as *const (),
435 )),
436 Box_::into_raw(f),
437 )
438 }
439 }
440
441 #[doc(alias = "can-activate-pull")]
442 fn connect_can_activate_pull_notify<F: Fn(&Self) + Send + Sync + 'static>(
443 &self,
444 f: F,
445 ) -> SignalHandlerId {
446 unsafe extern "C" fn notify_can_activate_pull_trampoline<
447 P: IsA<AudioBaseSink>,
448 F: Fn(&P) + Send + Sync + 'static,
449 >(
450 this: *mut ffi::GstAudioBaseSink,
451 _param_spec: glib::ffi::gpointer,
452 f: glib::ffi::gpointer,
453 ) {
454 let f: &F = &*(f as *const F);
455 f(AudioBaseSink::from_glib_borrow(this).unsafe_cast_ref())
456 }
457 unsafe {
458 let f: Box_<F> = Box_::new(f);
459 connect_raw(
460 self.as_ptr() as *mut _,
461 c"notify::can-activate-pull".as_ptr() as *const _,
462 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
463 notify_can_activate_pull_trampoline::<Self, F> as *const (),
464 )),
465 Box_::into_raw(f),
466 )
467 }
468 }
469
470 #[doc(alias = "discont-wait")]
471 fn connect_discont_wait_notify<F: Fn(&Self) + Send + Sync + 'static>(
472 &self,
473 f: F,
474 ) -> SignalHandlerId {
475 unsafe extern "C" fn notify_discont_wait_trampoline<
476 P: IsA<AudioBaseSink>,
477 F: Fn(&P) + Send + Sync + 'static,
478 >(
479 this: *mut ffi::GstAudioBaseSink,
480 _param_spec: glib::ffi::gpointer,
481 f: glib::ffi::gpointer,
482 ) {
483 let f: &F = &*(f as *const F);
484 f(AudioBaseSink::from_glib_borrow(this).unsafe_cast_ref())
485 }
486 unsafe {
487 let f: Box_<F> = Box_::new(f);
488 connect_raw(
489 self.as_ptr() as *mut _,
490 c"notify::discont-wait".as_ptr() as *const _,
491 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
492 notify_discont_wait_trampoline::<Self, F> as *const (),
493 )),
494 Box_::into_raw(f),
495 )
496 }
497 }
498
499 #[doc(alias = "drift-tolerance")]
500 fn connect_drift_tolerance_notify<F: Fn(&Self) + Send + Sync + 'static>(
501 &self,
502 f: F,
503 ) -> SignalHandlerId {
504 unsafe extern "C" fn notify_drift_tolerance_trampoline<
505 P: IsA<AudioBaseSink>,
506 F: Fn(&P) + Send + Sync + 'static,
507 >(
508 this: *mut ffi::GstAudioBaseSink,
509 _param_spec: glib::ffi::gpointer,
510 f: glib::ffi::gpointer,
511 ) {
512 let f: &F = &*(f as *const F);
513 f(AudioBaseSink::from_glib_borrow(this).unsafe_cast_ref())
514 }
515 unsafe {
516 let f: Box_<F> = Box_::new(f);
517 connect_raw(
518 self.as_ptr() as *mut _,
519 c"notify::drift-tolerance".as_ptr() as *const _,
520 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
521 notify_drift_tolerance_trampoline::<Self, F> as *const (),
522 )),
523 Box_::into_raw(f),
524 )
525 }
526 }
527
528 #[doc(alias = "latency-time")]
529 fn connect_latency_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
530 &self,
531 f: F,
532 ) -> SignalHandlerId {
533 unsafe extern "C" fn notify_latency_time_trampoline<
534 P: IsA<AudioBaseSink>,
535 F: Fn(&P) + Send + Sync + 'static,
536 >(
537 this: *mut ffi::GstAudioBaseSink,
538 _param_spec: glib::ffi::gpointer,
539 f: glib::ffi::gpointer,
540 ) {
541 let f: &F = &*(f as *const F);
542 f(AudioBaseSink::from_glib_borrow(this).unsafe_cast_ref())
543 }
544 unsafe {
545 let f: Box_<F> = Box_::new(f);
546 connect_raw(
547 self.as_ptr() as *mut _,
548 c"notify::latency-time".as_ptr() as *const _,
549 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
550 notify_latency_time_trampoline::<Self, F> as *const (),
551 )),
552 Box_::into_raw(f),
553 )
554 }
555 }
556
557 #[doc(alias = "provide-clock")]
558 fn connect_provide_clock_notify<F: Fn(&Self) + Send + Sync + 'static>(
559 &self,
560 f: F,
561 ) -> SignalHandlerId {
562 unsafe extern "C" fn notify_provide_clock_trampoline<
563 P: IsA<AudioBaseSink>,
564 F: Fn(&P) + Send + Sync + 'static,
565 >(
566 this: *mut ffi::GstAudioBaseSink,
567 _param_spec: glib::ffi::gpointer,
568 f: glib::ffi::gpointer,
569 ) {
570 let f: &F = &*(f as *const F);
571 f(AudioBaseSink::from_glib_borrow(this).unsafe_cast_ref())
572 }
573 unsafe {
574 let f: Box_<F> = Box_::new(f);
575 connect_raw(
576 self.as_ptr() as *mut _,
577 c"notify::provide-clock".as_ptr() as *const _,
578 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
579 notify_provide_clock_trampoline::<Self, F> as *const (),
580 )),
581 Box_::into_raw(f),
582 )
583 }
584 }
585
586 #[doc(alias = "slave-method")]
587 fn connect_slave_method_notify<F: Fn(&Self) + Send + Sync + 'static>(
588 &self,
589 f: F,
590 ) -> SignalHandlerId {
591 unsafe extern "C" fn notify_slave_method_trampoline<
592 P: IsA<AudioBaseSink>,
593 F: Fn(&P) + Send + Sync + 'static,
594 >(
595 this: *mut ffi::GstAudioBaseSink,
596 _param_spec: glib::ffi::gpointer,
597 f: glib::ffi::gpointer,
598 ) {
599 let f: &F = &*(f as *const F);
600 f(AudioBaseSink::from_glib_borrow(this).unsafe_cast_ref())
601 }
602 unsafe {
603 let f: Box_<F> = Box_::new(f);
604 connect_raw(
605 self.as_ptr() as *mut _,
606 c"notify::slave-method".as_ptr() as *const _,
607 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
608 notify_slave_method_trampoline::<Self, F> as *const (),
609 )),
610 Box_::into_raw(f),
611 )
612 }
613 }
614}
615
616impl<O: IsA<AudioBaseSink>> AudioBaseSinkExt for O {}