mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-22 17:41:05 +00:00
video/videoconverter: Add TryFrom<Structure> and inverse From impl for VideoConverterConfig
Allows converting between both types interchangebly.
This commit is contained in:
parent
02a43819a7
commit
f0e12bbf24
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;
|
||||
|
||||
|
@ -139,6 +140,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