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 | 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 unsafe {
397 let f: &F = &*(f as *const F);
398 f(AudioBaseSink::from_glib_borrow(this).unsafe_cast_ref())
399 }
400 }
401 unsafe {
402 let f: Box_<F> = Box_::new(f);
403 connect_raw(
404 self.as_ptr() as *mut _,
405 c"notify::alignment-threshold".as_ptr(),
406 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
407 notify_alignment_threshold_trampoline::<Self, F> as *const (),
408 )),
409 Box_::into_raw(f),
410 )
411 }
412 }
413
414 #[doc(alias = "buffer-time")]
415 fn connect_buffer_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
416 &self,
417 f: F,
418 ) -> SignalHandlerId {
419 unsafe extern "C" fn notify_buffer_time_trampoline<
420 P: IsA<AudioBaseSink>,
421 F: Fn(&P) + Send + Sync + 'static,
422 >(
423 this: *mut ffi::GstAudioBaseSink,
424 _param_spec: glib::ffi::gpointer,
425 f: glib::ffi::gpointer,
426 ) {
427 unsafe {
428 let f: &F = &*(f as *const F);
429 f(AudioBaseSink::from_glib_borrow(this).unsafe_cast_ref())
430 }
431 }
432 unsafe {
433 let f: Box_<F> = Box_::new(f);
434 connect_raw(
435 self.as_ptr() as *mut _,
436 c"notify::buffer-time".as_ptr(),
437 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
438 notify_buffer_time_trampoline::<Self, F> as *const (),
439 )),
440 Box_::into_raw(f),
441 )
442 }
443 }
444
445 #[doc(alias = "can-activate-pull")]
446 fn connect_can_activate_pull_notify<F: Fn(&Self) + Send + Sync + 'static>(
447 &self,
448 f: F,
449 ) -> SignalHandlerId {
450 unsafe extern "C" fn notify_can_activate_pull_trampoline<
451 P: IsA<AudioBaseSink>,
452 F: Fn(&P) + Send + Sync + 'static,
453 >(
454 this: *mut ffi::GstAudioBaseSink,
455 _param_spec: glib::ffi::gpointer,
456 f: glib::ffi::gpointer,
457 ) {
458 unsafe {
459 let f: &F = &*(f as *const F);
460 f(AudioBaseSink::from_glib_borrow(this).unsafe_cast_ref())
461 }
462 }
463 unsafe {
464 let f: Box_<F> = Box_::new(f);
465 connect_raw(
466 self.as_ptr() as *mut _,
467 c"notify::can-activate-pull".as_ptr(),
468 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
469 notify_can_activate_pull_trampoline::<Self, F> as *const (),
470 )),
471 Box_::into_raw(f),
472 )
473 }
474 }
475
476 #[doc(alias = "discont-wait")]
477 fn connect_discont_wait_notify<F: Fn(&Self) + Send + Sync + 'static>(
478 &self,
479 f: F,
480 ) -> SignalHandlerId {
481 unsafe extern "C" fn notify_discont_wait_trampoline<
482 P: IsA<AudioBaseSink>,
483 F: Fn(&P) + Send + Sync + 'static,
484 >(
485 this: *mut ffi::GstAudioBaseSink,
486 _param_spec: glib::ffi::gpointer,
487 f: glib::ffi::gpointer,
488 ) {
489 unsafe {
490 let f: &F = &*(f as *const F);
491 f(AudioBaseSink::from_glib_borrow(this).unsafe_cast_ref())
492 }
493 }
494 unsafe {
495 let f: Box_<F> = Box_::new(f);
496 connect_raw(
497 self.as_ptr() as *mut _,
498 c"notify::discont-wait".as_ptr(),
499 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
500 notify_discont_wait_trampoline::<Self, F> as *const (),
501 )),
502 Box_::into_raw(f),
503 )
504 }
505 }
506
507 #[doc(alias = "drift-tolerance")]
508 fn connect_drift_tolerance_notify<F: Fn(&Self) + Send + Sync + 'static>(
509 &self,
510 f: F,
511 ) -> SignalHandlerId {
512 unsafe extern "C" fn notify_drift_tolerance_trampoline<
513 P: IsA<AudioBaseSink>,
514 F: Fn(&P) + Send + Sync + 'static,
515 >(
516 this: *mut ffi::GstAudioBaseSink,
517 _param_spec: glib::ffi::gpointer,
518 f: glib::ffi::gpointer,
519 ) {
520 unsafe {
521 let f: &F = &*(f as *const F);
522 f(AudioBaseSink::from_glib_borrow(this).unsafe_cast_ref())
523 }
524 }
525 unsafe {
526 let f: Box_<F> = Box_::new(f);
527 connect_raw(
528 self.as_ptr() as *mut _,
529 c"notify::drift-tolerance".as_ptr(),
530 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
531 notify_drift_tolerance_trampoline::<Self, F> as *const (),
532 )),
533 Box_::into_raw(f),
534 )
535 }
536 }
537
538 #[doc(alias = "latency-time")]
539 fn connect_latency_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
540 &self,
541 f: F,
542 ) -> SignalHandlerId {
543 unsafe extern "C" fn notify_latency_time_trampoline<
544 P: IsA<AudioBaseSink>,
545 F: Fn(&P) + Send + Sync + 'static,
546 >(
547 this: *mut ffi::GstAudioBaseSink,
548 _param_spec: glib::ffi::gpointer,
549 f: glib::ffi::gpointer,
550 ) {
551 unsafe {
552 let f: &F = &*(f as *const F);
553 f(AudioBaseSink::from_glib_borrow(this).unsafe_cast_ref())
554 }
555 }
556 unsafe {
557 let f: Box_<F> = Box_::new(f);
558 connect_raw(
559 self.as_ptr() as *mut _,
560 c"notify::latency-time".as_ptr(),
561 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
562 notify_latency_time_trampoline::<Self, F> as *const (),
563 )),
564 Box_::into_raw(f),
565 )
566 }
567 }
568
569 #[doc(alias = "provide-clock")]
570 fn connect_provide_clock_notify<F: Fn(&Self) + Send + Sync + 'static>(
571 &self,
572 f: F,
573 ) -> SignalHandlerId {
574 unsafe extern "C" fn notify_provide_clock_trampoline<
575 P: IsA<AudioBaseSink>,
576 F: Fn(&P) + Send + Sync + 'static,
577 >(
578 this: *mut ffi::GstAudioBaseSink,
579 _param_spec: glib::ffi::gpointer,
580 f: glib::ffi::gpointer,
581 ) {
582 unsafe {
583 let f: &F = &*(f as *const F);
584 f(AudioBaseSink::from_glib_borrow(this).unsafe_cast_ref())
585 }
586 }
587 unsafe {
588 let f: Box_<F> = Box_::new(f);
589 connect_raw(
590 self.as_ptr() as *mut _,
591 c"notify::provide-clock".as_ptr(),
592 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
593 notify_provide_clock_trampoline::<Self, F> as *const (),
594 )),
595 Box_::into_raw(f),
596 )
597 }
598 }
599
600 #[doc(alias = "slave-method")]
601 fn connect_slave_method_notify<F: Fn(&Self) + Send + Sync + 'static>(
602 &self,
603 f: F,
604 ) -> SignalHandlerId {
605 unsafe extern "C" fn notify_slave_method_trampoline<
606 P: IsA<AudioBaseSink>,
607 F: Fn(&P) + Send + Sync + 'static,
608 >(
609 this: *mut ffi::GstAudioBaseSink,
610 _param_spec: glib::ffi::gpointer,
611 f: glib::ffi::gpointer,
612 ) {
613 unsafe {
614 let f: &F = &*(f as *const F);
615 f(AudioBaseSink::from_glib_borrow(this).unsafe_cast_ref())
616 }
617 }
618 unsafe {
619 let f: Box_<F> = Box_::new(f);
620 connect_raw(
621 self.as_ptr() as *mut _,
622 c"notify::slave-method".as_ptr(),
623 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
624 notify_slave_method_trampoline::<Self, F> as *const (),
625 )),
626 Box_::into_raw(f),
627 )
628 }
629 }
630}
631
632impl<O: IsA<AudioBaseSink>> AudioBaseSinkExt for O {}