gstreamer/auto/control_source.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, ClockTime, Object};
7use glib::{prelude::*, translate::*};
8
9glib::wrapper! {
10 /// The [`ControlSource`][crate::ControlSource] is a base class for control value sources that could
11 /// be used to get timestamp-value pairs. A control source essentially is a
12 /// function over time.
13 ///
14 /// A [`ControlSource`][crate::ControlSource] is used by first getting an instance of a specific
15 /// control-source, creating a binding for the control-source to the target property
16 /// of the element and then adding the binding to the element. The binding will
17 /// convert the data types and value range to fit to the bound property.
18 ///
19 /// For implementing a new [`ControlSource`][crate::ControlSource] one has to implement
20 /// `GstControlSourceGetValue` and `GstControlSourceGetValueArray` functions.
21 /// These are then used by [`ControlSourceExt::value()`][crate::prelude::ControlSourceExt::value()] and
22 /// [`ControlSourceExtManual::control_source_get_value_array()`][crate::prelude::ControlSourceExtManual::control_source_get_value_array()] to get values for specific timestamps.
23 ///
24 /// This is an Abstract Base Class, you cannot instantiate it.
25 ///
26 /// # Implements
27 ///
28 /// [`ControlSourceExt`][trait@crate::prelude::ControlSourceExt], [`GstObjectExt`][trait@crate::prelude::GstObjectExt], [`trait@glib::ObjectExt`], [`ControlSourceExtManual`][trait@crate::prelude::ControlSourceExtManual]
29 #[doc(alias = "GstControlSource")]
30 pub struct ControlSource(Object<ffi::GstControlSource, ffi::GstControlSourceClass>) @extends Object;
31
32 match fn {
33 type_ => || ffi::gst_control_source_get_type(),
34 }
35}
36
37impl ControlSource {
38 pub const NONE: Option<&'static ControlSource> = None;
39}
40
41unsafe impl Send for ControlSource {}
42unsafe impl Sync for ControlSource {}
43
44mod sealed {
45 pub trait Sealed {}
46 impl<T: super::IsA<super::ControlSource>> Sealed for T {}
47}
48
49/// Trait containing all [`struct@ControlSource`] methods.
50///
51/// # Implementors
52///
53/// [`ControlSource`][struct@crate::ControlSource]
54pub trait ControlSourceExt: IsA<ControlSource> + sealed::Sealed + 'static {
55 /// Gets the value for this [`ControlSource`][crate::ControlSource] at a given timestamp.
56 /// ## `timestamp`
57 /// the time for which the value should be returned
58 ///
59 /// # Returns
60 ///
61 /// [`false`] if the value couldn't be returned, [`true`] otherwise.
62 ///
63 /// ## `value`
64 /// the value
65 #[doc(alias = "gst_control_source_get_value")]
66 #[doc(alias = "control_source_get_value")]
67 fn value(&self, timestamp: ClockTime) -> Option<f64> {
68 unsafe {
69 let mut value = std::mem::MaybeUninit::uninit();
70 let ret = from_glib(ffi::gst_control_source_get_value(
71 self.as_ref().to_glib_none().0,
72 timestamp.into_glib(),
73 value.as_mut_ptr(),
74 ));
75 if ret {
76 Some(value.assume_init())
77 } else {
78 None
79 }
80 }
81 }
82}
83
84impl<O: IsA<ControlSource>> ControlSourceExt for O {}