diff --git a/Gir_Gst.toml b/Gir_Gst.toml index 3d5d50599..6f1c355ce 100644 --- a/Gir_Gst.toml +++ b/Gir_Gst.toml @@ -68,6 +68,7 @@ generate = [ "Gst.ClockType", "Gst.ClockReturn", "Gst.ElementFlags", + "Gst.Rank", ] manual = [ diff --git a/gstreamer/src/auto/device_provider_factory.rs b/gstreamer/src/auto/device_provider_factory.rs index 02c094431..b367eb15a 100644 --- a/gstreamer/src/auto/device_provider_factory.rs +++ b/gstreamer/src/auto/device_provider_factory.rs @@ -3,6 +3,7 @@ use DeviceProvider; use Object; +use Rank; use ffi; use glib; use glib::object::IsA; @@ -35,9 +36,12 @@ impl DeviceProviderFactory { } } - //pub fn list_get_device_providers(minrank: /*Ignored*/Rank) -> Vec { - // unsafe { TODO: call ffi::gst_device_provider_factory_list_get_device_providers() } - //} + pub fn list_get_device_providers(minrank: Rank) -> Vec { + assert_initialized_main_thread!(); + unsafe { + FromGlibPtrContainer::from_glib_full(ffi::gst_device_provider_factory_list_get_device_providers(minrank.to_glib())) + } + } } unsafe impl Send for DeviceProviderFactory {} diff --git a/gstreamer/src/auto/element_factory.rs b/gstreamer/src/auto/element_factory.rs index fee7c381c..0807015f8 100644 --- a/gstreamer/src/auto/element_factory.rs +++ b/gstreamer/src/auto/element_factory.rs @@ -6,6 +6,7 @@ use Element; use ElementFactoryListType; use Object; use PadDirection; +use Rank; use URIType; use ffi; use glib; @@ -122,9 +123,12 @@ impl ElementFactory { } } - //pub fn list_get_elements(type_: ElementFactoryListType, minrank: /*Ignored*/Rank) -> Vec { - // unsafe { TODO: call ffi::gst_element_factory_list_get_elements() } - //} + pub fn list_get_elements(type_: ElementFactoryListType, minrank: Rank) -> Vec { + assert_initialized_main_thread!(); + unsafe { + FromGlibPtrContainer::from_glib_full(ffi::gst_element_factory_list_get_elements(type_, minrank.to_glib())) + } + } pub fn make<'a, P: Into>>(factoryname: &str, name: P) -> Option { assert_initialized_main_thread!(); diff --git a/gstreamer/src/auto/enums.rs b/gstreamer/src/auto/enums.rs index 564b7df75..1f9b116c7 100644 --- a/gstreamer/src/auto/enums.rs +++ b/gstreamer/src/auto/enums.rs @@ -1541,6 +1541,69 @@ impl SetValue for QOSType { } } +#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] +pub enum Rank { + None, + Marginal, + Secondary, + Primary, + #[doc(hidden)] + __Unknown(i32), +} + +#[doc(hidden)] +impl ToGlib for Rank { + type GlibType = ffi::GstRank; + + fn to_glib(&self) -> ffi::GstRank { + match *self { + Rank::None => ffi::GST_RANK_NONE, + Rank::Marginal => ffi::GST_RANK_MARGINAL, + Rank::Secondary => ffi::GST_RANK_SECONDARY, + Rank::Primary => ffi::GST_RANK_PRIMARY, + Rank::__Unknown(value) => unsafe{std::mem::transmute(value)} + } + } +} + +#[doc(hidden)] +impl FromGlib for Rank { + fn from_glib(value: ffi::GstRank) -> Self { + skip_assert_initialized!(); + match value as i32 { + 0 => Rank::None, + 64 => Rank::Marginal, + 128 => Rank::Secondary, + 256 => Rank::Primary, + value => Rank::__Unknown(value), + } + } +} + +impl StaticType for Rank { + fn static_type() -> Type { + unsafe { from_glib(ffi::gst_rank_get_type()) } + } +} + +impl<'a> FromValueOptional<'a> for Rank { + unsafe fn from_value_optional(value: &Value) -> Option { + Some(FromValue::from_value(value)) + } +} + +impl<'a> FromValue<'a> for Rank { + unsafe fn from_value(value: &Value) -> Self { + from_glib(std::mem::transmute::(gobject_ffi::g_value_get_enum(value.to_glib_none().0))) + } +} + +impl SetValue for Rank { + unsafe fn set_value(value: &mut Value, this: &Self) { + gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib() as i32) + } +} + #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] pub enum ResourceError { Failed, diff --git a/gstreamer/src/auto/mod.rs b/gstreamer/src/auto/mod.rs index 8d6dae78a..22f7ebf0b 100644 --- a/gstreamer/src/auto/mod.rs +++ b/gstreamer/src/auto/mod.rs @@ -124,6 +124,7 @@ pub use self::enums::ParseError; pub use self::enums::PluginError; pub use self::enums::ProgressType; pub use self::enums::QOSType; +pub use self::enums::Rank; pub use self::enums::ResourceError; pub use self::enums::SeekType; pub use self::enums::State;