From 474749598e2d479a7492830d1d7e61ffcc5ee85a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 14 Aug 2017 22:15:37 +0300 Subject: [PATCH] Add GstElementFlags and suppressed_flags API of GstBin --- Gir_Gst.toml | 1 + gstreamer/src/auto/bin.rs | 30 ++++++++++++--------- gstreamer/src/auto/flags.rs | 53 +++++++++++++++++++++++++++++++++++++ gstreamer/src/auto/mod.rs | 8 ++++++ 4 files changed, 80 insertions(+), 12 deletions(-) diff --git a/Gir_Gst.toml b/Gir_Gst.toml index 4d33be4be..3d5d50599 100644 --- a/Gir_Gst.toml +++ b/Gir_Gst.toml @@ -67,6 +67,7 @@ generate = [ "Gst.TocSetter", "Gst.ClockType", "Gst.ClockReturn", + "Gst.ElementFlags", ] manual = [ diff --git a/gstreamer/src/auto/bin.rs b/gstreamer/src/auto/bin.rs index 6aa2240e3..5de138752 100644 --- a/gstreamer/src/auto/bin.rs +++ b/gstreamer/src/auto/bin.rs @@ -3,6 +3,8 @@ use ChildProxy; use Element; +#[cfg(feature = "v1_10")] +use ElementFlags; use Iterator; use Object; use Pad; @@ -56,8 +58,8 @@ pub trait BinExt { fn get_by_name_recurse_up(&self, name: &str) -> Option; - //#[cfg(feature = "v1_10")] - //fn get_suppressed_flags(&self) -> /*Ignored*/ElementFlags; + #[cfg(feature = "v1_10")] + fn get_suppressed_flags(&self) -> ElementFlags; fn iterate_all_by_interface(&self, iface: glib::types::Type) -> Option; @@ -77,8 +79,8 @@ pub trait BinExt { //fn remove_many>(&self, element_1: &P, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs); - //#[cfg(feature = "v1_10")] - //fn set_suppressed_flags(&self, flags: /*Ignored*/ElementFlags); + #[cfg(feature = "v1_10")] + fn set_suppressed_flags(&self, flags: ElementFlags); fn sync_children_states(&self) -> Result<(), glib::error::BoolError>; @@ -138,10 +140,12 @@ impl + IsA> BinExt for O { } } - //#[cfg(feature = "v1_10")] - //fn get_suppressed_flags(&self) -> /*Ignored*/ElementFlags { - // unsafe { TODO: call ffi::gst_bin_get_suppressed_flags() } - //} + #[cfg(feature = "v1_10")] + fn get_suppressed_flags(&self) -> ElementFlags { + unsafe { + from_glib(ffi::gst_bin_get_suppressed_flags(self.to_glib_none().0)) + } + } fn iterate_all_by_interface(&self, iface: glib::types::Type) -> Option { unsafe { @@ -195,10 +199,12 @@ impl + IsA> BinExt for O { // unsafe { TODO: call ffi::gst_bin_remove_many() } //} - //#[cfg(feature = "v1_10")] - //fn set_suppressed_flags(&self, flags: /*Ignored*/ElementFlags) { - // unsafe { TODO: call ffi::gst_bin_set_suppressed_flags() } - //} + #[cfg(feature = "v1_10")] + fn set_suppressed_flags(&self, flags: ElementFlags) { + unsafe { + ffi::gst_bin_set_suppressed_flags(self.to_glib_none().0, flags.to_glib()); + } + } fn sync_children_states(&self) -> Result<(), glib::error::BoolError> { unsafe { diff --git a/gstreamer/src/auto/flags.rs b/gstreamer/src/auto/flags.rs index 7eec3417b..fd511f571 100644 --- a/gstreamer/src/auto/flags.rs +++ b/gstreamer/src/auto/flags.rs @@ -67,6 +67,59 @@ impl SetValue for BufferFlags { } } +bitflags! { + pub struct ElementFlags: u32 { + const ELEMENT_FLAG_LOCKED_STATE = 16; + const ELEMENT_FLAG_SINK = 32; + const ELEMENT_FLAG_SOURCE = 64; + const ELEMENT_FLAG_PROVIDE_CLOCK = 128; + const ELEMENT_FLAG_REQUIRE_CLOCK = 256; + const ELEMENT_FLAG_INDEXABLE = 512; + const ELEMENT_FLAG_LAST = 16384; + } +} + +#[doc(hidden)] +impl ToGlib for ElementFlags { + type GlibType = ffi::GstElementFlags; + + fn to_glib(&self) -> ffi::GstElementFlags { + ffi::GstElementFlags::from_bits_truncate(self.bits()) + } +} + +#[doc(hidden)] +impl FromGlib for ElementFlags { + fn from_glib(value: ffi::GstElementFlags) -> ElementFlags { + skip_assert_initialized!(); + ElementFlags::from_bits_truncate(value.bits()) + } +} + +impl StaticType for ElementFlags { + fn static_type() -> Type { + unsafe { from_glib(ffi::gst_element_flags_get_type()) } + } +} + +impl<'a> FromValueOptional<'a> for ElementFlags { + unsafe fn from_value_optional(value: &Value) -> Option { + Some(FromValue::from_value(value)) + } +} + +impl<'a> FromValue<'a> for ElementFlags { + unsafe fn from_value(value: &Value) -> Self { + from_glib(ffi::GstElementFlags::from_bits_truncate(gobject_ffi::g_value_get_flags(value.to_glib_none().0))) + } +} + +impl SetValue for ElementFlags { + unsafe fn set_value(value: &mut Value, this: &Self) { + gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, this.to_glib().bits()) + } +} + bitflags! { pub struct PadProbeType: u32 { const PAD_PROBE_TYPE_INVALID = 0; diff --git a/gstreamer/src/auto/mod.rs b/gstreamer/src/auto/mod.rs index da5bff8c8..8d6dae78a 100644 --- a/gstreamer/src/auto/mod.rs +++ b/gstreamer/src/auto/mod.rs @@ -154,6 +154,14 @@ pub use self::flags::BUFFER_FLAG_DELTA_UNIT; pub use self::flags::BUFFER_FLAG_TAG_MEMORY; pub use self::flags::BUFFER_FLAG_SYNC_AFTER; pub use self::flags::BUFFER_FLAG_LAST; +pub use self::flags::ElementFlags; +pub use self::flags::ELEMENT_FLAG_LOCKED_STATE; +pub use self::flags::ELEMENT_FLAG_SINK; +pub use self::flags::ELEMENT_FLAG_SOURCE; +pub use self::flags::ELEMENT_FLAG_PROVIDE_CLOCK; +pub use self::flags::ELEMENT_FLAG_REQUIRE_CLOCK; +pub use self::flags::ELEMENT_FLAG_INDEXABLE; +pub use self::flags::ELEMENT_FLAG_LAST; pub use self::flags::PadProbeType; pub use self::flags::PAD_PROBE_TYPE_INVALID; pub use self::flags::PAD_PROBE_TYPE_IDLE;