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
|
|
|
|
|
|
|
use glib::translate::*;
|
|
|
|
|
2018-12-11 10:37:15 +00:00
|
|
|
pub trait GstParamSpecExt {
|
2020-11-27 13:37:49 +00:00
|
|
|
#[cfg(any(feature = "v1_14", feature = "dox"))]
|
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))]
|
2021-05-06 19:40:19 +00:00
|
|
|
fn new_array(
|
2018-12-11 10:37:15 +00:00
|
|
|
name: &str,
|
|
|
|
nick: &str,
|
|
|
|
blurb: &str,
|
|
|
|
element_spec: &glib::ParamSpec,
|
|
|
|
flags: glib::ParamFlags,
|
|
|
|
) -> Self;
|
|
|
|
|
2021-05-06 19:40:19 +00:00
|
|
|
fn new_fraction(
|
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,
|
|
|
|
) -> Self;
|
|
|
|
}
|
2018-11-29 19:18:06 +00:00
|
|
|
|
2018-12-11 10:37:15 +00:00
|
|
|
impl GstParamSpecExt for glib::ParamSpec {
|
2020-11-27 13:37:49 +00:00
|
|
|
#[cfg(any(feature = "v1_14", feature = "dox"))]
|
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))]
|
2021-05-06 19:40:19 +00:00
|
|
|
fn new_array(
|
2018-11-29 19:18:06 +00:00
|
|
|
name: &str,
|
|
|
|
nick: &str,
|
|
|
|
blurb: &str,
|
|
|
|
element_spec: &glib::ParamSpec,
|
|
|
|
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 {
|
2020-11-21 13:46:48 +00:00
|
|
|
from_glib_full(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,
|
|
|
|
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-05-06 19:40:19 +00:00
|
|
|
fn new_fraction(
|
2018-11-29 19:18:06 +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-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 {
|
2020-11-21 13:46:48 +00:00
|
|
|
from_glib_full(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,
|
|
|
|
*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
|
|
|
))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-12-11 10:37:15 +00:00
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
2020-11-21 13:46:48 +00:00
|
|
|
use crate::prelude::*;
|
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-05-06 19:40:19 +00:00
|
|
|
let _pspec = glib::ParamSpec::new_fraction(
|
2018-12-11 10:37:15 +00:00
|
|
|
"foo",
|
|
|
|
"Foo",
|
|
|
|
"Foo Bar",
|
|
|
|
(0, 1).into(),
|
|
|
|
(100, 1).into(),
|
|
|
|
(1, 1).into(),
|
|
|
|
glib::ParamFlags::READWRITE,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|