From 0ea48e9894894585b903fabff425cb952dbcf9df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 19 Feb 2021 18:42:38 +0200 Subject: [PATCH] gstreamer-video: Add support for VideoOrientation interface and VideoOrientationMethod enum --- gstreamer-video/Gir.toml | 21 +++ gstreamer-video/src/auto/enums.rs | 107 ++++++++++++ gstreamer-video/src/auto/mod.rs | 8 + gstreamer-video/src/auto/versions.txt | 4 +- gstreamer-video/src/auto/video_orientation.rs | 154 ++++++++++++++++++ gstreamer-video/sys/build.rs | 4 +- gstreamer-video/sys/src/lib.rs | 4 +- gstreamer-video/sys/tests/abi.rs | 4 +- gstreamer-video/sys/tests/constant.c | 4 +- gstreamer-video/sys/tests/layout.c | 4 +- 10 files changed, 302 insertions(+), 12 deletions(-) create mode 100644 gstreamer-video/src/auto/video_orientation.rs diff --git a/gstreamer-video/Gir.toml b/gstreamer-video/Gir.toml index a055f4199..43b28e626 100644 --- a/gstreamer-video/Gir.toml +++ b/gstreamer-video/Gir.toml @@ -27,6 +27,7 @@ generate = [ "GstVideo.VideoAlphaMode", "GstVideo.VideoChromaMode", "GstVideo.VideoMatrixMode", + "GstVideo.VideoOrientationMethod", "GstVideo.VideoGammaMode", "GstVideo.VideoPrimariesMode", "GstVideo.VideoResamplerMethod", @@ -72,6 +73,26 @@ name = "Gst.Caps" status = "manual" ref_mode = "ref" +[[object]] +name = "GstVideo.VideoOrientation" +status = "generate" + [[object.function]] + name = "set_hcenter" + [object.function.return] + bool_return_is_error = "Failed to set horizontal centering" + [[object.function]] + name = "set_hflip" + [object.function.return] + bool_return_is_error = "Failed to set horizontal flipping" + [[object.function]] + name = "set_vcenter" + [object.function.return] + bool_return_is_error = "Failed to set vertical centering" + [[object.function]] + name = "set_vflip" + [object.function.return] + bool_return_is_error = "Failed to set vertical flipping" + [[object]] name = "GstVideo.VideoOverlay" status = "generate" diff --git a/gstreamer-video/src/auto/enums.rs b/gstreamer-video/src/auto/enums.rs index 46b8c1624..b836169d7 100644 --- a/gstreamer-video/src/auto/enums.rs +++ b/gstreamer-video/src/auto/enums.rs @@ -1967,6 +1967,113 @@ impl SetValue for VideoMultiviewMode { } } +#[cfg(any(feature = "v1_10", feature = "dox"))] +#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] +#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] +#[non_exhaustive] +#[doc(alias = "GstVideoOrientationMethod")] +pub enum VideoOrientationMethod { + #[doc(alias = "GST_VIDEO_ORIENTATION_IDENTITY")] + Identity, + #[doc(alias = "GST_VIDEO_ORIENTATION_90R")] + _90r, + #[doc(alias = "GST_VIDEO_ORIENTATION_180")] + _180, + #[doc(alias = "GST_VIDEO_ORIENTATION_90L")] + _90l, + #[doc(alias = "GST_VIDEO_ORIENTATION_HORIZ")] + Horiz, + #[doc(alias = "GST_VIDEO_ORIENTATION_VERT")] + Vert, + #[doc(alias = "GST_VIDEO_ORIENTATION_UL_LR")] + UlLr, + #[doc(alias = "GST_VIDEO_ORIENTATION_UR_LL")] + UrLl, + #[doc(alias = "GST_VIDEO_ORIENTATION_AUTO")] + Auto, + #[doc(alias = "GST_VIDEO_ORIENTATION_CUSTOM")] + Custom, + #[doc(hidden)] + __Unknown(i32), +} + +#[cfg(any(feature = "v1_10", feature = "dox"))] +#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] +#[doc(hidden)] +impl ToGlib for VideoOrientationMethod { + type GlibType = ffi::GstVideoOrientationMethod; + + fn to_glib(&self) -> ffi::GstVideoOrientationMethod { + match *self { + VideoOrientationMethod::Identity => ffi::GST_VIDEO_ORIENTATION_IDENTITY, + VideoOrientationMethod::_90r => ffi::GST_VIDEO_ORIENTATION_90R, + VideoOrientationMethod::_180 => ffi::GST_VIDEO_ORIENTATION_180, + VideoOrientationMethod::_90l => ffi::GST_VIDEO_ORIENTATION_90L, + VideoOrientationMethod::Horiz => ffi::GST_VIDEO_ORIENTATION_HORIZ, + VideoOrientationMethod::Vert => ffi::GST_VIDEO_ORIENTATION_VERT, + VideoOrientationMethod::UlLr => ffi::GST_VIDEO_ORIENTATION_UL_LR, + VideoOrientationMethod::UrLl => ffi::GST_VIDEO_ORIENTATION_UR_LL, + VideoOrientationMethod::Auto => ffi::GST_VIDEO_ORIENTATION_AUTO, + VideoOrientationMethod::Custom => ffi::GST_VIDEO_ORIENTATION_CUSTOM, + VideoOrientationMethod::__Unknown(value) => value, + } + } +} + +#[cfg(any(feature = "v1_10", feature = "dox"))] +#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] +#[doc(hidden)] +impl FromGlib for VideoOrientationMethod { + unsafe fn from_glib(value: ffi::GstVideoOrientationMethod) -> Self { + skip_assert_initialized!(); + match value { + 0 => VideoOrientationMethod::Identity, + 1 => VideoOrientationMethod::_90r, + 2 => VideoOrientationMethod::_180, + 3 => VideoOrientationMethod::_90l, + 4 => VideoOrientationMethod::Horiz, + 5 => VideoOrientationMethod::Vert, + 6 => VideoOrientationMethod::UlLr, + 7 => VideoOrientationMethod::UrLl, + 8 => VideoOrientationMethod::Auto, + 9 => VideoOrientationMethod::Custom, + value => VideoOrientationMethod::__Unknown(value), + } + } +} + +#[cfg(any(feature = "v1_10", feature = "dox"))] +#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] +impl StaticType for VideoOrientationMethod { + fn static_type() -> Type { + unsafe { from_glib(ffi::gst_video_orientation_method_get_type()) } + } +} + +#[cfg(any(feature = "v1_10", feature = "dox"))] +#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] +impl<'a> FromValueOptional<'a> for VideoOrientationMethod { + unsafe fn from_value_optional(value: &glib::Value) -> Option { + Some(FromValue::from_value(value)) + } +} + +#[cfg(any(feature = "v1_10", feature = "dox"))] +#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] +impl<'a> FromValue<'a> for VideoOrientationMethod { + unsafe fn from_value(value: &glib::Value) -> Self { + from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) + } +} + +#[cfg(any(feature = "v1_10", feature = "dox"))] +#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] +impl SetValue for VideoOrientationMethod { + unsafe fn set_value(value: &mut glib::Value, this: &Self) { + glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib()) + } +} + #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GstVideoPrimariesMode")] diff --git a/gstreamer-video/src/auto/mod.rs b/gstreamer-video/src/auto/mod.rs index 1d803e2fc..0a2d86bb1 100644 --- a/gstreamer-video/src/auto/mod.rs +++ b/gstreamer-video/src/auto/mod.rs @@ -16,6 +16,10 @@ pub use self::video_encoder::{VideoEncoder, NONE_VIDEO_ENCODER}; mod video_filter; pub use self::video_filter::{VideoFilter, NONE_VIDEO_FILTER}; +mod video_orientation; +pub use self::video_orientation::VideoOrientationExt; +pub use self::video_orientation::{VideoOrientation, NONE_VIDEO_ORIENTATION}; + mod video_overlay; pub use self::video_overlay::VideoOverlayExt; pub use self::video_overlay::{VideoOverlay, NONE_VIDEO_OVERLAY}; @@ -48,6 +52,9 @@ pub use self::enums::VideoInterlaceMode; pub use self::enums::VideoMatrixMode; pub use self::enums::VideoMultiviewFramePacking; pub use self::enums::VideoMultiviewMode; +#[cfg(any(feature = "v1_10", feature = "dox"))] +#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] +pub use self::enums::VideoOrientationMethod; pub use self::enums::VideoPrimariesMode; pub use self::enums::VideoResamplerMethod; pub use self::enums::VideoTileMode; @@ -71,6 +78,7 @@ pub use self::flags::VideoTimeCodeFlags; pub mod traits { pub use super::VideoDecoderExt; pub use super::VideoEncoderExt; + pub use super::VideoOrientationExt; pub use super::VideoOverlayExt; pub use super::VideoSinkExt; } diff --git a/gstreamer-video/src/auto/versions.txt b/gstreamer-video/src/auto/versions.txt index 15a504bb4..3d54b6135 100644 --- a/gstreamer-video/src/auto/versions.txt +++ b/gstreamer-video/src/auto/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ 1c7b41a) -from gir-files (https://github.com/gtk-rs/gir-files @ 3c0281db) +Generated by gir (https://github.com/gtk-rs/gir @ d8408d8) +from gir-files (https://github.com/gtk-rs/gir-files @ 59d91b2a) diff --git a/gstreamer-video/src/auto/video_orientation.rs b/gstreamer-video/src/auto/video_orientation.rs new file mode 100644 index 000000000..47807590a --- /dev/null +++ b/gstreamer-video/src/auto/video_orientation.rs @@ -0,0 +1,154 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +use glib::object::IsA; +use glib::translate::*; +use std::mem; + +glib::wrapper! { + pub struct VideoOrientation(Interface); + + match fn { + get_type => || ffi::gst_video_orientation_get_type(), + } +} + +unsafe impl Send for VideoOrientation {} +unsafe impl Sync for VideoOrientation {} + +pub const NONE_VIDEO_ORIENTATION: Option<&VideoOrientation> = None; + +pub trait VideoOrientationExt: 'static { + #[doc(alias = "gst_video_orientation_get_hcenter")] + fn get_hcenter(&self) -> Option; + + #[doc(alias = "gst_video_orientation_get_hflip")] + fn get_hflip(&self) -> Option; + + #[doc(alias = "gst_video_orientation_get_vcenter")] + fn get_vcenter(&self) -> Option; + + #[doc(alias = "gst_video_orientation_get_vflip")] + fn get_vflip(&self) -> Option; + + #[doc(alias = "gst_video_orientation_set_hcenter")] + fn set_hcenter(&self, center: i32) -> Result<(), glib::error::BoolError>; + + #[doc(alias = "gst_video_orientation_set_hflip")] + fn set_hflip(&self, flip: bool) -> Result<(), glib::error::BoolError>; + + #[doc(alias = "gst_video_orientation_set_vcenter")] + fn set_vcenter(&self, center: i32) -> Result<(), glib::error::BoolError>; + + #[doc(alias = "gst_video_orientation_set_vflip")] + fn set_vflip(&self, flip: bool) -> Result<(), glib::error::BoolError>; +} + +impl> VideoOrientationExt for O { + fn get_hcenter(&self) -> Option { + unsafe { + let mut center = mem::MaybeUninit::uninit(); + let ret = from_glib(ffi::gst_video_orientation_get_hcenter( + self.as_ref().to_glib_none().0, + center.as_mut_ptr(), + )); + let center = center.assume_init(); + if ret { + Some(center) + } else { + None + } + } + } + + fn get_hflip(&self) -> Option { + unsafe { + let mut flip = mem::MaybeUninit::uninit(); + let ret = from_glib(ffi::gst_video_orientation_get_hflip( + self.as_ref().to_glib_none().0, + flip.as_mut_ptr(), + )); + let flip = flip.assume_init(); + if ret { + Some(from_glib(flip)) + } else { + None + } + } + } + + fn get_vcenter(&self) -> Option { + unsafe { + let mut center = mem::MaybeUninit::uninit(); + let ret = from_glib(ffi::gst_video_orientation_get_vcenter( + self.as_ref().to_glib_none().0, + center.as_mut_ptr(), + )); + let center = center.assume_init(); + if ret { + Some(center) + } else { + None + } + } + } + + fn get_vflip(&self) -> Option { + unsafe { + let mut flip = mem::MaybeUninit::uninit(); + let ret = from_glib(ffi::gst_video_orientation_get_vflip( + self.as_ref().to_glib_none().0, + flip.as_mut_ptr(), + )); + let flip = flip.assume_init(); + if ret { + Some(from_glib(flip)) + } else { + None + } + } + } + + fn set_hcenter(&self, center: i32) -> Result<(), glib::error::BoolError> { + unsafe { + glib::result_from_gboolean!( + ffi::gst_video_orientation_set_hcenter(self.as_ref().to_glib_none().0, center), + "Failed to set horizontal centering" + ) + } + } + + fn set_hflip(&self, flip: bool) -> Result<(), glib::error::BoolError> { + unsafe { + glib::result_from_gboolean!( + ffi::gst_video_orientation_set_hflip( + self.as_ref().to_glib_none().0, + flip.to_glib() + ), + "Failed to set horizontal flipping" + ) + } + } + + fn set_vcenter(&self, center: i32) -> Result<(), glib::error::BoolError> { + unsafe { + glib::result_from_gboolean!( + ffi::gst_video_orientation_set_vcenter(self.as_ref().to_glib_none().0, center), + "Failed to set vertical centering" + ) + } + } + + fn set_vflip(&self, flip: bool) -> Result<(), glib::error::BoolError> { + unsafe { + glib::result_from_gboolean!( + ffi::gst_video_orientation_set_vflip( + self.as_ref().to_glib_none().0, + flip.to_glib() + ), + "Failed to set vertical flipping" + ) + } + } +} diff --git a/gstreamer-video/sys/build.rs b/gstreamer-video/sys/build.rs index be8544dff..43c15118f 100644 --- a/gstreamer-video/sys/build.rs +++ b/gstreamer-video/sys/build.rs @@ -1,5 +1,5 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir @ 1c7b41a) -// from gir-files (https://github.com/gtk-rs/gir-files @ 3c0281db) +// This file was generated by gir (https://github.com/gtk-rs/gir @ d8408d8) +// from gir-files (https://github.com/gtk-rs/gir-files @ 59d91b2a) // DO NOT EDIT #[cfg(not(feature = "dox"))] diff --git a/gstreamer-video/sys/src/lib.rs b/gstreamer-video/sys/src/lib.rs index 295b3d61e..f847243e8 100644 --- a/gstreamer-video/sys/src/lib.rs +++ b/gstreamer-video/sys/src/lib.rs @@ -1,5 +1,5 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir @ 1c7b41a) -// from gir-files (https://github.com/gtk-rs/gir-files @ 3c0281db) +// This file was generated by gir (https://github.com/gtk-rs/gir @ d8408d8) +// from gir-files (https://github.com/gtk-rs/gir-files @ 59d91b2a) // DO NOT EDIT #![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)] diff --git a/gstreamer-video/sys/tests/abi.rs b/gstreamer-video/sys/tests/abi.rs index 6b6fda351..2d286847f 100644 --- a/gstreamer-video/sys/tests/abi.rs +++ b/gstreamer-video/sys/tests/abi.rs @@ -1,5 +1,5 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir @ 1c7b41a) -// from gir-files (https://github.com/gtk-rs/gir-files @ 3c0281db) +// This file was generated by gir (https://github.com/gtk-rs/gir @ d8408d8) +// from gir-files (https://github.com/gtk-rs/gir-files @ 59d91b2a) // DO NOT EDIT use gstreamer_video_sys::*; diff --git a/gstreamer-video/sys/tests/constant.c b/gstreamer-video/sys/tests/constant.c index 597e389d5..d109a0e01 100644 --- a/gstreamer-video/sys/tests/constant.c +++ b/gstreamer-video/sys/tests/constant.c @@ -1,5 +1,5 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir @ 1c7b41a) -// from gir-files (https://github.com/gtk-rs/gir-files @ 3c0281db) +// This file was generated by gir (https://github.com/gtk-rs/gir @ d8408d8) +// from gir-files (https://github.com/gtk-rs/gir-files @ 59d91b2a) // DO NOT EDIT #include "manual.h" diff --git a/gstreamer-video/sys/tests/layout.c b/gstreamer-video/sys/tests/layout.c index b496d9af2..8ef5b6b24 100644 --- a/gstreamer-video/sys/tests/layout.c +++ b/gstreamer-video/sys/tests/layout.c @@ -1,5 +1,5 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir @ 1c7b41a) -// from gir-files (https://github.com/gtk-rs/gir-files @ 3c0281db) +// This file was generated by gir (https://github.com/gtk-rs/gir @ d8408d8) +// from gir-files (https://github.com/gtk-rs/gir-files @ 59d91b2a) // DO NOT EDIT #include "manual.h"