Skip to main content

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::{SignalHandlerId, connect_raw},
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
266/// Trait containing all [`struct@BaseSink`] methods.
267///
268/// # Implementors
269///
270/// [`BaseSink`][struct@crate::BaseSink]
271pub trait BaseSinkExt: IsA<BaseSink> + 'static {
272    //#[doc(alias = "gst_base_sink_do_preroll")]
273    //fn do_preroll(&self, obj: /*Ignored*/&gst::MiniObject) -> Result<gst::FlowSuccess, gst::FlowError> {
274    //    unsafe { TODO: call ffi:gst_base_sink_do_preroll() }
275    //}
276
277    /// Get the number of bytes that the sink will pull when it is operating in pull
278    /// mode.
279    ///
280    /// # Returns
281    ///
282    /// the number of bytes `self` will pull in pull mode.
283    #[doc(alias = "gst_base_sink_get_blocksize")]
284    #[doc(alias = "get_blocksize")]
285    fn blocksize(&self) -> u32 {
286        unsafe { ffi::gst_base_sink_get_blocksize(self.as_ref().to_glib_none().0) }
287    }
288
289    /// Checks if `self` is currently configured to drop buffers which are outside
290    /// the current segment
291    ///
292    /// # Returns
293    ///
294    /// [`true`] if the sink is configured to drop buffers outside the
295    /// current segment.
296    #[doc(alias = "gst_base_sink_get_drop_out_of_segment")]
297    #[doc(alias = "get_drop_out_of_segment")]
298    fn drops_out_of_segment(&self) -> bool {
299        unsafe {
300            from_glib(ffi::gst_base_sink_get_drop_out_of_segment(
301                self.as_ref().to_glib_none().0,
302            ))
303        }
304    }
305
306    /// Get the last sample that arrived in the sink and was used for preroll or for
307    /// rendering. This property can be used to generate thumbnails.
308    ///
309    /// The [`gst::Caps`][crate::gst::Caps] on the sample can be used to determine the type of the buffer.
310    ///
311    /// Free-function: gst_sample_unref
312    ///
313    /// # Returns
314    ///
315    /// a [`gst::Sample`][crate::gst::Sample]. `gst_sample_unref()` after
316    ///  usage. This function returns [`None`] when no buffer has arrived in the
317    ///  sink yet or when the sink is not in PAUSED or PLAYING.
318    #[doc(alias = "gst_base_sink_get_last_sample")]
319    #[doc(alias = "get_last_sample")]
320    #[doc(alias = "last-sample")]
321    fn last_sample(&self) -> Option<gst::Sample> {
322        unsafe {
323            from_glib_full(ffi::gst_base_sink_get_last_sample(
324                self.as_ref().to_glib_none().0,
325            ))
326        }
327    }
328
329    /// Get the currently configured latency.
330    ///
331    /// # Returns
332    ///
333    /// The configured latency.
334    #[doc(alias = "gst_base_sink_get_latency")]
335    #[doc(alias = "get_latency")]
336    fn latency(&self) -> gst::ClockTime {
337        unsafe {
338            try_from_glib(ffi::gst_base_sink_get_latency(
339                self.as_ref().to_glib_none().0,
340            ))
341            .expect("mandatory glib value is None")
342        }
343    }
344
345    /// Get the maximum amount of bits per second that the sink will render.
346    ///
347    /// # Returns
348    ///
349    /// the maximum number of bits per second `self` will render.
350    #[doc(alias = "gst_base_sink_get_max_bitrate")]
351    #[doc(alias = "get_max_bitrate")]
352    #[doc(alias = "max-bitrate")]
353    fn max_bitrate(&self) -> u64 {
354        unsafe { ffi::gst_base_sink_get_max_bitrate(self.as_ref().to_glib_none().0) }
355    }
356
357    /// Gets the max lateness value. See [`set_max_lateness()`][Self::set_max_lateness()] for
358    /// more details.
359    ///
360    /// # Returns
361    ///
362    /// The maximum time in nanoseconds that a buffer can be late
363    /// before it is dropped and not rendered. A value of -1 means an
364    /// unlimited time.
365    #[doc(alias = "gst_base_sink_get_max_lateness")]
366    #[doc(alias = "get_max_lateness")]
367    #[doc(alias = "max-lateness")]
368    fn max_lateness(&self) -> i64 {
369        unsafe { ffi::gst_base_sink_get_max_lateness(self.as_ref().to_glib_none().0) }
370    }
371
372    /// Get the processing deadline of `self`. see
373    /// [`set_processing_deadline()`][Self::set_processing_deadline()] for more information about
374    /// the processing deadline.
375    ///
376    /// # Returns
377    ///
378    /// the processing deadline
379    #[cfg(feature = "v1_16")]
380    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
381    #[doc(alias = "gst_base_sink_get_processing_deadline")]
382    #[doc(alias = "get_processing_deadline")]
383    #[doc(alias = "processing-deadline")]
384    fn processing_deadline(&self) -> gst::ClockTime {
385        unsafe {
386            try_from_glib(ffi::gst_base_sink_get_processing_deadline(
387                self.as_ref().to_glib_none().0,
388            ))
389            .expect("mandatory glib value is None")
390        }
391    }
392
393    /// Get the render delay of `self`. see [`set_render_delay()`][Self::set_render_delay()] for more
394    /// information about the render delay.
395    ///
396    /// # Returns
397    ///
398    /// the render delay of `self`.
399    #[doc(alias = "gst_base_sink_get_render_delay")]
400    #[doc(alias = "get_render_delay")]
401    #[doc(alias = "render-delay")]
402    fn render_delay(&self) -> gst::ClockTime {
403        unsafe {
404            try_from_glib(ffi::gst_base_sink_get_render_delay(
405                self.as_ref().to_glib_none().0,
406            ))
407            .expect("mandatory glib value is None")
408        }
409    }
410
411    /// Return various [`BaseSink`][crate::BaseSink] statistics. This function returns a [`gst::Structure`][crate::gst::Structure]
412    /// with name `application/x-gst-base-sink-stats` with the following fields:
413    ///
414    /// - "average-rate" G_TYPE_DOUBLE average frame rate
415    /// - "dropped" G_TYPE_UINT64 Number of dropped frames
416    /// - "rendered" G_TYPE_UINT64 Number of rendered frames
417    ///
418    /// # Returns
419    ///
420    /// pointer to [`gst::Structure`][crate::gst::Structure]
421    #[cfg(feature = "v1_18")]
422    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
423    #[doc(alias = "gst_base_sink_get_stats")]
424    #[doc(alias = "get_stats")]
425    fn stats(&self) -> gst::Structure {
426        unsafe { from_glib_full(ffi::gst_base_sink_get_stats(self.as_ref().to_glib_none().0)) }
427    }
428
429    /// Checks if `self` is currently configured to synchronize against the
430    /// clock.
431    ///
432    /// # Returns
433    ///
434    /// [`true`] if the sink is configured to synchronize against the clock.
435    #[doc(alias = "gst_base_sink_get_sync")]
436    #[doc(alias = "get_sync")]
437    #[doc(alias = "sync")]
438    fn is_sync(&self) -> bool {
439        unsafe { from_glib(ffi::gst_base_sink_get_sync(self.as_ref().to_glib_none().0)) }
440    }
441
442    /// Get the time that will be inserted between frames to control the
443    /// maximum buffers per second.
444    ///
445    /// # Returns
446    ///
447    /// the number of nanoseconds `self` will put between frames.
448    #[doc(alias = "gst_base_sink_get_throttle_time")]
449    #[doc(alias = "get_throttle_time")]
450    #[doc(alias = "throttle-time")]
451    fn throttle_time(&self) -> u64 {
452        unsafe { ffi::gst_base_sink_get_throttle_time(self.as_ref().to_glib_none().0) }
453    }
454
455    /// Get the synchronisation offset of `self`.
456    ///
457    /// # Returns
458    ///
459    /// The synchronisation offset.
460    #[doc(alias = "gst_base_sink_get_ts_offset")]
461    #[doc(alias = "get_ts_offset")]
462    #[doc(alias = "ts-offset")]
463    fn ts_offset(&self) -> gst::ClockTimeDiff {
464        unsafe { ffi::gst_base_sink_get_ts_offset(self.as_ref().to_glib_none().0) }
465    }
466
467    /// Set the number of bytes that the sink will pull when it is operating in pull
468    /// mode.
469    /// ## `blocksize`
470    /// the blocksize in bytes
471    #[doc(alias = "gst_base_sink_set_blocksize")]
472    #[doc(alias = "blocksize")]
473    fn set_blocksize(&self, blocksize: u32) {
474        unsafe {
475            ffi::gst_base_sink_set_blocksize(self.as_ref().to_glib_none().0, blocksize);
476        }
477    }
478
479    /// Configure `self` to drop buffers which are outside the current segment
480    /// ## `drop_out_of_segment`
481    /// drop buffers outside the segment
482    #[doc(alias = "gst_base_sink_set_drop_out_of_segment")]
483    fn set_drop_out_of_segment(&self, drop_out_of_segment: bool) {
484        unsafe {
485            ffi::gst_base_sink_set_drop_out_of_segment(
486                self.as_ref().to_glib_none().0,
487                drop_out_of_segment.into_glib(),
488            );
489        }
490    }
491
492    /// Set the maximum amount of bits per second that the sink will render.
493    /// ## `max_bitrate`
494    /// the max_bitrate in bits per second
495    #[doc(alias = "gst_base_sink_set_max_bitrate")]
496    #[doc(alias = "max-bitrate")]
497    fn set_max_bitrate(&self, max_bitrate: u64) {
498        unsafe {
499            ffi::gst_base_sink_set_max_bitrate(self.as_ref().to_glib_none().0, max_bitrate);
500        }
501    }
502
503    /// Sets the new max lateness value to `max_lateness`. This value is
504    /// used to decide if a buffer should be dropped or not based on the
505    /// buffer timestamp and the current clock time. A value of -1 means
506    /// an unlimited time.
507    /// ## `max_lateness`
508    /// the new max lateness value.
509    #[doc(alias = "gst_base_sink_set_max_lateness")]
510    #[doc(alias = "max-lateness")]
511    fn set_max_lateness(&self, max_lateness: i64) {
512        unsafe {
513            ffi::gst_base_sink_set_max_lateness(self.as_ref().to_glib_none().0, max_lateness);
514        }
515    }
516
517    /// Maximum amount of time (in nanoseconds) that the pipeline can take
518    /// for processing the buffer. This is added to the latency of live
519    /// pipelines.
520    ///
521    /// This function is usually called by subclasses.
522    /// ## `processing_deadline`
523    /// the new processing deadline in nanoseconds.
524    #[cfg(feature = "v1_16")]
525    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
526    #[doc(alias = "gst_base_sink_set_processing_deadline")]
527    #[doc(alias = "processing-deadline")]
528    fn set_processing_deadline(&self, processing_deadline: gst::ClockTime) {
529        unsafe {
530            ffi::gst_base_sink_set_processing_deadline(
531                self.as_ref().to_glib_none().0,
532                processing_deadline.into_glib(),
533            );
534        }
535    }
536
537    /// Set the render delay in `self` to `delay`. The render delay is the time
538    /// between actual rendering of a buffer and its synchronisation time. Some
539    /// devices might delay media rendering which can be compensated for with this
540    /// function.
541    ///
542    /// After calling this function, this sink will report additional latency and
543    /// other sinks will adjust their latency to delay the rendering of their media.
544    ///
545    /// This function is usually called by subclasses.
546    /// ## `delay`
547    /// the new delay
548    #[doc(alias = "gst_base_sink_set_render_delay")]
549    #[doc(alias = "render-delay")]
550    fn set_render_delay(&self, delay: gst::ClockTime) {
551        unsafe {
552            ffi::gst_base_sink_set_render_delay(self.as_ref().to_glib_none().0, delay.into_glib());
553        }
554    }
555
556    /// Configures `self` to synchronize on the clock or not. When
557    /// `sync` is [`false`], incoming samples will be played as fast as
558    /// possible. If `sync` is [`true`], the timestamps of the incoming
559    /// buffers will be used to schedule the exact render time of its
560    /// contents.
561    /// ## `sync`
562    /// the new sync value.
563    #[doc(alias = "gst_base_sink_set_sync")]
564    #[doc(alias = "sync")]
565    fn set_sync(&self, sync: bool) {
566        unsafe {
567            ffi::gst_base_sink_set_sync(self.as_ref().to_glib_none().0, sync.into_glib());
568        }
569    }
570
571    /// Set the time that will be inserted between rendered buffers. This
572    /// can be used to control the maximum buffers per second that the sink
573    /// will render.
574    /// ## `throttle`
575    /// the throttle time in nanoseconds
576    #[doc(alias = "gst_base_sink_set_throttle_time")]
577    #[doc(alias = "throttle-time")]
578    fn set_throttle_time(&self, throttle: u64) {
579        unsafe {
580            ffi::gst_base_sink_set_throttle_time(self.as_ref().to_glib_none().0, throttle);
581        }
582    }
583
584    /// Adjust the synchronisation of `self` with `offset`. A negative value will
585    /// render buffers earlier than their timestamp. A positive value will delay
586    /// rendering. This function can be used to fix playback of badly timestamped
587    /// buffers.
588    /// ## `offset`
589    /// the new offset
590    #[doc(alias = "gst_base_sink_set_ts_offset")]
591    #[doc(alias = "ts-offset")]
592    fn set_ts_offset(&self, offset: gst::ClockTimeDiff) {
593        unsafe {
594            ffi::gst_base_sink_set_ts_offset(self.as_ref().to_glib_none().0, offset);
595        }
596    }
597
598    /// This function will wait for preroll to complete and will then block until `time`
599    /// is reached. It is usually called by subclasses that use their own internal
600    /// synchronisation but want to let some synchronization (like EOS) be handled
601    /// by the base class.
602    ///
603    /// This function should only be called with the PREROLL_LOCK held (like when
604    /// receiving an EOS event in the ::event vmethod or when handling buffers in
605    /// ::render).
606    ///
607    /// The `time` argument should be the running_time of when the timeout should happen
608    /// and will be adjusted with any latency and offset configured in the sink.
609    /// ## `time`
610    /// the running_time to be reached
611    ///
612    /// # Returns
613    ///
614    /// [`gst::FlowReturn`][crate::gst::FlowReturn]
615    ///
616    /// ## `jitter`
617    /// the jitter to be filled with time diff, or [`None`]
618    #[doc(alias = "gst_base_sink_wait")]
619    fn wait(
620        &self,
621        time: impl Into<Option<gst::ClockTime>>,
622    ) -> (Result<gst::FlowSuccess, gst::FlowError>, gst::ClockTimeDiff) {
623        unsafe {
624            let mut jitter = std::mem::MaybeUninit::uninit();
625            let ret = try_from_glib(ffi::gst_base_sink_wait(
626                self.as_ref().to_glib_none().0,
627                time.into().into_glib(),
628                jitter.as_mut_ptr(),
629            ));
630            (ret, jitter.assume_init())
631        }
632    }
633
634    /// This function will block until `time` is reached. It is usually called by
635    /// subclasses that use their own internal synchronisation.
636    ///
637    /// If `time` is not valid, no synchronisation is done and [`gst::ClockReturn::Badtime`][crate::gst::ClockReturn::Badtime] is
638    /// returned. Likewise, if synchronisation is disabled in the element or there
639    /// is no clock, no synchronisation is done and [`gst::ClockReturn::Badtime`][crate::gst::ClockReturn::Badtime] is returned.
640    ///
641    /// This function should only be called with the PREROLL_LOCK held, like when
642    /// receiving an EOS event in the `GstBaseSinkClass::event` vmethod or when
643    /// receiving a buffer in
644    /// the `GstBaseSinkClass::render` vmethod.
645    ///
646    /// The `time` argument should be the running_time of when this method should
647    /// return and is not adjusted with any latency or offset configured in the
648    /// sink.
649    /// ## `time`
650    /// the running_time to be reached
651    ///
652    /// # Returns
653    ///
654    /// [`gst::ClockReturn`][crate::gst::ClockReturn]
655    ///
656    /// ## `jitter`
657    /// the jitter to be filled with time diff, or [`None`]
658    #[doc(alias = "gst_base_sink_wait_clock")]
659    fn wait_clock(
660        &self,
661        time: gst::ClockTime,
662    ) -> (
663        Result<gst::ClockSuccess, gst::ClockError>,
664        gst::ClockTimeDiff,
665    ) {
666        unsafe {
667            let mut jitter = std::mem::MaybeUninit::uninit();
668            let ret = try_from_glib(ffi::gst_base_sink_wait_clock(
669                self.as_ref().to_glib_none().0,
670                time.into_glib(),
671                jitter.as_mut_ptr(),
672            ));
673            (ret, jitter.assume_init())
674        }
675    }
676
677    /// If the `GstBaseSinkClass::render` method performs its own synchronisation
678    /// against the clock it must unblock when going from PLAYING to the PAUSED state
679    /// and call this method before continuing to render the remaining data.
680    ///
681    /// If the `GstBaseSinkClass::render` method can block on something else than
682    /// the clock, it must also be ready to unblock immediately on
683    /// the `GstBaseSinkClass::unlock` method and cause the
684    /// `GstBaseSinkClass::render` method to immediately call this function.
685    /// In this case, the subclass must be prepared to continue rendering where it
686    /// left off if this function returns [`gst::FlowReturn::Ok`][crate::gst::FlowReturn::Ok].
687    ///
688    /// This function will block until a state change to PLAYING happens (in which
689    /// case this function returns [`gst::FlowReturn::Ok`][crate::gst::FlowReturn::Ok]) or the processing must be stopped due
690    /// to a state change to READY or a FLUSH event (in which case this function
691    /// returns [`gst::FlowReturn::Flushing`][crate::gst::FlowReturn::Flushing]).
692    ///
693    /// This function should only be called with the PREROLL_LOCK held, like in the
694    /// render function.
695    ///
696    /// # Returns
697    ///
698    /// [`gst::FlowReturn::Ok`][crate::gst::FlowReturn::Ok] if the preroll completed and processing can
699    /// continue. Any other return value should be returned from the render vmethod.
700    #[doc(alias = "gst_base_sink_wait_preroll")]
701    fn wait_preroll(&self) -> Result<gst::FlowSuccess, gst::FlowError> {
702        unsafe {
703            try_from_glib(ffi::gst_base_sink_wait_preroll(
704                self.as_ref().to_glib_none().0,
705            ))
706        }
707    }
708
709    /// If set to [`true`], the basesink will perform asynchronous state changes.
710    /// When set to [`false`], the sink will not signal the parent when it prerolls.
711    /// Use this option when dealing with sparse streams or when synchronisation is
712    /// not required.
713    #[doc(alias = "async")]
714    fn is_async(&self) -> bool {
715        ObjectExt::property(self.as_ref(), "async")
716    }
717
718    /// If set to [`true`], the basesink will perform asynchronous state changes.
719    /// When set to [`false`], the sink will not signal the parent when it prerolls.
720    /// Use this option when dealing with sparse streams or when synchronisation is
721    /// not required.
722    #[doc(alias = "async")]
723    fn set_async(&self, async_: bool) {
724        ObjectExt::set_property(self.as_ref(), "async", async_)
725    }
726
727    /// Enable the last-sample property. If [`false`], basesink doesn't keep a
728    /// reference to the last buffer arrived and the last-sample property is always
729    /// set to [`None`]. This can be useful if you need buffers to be released as soon
730    /// as possible, eg. if you're using a buffer pool.
731    #[doc(alias = "enable-last-sample")]
732    fn enables_last_sample(&self) -> bool {
733        ObjectExt::property(self.as_ref(), "enable-last-sample")
734    }
735
736    /// Enable the last-sample property. If [`false`], basesink doesn't keep a
737    /// reference to the last buffer arrived and the last-sample property is always
738    /// set to [`None`]. This can be useful if you need buffers to be released as soon
739    /// as possible, eg. if you're using a buffer pool.
740    #[doc(alias = "enable-last-sample")]
741    fn set_enable_last_sample(&self, enable_last_sample: bool) {
742        ObjectExt::set_property(self.as_ref(), "enable-last-sample", enable_last_sample)
743    }
744
745    fn is_qos(&self) -> bool {
746        ObjectExt::property(self.as_ref(), "qos")
747    }
748
749    fn set_qos(&self, qos: bool) {
750        ObjectExt::set_property(self.as_ref(), "qos", qos)
751    }
752
753    #[doc(alias = "async")]
754    fn connect_async_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
755        unsafe extern "C" fn notify_async_trampoline<
756            P: IsA<BaseSink>,
757            F: Fn(&P) + Send + Sync + 'static,
758        >(
759            this: *mut ffi::GstBaseSink,
760            _param_spec: glib::ffi::gpointer,
761            f: glib::ffi::gpointer,
762        ) {
763            unsafe {
764                let f: &F = &*(f as *const F);
765                f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
766            }
767        }
768        unsafe {
769            let f: Box_<F> = Box_::new(f);
770            connect_raw(
771                self.as_ptr() as *mut _,
772                c"notify::async".as_ptr(),
773                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
774                    notify_async_trampoline::<Self, F> as *const (),
775                )),
776                Box_::into_raw(f),
777            )
778        }
779    }
780
781    #[doc(alias = "blocksize")]
782    fn connect_blocksize_notify<F: Fn(&Self) + Send + Sync + 'static>(
783        &self,
784        f: F,
785    ) -> SignalHandlerId {
786        unsafe extern "C" fn notify_blocksize_trampoline<
787            P: IsA<BaseSink>,
788            F: Fn(&P) + Send + Sync + 'static,
789        >(
790            this: *mut ffi::GstBaseSink,
791            _param_spec: glib::ffi::gpointer,
792            f: glib::ffi::gpointer,
793        ) {
794            unsafe {
795                let f: &F = &*(f as *const F);
796                f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
797            }
798        }
799        unsafe {
800            let f: Box_<F> = Box_::new(f);
801            connect_raw(
802                self.as_ptr() as *mut _,
803                c"notify::blocksize".as_ptr(),
804                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
805                    notify_blocksize_trampoline::<Self, F> as *const (),
806                )),
807                Box_::into_raw(f),
808            )
809        }
810    }
811
812    #[doc(alias = "enable-last-sample")]
813    fn connect_enable_last_sample_notify<F: Fn(&Self) + Send + Sync + 'static>(
814        &self,
815        f: F,
816    ) -> SignalHandlerId {
817        unsafe extern "C" fn notify_enable_last_sample_trampoline<
818            P: IsA<BaseSink>,
819            F: Fn(&P) + Send + Sync + 'static,
820        >(
821            this: *mut ffi::GstBaseSink,
822            _param_spec: glib::ffi::gpointer,
823            f: glib::ffi::gpointer,
824        ) {
825            unsafe {
826                let f: &F = &*(f as *const F);
827                f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
828            }
829        }
830        unsafe {
831            let f: Box_<F> = Box_::new(f);
832            connect_raw(
833                self.as_ptr() as *mut _,
834                c"notify::enable-last-sample".as_ptr(),
835                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
836                    notify_enable_last_sample_trampoline::<Self, F> as *const (),
837                )),
838                Box_::into_raw(f),
839            )
840        }
841    }
842
843    #[doc(alias = "last-sample")]
844    fn connect_last_sample_notify<F: Fn(&Self) + Send + Sync + 'static>(
845        &self,
846        f: F,
847    ) -> SignalHandlerId {
848        unsafe extern "C" fn notify_last_sample_trampoline<
849            P: IsA<BaseSink>,
850            F: Fn(&P) + Send + Sync + 'static,
851        >(
852            this: *mut ffi::GstBaseSink,
853            _param_spec: glib::ffi::gpointer,
854            f: glib::ffi::gpointer,
855        ) {
856            unsafe {
857                let f: &F = &*(f as *const F);
858                f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
859            }
860        }
861        unsafe {
862            let f: Box_<F> = Box_::new(f);
863            connect_raw(
864                self.as_ptr() as *mut _,
865                c"notify::last-sample".as_ptr(),
866                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
867                    notify_last_sample_trampoline::<Self, F> as *const (),
868                )),
869                Box_::into_raw(f),
870            )
871        }
872    }
873
874    #[doc(alias = "max-bitrate")]
875    fn connect_max_bitrate_notify<F: Fn(&Self) + Send + Sync + 'static>(
876        &self,
877        f: F,
878    ) -> SignalHandlerId {
879        unsafe extern "C" fn notify_max_bitrate_trampoline<
880            P: IsA<BaseSink>,
881            F: Fn(&P) + Send + Sync + 'static,
882        >(
883            this: *mut ffi::GstBaseSink,
884            _param_spec: glib::ffi::gpointer,
885            f: glib::ffi::gpointer,
886        ) {
887            unsafe {
888                let f: &F = &*(f as *const F);
889                f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
890            }
891        }
892        unsafe {
893            let f: Box_<F> = Box_::new(f);
894            connect_raw(
895                self.as_ptr() as *mut _,
896                c"notify::max-bitrate".as_ptr(),
897                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
898                    notify_max_bitrate_trampoline::<Self, F> as *const (),
899                )),
900                Box_::into_raw(f),
901            )
902        }
903    }
904
905    #[doc(alias = "max-lateness")]
906    fn connect_max_lateness_notify<F: Fn(&Self) + Send + Sync + 'static>(
907        &self,
908        f: F,
909    ) -> SignalHandlerId {
910        unsafe extern "C" fn notify_max_lateness_trampoline<
911            P: IsA<BaseSink>,
912            F: Fn(&P) + Send + Sync + 'static,
913        >(
914            this: *mut ffi::GstBaseSink,
915            _param_spec: glib::ffi::gpointer,
916            f: glib::ffi::gpointer,
917        ) {
918            unsafe {
919                let f: &F = &*(f as *const F);
920                f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
921            }
922        }
923        unsafe {
924            let f: Box_<F> = Box_::new(f);
925            connect_raw(
926                self.as_ptr() as *mut _,
927                c"notify::max-lateness".as_ptr(),
928                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
929                    notify_max_lateness_trampoline::<Self, F> as *const (),
930                )),
931                Box_::into_raw(f),
932            )
933        }
934    }
935
936    #[cfg(feature = "v1_16")]
937    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
938    #[doc(alias = "processing-deadline")]
939    fn connect_processing_deadline_notify<F: Fn(&Self) + Send + Sync + 'static>(
940        &self,
941        f: F,
942    ) -> SignalHandlerId {
943        unsafe extern "C" fn notify_processing_deadline_trampoline<
944            P: IsA<BaseSink>,
945            F: Fn(&P) + Send + Sync + 'static,
946        >(
947            this: *mut ffi::GstBaseSink,
948            _param_spec: glib::ffi::gpointer,
949            f: glib::ffi::gpointer,
950        ) {
951            unsafe {
952                let f: &F = &*(f as *const F);
953                f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
954            }
955        }
956        unsafe {
957            let f: Box_<F> = Box_::new(f);
958            connect_raw(
959                self.as_ptr() as *mut _,
960                c"notify::processing-deadline".as_ptr(),
961                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
962                    notify_processing_deadline_trampoline::<Self, F> as *const (),
963                )),
964                Box_::into_raw(f),
965            )
966        }
967    }
968
969    #[doc(alias = "qos")]
970    fn connect_qos_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
971        unsafe extern "C" fn notify_qos_trampoline<
972            P: IsA<BaseSink>,
973            F: Fn(&P) + Send + Sync + 'static,
974        >(
975            this: *mut ffi::GstBaseSink,
976            _param_spec: glib::ffi::gpointer,
977            f: glib::ffi::gpointer,
978        ) {
979            unsafe {
980                let f: &F = &*(f as *const F);
981                f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
982            }
983        }
984        unsafe {
985            let f: Box_<F> = Box_::new(f);
986            connect_raw(
987                self.as_ptr() as *mut _,
988                c"notify::qos".as_ptr(),
989                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
990                    notify_qos_trampoline::<Self, F> as *const (),
991                )),
992                Box_::into_raw(f),
993            )
994        }
995    }
996
997    #[doc(alias = "render-delay")]
998    fn connect_render_delay_notify<F: Fn(&Self) + Send + Sync + 'static>(
999        &self,
1000        f: F,
1001    ) -> SignalHandlerId {
1002        unsafe extern "C" fn notify_render_delay_trampoline<
1003            P: IsA<BaseSink>,
1004            F: Fn(&P) + Send + Sync + 'static,
1005        >(
1006            this: *mut ffi::GstBaseSink,
1007            _param_spec: glib::ffi::gpointer,
1008            f: glib::ffi::gpointer,
1009        ) {
1010            unsafe {
1011                let f: &F = &*(f as *const F);
1012                f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
1013            }
1014        }
1015        unsafe {
1016            let f: Box_<F> = Box_::new(f);
1017            connect_raw(
1018                self.as_ptr() as *mut _,
1019                c"notify::render-delay".as_ptr(),
1020                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1021                    notify_render_delay_trampoline::<Self, F> as *const (),
1022                )),
1023                Box_::into_raw(f),
1024            )
1025        }
1026    }
1027
1028    #[cfg(feature = "v1_18")]
1029    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
1030    #[doc(alias = "stats")]
1031    fn connect_stats_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
1032        unsafe extern "C" fn notify_stats_trampoline<
1033            P: IsA<BaseSink>,
1034            F: Fn(&P) + Send + Sync + 'static,
1035        >(
1036            this: *mut ffi::GstBaseSink,
1037            _param_spec: glib::ffi::gpointer,
1038            f: glib::ffi::gpointer,
1039        ) {
1040            unsafe {
1041                let f: &F = &*(f as *const F);
1042                f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
1043            }
1044        }
1045        unsafe {
1046            let f: Box_<F> = Box_::new(f);
1047            connect_raw(
1048                self.as_ptr() as *mut _,
1049                c"notify::stats".as_ptr(),
1050                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1051                    notify_stats_trampoline::<Self, F> as *const (),
1052                )),
1053                Box_::into_raw(f),
1054            )
1055        }
1056    }
1057
1058    #[doc(alias = "sync")]
1059    fn connect_sync_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
1060        unsafe extern "C" fn notify_sync_trampoline<
1061            P: IsA<BaseSink>,
1062            F: Fn(&P) + Send + Sync + 'static,
1063        >(
1064            this: *mut ffi::GstBaseSink,
1065            _param_spec: glib::ffi::gpointer,
1066            f: glib::ffi::gpointer,
1067        ) {
1068            unsafe {
1069                let f: &F = &*(f as *const F);
1070                f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
1071            }
1072        }
1073        unsafe {
1074            let f: Box_<F> = Box_::new(f);
1075            connect_raw(
1076                self.as_ptr() as *mut _,
1077                c"notify::sync".as_ptr(),
1078                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1079                    notify_sync_trampoline::<Self, F> as *const (),
1080                )),
1081                Box_::into_raw(f),
1082            )
1083        }
1084    }
1085
1086    #[doc(alias = "throttle-time")]
1087    fn connect_throttle_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
1088        &self,
1089        f: F,
1090    ) -> SignalHandlerId {
1091        unsafe extern "C" fn notify_throttle_time_trampoline<
1092            P: IsA<BaseSink>,
1093            F: Fn(&P) + Send + Sync + 'static,
1094        >(
1095            this: *mut ffi::GstBaseSink,
1096            _param_spec: glib::ffi::gpointer,
1097            f: glib::ffi::gpointer,
1098        ) {
1099            unsafe {
1100                let f: &F = &*(f as *const F);
1101                f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
1102            }
1103        }
1104        unsafe {
1105            let f: Box_<F> = Box_::new(f);
1106            connect_raw(
1107                self.as_ptr() as *mut _,
1108                c"notify::throttle-time".as_ptr(),
1109                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1110                    notify_throttle_time_trampoline::<Self, F> as *const (),
1111                )),
1112                Box_::into_raw(f),
1113            )
1114        }
1115    }
1116
1117    #[doc(alias = "ts-offset")]
1118    fn connect_ts_offset_notify<F: Fn(&Self) + Send + Sync + 'static>(
1119        &self,
1120        f: F,
1121    ) -> SignalHandlerId {
1122        unsafe extern "C" fn notify_ts_offset_trampoline<
1123            P: IsA<BaseSink>,
1124            F: Fn(&P) + Send + Sync + 'static,
1125        >(
1126            this: *mut ffi::GstBaseSink,
1127            _param_spec: glib::ffi::gpointer,
1128            f: glib::ffi::gpointer,
1129        ) {
1130            unsafe {
1131                let f: &F = &*(f as *const F);
1132                f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
1133            }
1134        }
1135        unsafe {
1136            let f: Box_<F> = Box_::new(f);
1137            connect_raw(
1138                self.as_ptr() as *mut _,
1139                c"notify::ts-offset".as_ptr(),
1140                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1141                    notify_ts_offset_trampoline::<Self, F> as *const (),
1142                )),
1143                Box_::into_raw(f),
1144            )
1145        }
1146    }
1147}
1148
1149impl<O: IsA<BaseSink>> BaseSinkExt for O {}