forked from mirrors/gstreamer-rs
gstreamer: allow to register using Rank enum directly
Prevent user to have to cast to a u32 manually.
This commit is contained in:
parent
2c31baaa0c
commit
1cd733fb0b
6 changed files with 53 additions and 25 deletions
|
@ -535,8 +535,7 @@ status = "generate"
|
||||||
|
|
||||||
[[object.function]]
|
[[object.function]]
|
||||||
name = "register"
|
name = "register"
|
||||||
[object.function.return]
|
ignore = true
|
||||||
bool_return_is_error = "Failed to register element factory"
|
|
||||||
|
|
||||||
[[object]]
|
[[object]]
|
||||||
name = "Gst.ElementFactory"
|
name = "Gst.ElementFactory"
|
||||||
|
@ -568,8 +567,7 @@ status = "generate"
|
||||||
|
|
||||||
[[object.function]]
|
[[object.function]]
|
||||||
name = "register"
|
name = "register"
|
||||||
[object.function.return]
|
ignore = true
|
||||||
bool_return_is_error = "Failed to register device provider factory"
|
|
||||||
|
|
||||||
[[object.function]]
|
[[object.function]]
|
||||||
name = "get_metadata"
|
name = "get_metadata"
|
||||||
|
|
|
@ -6,7 +6,6 @@ use Bus;
|
||||||
use Device;
|
use Device;
|
||||||
use DeviceProviderFactory;
|
use DeviceProviderFactory;
|
||||||
use Object;
|
use Object;
|
||||||
use Plugin;
|
|
||||||
use glib;
|
use glib;
|
||||||
use glib::GString;
|
use glib::GString;
|
||||||
use glib::object::Cast;
|
use glib::object::Cast;
|
||||||
|
@ -28,15 +27,6 @@ glib_wrapper! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DeviceProvider {
|
|
||||||
pub fn register(plugin: Option<&Plugin>, name: &str, rank: u32, type_: glib::types::Type) -> Result<(), glib::error::BoolError> {
|
|
||||||
assert_initialized_main_thread!();
|
|
||||||
unsafe {
|
|
||||||
glib_result_from_gboolean!(gst_sys::gst_device_provider_register(plugin.to_glib_none().0, name.to_glib_none().0, rank, type_.to_glib()), "Failed to register device provider factory")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe impl Send for DeviceProvider {}
|
unsafe impl Send for DeviceProvider {}
|
||||||
unsafe impl Sync for DeviceProvider {}
|
unsafe impl Sync for DeviceProvider {}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@ use Object;
|
||||||
use Pad;
|
use Pad;
|
||||||
use PadLinkCheck;
|
use PadLinkCheck;
|
||||||
use PadTemplate;
|
use PadTemplate;
|
||||||
use Plugin;
|
|
||||||
use URIType;
|
use URIType;
|
||||||
use glib;
|
use glib;
|
||||||
use glib::object::Cast;
|
use glib::object::Cast;
|
||||||
|
@ -45,13 +44,6 @@ impl Element {
|
||||||
if error.is_null() { Ok(from_glib_none(ret)) } else { Err(from_glib_full(error)) }
|
if error.is_null() { Ok(from_glib_none(ret)) } else { Err(from_glib_full(error)) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn register(plugin: Option<&Plugin>, name: &str, rank: u32, type_: glib::types::Type) -> Result<(), glib::error::BoolError> {
|
|
||||||
assert_initialized_main_thread!();
|
|
||||||
unsafe {
|
|
||||||
glib_result_from_gboolean!(gst_sys::gst_element_register(plugin.to_glib_none().0, name.to_glib_none().0, rank, type_.to_glib()), "Failed to register element factory")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for Element {}
|
unsafe impl Send for Element {}
|
||||||
|
|
|
@ -7,8 +7,11 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use DeviceProvider;
|
use DeviceProvider;
|
||||||
|
use Plugin;
|
||||||
|
use Rank;
|
||||||
|
|
||||||
use glib::object::IsA;
|
use glib::object::IsA;
|
||||||
|
use glib::translate::ToGlib;
|
||||||
use glib::translate::ToGlibPtr;
|
use glib::translate::ToGlibPtr;
|
||||||
|
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
|
@ -16,6 +19,28 @@ use std::ffi::CStr;
|
||||||
use gobject_sys;
|
use gobject_sys;
|
||||||
use gst_sys;
|
use gst_sys;
|
||||||
|
|
||||||
|
impl DeviceProvider {
|
||||||
|
pub fn register(
|
||||||
|
plugin: Option<&Plugin>,
|
||||||
|
name: &str,
|
||||||
|
rank: Rank,
|
||||||
|
type_: glib::types::Type,
|
||||||
|
) -> Result<(), glib::error::BoolError> {
|
||||||
|
assert_initialized_main_thread!();
|
||||||
|
unsafe {
|
||||||
|
glib_result_from_gboolean!(
|
||||||
|
gst_sys::gst_device_provider_register(
|
||||||
|
plugin.to_glib_none().0,
|
||||||
|
name.to_glib_none().0,
|
||||||
|
rank.to_glib() as u32,
|
||||||
|
type_.to_glib()
|
||||||
|
),
|
||||||
|
"Failed to register device provider factory"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub trait DeviceProviderExtManual: 'static {
|
pub trait DeviceProviderExtManual: 'static {
|
||||||
fn get_metadata<'a>(&self, key: &str) -> Option<&'a str>;
|
fn get_metadata<'a>(&self, key: &str) -> Option<&'a str>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,9 @@ use FormattedValue;
|
||||||
use GenericFormattedValue;
|
use GenericFormattedValue;
|
||||||
use Pad;
|
use Pad;
|
||||||
use PadTemplate;
|
use PadTemplate;
|
||||||
|
use Plugin;
|
||||||
use QueryRef;
|
use QueryRef;
|
||||||
|
use Rank;
|
||||||
use SpecificFormattedValue;
|
use SpecificFormattedValue;
|
||||||
use State;
|
use State;
|
||||||
use StateChange;
|
use StateChange;
|
||||||
|
@ -74,6 +76,26 @@ impl Element {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn register(
|
||||||
|
plugin: Option<&Plugin>,
|
||||||
|
name: &str,
|
||||||
|
rank: Rank,
|
||||||
|
type_: glib::types::Type,
|
||||||
|
) -> Result<(), glib::error::BoolError> {
|
||||||
|
assert_initialized_main_thread!();
|
||||||
|
unsafe {
|
||||||
|
glib_result_from_gboolean!(
|
||||||
|
gst_sys::gst_element_register(
|
||||||
|
plugin.to_glib_none().0,
|
||||||
|
name.to_glib_none().0,
|
||||||
|
rank.to_glib() as u32,
|
||||||
|
type_.to_glib()
|
||||||
|
),
|
||||||
|
"Failed to register element factory"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Copy, Clone, Debug, Hash)]
|
#[derive(PartialEq, Eq, Copy, Clone, Debug, Hash)]
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
use gst_sys;
|
use gst_sys;
|
||||||
use Caps;
|
use Caps;
|
||||||
use Plugin;
|
use Plugin;
|
||||||
|
use Rank;
|
||||||
use TypeFindFactory;
|
use TypeFindFactory;
|
||||||
use TypeFindProbability;
|
use TypeFindProbability;
|
||||||
|
|
||||||
|
@ -35,7 +36,7 @@ impl<'a> TypeFind<'a> {
|
||||||
pub fn register<F>(
|
pub fn register<F>(
|
||||||
plugin: Option<&Plugin>,
|
plugin: Option<&Plugin>,
|
||||||
name: &str,
|
name: &str,
|
||||||
rank: u32,
|
rank: Rank,
|
||||||
extensions: Option<&str>,
|
extensions: Option<&str>,
|
||||||
possible_caps: Option<&Caps>,
|
possible_caps: Option<&Caps>,
|
||||||
func: F,
|
func: F,
|
||||||
|
@ -50,7 +51,7 @@ impl<'a> TypeFind<'a> {
|
||||||
let res = gst_sys::gst_type_find_register(
|
let res = gst_sys::gst_type_find_register(
|
||||||
plugin.to_glib_none().0,
|
plugin.to_glib_none().0,
|
||||||
name.to_glib_none().0,
|
name.to_glib_none().0,
|
||||||
rank,
|
rank.to_glib() as u32,
|
||||||
Some(type_find_trampoline::<F>),
|
Some(type_find_trampoline::<F>),
|
||||||
extensions.to_glib_none().0,
|
extensions.to_glib_none().0,
|
||||||
possible_caps.to_glib_none().0,
|
possible_caps.to_glib_none().0,
|
||||||
|
@ -265,7 +266,7 @@ mod tests {
|
||||||
TypeFind::register(
|
TypeFind::register(
|
||||||
None,
|
None,
|
||||||
"test_typefind",
|
"test_typefind",
|
||||||
::Rank::Primary.to_glib() as u32,
|
::Rank::Primary,
|
||||||
None,
|
None,
|
||||||
Some(&Caps::new_simple("test/test", &[])),
|
Some(&Caps::new_simple("test/test", &[])),
|
||||||
|typefind| {
|
|typefind| {
|
||||||
|
|
Loading…
Reference in a new issue