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