diff --git a/gstreamer-video/Gir.toml b/gstreamer-video/Gir.toml index 75f63ec2d..24e9ba12a 100644 --- a/gstreamer-video/Gir.toml +++ b/gstreamer-video/Gir.toml @@ -17,6 +17,9 @@ external_libraries = [ ] generate = [ + "GstVideo.ColorBalance", + "GstVideo.ColorBalanceChannel", + "GstVideo.ColorBalanceType", "GstVideo.VideoAFDSpec", "GstVideo.VideoAFDValue", "GstVideo.VideoAggregatorParallelConvertPad", diff --git a/gstreamer-video/src/auto/color_balance.rs b/gstreamer-video/src/auto/color_balance.rs new file mode 100644 index 000000000..6b2520bc2 --- /dev/null +++ b/gstreamer-video/src/auto/color_balance.rs @@ -0,0 +1,135 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +use crate::ColorBalanceChannel; +use crate::ColorBalanceType; +use glib::object::Cast; +use glib::object::IsA; +use glib::signal::connect_raw; +use glib::signal::SignalHandlerId; +use glib::translate::*; +use std::boxed::Box as Box_; +use std::mem::transmute; + +glib::wrapper! { + #[doc(alias = "GstColorBalance")] + pub struct ColorBalance(Interface); + + match fn { + type_ => || ffi::gst_color_balance_get_type(), + } +} + +unsafe impl Send for ColorBalance {} +unsafe impl Sync for ColorBalance {} + +impl ColorBalance { + pub const NONE: Option<&'static ColorBalance> = None; +} + +pub trait ColorBalanceExt: 'static { + #[doc(alias = "gst_color_balance_get_balance_type")] + #[doc(alias = "get_balance_type")] + fn balance_type(&self) -> ColorBalanceType; + + #[doc(alias = "gst_color_balance_get_value")] + #[doc(alias = "get_value")] + fn value(&self, channel: &impl IsA) -> i32; + + #[doc(alias = "gst_color_balance_list_channels")] + fn list_channels(&self) -> Vec; + + #[doc(alias = "gst_color_balance_set_value")] + fn set_value(&self, channel: &impl IsA, value: i32); + + #[doc(alias = "gst_color_balance_value_changed")] + fn value_changed(&self, channel: &impl IsA, value: i32); + + #[doc(alias = "value-changed")] + fn connect_value_changed( + &self, + f: F, + ) -> SignalHandlerId; +} + +impl> ColorBalanceExt for O { + fn balance_type(&self) -> ColorBalanceType { + unsafe { + from_glib(ffi::gst_color_balance_get_balance_type( + self.as_ref().to_glib_none().0, + )) + } + } + + fn value(&self, channel: &impl IsA) -> i32 { + unsafe { + ffi::gst_color_balance_get_value( + self.as_ref().to_glib_none().0, + channel.as_ref().to_glib_none().0, + ) + } + } + + fn list_channels(&self) -> Vec { + unsafe { + FromGlibPtrContainer::from_glib_none(ffi::gst_color_balance_list_channels( + self.as_ref().to_glib_none().0, + )) + } + } + + fn set_value(&self, channel: &impl IsA, value: i32) { + unsafe { + ffi::gst_color_balance_set_value( + self.as_ref().to_glib_none().0, + channel.as_ref().to_glib_none().0, + value, + ); + } + } + + fn value_changed(&self, channel: &impl IsA, value: i32) { + unsafe { + ffi::gst_color_balance_value_changed( + self.as_ref().to_glib_none().0, + channel.as_ref().to_glib_none().0, + value, + ); + } + } + + fn connect_value_changed( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn value_changed_trampoline< + P: IsA, + F: Fn(&P, &ColorBalanceChannel, i32) + Send + Sync + 'static, + >( + this: *mut ffi::GstColorBalance, + channel: *mut ffi::GstColorBalanceChannel, + value: libc::c_int, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f( + ColorBalance::from_glib_borrow(this).unsafe_cast_ref(), + &from_glib_borrow(channel), + value, + ) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"value-changed\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + value_changed_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } +} diff --git a/gstreamer-video/src/auto/color_balance_channel.rs b/gstreamer-video/src/auto/color_balance_channel.rs new file mode 100644 index 000000000..e423a83f3 --- /dev/null +++ b/gstreamer-video/src/auto/color_balance_channel.rs @@ -0,0 +1,69 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +use glib::object::Cast; +use glib::object::IsA; +use glib::signal::connect_raw; +use glib::signal::SignalHandlerId; +use glib::translate::*; +use std::boxed::Box as Box_; +use std::mem::transmute; + +glib::wrapper! { + #[doc(alias = "GstColorBalanceChannel")] + pub struct ColorBalanceChannel(Object); + + match fn { + type_ => || ffi::gst_color_balance_channel_get_type(), + } +} + +unsafe impl Send for ColorBalanceChannel {} +unsafe impl Sync for ColorBalanceChannel {} + +impl ColorBalanceChannel { + pub const NONE: Option<&'static ColorBalanceChannel> = None; +} + +pub trait ColorBalanceChannelExt: 'static { + #[doc(alias = "value-changed")] + fn connect_value_changed( + &self, + f: F, + ) -> SignalHandlerId; +} + +impl> ColorBalanceChannelExt for O { + fn connect_value_changed( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn value_changed_trampoline< + P: IsA, + F: Fn(&P, i32) + Send + Sync + 'static, + >( + this: *mut ffi::GstColorBalanceChannel, + value: libc::c_int, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f( + ColorBalanceChannel::from_glib_borrow(this).unsafe_cast_ref(), + value, + ) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + b"value-changed\0".as_ptr() as *const _, + Some(transmute::<_, unsafe extern "C" fn()>( + value_changed_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } +} diff --git a/gstreamer-video/src/auto/enums.rs b/gstreamer-video/src/auto/enums.rs index 7d1418eb3..7a05ba005 100644 --- a/gstreamer-video/src/auto/enums.rs +++ b/gstreamer-video/src/auto/enums.rs @@ -11,6 +11,76 @@ use glib::Type; use std::ffi::CStr; use std::fmt; +#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] +#[non_exhaustive] +#[doc(alias = "GstColorBalanceType")] +pub enum ColorBalanceType { + #[doc(alias = "GST_COLOR_BALANCE_HARDWARE")] + Hardware, + #[doc(alias = "GST_COLOR_BALANCE_SOFTWARE")] + Software, + #[doc(hidden)] + __Unknown(i32), +} + +#[doc(hidden)] +impl IntoGlib for ColorBalanceType { + type GlibType = ffi::GstColorBalanceType; + + fn into_glib(self) -> ffi::GstColorBalanceType { + match self { + Self::Hardware => ffi::GST_COLOR_BALANCE_HARDWARE, + Self::Software => ffi::GST_COLOR_BALANCE_SOFTWARE, + Self::__Unknown(value) => value, + } + } +} + +#[doc(hidden)] +impl FromGlib for ColorBalanceType { + unsafe fn from_glib(value: ffi::GstColorBalanceType) -> Self { + skip_assert_initialized!(); + match value { + ffi::GST_COLOR_BALANCE_HARDWARE => Self::Hardware, + ffi::GST_COLOR_BALANCE_SOFTWARE => Self::Software, + value => Self::__Unknown(value), + } + } +} + +impl StaticType for ColorBalanceType { + fn static_type() -> Type { + unsafe { from_glib(ffi::gst_color_balance_type_get_type()) } + } +} + +impl glib::value::ValueType for ColorBalanceType { + type Type = Self; +} + +unsafe impl<'a> FromValue<'a> for ColorBalanceType { + type Checker = glib::value::GenericValueTypeChecker; + + unsafe fn from_value(value: &'a glib::Value) -> Self { + skip_assert_initialized!(); + from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) + } +} + +impl ToValue for ColorBalanceType { + fn to_value(&self) -> glib::Value { + let mut value = glib::Value::for_value_type::(); + unsafe { + glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); + } + value + } + + fn value_type(&self) -> glib::Type { + Self::static_type() + } +} + #[cfg(any(feature = "v1_18", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))] #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] diff --git a/gstreamer-video/src/auto/mod.rs b/gstreamer-video/src/auto/mod.rs index cca809fc0..ca2a10b66 100644 --- a/gstreamer-video/src/auto/mod.rs +++ b/gstreamer-video/src/auto/mod.rs @@ -3,6 +3,12 @@ // from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) // DO NOT EDIT +mod color_balance; +pub use self::color_balance::ColorBalance; + +mod color_balance_channel; +pub use self::color_balance_channel::ColorBalanceChannel; + #[cfg(any(feature = "v1_20", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))] mod video_aggregator_parallel_convert_pad; @@ -32,6 +38,7 @@ mod video_sink; pub use self::video_sink::VideoSink; mod enums; +pub use self::enums::ColorBalanceType; #[cfg(any(feature = "v1_18", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))] pub use self::enums::VideoAFDSpec; @@ -82,6 +89,8 @@ pub use self::flags::VideoTimeCodeFlags; #[doc(hidden)] pub mod traits { + pub use super::color_balance::ColorBalanceExt; + pub use super::color_balance_channel::ColorBalanceChannelExt; pub use super::video_decoder::VideoDecoderExt; pub use super::video_encoder::VideoEncoderExt; pub use super::video_orientation::VideoOrientationExt; diff --git a/gstreamer-video/src/color_balance_channel.rs b/gstreamer-video/src/color_balance_channel.rs new file mode 100644 index 000000000..14f0408fd --- /dev/null +++ b/gstreamer-video/src/color_balance_channel.rs @@ -0,0 +1,19 @@ +// Take a look at the license at the top of the repository in the LICENSE file. + +use crate::ColorBalanceChannel; +use glib::prelude::*; +use glib::translate::*; + +impl ColorBalanceChannel { + pub fn label(&self) -> glib::GString { + unsafe { from_glib_none((*self.as_ptr()).label) } + } + + pub fn min_value(&self) -> i32 { + unsafe { (*self.as_ptr()).min_value } + } + + pub fn max_value(&self) -> i32 { + unsafe { (*self.as_ptr()).max_value } + } +} diff --git a/gstreamer-video/src/lib.rs b/gstreamer-video/src/lib.rs index 6a20b5112..6cd578fd2 100644 --- a/gstreamer-video/src/lib.rs +++ b/gstreamer-video/src/lib.rs @@ -114,6 +114,8 @@ mod video_hdr; #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))] pub use crate::video_hdr::*; +mod color_balance_channel; + pub const VIDEO_ENCODER_FLOW_NEED_DATA: gst::FlowSuccess = gst::FlowSuccess::CustomSuccess; pub const VIDEO_DECODER_FLOW_NEED_DATA: gst::FlowSuccess = gst::FlowSuccess::CustomSuccess;