gstreamer_base/auto/base_sink.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
4// DO NOT EDIT
5
6use crate::ffi;
7use glib::{
8 prelude::*,
9 signal::{connect_raw, SignalHandlerId},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 /// [`BaseSink`][crate::BaseSink] is the base class for sink elements in GStreamer, such as
16 /// xvimagesink or filesink. It is a layer on top of [`gst::Element`][crate::gst::Element] that provides a
17 /// simplified interface to plugin writers. [`BaseSink`][crate::BaseSink] handles many details
18 /// for you, for example: preroll, clock synchronization, state changes,
19 /// activation in push or pull mode, and queries.
20 ///
21 /// In most cases, when writing sink elements, there is no need to implement
22 /// class methods from [`gst::Element`][crate::gst::Element] or to set functions on pads, because the
23 /// [`BaseSink`][crate::BaseSink] infrastructure should be sufficient.
24 ///
25 /// [`BaseSink`][crate::BaseSink] provides support for exactly one sink pad, which should be
26 /// named "sink". A sink implementation (subclass of [`BaseSink`][crate::BaseSink]) should
27 /// install a pad template in its class_init function, like so:
28 ///
29 ///
30 /// **⚠️ The following code is in C ⚠️**
31 ///
32 /// ```C
33 /// static void
34 /// my_element_class_init (GstMyElementClass *klass)
35 /// {
36 /// GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
37 ///
38 /// // sinktemplate should be a #GstStaticPadTemplate with direction
39 /// // %GST_PAD_SINK and name "sink"
40 /// gst_element_class_add_static_pad_template (gstelement_class, &sinktemplate);
41 ///
42 /// gst_element_class_set_static_metadata (gstelement_class,
43 /// "Sink name",
44 /// "Sink",
45 /// "My Sink element",
46 /// "The author <my.sink@my.email>");
47 /// }
48 /// ```
49 ///
50 /// [`BaseSink`][crate::BaseSink] will handle the prerolling correctly. This means that it will
51 /// return [`gst::StateChangeReturn::Async`][crate::gst::StateChangeReturn::Async] from a state change to PAUSED until the first
52 /// buffer arrives in this element. The base class will call the
53 /// `GstBaseSinkClass::preroll` vmethod with this preroll buffer and will then
54 /// commit the state change to the next asynchronously pending state.
55 ///
56 /// When the element is set to PLAYING, [`BaseSink`][crate::BaseSink] will synchronise on the
57 /// clock using the times returned from `GstBaseSinkClass::get_times`. If this
58 /// function returns `GST_CLOCK_TIME_NONE` for the start time, no synchronisation
59 /// will be done. Synchronisation can be disabled entirely by setting the object
60 /// [`sync`][struct@crate::BaseSink#sync] property to [`false`].
61 ///
62 /// After synchronisation the virtual method `GstBaseSinkClass::render` will be
63 /// called. Subclasses should minimally implement this method.
64 ///
65 /// Subclasses that synchronise on the clock in the `GstBaseSinkClass::render`
66 /// method are supported as well. These classes typically receive a buffer in
67 /// the render method and can then potentially block on the clock while
68 /// rendering. A typical example is an audiosink.
69 /// These subclasses can use [`BaseSinkExt::wait_preroll()`][crate::prelude::BaseSinkExt::wait_preroll()] to perform the
70 /// blocking wait.
71 ///
72 /// Upon receiving the EOS event in the PLAYING state, [`BaseSink`][crate::BaseSink] will wait
73 /// for the clock to reach the time indicated by the stop time of the last
74 /// `GstBaseSinkClass::get_times` call before posting an EOS message. When the
75 /// element receives EOS in PAUSED, preroll completes, the event is queued and an
76 /// EOS message is posted when going to PLAYING.
77 ///
78 /// [`BaseSink`][crate::BaseSink] will internally use the [`gst::EventType::Segment`][crate::gst::EventType::Segment] events to schedule
79 /// synchronisation and clipping of buffers. Buffers that fall completely outside
80 /// of the current segment are dropped. Buffers that fall partially in the
81 /// segment are rendered (and prerolled). Subclasses should do any subbuffer
82 /// clipping themselves when needed.
83 ///
84 /// [`BaseSink`][crate::BaseSink] will by default report the current playback position in
85 /// [`gst::Format::Time`][crate::gst::Format::Time] based on the current clock time and segment information.
86 /// If no clock has been set on the element, the query will be forwarded
87 /// upstream.
88 ///
89 /// The `GstBaseSinkClass::set_caps` function will be called when the subclass
90 /// should configure itself to process a specific media type.
91 ///
92 /// The `GstBaseSinkClass::start` and `GstBaseSinkClass::stop` virtual methods
93 /// will be called when resources should be allocated. Any
94 /// `GstBaseSinkClass::preroll`, `GstBaseSinkClass::render` and
95 /// `GstBaseSinkClass::set_caps` function will be called between the
96 /// `GstBaseSinkClass::start` and `GstBaseSinkClass::stop` calls.
97 ///
98 /// The `GstBaseSinkClass::event` virtual method will be called when an event is
99 /// received by [`BaseSink`][crate::BaseSink]. Normally this method should only be overridden by
100 /// very specific elements (such as file sinks) which need to handle the
101 /// newsegment event specially.
102 ///
103 /// The `GstBaseSinkClass::unlock` method is called when the elements should
104 /// unblock any blocking operations they perform in the
105 /// `GstBaseSinkClass::render` method. This is mostly useful when the
106 /// `GstBaseSinkClass::render` method performs a blocking write on a file
107 /// descriptor, for example.
108 ///
109 /// The [`max-lateness`][struct@crate::BaseSink#max-lateness] property affects how the sink deals with
110 /// buffers that arrive too late in the sink. A buffer arrives too late in the
111 /// sink when the presentation time (as a combination of the last segment, buffer
112 /// timestamp and element base_time) plus the duration is before the current
113 /// time of the clock.
114 /// If the frame is later than max-lateness, the sink will drop the buffer
115 /// without calling the render method.
116 /// This feature is disabled if sync is disabled, the
117 /// `GstBaseSinkClass::get_times` method does not return a valid start time or
118 /// max-lateness is set to -1 (the default).
119 /// Subclasses can use [`BaseSinkExt::set_max_lateness()`][crate::prelude::BaseSinkExt::set_max_lateness()] to configure the
120 /// max-lateness value.
121 ///
122 /// The [`qos`][struct@crate::BaseSink#qos] property will enable the quality-of-service features of
123 /// the basesink which gather statistics about the real-time performance of the
124 /// clock synchronisation. For each buffer received in the sink, statistics are
125 /// gathered and a QOS event is sent upstream with these numbers. This
126 /// information can then be used by upstream elements to reduce their processing
127 /// rate, for example.
128 ///
129 /// The [`async`][struct@crate::BaseSink#async] property can be used to instruct the sink to never
130 /// perform an ASYNC state change. This feature is mostly usable when dealing
131 /// with non-synchronized streams or sparse streams.
132 ///
133 /// This is an Abstract Base Class, you cannot instantiate it.
134 ///
135 /// ## Properties
136 ///
137 ///
138 /// #### `async`
139 /// If set to [`true`], the basesink will perform asynchronous state changes.
140 /// When set to [`false`], the sink will not signal the parent when it prerolls.
141 /// Use this option when dealing with sparse streams or when synchronisation is
142 /// not required.
143 ///
144 /// Readable | Writeable
145 ///
146 ///
147 /// #### `blocksize`
148 /// The amount of bytes to pull when operating in pull mode.
149 ///
150 /// Readable | Writeable
151 ///
152 ///
153 /// #### `enable-last-sample`
154 /// Enable the last-sample property. If [`false`], basesink doesn't keep a
155 /// reference to the last buffer arrived and the last-sample property is always
156 /// set to [`None`]. This can be useful if you need buffers to be released as soon
157 /// as possible, eg. if you're using a buffer pool.
158 ///
159 /// Readable | Writeable
160 ///
161 ///
162 /// #### `last-sample`
163 /// The last buffer that arrived in the sink and was used for preroll or for
164 /// rendering. This property can be used to generate thumbnails. This property
165 /// can be [`None`] when the sink has not yet received a buffer.
166 ///
167 /// Readable
168 ///
169 ///
170 /// #### `max-bitrate`
171 /// Control the maximum amount of bits that will be rendered per second.
172 /// Setting this property to a value bigger than 0 will make the sink delay
173 /// rendering of the buffers when it would exceed to max-bitrate.
174 ///
175 /// Readable | Writeable
176 ///
177 ///
178 /// #### `max-lateness`
179 /// Readable | Writeable
180 ///
181 ///
182 /// #### `processing-deadline`
183 /// Maximum amount of time (in nanoseconds) that the pipeline can take
184 /// for processing the buffer. This is added to the latency of live
185 /// pipelines.
186 ///
187 /// Readable | Writeable
188 ///
189 ///
190 /// #### `qos`
191 /// Readable | Writeable
192 ///
193 ///
194 /// #### `render-delay`
195 /// The additional delay between synchronisation and actual rendering of the
196 /// media. This property will add additional latency to the device in order to
197 /// make other sinks compensate for the delay.
198 ///
199 /// Readable | Writeable
200 ///
201 ///
202 /// #### `stats`
203 /// Various [`BaseSink`][crate::BaseSink] statistics. This property returns a [`gst::Structure`][crate::gst::Structure]
204 /// with name `application/x-gst-base-sink-stats` with the following fields:
205 ///
206 /// - "average-rate" G_TYPE_DOUBLE average frame rate
207 /// - "dropped" G_TYPE_UINT64 Number of dropped frames
208 /// - "rendered" G_TYPE_UINT64 Number of rendered frames
209 ///
210 /// Readable
211 ///
212 ///
213 /// #### `sync`
214 /// Readable | Writeable
215 ///
216 ///
217 /// #### `throttle-time`
218 /// The time to insert between buffers. This property can be used to control
219 /// the maximum amount of buffers per second to render. Setting this property
220 /// to a value bigger than 0 will make the sink create THROTTLE QoS events.
221 ///
222 /// Readable | Writeable
223 ///
224 ///
225 /// #### `ts-offset`
226 /// Controls the final synchronisation, a negative value will render the buffer
227 /// earlier while a positive value delays playback. This property can be
228 /// used to fix synchronisation in bad files.
229 ///
230 /// Readable | Writeable
231 /// <details><summary><h4>Object</h4></summary>
232 ///
233 ///
234 /// #### `name`
235 /// Readable | Writeable | Construct
236 ///
237 ///
238 /// #### `parent`
239 /// The parent of the object. Please note, that when changing the 'parent'
240 /// property, we don't emit [`notify`][struct@crate::glib::Object#notify] and [`deep-notify`][struct@crate::gst::Object#deep-notify]
241 /// signals due to locking issues. In some cases one can use
242 /// `GstBin::element-added` or `GstBin::element-removed` signals on the parent to
243 /// achieve a similar effect.
244 ///
245 /// Readable | Writeable
246 /// </details>
247 ///
248 /// # Implements
249 ///
250 /// [`BaseSinkExt`][trait@crate::prelude::BaseSinkExt], [`trait@gst::prelude::ElementExt`], [`trait@gst::prelude::ObjectExt`], [`trait@glib::ObjectExt`], [`BaseSinkExtManual`][trait@crate::prelude::BaseSinkExtManual]
251 #[doc(alias = "GstBaseSink")]
252 pub struct BaseSink(Object<ffi::GstBaseSink, ffi::GstBaseSinkClass>) @extends gst::Element, gst::Object;
253
254 match fn {
255 type_ => || ffi::gst_base_sink_get_type(),
256 }
257}
258
259impl BaseSink {
260 pub const NONE: Option<&'static BaseSink> = None;
261}
262
263unsafe impl Send for BaseSink {}
264unsafe impl Sync for BaseSink {}
265
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 let f: &F = &*(f as *const F);
764 f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
765 }
766 unsafe {
767 let f: Box_<F> = Box_::new(f);
768 connect_raw(
769 self.as_ptr() as *mut _,
770 c"notify::async".as_ptr() as *const _,
771 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
772 notify_async_trampoline::<Self, F> as *const (),
773 )),
774 Box_::into_raw(f),
775 )
776 }
777 }
778
779 #[doc(alias = "blocksize")]
780 fn connect_blocksize_notify<F: Fn(&Self) + Send + Sync + 'static>(
781 &self,
782 f: F,
783 ) -> SignalHandlerId {
784 unsafe extern "C" fn notify_blocksize_trampoline<
785 P: IsA<BaseSink>,
786 F: Fn(&P) + Send + Sync + 'static,
787 >(
788 this: *mut ffi::GstBaseSink,
789 _param_spec: glib::ffi::gpointer,
790 f: glib::ffi::gpointer,
791 ) {
792 let f: &F = &*(f as *const F);
793 f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
794 }
795 unsafe {
796 let f: Box_<F> = Box_::new(f);
797 connect_raw(
798 self.as_ptr() as *mut _,
799 c"notify::blocksize".as_ptr() as *const _,
800 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
801 notify_blocksize_trampoline::<Self, F> as *const (),
802 )),
803 Box_::into_raw(f),
804 )
805 }
806 }
807
808 #[doc(alias = "enable-last-sample")]
809 fn connect_enable_last_sample_notify<F: Fn(&Self) + Send + Sync + 'static>(
810 &self,
811 f: F,
812 ) -> SignalHandlerId {
813 unsafe extern "C" fn notify_enable_last_sample_trampoline<
814 P: IsA<BaseSink>,
815 F: Fn(&P) + Send + Sync + 'static,
816 >(
817 this: *mut ffi::GstBaseSink,
818 _param_spec: glib::ffi::gpointer,
819 f: glib::ffi::gpointer,
820 ) {
821 let f: &F = &*(f as *const F);
822 f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
823 }
824 unsafe {
825 let f: Box_<F> = Box_::new(f);
826 connect_raw(
827 self.as_ptr() as *mut _,
828 c"notify::enable-last-sample".as_ptr() as *const _,
829 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
830 notify_enable_last_sample_trampoline::<Self, F> as *const (),
831 )),
832 Box_::into_raw(f),
833 )
834 }
835 }
836
837 #[doc(alias = "last-sample")]
838 fn connect_last_sample_notify<F: Fn(&Self) + Send + Sync + 'static>(
839 &self,
840 f: F,
841 ) -> SignalHandlerId {
842 unsafe extern "C" fn notify_last_sample_trampoline<
843 P: IsA<BaseSink>,
844 F: Fn(&P) + Send + Sync + 'static,
845 >(
846 this: *mut ffi::GstBaseSink,
847 _param_spec: glib::ffi::gpointer,
848 f: glib::ffi::gpointer,
849 ) {
850 let f: &F = &*(f as *const F);
851 f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
852 }
853 unsafe {
854 let f: Box_<F> = Box_::new(f);
855 connect_raw(
856 self.as_ptr() as *mut _,
857 c"notify::last-sample".as_ptr() as *const _,
858 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
859 notify_last_sample_trampoline::<Self, F> as *const (),
860 )),
861 Box_::into_raw(f),
862 )
863 }
864 }
865
866 #[doc(alias = "max-bitrate")]
867 fn connect_max_bitrate_notify<F: Fn(&Self) + Send + Sync + 'static>(
868 &self,
869 f: F,
870 ) -> SignalHandlerId {
871 unsafe extern "C" fn notify_max_bitrate_trampoline<
872 P: IsA<BaseSink>,
873 F: Fn(&P) + Send + Sync + 'static,
874 >(
875 this: *mut ffi::GstBaseSink,
876 _param_spec: glib::ffi::gpointer,
877 f: glib::ffi::gpointer,
878 ) {
879 let f: &F = &*(f as *const F);
880 f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
881 }
882 unsafe {
883 let f: Box_<F> = Box_::new(f);
884 connect_raw(
885 self.as_ptr() as *mut _,
886 c"notify::max-bitrate".as_ptr() as *const _,
887 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
888 notify_max_bitrate_trampoline::<Self, F> as *const (),
889 )),
890 Box_::into_raw(f),
891 )
892 }
893 }
894
895 #[doc(alias = "max-lateness")]
896 fn connect_max_lateness_notify<F: Fn(&Self) + Send + Sync + 'static>(
897 &self,
898 f: F,
899 ) -> SignalHandlerId {
900 unsafe extern "C" fn notify_max_lateness_trampoline<
901 P: IsA<BaseSink>,
902 F: Fn(&P) + Send + Sync + 'static,
903 >(
904 this: *mut ffi::GstBaseSink,
905 _param_spec: glib::ffi::gpointer,
906 f: glib::ffi::gpointer,
907 ) {
908 let f: &F = &*(f as *const F);
909 f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
910 }
911 unsafe {
912 let f: Box_<F> = Box_::new(f);
913 connect_raw(
914 self.as_ptr() as *mut _,
915 c"notify::max-lateness".as_ptr() as *const _,
916 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
917 notify_max_lateness_trampoline::<Self, F> as *const (),
918 )),
919 Box_::into_raw(f),
920 )
921 }
922 }
923
924 #[cfg(feature = "v1_16")]
925 #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
926 #[doc(alias = "processing-deadline")]
927 fn connect_processing_deadline_notify<F: Fn(&Self) + Send + Sync + 'static>(
928 &self,
929 f: F,
930 ) -> SignalHandlerId {
931 unsafe extern "C" fn notify_processing_deadline_trampoline<
932 P: IsA<BaseSink>,
933 F: Fn(&P) + Send + Sync + 'static,
934 >(
935 this: *mut ffi::GstBaseSink,
936 _param_spec: glib::ffi::gpointer,
937 f: glib::ffi::gpointer,
938 ) {
939 let f: &F = &*(f as *const F);
940 f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
941 }
942 unsafe {
943 let f: Box_<F> = Box_::new(f);
944 connect_raw(
945 self.as_ptr() as *mut _,
946 c"notify::processing-deadline".as_ptr() as *const _,
947 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
948 notify_processing_deadline_trampoline::<Self, F> as *const (),
949 )),
950 Box_::into_raw(f),
951 )
952 }
953 }
954
955 #[doc(alias = "qos")]
956 fn connect_qos_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
957 unsafe extern "C" fn notify_qos_trampoline<
958 P: IsA<BaseSink>,
959 F: Fn(&P) + Send + Sync + 'static,
960 >(
961 this: *mut ffi::GstBaseSink,
962 _param_spec: glib::ffi::gpointer,
963 f: glib::ffi::gpointer,
964 ) {
965 let f: &F = &*(f as *const F);
966 f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
967 }
968 unsafe {
969 let f: Box_<F> = Box_::new(f);
970 connect_raw(
971 self.as_ptr() as *mut _,
972 c"notify::qos".as_ptr() as *const _,
973 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
974 notify_qos_trampoline::<Self, F> as *const (),
975 )),
976 Box_::into_raw(f),
977 )
978 }
979 }
980
981 #[doc(alias = "render-delay")]
982 fn connect_render_delay_notify<F: Fn(&Self) + Send + Sync + 'static>(
983 &self,
984 f: F,
985 ) -> SignalHandlerId {
986 unsafe extern "C" fn notify_render_delay_trampoline<
987 P: IsA<BaseSink>,
988 F: Fn(&P) + Send + Sync + 'static,
989 >(
990 this: *mut ffi::GstBaseSink,
991 _param_spec: glib::ffi::gpointer,
992 f: glib::ffi::gpointer,
993 ) {
994 let f: &F = &*(f as *const F);
995 f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
996 }
997 unsafe {
998 let f: Box_<F> = Box_::new(f);
999 connect_raw(
1000 self.as_ptr() as *mut _,
1001 c"notify::render-delay".as_ptr() as *const _,
1002 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1003 notify_render_delay_trampoline::<Self, F> as *const (),
1004 )),
1005 Box_::into_raw(f),
1006 )
1007 }
1008 }
1009
1010 #[cfg(feature = "v1_18")]
1011 #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
1012 #[doc(alias = "stats")]
1013 fn connect_stats_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
1014 unsafe extern "C" fn notify_stats_trampoline<
1015 P: IsA<BaseSink>,
1016 F: Fn(&P) + Send + Sync + 'static,
1017 >(
1018 this: *mut ffi::GstBaseSink,
1019 _param_spec: glib::ffi::gpointer,
1020 f: glib::ffi::gpointer,
1021 ) {
1022 let f: &F = &*(f as *const F);
1023 f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
1024 }
1025 unsafe {
1026 let f: Box_<F> = Box_::new(f);
1027 connect_raw(
1028 self.as_ptr() as *mut _,
1029 c"notify::stats".as_ptr() as *const _,
1030 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1031 notify_stats_trampoline::<Self, F> as *const (),
1032 )),
1033 Box_::into_raw(f),
1034 )
1035 }
1036 }
1037
1038 #[doc(alias = "sync")]
1039 fn connect_sync_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
1040 unsafe extern "C" fn notify_sync_trampoline<
1041 P: IsA<BaseSink>,
1042 F: Fn(&P) + Send + Sync + 'static,
1043 >(
1044 this: *mut ffi::GstBaseSink,
1045 _param_spec: glib::ffi::gpointer,
1046 f: glib::ffi::gpointer,
1047 ) {
1048 let f: &F = &*(f as *const F);
1049 f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
1050 }
1051 unsafe {
1052 let f: Box_<F> = Box_::new(f);
1053 connect_raw(
1054 self.as_ptr() as *mut _,
1055 c"notify::sync".as_ptr() as *const _,
1056 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1057 notify_sync_trampoline::<Self, F> as *const (),
1058 )),
1059 Box_::into_raw(f),
1060 )
1061 }
1062 }
1063
1064 #[doc(alias = "throttle-time")]
1065 fn connect_throttle_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
1066 &self,
1067 f: F,
1068 ) -> SignalHandlerId {
1069 unsafe extern "C" fn notify_throttle_time_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 let f: &F = &*(f as *const F);
1078 f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
1079 }
1080 unsafe {
1081 let f: Box_<F> = Box_::new(f);
1082 connect_raw(
1083 self.as_ptr() as *mut _,
1084 c"notify::throttle-time".as_ptr() as *const _,
1085 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1086 notify_throttle_time_trampoline::<Self, F> as *const (),
1087 )),
1088 Box_::into_raw(f),
1089 )
1090 }
1091 }
1092
1093 #[doc(alias = "ts-offset")]
1094 fn connect_ts_offset_notify<F: Fn(&Self) + Send + Sync + 'static>(
1095 &self,
1096 f: F,
1097 ) -> SignalHandlerId {
1098 unsafe extern "C" fn notify_ts_offset_trampoline<
1099 P: IsA<BaseSink>,
1100 F: Fn(&P) + Send + Sync + 'static,
1101 >(
1102 this: *mut ffi::GstBaseSink,
1103 _param_spec: glib::ffi::gpointer,
1104 f: glib::ffi::gpointer,
1105 ) {
1106 let f: &F = &*(f as *const F);
1107 f(BaseSink::from_glib_borrow(this).unsafe_cast_ref())
1108 }
1109 unsafe {
1110 let f: Box_<F> = Box_::new(f);
1111 connect_raw(
1112 self.as_ptr() as *mut _,
1113 c"notify::ts-offset".as_ptr() as *const _,
1114 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1115 notify_ts_offset_trampoline::<Self, F> as *const (),
1116 )),
1117 Box_::into_raw(f),
1118 )
1119 }
1120 }
1121}
1122
1123impl<O: IsA<BaseSink>> BaseSinkExt for O {}