forked from mirrors/gstreamer-rs
video/videoconverter: Add TryFrom<Structure> and inverse From impl for VideoConverterConfig
Allows converting between both types interchangebly.
This commit is contained in:
parent
487970f620
commit
8e96888c63
1 changed files with 30 additions and 0 deletions
|
@ -12,6 +12,7 @@ use glib;
|
|||
use glib::translate::ToGlibPtr;
|
||||
use gst;
|
||||
|
||||
use std::convert;
|
||||
use std::ops;
|
||||
use std::ptr;
|
||||
|
||||
|
@ -138,6 +139,35 @@ impl Default for VideoConverterConfig {
|
|||
}
|
||||
}
|
||||
|
||||
impl convert::TryFrom<gst::Structure> for VideoConverterConfig {
|
||||
type Error = glib::BoolError;
|
||||
|
||||
fn try_from(v: gst::Structure) -> Result<VideoConverterConfig, Self::Error> {
|
||||
skip_assert_initialized!();
|
||||
if v.get_name() == "GstVideoConverter" {
|
||||
Ok(VideoConverterConfig(v))
|
||||
} else {
|
||||
Err(glib_bool_error!("Structure is no VideoConverterConfig"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> convert::TryFrom<&'a gst::StructureRef> for VideoConverterConfig {
|
||||
type Error = glib::BoolError;
|
||||
|
||||
fn try_from(v: &'a gst::StructureRef) -> Result<VideoConverterConfig, Self::Error> {
|
||||
skip_assert_initialized!();
|
||||
VideoConverterConfig::try_from(v.to_owned())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<VideoConverterConfig> for gst::Structure {
|
||||
fn from(v: VideoConverterConfig) -> gst::Structure {
|
||||
skip_assert_initialized!();
|
||||
v.0
|
||||
}
|
||||
}
|
||||
|
||||
impl VideoConverterConfig {
|
||||
pub fn new() -> Self {
|
||||
VideoConverterConfig(gst::Structure::new_empty("GstVideoConverter"))
|
||||
|
|
Loading…
Reference in a new issue