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
44/// Trait containing all [`struct@ControlSource`] methods.
45///
46/// # Implementors
47///
48/// [`ControlSource`][struct@crate::ControlSource]
49pub trait ControlSourceExt: IsA<ControlSource> + 'static {
50    /// Gets the value for this [`ControlSource`][crate::ControlSource] at a given timestamp.
51    /// ## `timestamp`
52    /// the time for which the value should be returned
53    ///
54    /// # Returns
55    ///
56    /// [`false`] if the value couldn't be returned, [`true`] otherwise.
57    ///
58    /// ## `value`
59    /// the value
60    #[doc(alias = "gst_control_source_get_value")]
61    #[doc(alias = "control_source_get_value")]
62    fn value(&self, timestamp: ClockTime) -> Option<f64> {
63        unsafe {
64            let mut value = std::mem::MaybeUninit::uninit();
65            let ret = from_glib(ffi::gst_control_source_get_value(
66                self.as_ref().to_glib_none().0,
67                timestamp.into_glib(),
68                value.as_mut_ptr(),
69            ));
70            if ret {
71                Some(value.assume_init())
72            } else {
73                None
74            }
75        }
76    }
77}
78
79impl<O: IsA<ControlSource>> ControlSourceExt for O {}