mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-12-23 00:26:31 +00:00
gstreamer: Add Value::deserialize_with_pspec() from 1.20
This commit is contained in:
parent
c5c9fd81e4
commit
43bfd1ae85
1 changed files with 32 additions and 0 deletions
|
@ -840,6 +840,13 @@ pub trait GstValueExt: Sized {
|
|||
s: T,
|
||||
type_: glib::Type,
|
||||
) -> Result<glib::Value, glib::BoolError>;
|
||||
#[cfg(any(feature = "v1_20", feature = "dox"))]
|
||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))]
|
||||
#[doc(alias = "gst_value_deserialize_with_pspec")]
|
||||
fn deserialize_with_pspec<'a, T: Into<&'a str>>(
|
||||
s: T,
|
||||
pspec: &glib::ParamSpec,
|
||||
) -> Result<glib::Value, glib::BoolError>;
|
||||
}
|
||||
|
||||
impl GstValueExt for glib::Value {
|
||||
|
@ -1000,6 +1007,31 @@ impl GstValueExt for glib::Value {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "v1_20", feature = "dox"))]
|
||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))]
|
||||
fn deserialize_with_pspec<'a, T: Into<&'a str>>(
|
||||
s: T,
|
||||
pspec: &glib::ParamSpec,
|
||||
) -> Result<glib::Value, glib::BoolError> {
|
||||
assert_initialized_main_thread!();
|
||||
|
||||
let s = s.into();
|
||||
|
||||
unsafe {
|
||||
let mut value = glib::Value::from_type(pspec.value_type());
|
||||
let ret: bool = from_glib(ffi::gst_value_deserialize_with_pspec(
|
||||
value.to_glib_none_mut().0,
|
||||
s.to_glib_none().0,
|
||||
pspec.to_glib_none().0,
|
||||
));
|
||||
if ret {
|
||||
Ok(value)
|
||||
} else {
|
||||
Err(glib::bool_error!("Failed to deserialize value"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
Loading…
Reference in a new issue