gstreamer_base/auto/
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    /// [`BaseSink`][crate::BaseSink] is the base class for sink elements in GStreamer, such as
16    /// xvimagesink or filesink. It is a layer on top of [`gst::Element`][crate::gst::Element] that provides a
17    /// simplified interface to plugin writers. [`BaseSink`][crate::BaseSink] handles many details
18    /// for you, for example: preroll, clock synchronization, state changes,
19    /// activation in push or pull mode, and queries.
20    ///
21    /// In most cases, when writing sink elements, there is no need to implement
22    /// class methods from [`gst::Element`][crate::gst::Element] or to set functions on pads, because the
23    /// [`BaseSink`][crate::BaseSink] infrastructure should be sufficient.
24    ///
25    /// [`BaseSink`][crate::BaseSink] provides support for exactly one sink pad, which should be
26    /// named "sink". A sink implementation (subclass of [`BaseSink`][crate::BaseSink]) should
27    /// install a pad template in its class_init function, like so:
28    ///
29    ///
30    /// **⚠️ The following code is in C ⚠️**
31    ///
32    /// ```C
33    /// static void
34    /// my_element_class_init (GstMyElementClass *klass)
35    /// {
36    ///   GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
37    ///
38    ///   // sinktemplate should be a #GstStaticPadTemplate with direction
39    ///   // %GST_PAD_SINK and name "sink"
40    ///   gst_element_class_add_static_pad_template (gstelement_class, &sinktemplate);
41    ///
42    ///   gst_element_class_set_static_metadata (gstelement_class,
43    ///       "Sink name",
44    ///       "Sink",
45    ///       "My Sink element",
46    ///       "The author <my.sink@my.email>");
47    /// }
48    /// ```
49    ///
50    /// [`BaseSink`][crate::BaseSink] will handle the prerolling correctly. This means that it will
51    /// return [`gst::StateChangeReturn::Async`][crate::gst::StateChangeReturn::Async] from a state change to PAUSED until the first
52    /// buffer arrives in this element. The base class will call the
53    /// `GstBaseSinkClass::preroll` vmethod with this preroll buffer and will then
54    /// commit the state change to the next asynchronously pending state.
55    ///
56    /// When the element is set to PLAYING, [`BaseSink`][crate::BaseSink] will synchronise on the
57    /// clock using the times returned from `GstBaseSinkClass::get_times`. If this
58    /// function returns `GST_CLOCK_TIME_NONE` for the start time, no synchronisation
59    /// will be done. Synchronisation can be disabled entirely by setting the object
60    /// [`sync`][struct@crate::BaseSink#sync] property to [`false`].
61    ///
62    /// After synchronisation the virtual method `GstBaseSinkClass::render` will be
63    /// called. Subclasses should minimally implement this method.
64    ///
65    /// Subclasses that synchronise on the clock in the `GstBaseSinkClass::render`
66    /// method are supported as well. These classes typically receive a buffer in
67    /// the render method and can then potentially block on the clock while
68    /// rendering. A typical example is an audiosink.
69    /// These subclasses can use [`BaseSinkExt::wait_preroll()`][crate::prelude::BaseSinkExt::wait_preroll()] to perform the
70    /// blocking wait.
71    ///
72    /// Upon receiving the EOS event in the PLAYING state, [`BaseSink`][crate::BaseSink] will wait
73    /// for the clock to reach the time indicated by the stop time of the last
74    /// `GstBaseSinkClass::get_times` call before posting an EOS message. When the
75    /// element receives EOS in PAUSED, preroll completes, the event is queued and an
76    /// EOS message is posted when going to PLAYING.
77    ///
78    /// [`BaseSink`][crate::BaseSink] will internally use the [`gst::EventType::Segment`][crate::gst::EventType::Segment] events to schedule
79    /// synchronisation and clipping of buffers. Buffers that fall completely outside
80    /// of the current segment are dropped. Buffers that fall partially in the
81    /// segment are rendered (and prerolled). Subclasses should do any subbuffer
82    /// clipping themselves when needed.
83    ///
84    /// [`BaseSink`][crate::BaseSink] will by default report the current playback position in
85    /// [`gst::Format::Time`][crate::gst::Format::Time] based on the current clock time and segment information.
86    /// If no clock has been set on the element, the query will be forwarded
87    /// upstream.
88    ///
89    /// The `GstBaseSinkClass::set_caps` function will be called when the subclass
90    /// should configure itself to process a specific media type.
91    ///
92    /// The `GstBaseSinkClass::start` and `GstBaseSinkClass::stop` virtual methods
93    /// will be called when resources should be allocated. Any
94    /// `GstBaseSinkClass::preroll`, `GstBaseSinkClass::render` and
95    /// `GstBaseSinkClass::set_caps` function will be called between the
96    /// `GstBaseSinkClass::start` and `GstBaseSinkClass::stop` calls.
97    ///
98    /// The `GstBaseSinkClass::event` virtual method will be called when an event is
99    /// received by [`BaseSink`][crate::BaseSink]. Normally this method should only be overridden by
100    /// very specific elements (such as file sinks) which need to handle the
101    /// newsegment event specially.
102    ///
103    /// The `GstBaseSinkClass::unlock` method is called when the elements should
104    /// unblock any blocking operations they perform in the
105    /// `GstBaseSinkClass::render` method. This is mostly useful when the
106    /// `GstBaseSinkClass::render` method performs a blocking write on a file
107    /// descriptor, for example.
108    ///
109    /// The [`max-lateness`][struct@crate::BaseSink#max-lateness] property affects how the sink deals with
110    /// buffers that arrive too late in the sink. A buffer arrives too late in the
111    /// sink when the presentation time (as a combination of the last segment, buffer
112    /// timestamp and element base_time) plus the duration is before the current
113    /// time of the clock.
114    /// If the frame is later than max-lateness, the sink will drop the buffer
115    /// without calling the render method.
116    /// This feature is disabled if sync is disabled, the
117    /// `GstBaseSinkClass::get_times` method does not return a valid start time or
118    /// max-lateness is set to -1 (the default).
119    /// Subclasses can use [`BaseSinkExt::set_max_lateness()`][crate::prelude::BaseSinkExt::set_max_lateness()] to configure the
120    /// max-lateness value.
121    ///
122    /// The [`qos`][struct@crate::BaseSink#qos] property will enable the quality-of-service features of
123    /// the basesink which gather statistics about the real-time performance of the
124    /// clock synchronisation. For each buffer received in the sink, statistics are
125    /// gathered and a QOS event is sent upstream with these numbers. This
126    /// information can then be used by upstream elements to reduce their processing
127    /// rate, for example.
128    ///
129    /// The [`async`][struct@crate::BaseSink#async] property can be used to instruct the sink to never
130    /// perform an ASYNC state change. This feature is mostly usable when dealing
131    /// with non-synchronized streams or sparse streams.
132    ///
133    /// This is an Abstract Base Class, you cannot instantiate it.
134    ///
135    /// ## Properties
136    ///
137    ///
138    /// #### `async`
139    ///  If set to [`true`], the basesink will perform asynchronous state changes.
140    /// When set to [`false`], the sink will not signal the parent when it prerolls.
141    /// Use this option when dealing with sparse streams or when synchronisation is
142    /// not required.
143    ///
144    /// Readable | Writeable
145    ///
146    ///
147    /// #### `blocksize`
148    ///  The amount of bytes to pull when operating in pull mode.
149    ///
150    /// Readable | Writeable
151    ///
152    ///
153    /// #### `enable-last-sample`
154    ///  Enable the last-sample property. If [`false`], basesink doesn't keep a
155    /// reference to the last buffer arrived and the last-sample property is always
156    /// set to [`None`]. This can be useful if you need buffers to be released as soon
157    /// as possible, eg. if you're using a buffer pool.
158    ///
159    /// Readable | Writeable
160    ///
161    ///
162    /// #### `last-sample`
163    ///  The last buffer that arrived in the sink and was used for preroll or for
164    /// rendering. This property can be used to generate thumbnails. This property
165    /// can be [`None`] when the sink has not yet received a buffer.
166    ///
167    /// Readable
168    ///
169    ///
170    /// #### `max-bitrate`
171    ///  Control the maximum amount of bits that will be rendered per second.
172    /// Setting this property to a value bigger than 0 will make the sink delay
173    /// rendering of the buffers when it would exceed to max-bitrate.
174    ///
175    /// Readable | Writeable
176    ///
177    ///
178    /// #### `max-lateness`
179    ///  Readable | Writeable
180    ///
181    ///
182    /// #### `processing-deadline`
183    ///  Maximum amount of time (in nanoseconds) that the pipeline can take
184    /// for processing the buffer. This is added to the latency of live
185    /// pipelines.
186    ///
187    /// Readable | Writeable
188    ///
189    ///
190    /// #### `qos`
191    ///  Readable | Writeable
192    ///
193    ///
194    /// #### `render-delay`
195    ///  The additional delay between synchronisation and actual rendering of the
196    /// media. This property will add additional latency to the device in order to
197    /// make other sinks compensate for the delay.
198    ///
199    /// Readable | Writeable
200    ///
201    ///
202    /// #### `stats`
203    ///  Various [`BaseSink`][crate::BaseSink] statistics. This property returns a [`gst::Structure`][crate::gst::Structure]
204    /// with name `application/x-gst-base-sink-stats` with the following fields:
205    ///
206    /// - "average-rate" G_TYPE_DOUBLE average frame rate
207    /// - "dropped" G_TYPE_UINT64 Number of dropped frames
208    /// - "rendered" G_TYPE_UINT64 Number of rendered frames
209    ///
210    /// Readable
211    ///
212    ///
213    /// #### `sync`
214    ///  Readable | Writeable
215    ///
216    ///
217    /// #### `throttle-time`
218    ///  The time to insert between buffers. This property can be used to control
219    /// the maximum amount of buffers per second to render. Setting this property
220    /// to a value bigger than 0 will make the sink create THROTTLE QoS events.
221    ///
222    /// Readable | Writeable
223    ///
224    ///
225    /// #### `ts-offset`
226    ///  Controls the final synchronisation, a negative value will render the buffer
227    /// earlier while a positive value delays playback. This property can be
228    /// used to fix synchronisation in bad files.
229    ///
230    /// Readable | Writeable
231    /// <details><summary><h4>Object</h4></summary>
232    ///
233    ///
234    /// #### `name`
235    ///  Readable | Writeable | Construct
236    ///
237    ///
238    /// #### `parent`
239    ///  The parent of the object. Please note, that when changing the 'parent'
240    /// property, we don't emit [`notify`][struct@crate::glib::Object#notify] and [`deep-notify`][struct@crate::gst::Object#deep-notify]
241    /// signals due to locking issues. In some cases one can use
242    /// `GstBin::element-added` or `GstBin::element-removed` signals on the parent to
243    /// achieve a similar effect.
244    ///
245    /// Readable | Writeable
246    /// </details>
247    ///
248    /// # Implements
249    ///
250    /// [`BaseSinkExt`][trait@crate::prelude::BaseSinkExt], [`trait@gst::prelude::ElementExt`], [`trait@gst::prelude::ObjectExt`], [`trait@glib::ObjectExt`], [`BaseSinkExtManual`][trait@crate::prelude::BaseSinkExtManual]
251    #[doc(alias = "GstBaseSink")]
252    pub struct BaseSink(Object<ffi::GstBaseSink, ffi::GstBaseSinkClass>) @extends gst::Element, gst::Object;
253
254    match fn {
255        type_ => || ffi::gst_base_sink_get_type(),
256    }
257}
258
259impl BaseSink {
260    pub const NONE: Option<&'static BaseSink> = None;
261}
262
263unsafe impl Send for BaseSink {}
264unsafe impl Sync for BaseSink {}
265
266mod sealed {
267    pub trait Sealed {}
268    impl<T: super::IsA<super::BaseSink>> Sealed for T {}
269}
270
271/// Trait containing all [`struct@BaseSink`] methods.
272///
273/// # Implementors
274///
275/// [`BaseSink`][struct@crate::BaseSink]
276pub trait BaseSinkExt: IsA<BaseSink> + sealed::Sealed + 'static {
277    //#[doc(alias = "gst_base_sink_do_preroll")]
278    //fn do_preroll(&self, obj: /*Ignored*/&gst::MiniObject) -> Result<gst::FlowSuccess, gst::FlowError> {
279    //    unsafe { TODO: call ffi:gst_base_sink_do_preroll() }
280    //}
281
282    /// Get the number of bytes that the sink will pull when it is operating in pull
283    /// mode.
284    ///
285    /// # Returns
286    ///
287    /// the number of bytes `self` will pull in pull mode.
288    #[doc(alias = "gst_base_sink_get_blocksize")]
289    #[doc(alias = "get_blocksize")]
290    fn blocksize(&self) -> u32 {
291        unsafe { ffi::gst_base_sink_get_blocksize(self.as_ref().to_glib_none().0) }
292    }
293
294    /// Checks if `self` is currently configured to drop buffers which are outside
295    /// the current segment
296    ///
297    /// # Returns
298    ///
299    /// [`true`] if the sink is configured to drop buffers outside the
300    /// current segment.
301    #[doc(alias = "gst_base_sink_get_drop_out_of_segment")]
302    #[doc(alias = "get_drop_out_of_segment")]
303    fn drops_out_of_segment(&self) -> bool {
304        unsafe {
305            from_glib(ffi::gst_base_sink_get_drop_out_of_segment(
306                self.as_ref().to_glib_none().0,
307            ))
308        }
309    }
310
311    /// Get the last sample that arrived in the sink and was used for preroll or for
312    /// rendering. This property can be used to generate thumbnails.
313    ///
314    /// The [`gst::Caps`][crate::gst::Caps] on the sample can be used to determine the type of the buffer.
315    ///
316    /// Free-function: gst_sample_unref
317    ///
318    /// # Returns
319    ///
320    /// a [`gst::Sample`][crate::gst::Sample]. `gst_sample_unref()` after
321    ///  usage. This function returns [`None`] when no buffer has arrived in the
322    ///  sink yet or when the sink is not in PAUSED or PLAYING.
323    #[doc(alias = "gst_base_sink_get_last_sample")]
324    #[doc(alias = "get_last_sample")]
325    #[doc(alias = "last-sample")]
326    fn last_sample(&self) -> Option<gst::Sample> {
327        unsafe {
328            from_glib_full(ffi::gst_base_sink_get_last_sample(
329                self.as_ref().to_glib_none().0,
330            ))
331        }
332    }
333
334    /// Get the currently configured latency.
335    ///
336    /// # Returns
337    ///
338    /// The configured latency.
339    #[doc(alias = "gst_base_sink_get_latency")]
340    #[doc(alias = "get_latency")]
341    fn latency(&self) -> gst::ClockTime {
342        unsafe {
343            try_from_glib(ffi::gst_base_sink_get_latency(
344                self.as_ref().to_glib_none().0,
345            ))
346            .expect("mandatory glib value is None")
347        }
348    }
349
350    /// Get the maximum amount of bits per second that the sink will render.
351    ///
352    /// # Returns
353    ///
354    /// the maximum number of bits per second `self` will render.
355    #[doc(alias = "gst_base_sink_get_max_bitrate")]
356    #[doc(alias = "get_max_bitrate")]
357    #[doc(alias = "max-bitrate")]
358    fn max_bitrate(&self) -> u64 {
359        unsafe { ffi::gst_base_sink_get_max_bitrate(self.as_ref().to_glib_none().0) }
360    }
361
362    /// Gets the max lateness value. See [`set_max_lateness()`][Self::set_max_lateness()] for
363    /// more details.
364    ///
365    /// # Returns
366    ///
367    /// The maximum time in nanoseconds that a buffer can be late
368    /// before it is dropped and not rendered. A value of -1 means an
369    /// unlimited time.
370    #[doc(alias = "gst_base_sink_get_max_lateness")]
371    #[doc(alias = "get_max_lateness")]
372    #[doc(alias = "max-lateness")]
373    fn max_lateness(&self) -> i64 {
374        unsafe { ffi::gst_base_sink_get_max_lateness(self.as_ref().to_glib_none().0) }
375    }
376
377    /// Get the processing deadline of `self`. see
378    /// [`set_processing_deadline()`][Self::set_processing_deadline()] for more information about
379    /// the processing deadline.
380    ///
381    /// # Returns
382    ///
383    /// the processing deadline
384    #[cfg(feature = "v1_16")]
385    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
386    #[doc(alias = "gst_base_sink_get_processing_deadline")]
387    #[doc(alias = "get_processing_deadline")]
388    #[doc(alias = "processing-deadline")]
389    fn processing_deadline(&self) -> gst::ClockTime {
390        unsafe {
391            try_from_glib(ffi::gst_base_sink_get_processing_deadline(
392                self.as_ref().to_glib_none().0,
393            ))
394            .expect("mandatory glib value is None")
395        }
396    }
397
398    /// Get the render delay of `self`. see [`set_render_delay()`][Self::set_render_delay()] for more
399    /// information about the render delay.
400    ///
401    /// # Returns
402    ///
403    /// the render delay of `self`.
404    #[doc(alias = "gst_base_sink_get_render_delay")]
405    #[doc(alias = "get_render_delay")]
406    #[doc(alias = "render-delay")]
407    fn render_delay(&self) -> gst::ClockTime {
408        unsafe {
409            try_from_glib(ffi::gst_base_sink_get_render_delay(
410                self.as_ref().to_glib_none().0,
411            ))
412            .expect("mandatory glib value is None")
413        }
414    }
415
416    /// Return various [`BaseSink`][crate::BaseSink] statistics. This function returns a [`gst::Structure`][crate::gst::Structure]
417    /// with name `application/x-gst-base-sink-stats` with the following fields:
418    ///
419    /// - "average-rate" G_TYPE_DOUBLE average frame rate
420    /// - "dropped" G_TYPE_UINT64 Number of dropped frames
421    /// - "rendered" G_TYPE_UINT64 Number of rendered frames
422    ///
423    /// # Returns
424    ///
425    /// pointer to [`gst::Structure`][crate::gst::Structure]
426    #[cfg(feature = "v1_18")]
427    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
428    #[doc(alias = "gst_base_sink_get_stats")]
429    #[doc(alias = "get_stats")]
430    fn stats(&self) -> gst::Structure {
431        unsafe { from_glib_full(ffi::gst_base_sink_get_stats(self.as_ref().to_glib_none().0)) }
432    }
433
434    /// Checks if `self` is currently configured to synchronize against the
435    /// clock.
436    ///
437    /// # Returns
438    ///
439    /// [`true`] if the sink is configured to synchronize against the clock.
440    #[doc(alias = "gst_base_sink_get_sync")]
441    #[doc(alias = "get_sync")]
442    #[doc(alias = "sync")]
443    fn is_sync(&self) -> bool {
444        unsafe { from_glib(ffi::gst_base_sink_get_sync(self.as_ref().to_glib_none().0)) }
445    }
446
447    /// Get the time that will be inserted between frames to control the
448    /// maximum buffers per second.
449    ///
450    /// # Returns
451    ///
452    /// the number of nanoseconds `self` will put between frames.
453    #[doc(alias = "gst_base_sink_get_throttle_time")]
454    #[doc(alias = "get_throttle_time")]
455    #[doc(alias = "throttle-time")]
456    fn throttle_time(&self) -> u64 {
457        unsafe { ffi::gst_base_sink_get_throttle_time(self.as_ref().to_glib_none().0) }
458    }
459
460    /// Get the synchronisation offset of `self`.
461    ///
462    /// # Returns
463    ///
464    /// The synchronisation offset.
465    #[doc(alias = "gst_base_sink_get_ts_offset")]
466    #[doc(alias = "get_ts_offset")]
467    #[doc(alias = "ts-offset")]
468    fn ts_offset(&self) -> gst::ClockTimeDiff {
469        unsafe { ffi::gst_base_sink_get_ts_offset(self.as_ref().to_glib_none().0) }
470    }
471
472    /// Set the number of bytes that the sink will pull when it is operating in pull
473    /// mode.
474    /// ## `blocksize`
475    /// the blocksize in bytes
476    #[doc(alias = "gst_base_sink_set_blocksize")]
477    #[doc(alias = "blocksize")]
478    fn set_blocksize(&self, blocksize: u32) {
479        unsafe {
480            ffi::gst_base_sink_set_blocksize(self.as_ref().to_glib_none().0, blocksize);
481        }
482    }
483
484    /// Configure `self` to drop buffers which are outside the current segment
485    /// ## `drop_out_of_segment`
486    /// drop buffers outside the segment
487    #[doc(alias = "gst_base_sink_set_drop_out_of_segment")]
488    fn set_drop_out_of_segment(&self, drop_out_of_segment: bool) {
489        unsafe {
490            ffi::gst_base_sink_set_drop_out_of_segment(
491                self.as_ref().to_glib_none().0,
492                drop_out_of_segment.into_glib(),
493            );
494        }
495    }
496
497    /// Set the maximum amount of bits per second that the sink will render.
498    /// ## `max_bitrate`
499    /// the max_bitrate in bits per second
500    #[doc(alias = "gst_base_sink_set_max_bitrate")]
501    #[doc(alias = "max-bitrate")]
502    fn set_max_bitrate(&self, max_bitrate: u64) {
503        unsafe {
504            ffi::gst_base_sink_set_max_bitrate(self.as_ref().to_glib_none().0, max_bitrate);
505        }
506    }
507
508    /// Sets the new max lateness value to `max_lateness`. This value is
509    /// used to decide if a buffer should be dropped or not based on the
510    /// buffer timestamp and the current clock time. A value of -1 means
511    /// an unlimited time.
512    /// ## `max_lateness`
513    /// the new max lateness value.
514    #[doc(alias = "gst_base_sink_set_max_lateness")]
515    #[doc(alias = "max-lateness")]
516    fn set_max_lateness(&self, max_lateness: i64) {
517        unsafe {
518            ffi::gst_base_sink_set_max_lateness(self.as_ref().to_glib_none().0, max_lateness);
519        }
520    }
521
522    /// Maximum amount of time (in nanoseconds) that the pipeline can take
523    /// for processing the buffer. This is added to the latency of live
524    /// pipelines.
525    ///
526    /// This function is usually called by subclasses.
527    /// ## `processing_deadline`
528    /// the new processing deadline in nanoseconds.
529    #[cfg(feature = "v1_16")]
530    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
531    #[doc(alias = "gst_base_sink_set_processing_deadline")]
532    #[doc(alias = "processing-deadline")]
533    fn set_processing_deadline(&self, processing_deadline: gst::ClockTime) {
534        unsafe {
535            ffi::gst_base_sink_set_processing_deadline(
536                self.as_ref().to_glib_none().0,
537                processing_deadline.into_glib(),
538            );
539        }
540    }
541
542    /// Set the render delay in `self` to `delay`. The render delay is the time
543    /// between actual rendering of a buffer and its synchronisation time. Some
544    /// devices might delay media rendering which can be compensated for with this
545    /// function.
546    ///
547    /// After calling this function, this sink will report additional latency and
548    /// other sinks will adjust their latency to delay the rendering of their media.
549    ///
550    /// This function is usually called by subclasses.
551    /// ## `delay`
552    /// the new delay
553    #[doc(alias = "gst_base_sink_set_render_delay")]
554    #[doc(alias = "render-delay")]
555    fn set_render_delay(&self, delay: gst::ClockTime) {
556        unsafe {
557            ffi::gst_base_sink_set_render_delay(self.as_ref().to_glib_none().0, delay.into_glib());
558        }
559    }
560
561    /// Configures `self` to synchronize on the clock or not. When
562    /// `sync` is [`false`], incoming samples will be played as fast as
563    /// possible. If `sync` is [`true`], the timestamps of the incoming
564    /// buffers will be used to schedule the exact render time of its
565    /// contents.
566    /// ## `sync`
567    /// the new sync value.
568    #[doc(alias = "gst_base_sink_set_sync")]
569    #[doc(alias = "sync")]
570    fn set_sync(&self, sync: bool) {
571        unsafe {
572            ffi::gst_base_sink_set_sync(self.as_ref().to_glib_none().0, sync.into_glib());
573        }
574    }
575
576    /// Set the time that will be inserted between rendered buffers. This
577    /// can be used to control the maximum buffers per second that the sink
578    /// will render.
579    /// ## `throttle`
580    /// the throttle time in nanoseconds
581    #[doc(alias = "gst_base_sink_set_throttle_time")]
582    #[doc(alias = "throttle-time")]
583    fn set_throttle_time(&self, throttle: u64) {
584        unsafe {
585            ffi::gst_base_sink_set_throttle_time(self.as_ref().to_glib_none().0, throttle);
586        }
587    }
588
589    /// Adjust the synchronisation of `self` with `offset`. A negative value will
590    /// render buffers earlier than their timestamp. A positive value will delay
591    /// rendering. This function can be used to fix playback of badly timestamped
592    /// buffers.
593    /// ## `offset`
594    /// the new offset
595    #[doc(alias = "gst_base_sink_set_ts_offset")]
596    #[doc(alias = "ts-offset")]
597    fn set_ts_offset(&self, offset: gst::ClockTimeDiff) {
598        unsafe {
599            ffi::gst_base_sink_set_ts_offset(self.as_ref().to_glib_none().0, offset);
600        }
601    }
602
603    /// This function will wait for preroll to complete and will then block until `time`
604    /// is reached. It is usually called by subclasses that use their own internal
605    /// synchronisation but want to let some synchronization (like EOS) be handled
606    /// by the base class.
607    ///
608    /// This function should only be called with the PREROLL_LOCK held (like when
609    /// receiving an EOS event in the ::event vmethod or when handling buffers in
610    /// ::render).
611    ///
612    /// The `time` argument should be the running_time of when the timeout should happen
613    /// and will be adjusted with any latency and offset configured in the sink.
614    /// ## `time`
615    /// the running_time to be reached
616    ///
617    /// # Returns
618    ///
619    /// [`gst::FlowReturn`][crate::gst::FlowReturn]
620    ///
621    /// ## `jitter`
622    /// the jitter to be filled with time diff, or [`None`]
623    #[doc(alias = "gst_base_sink_wait")]
624    fn wait(
625        &self,
626        time: impl Into<Option<gst::ClockTime>>,
627    ) -> (Result<gst::FlowSuccess, gst::FlowError>, gst::ClockTimeDiff) {
628        unsafe {
629            let mut jitter = std::mem::MaybeUninit::uninit();
630            let ret = try_from_glib(ffi::gst_base_sink_wait(
631                self.as_ref().to_glib_none().0,
632                time.into().into_glib(),
633                jitter.as_mut_ptr(),
634            ));
635            (ret, jitter.assume_init())
636        }
637    }
638
639    /// This function will block until `time` is reached. It is usually called by
640    /// subclasses that use their own internal synchronisation.
641    ///
642    /// If `time` is not valid, no synchronisation is done and [`gst::ClockReturn::Badtime`][crate::gst::ClockReturn::Badtime] is
643    /// returned. Likewise, if synchronisation is disabled in the element or there
644    /// is no clock, no synchronisation is done and [`gst::ClockReturn::Badtime`][crate::gst::ClockReturn::Badtime] is returned.
645    ///
646    /// This function should only be called with the PREROLL_LOCK held, like when
647    /// receiving an EOS event in the `GstBaseSinkClass::event` vmethod or when
648    /// receiving a buffer in
649    /// the `GstBaseSinkClass::render` vmethod.
650    ///
651    /// The `time` argument should be the running_time of when this method should
652    /// return and is not adjusted with any latency or offset configured in the
653    /// sink.
654    /// ## `time`
655    /// the running_time to be reached
656    ///
657    /// # Returns
658    ///
659    /// [`gst::ClockReturn`][crate::gst::ClockReturn]
660    ///
661    /// ## `jitter`
662    /// the jitter to be filled with time diff, or [`None`]
663    #[doc(alias = "gst_base_sink_wait_clock")]
664    fn wait_clock(
665        &self,
666        time: gst::ClockTime,
667    ) -> (
668        Result<gst::ClockSuccess, gst::ClockError>,
669        gst::ClockTimeDiff,
670    ) {
671        unsafe {
672            let mut jitter = std::mem::MaybeUninit::uninit();
673            let ret = try_from_glib(ffi::gst_base_sink_wait_clock(
674                self.as_ref().to_glib_none().0,
675                time.into_glib(),
676                jitter.as_mut_ptr(),
677            ));
678            (ret, jitter.assume_init())
679        }
680    }
681
682    /// If the `GstBaseSinkClass::render` method performs its own synchronisation
683    /// against the clock it must unblock when going from PLAYING to the PAUSED state
684    /// and call this method before continuing to render the remaining data.
685    ///
686    /// If the `GstBaseSinkClass::render` method can block on something else than
687    /// the clock, it must also be ready to unblock immediately on
688    /// the `GstBaseSinkClass::unlock` method and cause the
689    /// `GstBaseSinkClass::render` method to immediately call this function.
690    /// In this case, the subclass must be prepared to continue rendering where it
691    /// left off if this function returns [`gst::FlowReturn::Ok`][crate::gst::FlowReturn::Ok].
692    ///
693    /// This function will block until a state change to PLAYING happens (in which
694    /// case this function returns [`gst::FlowReturn::Ok`][crate::gst::FlowReturn::Ok]) or the processing must be stopped due
695    /// to a state change to READY or a FLUSH event (in which case this function
696    /// returns [`gst::FlowReturn::Flushing`][crate::gst::FlowReturn::Flushing]).
697    ///
698    /// This function should only be called with the PREROLL_LOCK held, like in the
699    /// render function.
700    ///
701    /// # Returns
702    ///
703    /// [`gst::FlowReturn::Ok`][crate::gst::FlowReturn::Ok] if the preroll completed and processing can
704    /// continue. Any other return value should be returned from the render vmethod.
705    #[doc(alias = "gst_base_sink_wait_preroll")]
706    fn wait_preroll(&self) -> Result<gst::FlowSuccess, gst::FlowError> {
707        unsafe {
708            try_from_glib(ffi::gst_base_sink_wait_preroll(
709                self.as_ref().to_glib_none().0,
710            ))
711        }
712    }
713
714    /// If set to [`true`], the basesink will perform asynchronous state changes.
715    /// When set to [`false`], the sink will not signal the parent when it prerolls.
716    /// Use this option when dealing with sparse streams or when synchronisation is
717    /// not required.
718    #[doc(alias = "async")]
719    fn is_async(&self) -> bool {
720        ObjectExt::property(self.as_ref(), "async")
721    }
722
723    /// If set to [`true`], the basesink will perform asynchronous state changes.
724    /// When set to [`false`], the sink will not signal the parent when it prerolls.
725    /// Use this option when dealing with sparse streams or when synchronisation is
726    /// not required.
727    #[doc(alias = "async")]
728    fn set_async(&self, async_: bool) {
729        ObjectExt::set_property(self.as_ref(), "async", async_)
730    }
731
732    /// Enable the last-sample property. If [`false`], basesink doesn't keep a
733    /// reference to the last buffer arrived and the last-sample property is always
734    /// set to [`None`]. This can be useful if you need buffers to be released as soon
735    /// as possible, eg. if you're using a buffer pool.
736    #[doc(alias = "enable-last-sample")]
737    fn enables_last_sample(&self) -> bool {
738        ObjectExt::property(self.as_ref(), "enable-last-sample")
739    }
740
741    /// Enable the last-sample property. If [`false`], basesink doesn't keep a
742    /// reference to the last buffer arrived and the last-sample property is always
743    /// set to [`None`]. This can be useful if you need buffers to be released as soon
744    /// as possible, eg. if you're using a buffer pool.
745    #[doc(alias = "enable-last-sample")]
746    fn set_enable_last_sample(&self, enable_last_sample: bool) {
747        ObjectExt::set_property(self.as_ref(), "enable-last-sample", enable_last_sample)
748    }
749
750    fn is_qos(&self) -> bool {
751        ObjectExt::property(self.as_ref(), "qos")
752    }
753
754    fn set_qos(&self, qos: bool) {
755        ObjectExt::set_property(self.as_ref(), "qos", qos)
756    }
757
758    #[doc(alias = "async")]
759    fn connect_async_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
760        unsafe extern "C" fn notify_async_trampoline<
761            P: IsA<BaseSink>,
762            F: Fn(&P) + Send + Sync + 'static,
763        >(
764            this: *mut ffi::GstBaseSink,
765            _param_spec: glib::ffi::gpointer,
766            f: glib::ffi::gpointer,
767        ) {
768            let f: &F = &*(f as *const F);
769            f(BaseSink::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::async\0".as_ptr() as *const _,
776                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
777                    notify_async_trampoline::<Self, F> as *const (),
778                )),
779                Box_::into_raw(f),
780            )
781        }
782    }
783
784    #[doc(alias = "blocksize")]
785    fn connect_blocksize_notify<F: Fn(&Self) + Send + Sync + 'static>(
786        &self,
787        f: F,
788    ) -> SignalHandlerId {
789        unsafe extern "C" fn notify_blocksize_trampoline<
790            P: IsA<BaseSink>,
791            F: Fn(&P) + Send + Sync + 'static,
792        >(
793            this: *mut ffi::GstBaseSink,
794            _param_spec: glib::ffi::gpointer,
795            f: glib::ffi::gpointer,
796        ) {
797            let f: &F = &*(f as *const F);
798            f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
799        }
800        unsafe {
801            let f: Box_<F> = Box_::new(f);
802            connect_raw(
803                self.as_ptr() as *mut _,
804                b"notify::blocksize\0".as_ptr() as *const _,
805                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
806                    notify_blocksize_trampoline::<Self, F> as *const (),
807                )),
808                Box_::into_raw(f),
809            )
810        }
811    }
812
813    #[doc(alias = "enable-last-sample")]
814    fn connect_enable_last_sample_notify<F: Fn(&Self) + Send + Sync + 'static>(
815        &self,
816        f: F,
817    ) -> SignalHandlerId {
818        unsafe extern "C" fn notify_enable_last_sample_trampoline<
819            P: IsA<BaseSink>,
820            F: Fn(&P) + Send + Sync + 'static,
821        >(
822            this: *mut ffi::GstBaseSink,
823            _param_spec: glib::ffi::gpointer,
824            f: glib::ffi::gpointer,
825        ) {
826            let f: &F = &*(f as *const F);
827            f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
828        }
829        unsafe {
830            let f: Box_<F> = Box_::new(f);
831            connect_raw(
832                self.as_ptr() as *mut _,
833                b"notify::enable-last-sample\0".as_ptr() as *const _,
834                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
835                    notify_enable_last_sample_trampoline::<Self, F> as *const (),
836                )),
837                Box_::into_raw(f),
838            )
839        }
840    }
841
842    #[doc(alias = "last-sample")]
843    fn connect_last_sample_notify<F: Fn(&Self) + Send + Sync + 'static>(
844        &self,
845        f: F,
846    ) -> SignalHandlerId {
847        unsafe extern "C" fn notify_last_sample_trampoline<
848            P: IsA<BaseSink>,
849            F: Fn(&P) + Send + Sync + 'static,
850        >(
851            this: *mut ffi::GstBaseSink,
852            _param_spec: glib::ffi::gpointer,
853            f: glib::ffi::gpointer,
854        ) {
855            let f: &F = &*(f as *const F);
856            f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
857        }
858        unsafe {
859            let f: Box_<F> = Box_::new(f);
860            connect_raw(
861                self.as_ptr() as *mut _,
862                b"notify::last-sample\0".as_ptr() as *const _,
863                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
864                    notify_last_sample_trampoline::<Self, F> as *const (),
865                )),
866                Box_::into_raw(f),
867            )
868        }
869    }
870
871    #[doc(alias = "max-bitrate")]
872    fn connect_max_bitrate_notify<F: Fn(&Self) + Send + Sync + 'static>(
873        &self,
874        f: F,
875    ) -> SignalHandlerId {
876        unsafe extern "C" fn notify_max_bitrate_trampoline<
877            P: IsA<BaseSink>,
878            F: Fn(&P) + Send + Sync + 'static,
879        >(
880            this: *mut ffi::GstBaseSink,
881            _param_spec: glib::ffi::gpointer,
882            f: glib::ffi::gpointer,
883        ) {
884            let f: &F = &*(f as *const F);
885            f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
886        }
887        unsafe {
888            let f: Box_<F> = Box_::new(f);
889            connect_raw(
890                self.as_ptr() as *mut _,
891                b"notify::max-bitrate\0".as_ptr() as *const _,
892                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
893                    notify_max_bitrate_trampoline::<Self, F> as *const (),
894                )),
895                Box_::into_raw(f),
896            )
897        }
898    }
899
900    #[doc(alias = "max-lateness")]
901    fn connect_max_lateness_notify<F: Fn(&Self) + Send + Sync + 'static>(
902        &self,
903        f: F,
904    ) -> SignalHandlerId {
905        unsafe extern "C" fn notify_max_lateness_trampoline<
906            P: IsA<BaseSink>,
907            F: Fn(&P) + Send + Sync + 'static,
908        >(
909            this: *mut ffi::GstBaseSink,
910            _param_spec: glib::ffi::gpointer,
911            f: glib::ffi::gpointer,
912        ) {
913            let f: &F = &*(f as *const F);
914            f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
915        }
916        unsafe {
917            let f: Box_<F> = Box_::new(f);
918            connect_raw(
919                self.as_ptr() as *mut _,
920                b"notify::max-lateness\0".as_ptr() as *const _,
921                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
922                    notify_max_lateness_trampoline::<Self, F> as *const (),
923                )),
924                Box_::into_raw(f),
925            )
926        }
927    }
928
929    #[cfg(feature = "v1_16")]
930    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
931    #[doc(alias = "processing-deadline")]
932    fn connect_processing_deadline_notify<F: Fn(&Self) + Send + Sync + 'static>(
933        &self,
934        f: F,
935    ) -> SignalHandlerId {
936        unsafe extern "C" fn notify_processing_deadline_trampoline<
937            P: IsA<BaseSink>,
938            F: Fn(&P) + Send + Sync + 'static,
939        >(
940            this: *mut ffi::GstBaseSink,
941            _param_spec: glib::ffi::gpointer,
942            f: glib::ffi::gpointer,
943        ) {
944            let f: &F = &*(f as *const F);
945            f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
946        }
947        unsafe {
948            let f: Box_<F> = Box_::new(f);
949            connect_raw(
950                self.as_ptr() as *mut _,
951                b"notify::processing-deadline\0".as_ptr() as *const _,
952                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
953                    notify_processing_deadline_trampoline::<Self, F> as *const (),
954                )),
955                Box_::into_raw(f),
956            )
957        }
958    }
959
960    #[doc(alias = "qos")]
961    fn connect_qos_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
962        unsafe extern "C" fn notify_qos_trampoline<
963            P: IsA<BaseSink>,
964            F: Fn(&P) + Send + Sync + 'static,
965        >(
966            this: *mut ffi::GstBaseSink,
967            _param_spec: glib::ffi::gpointer,
968            f: glib::ffi::gpointer,
969        ) {
970            let f: &F = &*(f as *const F);
971            f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
972        }
973        unsafe {
974            let f: Box_<F> = Box_::new(f);
975            connect_raw(
976                self.as_ptr() as *mut _,
977                b"notify::qos\0".as_ptr() as *const _,
978                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
979                    notify_qos_trampoline::<Self, F> as *const (),
980                )),
981                Box_::into_raw(f),
982            )
983        }
984    }
985
986    #[doc(alias = "render-delay")]
987    fn connect_render_delay_notify<F: Fn(&Self) + Send + Sync + 'static>(
988        &self,
989        f: F,
990    ) -> SignalHandlerId {
991        unsafe extern "C" fn notify_render_delay_trampoline<
992            P: IsA<BaseSink>,
993            F: Fn(&P) + Send + Sync + 'static,
994        >(
995            this: *mut ffi::GstBaseSink,
996            _param_spec: glib::ffi::gpointer,
997            f: glib::ffi::gpointer,
998        ) {
999            let f: &F = &*(f as *const F);
1000            f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
1001        }
1002        unsafe {
1003            let f: Box_<F> = Box_::new(f);
1004            connect_raw(
1005                self.as_ptr() as *mut _,
1006                b"notify::render-delay\0".as_ptr() as *const _,
1007                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1008                    notify_render_delay_trampoline::<Self, F> as *const (),
1009                )),
1010                Box_::into_raw(f),
1011            )
1012        }
1013    }
1014
1015    #[cfg(feature = "v1_18")]
1016    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
1017    #[doc(alias = "stats")]
1018    fn connect_stats_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
1019        unsafe extern "C" fn notify_stats_trampoline<
1020            P: IsA<BaseSink>,
1021            F: Fn(&P) + Send + Sync + 'static,
1022        >(
1023            this: *mut ffi::GstBaseSink,
1024            _param_spec: glib::ffi::gpointer,
1025            f: glib::ffi::gpointer,
1026        ) {
1027            let f: &F = &*(f as *const F);
1028            f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
1029        }
1030        unsafe {
1031            let f: Box_<F> = Box_::new(f);
1032            connect_raw(
1033                self.as_ptr() as *mut _,
1034                b"notify::stats\0".as_ptr() as *const _,
1035                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1036                    notify_stats_trampoline::<Self, F> as *const (),
1037                )),
1038                Box_::into_raw(f),
1039            )
1040        }
1041    }
1042
1043    #[doc(alias = "sync")]
1044    fn connect_sync_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
1045        unsafe extern "C" fn notify_sync_trampoline<
1046            P: IsA<BaseSink>,
1047            F: Fn(&P) + Send + Sync + 'static,
1048        >(
1049            this: *mut ffi::GstBaseSink,
1050            _param_spec: glib::ffi::gpointer,
1051            f: glib::ffi::gpointer,
1052        ) {
1053            let f: &F = &*(f as *const F);
1054            f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
1055        }
1056        unsafe {
1057            let f: Box_<F> = Box_::new(f);
1058            connect_raw(
1059                self.as_ptr() as *mut _,
1060                b"notify::sync\0".as_ptr() as *const _,
1061                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1062                    notify_sync_trampoline::<Self, F> as *const (),
1063                )),
1064                Box_::into_raw(f),
1065            )
1066        }
1067    }
1068
1069    #[doc(alias = "throttle-time")]
1070    fn connect_throttle_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
1071        &self,
1072        f: F,
1073    ) -> SignalHandlerId {
1074        unsafe extern "C" fn notify_throttle_time_trampoline<
1075            P: IsA<BaseSink>,
1076            F: Fn(&P) + Send + Sync + 'static,
1077        >(
1078            this: *mut ffi::GstBaseSink,
1079            _param_spec: glib::ffi::gpointer,
1080            f: glib::ffi::gpointer,
1081        ) {
1082            let f: &F = &*(f as *const F);
1083            f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
1084        }
1085        unsafe {
1086            let f: Box_<F> = Box_::new(f);
1087            connect_raw(
1088                self.as_ptr() as *mut _,
1089                b"notify::throttle-time\0".as_ptr() as *const _,
1090                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1091                    notify_throttle_time_trampoline::<Self, F> as *const (),
1092                )),
1093                Box_::into_raw(f),
1094            )
1095        }
1096    }
1097
1098    #[doc(alias = "ts-offset")]
1099    fn connect_ts_offset_notify<F: Fn(&Self) + Send + Sync + 'static>(
1100        &self,
1101        f: F,
1102    ) -> SignalHandlerId {
1103        unsafe extern "C" fn notify_ts_offset_trampoline<
1104            P: IsA<BaseSink>,
1105            F: Fn(&P) + Send + Sync + 'static,
1106        >(
1107            this: *mut ffi::GstBaseSink,
1108            _param_spec: glib::ffi::gpointer,
1109            f: glib::ffi::gpointer,
1110        ) {
1111            let f: &F = &*(f as *const F);
1112            f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
1113        }
1114        unsafe {
1115            let f: Box_<F> = Box_::new(f);
1116            connect_raw(
1117                self.as_ptr() as *mut _,
1118                b"notify::ts-offset\0".as_ptr() as *const _,
1119                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1120                    notify_ts_offset_trampoline::<Self, F> as *const (),
1121                )),
1122                Box_::into_raw(f),
1123            )
1124        }
1125    }
1126}
1127
1128impl<O: IsA<BaseSink>> BaseSinkExt for O {}