Add bindings for Registry and PluginFeature

This commit is contained in:
Sebastian Dröge 2017-12-03 14:40:38 +02:00
parent c6c7693550
commit 49e1fe1c3f
6 changed files with 285 additions and 2 deletions

View file

@ -583,6 +583,46 @@ name = "Gst.Plugin"
status = "generate" status = "generate"
trait = false trait = false
[[object]]
name = "Gst.PluginFeature"
status = "generate"
[[object.function]]
pattern = "list_.*"
ignore = true
[[object.function]]
name = "rank_compare_func"
ignore = true
[[object]]
name = "Gst.Registry"
status = "generate"
trait = false
[[object.function]]
pattern = "fork_.*"
ignore = true
[[object.function]]
name = "get"
[object.function.return]
nullable = false
[[object.function]]
name = "add_feature"
[object.function.return]
bool_return_is_error = "Failed to add feature"
[[object.function]]
name = "add_plugin"
[object.function.return]
bool_return_is_error = "Failed to add plugin"
[[object.function]]
name = "scan_path"
[object.function.return]
bool_return_is_error = "Failed to scan path"
[[object]] [[object]]
name = "Gst.*" name = "Gst.*"
status = "generate" status = "generate"

View file

@ -3,6 +3,7 @@
use DeviceProvider; use DeviceProvider;
use Object; use Object;
use PluginFeature;
use Rank; use Rank;
use ffi; use ffi;
use glib; use glib;
@ -13,7 +14,7 @@ use std::mem;
use std::ptr; use std::ptr;
glib_wrapper! { glib_wrapper! {
pub struct DeviceProviderFactory(Object<ffi::GstDeviceProviderFactory, ffi::GstDeviceProviderFactoryClass>): Object; pub struct DeviceProviderFactory(Object<ffi::GstDeviceProviderFactory, ffi::GstDeviceProviderFactoryClass>): PluginFeature, Object;
match fn { match fn {
get_type => || ffi::gst_device_provider_factory_get_type(), get_type => || ffi::gst_device_provider_factory_get_type(),

View file

@ -6,6 +6,7 @@ use Element;
use ElementFactoryListType; use ElementFactoryListType;
use Object; use Object;
use PadDirection; use PadDirection;
use PluginFeature;
use Rank; use Rank;
use StaticPadTemplate; use StaticPadTemplate;
use URIType; use URIType;
@ -18,7 +19,7 @@ use std::mem;
use std::ptr; use std::ptr;
glib_wrapper! { glib_wrapper! {
pub struct ElementFactory(Object<ffi::GstElementFactory, ffi::GstElementFactoryClass>): Object; pub struct ElementFactory(Object<ffi::GstElementFactory, ffi::GstElementFactoryClass>): PluginFeature, Object;
match fn { match fn {
get_type => || ffi::gst_element_factory_get_type(), get_type => || ffi::gst_element_factory_get_type(),

View file

@ -60,6 +60,10 @@ pub use self::pipeline::PipelineExt;
mod plugin; mod plugin;
pub use self::plugin::Plugin; pub use self::plugin::Plugin;
mod plugin_feature;
pub use self::plugin_feature::PluginFeature;
pub use self::plugin_feature::PluginFeatureExt;
mod preset; mod preset;
pub use self::preset::Preset; pub use self::preset::Preset;
pub use self::preset::PresetExt; pub use self::preset::PresetExt;
@ -68,6 +72,9 @@ mod proxy_pad;
pub use self::proxy_pad::ProxyPad; pub use self::proxy_pad::ProxyPad;
pub use self::proxy_pad::ProxyPadExt; pub use self::proxy_pad::ProxyPadExt;
mod registry;
pub use self::registry::Registry;
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
mod stream; mod stream;
#[cfg(any(feature = "v1_10", feature = "dox"))] #[cfg(any(feature = "v1_10", feature = "dox"))]
@ -170,6 +177,7 @@ pub mod traits {
pub use super::GstObjectExt; pub use super::GstObjectExt;
pub use super::PadExt; pub use super::PadExt;
pub use super::PipelineExt; pub use super::PipelineExt;
pub use super::PluginFeatureExt;
pub use super::PresetExt; pub use super::PresetExt;
pub use super::ProxyPadExt; pub use super::ProxyPadExt;
pub use super::SystemClockExt; pub use super::SystemClockExt;

View file

@ -0,0 +1,75 @@
// This file was generated by gir (d50d839) from gir-files (???)
// DO NOT EDIT
use Object;
use Plugin;
use ffi;
use glib::object::IsA;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use std::mem;
use std::ptr;
glib_wrapper! {
pub struct PluginFeature(Object<ffi::GstPluginFeature, ffi::GstPluginFeatureClass>): Object;
match fn {
get_type => || ffi::gst_plugin_feature_get_type(),
}
}
unsafe impl Send for PluginFeature {}
unsafe impl Sync for PluginFeature {}
pub trait PluginFeatureExt {
fn check_version(&self, min_major: u32, min_minor: u32, min_micro: u32) -> bool;
fn get_plugin(&self) -> Option<Plugin>;
fn get_plugin_name(&self) -> Option<String>;
fn get_rank(&self) -> u32;
fn load(&self) -> Option<PluginFeature>;
fn set_rank(&self, rank: u32);
}
impl<O: IsA<PluginFeature>> PluginFeatureExt for O {
fn check_version(&self, min_major: u32, min_minor: u32, min_micro: u32) -> bool {
unsafe {
from_glib(ffi::gst_plugin_feature_check_version(self.to_glib_none().0, min_major, min_minor, min_micro))
}
}
fn get_plugin(&self) -> Option<Plugin> {
unsafe {
from_glib_full(ffi::gst_plugin_feature_get_plugin(self.to_glib_none().0))
}
}
fn get_plugin_name(&self) -> Option<String> {
unsafe {
from_glib_none(ffi::gst_plugin_feature_get_plugin_name(self.to_glib_none().0))
}
}
fn get_rank(&self) -> u32 {
unsafe {
ffi::gst_plugin_feature_get_rank(self.to_glib_none().0)
}
}
fn load(&self) -> Option<PluginFeature> {
unsafe {
from_glib_full(ffi::gst_plugin_feature_load(self.to_glib_none().0))
}
}
fn set_rank(&self, rank: u32) {
unsafe {
ffi::gst_plugin_feature_set_rank(self.to_glib_none().0, rank);
}
}
}

View file

@ -0,0 +1,158 @@
// This file was generated by gir (d50d839) from gir-files (???)
// DO NOT EDIT
use Object;
use Plugin;
use PluginFeature;
use ffi;
use glib;
use glib::object::IsA;
use glib::signal::SignalHandlerId;
use glib::signal::connect;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use std::boxed::Box as Box_;
use std::mem;
use std::mem::transmute;
use std::ptr;
glib_wrapper! {
pub struct Registry(Object<ffi::GstRegistry, ffi::GstRegistryClass>): Object;
match fn {
get_type => || ffi::gst_registry_get_type(),
}
}
impl Registry {
pub fn add_feature<P: IsA<PluginFeature>>(&self, feature: &P) -> Result<(), glib::error::BoolError> {
unsafe {
glib::error::BoolError::from_glib(ffi::gst_registry_add_feature(self.to_glib_none().0, feature.to_glib_none().0), "Failed to add feature")
}
}
pub fn add_plugin(&self, plugin: &Plugin) -> Result<(), glib::error::BoolError> {
unsafe {
glib::error::BoolError::from_glib(ffi::gst_registry_add_plugin(self.to_glib_none().0, plugin.to_glib_none().0), "Failed to add plugin")
}
}
pub fn check_feature_version(&self, feature_name: &str, min_major: u32, min_minor: u32, min_micro: u32) -> bool {
unsafe {
from_glib(ffi::gst_registry_check_feature_version(self.to_glib_none().0, feature_name.to_glib_none().0, min_major, min_minor, min_micro))
}
}
//pub fn feature_filter<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, filter: /*Unknown conversion*//*Unimplemented*/PluginFeatureFilter, first: bool, user_data: P) -> Vec<PluginFeature> {
// unsafe { TODO: call ffi::gst_registry_feature_filter() }
//}
pub fn find_feature(&self, name: &str, type_: glib::types::Type) -> Option<PluginFeature> {
unsafe {
from_glib_full(ffi::gst_registry_find_feature(self.to_glib_none().0, name.to_glib_none().0, type_.to_glib()))
}
}
pub fn find_plugin(&self, name: &str) -> Option<Plugin> {
unsafe {
from_glib_full(ffi::gst_registry_find_plugin(self.to_glib_none().0, name.to_glib_none().0))
}
}
pub fn get_feature_list(&self, type_: glib::types::Type) -> Vec<PluginFeature> {
unsafe {
FromGlibPtrContainer::from_glib_full(ffi::gst_registry_get_feature_list(self.to_glib_none().0, type_.to_glib()))
}
}
pub fn get_feature_list_by_plugin(&self, name: &str) -> Vec<PluginFeature> {
unsafe {
FromGlibPtrContainer::from_glib_full(ffi::gst_registry_get_feature_list_by_plugin(self.to_glib_none().0, name.to_glib_none().0))
}
}
pub fn get_feature_list_cookie(&self) -> u32 {
unsafe {
ffi::gst_registry_get_feature_list_cookie(self.to_glib_none().0)
}
}
pub fn get_plugin_list(&self) -> Vec<Plugin> {
unsafe {
FromGlibPtrContainer::from_glib_full(ffi::gst_registry_get_plugin_list(self.to_glib_none().0))
}
}
pub fn lookup(&self, filename: &str) -> Option<Plugin> {
unsafe {
from_glib_full(ffi::gst_registry_lookup(self.to_glib_none().0, filename.to_glib_none().0))
}
}
pub fn lookup_feature(&self, name: &str) -> Option<PluginFeature> {
unsafe {
from_glib_full(ffi::gst_registry_lookup_feature(self.to_glib_none().0, name.to_glib_none().0))
}
}
//pub fn plugin_filter<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, filter: /*Unknown conversion*//*Unimplemented*/PluginFilter, first: bool, user_data: P) -> Vec<Plugin> {
// unsafe { TODO: call ffi::gst_registry_plugin_filter() }
//}
pub fn remove_feature<P: IsA<PluginFeature>>(&self, feature: &P) {
unsafe {
ffi::gst_registry_remove_feature(self.to_glib_none().0, feature.to_glib_none().0);
}
}
pub fn remove_plugin(&self, plugin: &Plugin) {
unsafe {
ffi::gst_registry_remove_plugin(self.to_glib_none().0, plugin.to_glib_none().0);
}
}
pub fn scan_path(&self, path: &str) -> Result<(), glib::error::BoolError> {
unsafe {
glib::error::BoolError::from_glib(ffi::gst_registry_scan_path(self.to_glib_none().0, path.to_glib_none().0), "Failed to scan path")
}
}
pub fn get() -> Registry {
assert_initialized_main_thread!();
unsafe {
from_glib_none(ffi::gst_registry_get())
}
}
pub fn connect_feature_added<F: Fn(&Registry, &PluginFeature) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Registry, &PluginFeature) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "feature-added",
transmute(feature_added_trampoline as usize), Box_::into_raw(f) as *mut _)
}
}
pub fn connect_plugin_added<F: Fn(&Registry, &Plugin) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Registry, &Plugin) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "plugin-added",
transmute(plugin_added_trampoline as usize), Box_::into_raw(f) as *mut _)
}
}
}
unsafe impl Send for Registry {}
unsafe impl Sync for Registry {}
unsafe extern "C" fn feature_added_trampoline(this: *mut ffi::GstRegistry, feature: *mut ffi::GstPluginFeature, f: glib_ffi::gpointer) {
callback_guard!();
let f: &&(Fn(&Registry, &PluginFeature) + Send + Sync + 'static) = transmute(f);
f(&from_glib_borrow(this), &from_glib_borrow(feature))
}
unsafe extern "C" fn plugin_added_trampoline(this: *mut ffi::GstRegistry, plugin: *mut ffi::GstPlugin, f: glib_ffi::gpointer) {
callback_guard!();
let f: &&(Fn(&Registry, &Plugin) + Send + Sync + 'static) = transmute(f);
f(&from_glib_borrow(this), &from_glib_borrow(plugin))
}