Commit 97bca104 authored by Sebastian Dröge's avatar Sebastian Dröge 🍵

Add GstRank

parent 47474959
......@@ -68,6 +68,7 @@ generate = [
"Gst.ClockType",
"Gst.ClockReturn",
"Gst.ElementFlags",
"Gst.Rank",
]
manual = [
......
......@@ -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<DeviceProviderFactory> {
// unsafe { TODO: call ffi::gst_device_provider_factory_list_get_device_providers() }
//}
pub fn list_get_device_providers(minrank: Rank) -> Vec<DeviceProviderFactory> {
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 {}
......
......@@ -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<ElementFactory> {
// unsafe { TODO: call ffi::gst_element_factory_list_get_elements() }
//}
pub fn list_get_elements(type_: ElementFactoryListType, minrank: Rank) -> Vec<ElementFactory> {
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> {
assert_initialized_main_thread!();
......
......@@ -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)]
pub enum ResourceError {
Failed,
......
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment