2020-12-15 10:53:31 +00:00
|
|
|
// Take a look at the license at the top of the repository in the LICENSE file.
|
2018-11-29 19:18:06 +00:00
|
|
|
|
2021-11-20 10:17:58 +00:00
|
|
|
use glib::gobject_ffi;
|
2018-11-29 19:18:06 +00:00
|
|
|
use glib::translate::*;
|
2021-11-20 10:17:58 +00:00
|
|
|
use glib::ParamSpec;
|
2018-11-29 19:18:06 +00:00
|
|
|
|
2021-11-20 10:17:58 +00:00
|
|
|
glib::wrapper! {
|
|
|
|
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
|
|
#[doc(alias = "GstParamSpecFraction")]
|
|
|
|
pub struct ParamSpecFraction(Shared<ffi::GstParamSpecFraction>);
|
2018-12-11 10:37:15 +00:00
|
|
|
|
2021-11-20 10:17:58 +00:00
|
|
|
match fn {
|
|
|
|
ref => |ptr| gobject_ffi::g_param_spec_ref_sink(ptr as *mut gobject_ffi::GParamSpec),
|
|
|
|
unref => |ptr| gobject_ffi::g_param_spec_unref(ptr as *mut gobject_ffi::GParamSpec),
|
|
|
|
type_ => || ffi::gst_param_spec_fraction_get_type(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe impl Send for ParamSpecFraction {}
|
|
|
|
unsafe impl Sync for ParamSpecFraction {}
|
|
|
|
|
|
|
|
impl std::ops::Deref for ParamSpecFraction {
|
|
|
|
type Target = ParamSpec;
|
|
|
|
|
|
|
|
fn deref(&self) -> &Self::Target {
|
|
|
|
unsafe { &*(self as *const ParamSpecFraction as *const ParamSpec) }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe impl glib::ParamSpecType for ParamSpecFraction {}
|
|
|
|
|
|
|
|
#[doc(hidden)]
|
|
|
|
impl FromGlibPtrFull<*mut gobject_ffi::GParamSpec> for ParamSpecFraction {
|
|
|
|
unsafe fn from_glib_full(ptr: *mut gobject_ffi::GParamSpec) -> Self {
|
|
|
|
from_glib_full(ptr as *mut ffi::GstParamSpecFraction)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl ParamSpecFraction {
|
|
|
|
#[allow(clippy::new_ret_no_self)]
|
|
|
|
#[doc(alias = "gst_param_spec_fraction")]
|
|
|
|
pub fn new(
|
2018-12-11 10:37:15 +00:00
|
|
|
name: &str,
|
|
|
|
nick: &str,
|
|
|
|
blurb: &str,
|
2020-11-21 13:46:48 +00:00
|
|
|
min: crate::Fraction,
|
|
|
|
max: crate::Fraction,
|
|
|
|
default: crate::Fraction,
|
2018-12-11 10:37:15 +00:00
|
|
|
flags: glib::ParamFlags,
|
2018-11-29 19:18:06 +00:00
|
|
|
) -> glib::ParamSpec {
|
2020-03-22 14:18:47 +00:00
|
|
|
assert_initialized_main_thread!();
|
2018-11-29 19:18:06 +00:00
|
|
|
unsafe {
|
2021-11-20 10:17:58 +00:00
|
|
|
from_glib_none(ffi::gst_param_spec_fraction(
|
2018-11-29 19:18:06 +00:00
|
|
|
name.to_glib_none().0,
|
|
|
|
nick.to_glib_none().0,
|
|
|
|
blurb.to_glib_none().0,
|
2021-11-20 10:17:58 +00:00
|
|
|
min.numer(),
|
|
|
|
min.denom(),
|
|
|
|
max.numer(),
|
|
|
|
max.denom(),
|
|
|
|
default.numer(),
|
|
|
|
default.denom(),
|
2021-04-27 15:15:46 +00:00
|
|
|
flags.into_glib(),
|
2018-11-29 19:18:06 +00:00
|
|
|
))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-20 10:17:58 +00:00
|
|
|
pub fn minimum(&self) -> crate::Fraction {
|
|
|
|
unsafe {
|
|
|
|
let ptr = self.to_glib_none().0;
|
|
|
|
|
|
|
|
crate::Fraction::new((*ptr).min_num, (*ptr).min_den)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn maximum(&self) -> crate::Fraction {
|
|
|
|
unsafe {
|
|
|
|
let ptr = self.to_glib_none().0;
|
|
|
|
|
|
|
|
crate::Fraction::new((*ptr).max_num, (*ptr).max_den)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn default_value(&self) -> crate::Fraction {
|
|
|
|
unsafe {
|
|
|
|
let ptr = self.to_glib_none().0;
|
|
|
|
|
|
|
|
crate::Fraction::new((*ptr).def_num, (*ptr).def_den)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn upcast(self) -> ParamSpec {
|
|
|
|
unsafe { from_glib_full(self.to_glib_full() as *mut gobject_ffi::GParamSpec) }
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn upcast_ref(&self) -> &ParamSpec {
|
|
|
|
&*self
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(any(feature = "v1_14", feature = "dox"))]
|
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))]
|
|
|
|
glib::wrapper! {
|
|
|
|
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
|
|
#[doc(alias = "GstParamSpecArray")]
|
|
|
|
pub struct ParamSpecArray(Shared<ffi::GstParamSpecArray>);
|
|
|
|
|
|
|
|
match fn {
|
|
|
|
ref => |ptr| gobject_ffi::g_param_spec_ref_sink(ptr as *mut gobject_ffi::GParamSpec),
|
|
|
|
unref => |ptr| gobject_ffi::g_param_spec_unref(ptr as *mut gobject_ffi::GParamSpec),
|
|
|
|
type_ => || ffi::gst_param_spec_fraction_get_type(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(any(feature = "v1_14", feature = "dox"))]
|
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))]
|
|
|
|
unsafe impl Send for ParamSpecArray {}
|
|
|
|
#[cfg(any(feature = "v1_14", feature = "dox"))]
|
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))]
|
|
|
|
unsafe impl Sync for ParamSpecArray {}
|
|
|
|
|
|
|
|
#[cfg(any(feature = "v1_14", feature = "dox"))]
|
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))]
|
|
|
|
impl std::ops::Deref for ParamSpecArray {
|
|
|
|
type Target = ParamSpec;
|
|
|
|
|
|
|
|
fn deref(&self) -> &Self::Target {
|
|
|
|
unsafe { &*(self as *const ParamSpecArray as *const ParamSpec) }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(any(feature = "v1_14", feature = "dox"))]
|
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))]
|
|
|
|
unsafe impl glib::ParamSpecType for ParamSpecArray {}
|
|
|
|
|
|
|
|
#[cfg(any(feature = "v1_14", feature = "dox"))]
|
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))]
|
|
|
|
#[doc(hidden)]
|
|
|
|
impl FromGlibPtrFull<*mut gobject_ffi::GParamSpec> for ParamSpecArray {
|
|
|
|
unsafe fn from_glib_full(ptr: *mut gobject_ffi::GParamSpec) -> Self {
|
|
|
|
from_glib_full(ptr as *mut ffi::GstParamSpecArray)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(any(feature = "v1_14", feature = "dox"))]
|
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))]
|
|
|
|
impl ParamSpecArray {
|
|
|
|
#[allow(clippy::new_ret_no_self)]
|
|
|
|
#[doc(alias = "gst_param_spec_array")]
|
|
|
|
pub fn new_array(
|
2018-11-29 19:18:06 +00:00
|
|
|
name: &str,
|
|
|
|
nick: &str,
|
|
|
|
blurb: &str,
|
2021-11-20 10:17:58 +00:00
|
|
|
element_spec: Option<&glib::ParamSpec>,
|
2018-11-29 19:18:06 +00:00
|
|
|
flags: glib::ParamFlags,
|
|
|
|
) -> glib::ParamSpec {
|
2020-03-22 14:18:47 +00:00
|
|
|
assert_initialized_main_thread!();
|
2018-11-29 19:18:06 +00:00
|
|
|
unsafe {
|
2021-11-20 10:17:58 +00:00
|
|
|
from_glib_none(ffi::gst_param_spec_array(
|
2018-11-29 19:18:06 +00:00
|
|
|
name.to_glib_none().0,
|
|
|
|
nick.to_glib_none().0,
|
|
|
|
blurb.to_glib_none().0,
|
2021-11-20 10:17:58 +00:00
|
|
|
element_spec.to_glib_none().0,
|
2021-04-27 15:15:46 +00:00
|
|
|
flags.into_glib(),
|
2018-11-29 19:18:06 +00:00
|
|
|
))
|
|
|
|
}
|
|
|
|
}
|
2021-11-20 10:17:58 +00:00
|
|
|
|
|
|
|
pub fn element_spec(&self) -> Option<ParamSpec> {
|
|
|
|
unsafe {
|
|
|
|
let ptr = self.to_glib_none().0;
|
|
|
|
|
|
|
|
from_glib_none((*ptr).element_spec)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn upcast(self) -> ParamSpec {
|
|
|
|
unsafe { from_glib_full(self.to_glib_full() as *mut gobject_ffi::GParamSpec) }
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn upcast_ref(&self) -> &ParamSpec {
|
|
|
|
&*self
|
|
|
|
}
|
2018-11-29 19:18:06 +00:00
|
|
|
}
|
2018-12-11 10:37:15 +00:00
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
2021-11-20 10:17:58 +00:00
|
|
|
use super::*;
|
2018-12-11 10:37:15 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_trait() {
|
2020-11-21 13:46:48 +00:00
|
|
|
crate::init().unwrap();
|
2018-12-11 10:37:15 +00:00
|
|
|
|
2021-11-20 10:17:58 +00:00
|
|
|
let _pspec = ParamSpecFraction::new(
|
2018-12-11 10:37:15 +00:00
|
|
|
"foo",
|
|
|
|
"Foo",
|
|
|
|
"Foo Bar",
|
|
|
|
(0, 1).into(),
|
|
|
|
(100, 1).into(),
|
|
|
|
(1, 1).into(),
|
|
|
|
glib::ParamFlags::READWRITE,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|