Add GstRank

This commit is contained in:
Sebastian Dröge 2017-08-14 22:18:34 +03:00
parent 474749598e
commit 97bca10484
5 changed files with 79 additions and 6 deletions

View file

@ -68,6 +68,7 @@ generate = [
"Gst.ClockType", "Gst.ClockType",
"Gst.ClockReturn", "Gst.ClockReturn",
"Gst.ElementFlags", "Gst.ElementFlags",
"Gst.Rank",
] ]
manual = [ manual = [

View file

@ -3,6 +3,7 @@
use DeviceProvider; use DeviceProvider;
use Object; use Object;
use Rank;
use ffi; use ffi;
use glib; use glib;
use glib::object::IsA; use glib::object::IsA;
@ -35,9 +36,12 @@ impl DeviceProviderFactory {
} }
} }
//pub fn list_get_device_providers(minrank: /*Ignored*/Rank) -> Vec<DeviceProviderFactory> { pub fn list_get_device_providers(minrank: Rank) -> Vec<DeviceProviderFactory> {
// unsafe { TODO: call ffi::gst_device_provider_factory_list_get_device_providers() } 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 {} unsafe impl Send for DeviceProviderFactory {}

View file

@ -6,6 +6,7 @@ use Element;
use ElementFactoryListType; use ElementFactoryListType;
use Object; use Object;
use PadDirection; use PadDirection;
use Rank;
use URIType; use URIType;
use ffi; use ffi;
use glib; use glib;
@ -122,9 +123,12 @@ impl ElementFactory {
} }
} }
//pub fn list_get_elements(type_: ElementFactoryListType, minrank: /*Ignored*/Rank) -> Vec<ElementFactory> { pub fn list_get_elements(type_: ElementFactoryListType, minrank: Rank) -> Vec<ElementFactory> {
// unsafe { TODO: call ffi::gst_element_factory_list_get_elements() } 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<Option<&'a str>>>(factoryname: &str, name: P) -> Option<Element> { pub fn make<'a, P: Into<Option<&'a str>>>(factoryname: &str, name: P) -> Option<Element> {
assert_initialized_main_thread!(); assert_initialized_main_thread!();

View file

@ -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<ffi::GstRank> 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<Self> {
Some(FromValue::from_value(value))
}
}
impl<'a> FromValue<'a> for Rank {
unsafe fn from_value(value: &Value) -> Self {
from_glib(std::mem::transmute::<i32, ffi::GstRank>(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)] #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
pub enum ResourceError { pub enum ResourceError {
Failed, Failed,

View file

@ -124,6 +124,7 @@ pub use self::enums::ParseError;
pub use self::enums::PluginError; pub use self::enums::PluginError;
pub use self::enums::ProgressType; pub use self::enums::ProgressType;
pub use self::enums::QOSType; pub use self::enums::QOSType;
pub use self::enums::Rank;
pub use self::enums::ResourceError; pub use self::enums::ResourceError;
pub use self::enums::SeekType; pub use self::enums::SeekType;
pub use self::enums::State; pub use self::enums::State;