diff --git a/Gir_Gst.toml b/Gir_Gst.toml index e264ac953..3b7d1c6cd 100644 --- a/Gir_Gst.toml +++ b/Gir_Gst.toml @@ -25,7 +25,6 @@ generate = [ "Gst.PadTemplate", "Gst.URIHandler", "Gst.URIType", - "Gst.ElementFactory", "Gst.ElementFactoryListType", "Gst.Format", "Gst.MessageType", @@ -62,6 +61,7 @@ status = "generate" [[object]] name = "Gst.Bus" status = "generate" +trait = false [[object.function]] name = "remove_watch" # Needs manual bindings and GSource support in glib-rs @@ -136,6 +136,11 @@ status = "generate" [object.function.return] bool_return_is_error = "Failed to sync state with parent" +[[object]] +name = "Gst.ElementFactory" +status = "generate" +trait = false + [[object]] name = "Gst.Object" status = "generate" @@ -182,6 +187,11 @@ status = "generate" [object.function.return] bool_return_is_error = "Failed to activate pad" +[[object]] +name = "Gst.Plugin" +status = "generate" +trait = false + [[object]] name = "Gst.*" status = "generate" diff --git a/gstreamer/src/auto/bus.rs b/gstreamer/src/auto/bus.rs index 95ce98683..fe19ef997 100644 --- a/gstreamer/src/auto/bus.rs +++ b/gstreamer/src/auto/bus.rs @@ -5,9 +5,6 @@ use ClockTime; use Message; use Object; use ffi; -use glib; -use glib::object::Downcast; -use glib::object::IsA; use glib::signal::connect; use glib::translate::*; use glib_ffi; @@ -28,169 +25,125 @@ impl Bus { from_glib_full(ffi::gst_bus_new()) } } -} -unsafe impl Send for Bus {} -unsafe impl Sync for Bus {} - -pub trait BusExt { - fn add_signal_watch(&self); - - fn add_signal_watch_full(&self, priority: i32); - - //fn add_watch>>(&self, func: /*Unknown conversion*//*Unimplemented*/BusFunc, user_data: P) -> u32; - - //fn add_watch_full>>(&self, priority: i32, func: /*Unknown conversion*//*Unimplemented*/BusFunc, user_data: P, notify: /*Unknown conversion*//*Unimplemented*/DestroyNotify) -> u32; - - //fn async_signal_func>>(&self, message: &mut Message, data: P) -> bool; - - //fn create_watch(&self) -> /*Ignored*/Option; - - fn disable_sync_message_emission(&self); - - fn enable_sync_message_emission(&self); - - fn have_pending(&self) -> bool; - - fn peek(&self) -> Option; - - fn pop(&self) -> Option; - - fn post(&self, message: &mut Message) -> bool; - - fn remove_signal_watch(&self); - - fn set_flushing(&self, flushing: bool); - - //fn set_sync_handler<'a, P: Into>, Q: Into>>(&self, func: P, user_data: Q, notify: /*Unknown conversion*//*Unimplemented*/DestroyNotify); - - //fn sync_signal_handler>>(&self, message: &mut Message, data: P) -> /*Ignored*/BusSyncReply; - - fn timed_pop(&self, timeout: ClockTime) -> Option; - - fn connect_message(&self, f: F) -> u64; - - fn connect_sync_message(&self, f: F) -> u64; -} - -impl + IsA> BusExt for O { - fn add_signal_watch(&self) { + pub fn add_signal_watch(&self) { unsafe { ffi::gst_bus_add_signal_watch(self.to_glib_none().0); } } - fn add_signal_watch_full(&self, priority: i32) { + pub fn add_signal_watch_full(&self, priority: i32) { unsafe { ffi::gst_bus_add_signal_watch_full(self.to_glib_none().0, priority); } } - //fn add_watch>>(&self, func: /*Unknown conversion*//*Unimplemented*/BusFunc, user_data: P) -> u32 { + //pub fn add_watch>>(&self, func: /*Unknown conversion*//*Unimplemented*/BusFunc, user_data: P) -> u32 { // unsafe { TODO: call ffi::gst_bus_add_watch() } //} - //fn add_watch_full>>(&self, priority: i32, func: /*Unknown conversion*//*Unimplemented*/BusFunc, user_data: P, notify: /*Unknown conversion*//*Unimplemented*/DestroyNotify) -> u32 { + //pub fn add_watch_full>>(&self, priority: i32, func: /*Unknown conversion*//*Unimplemented*/BusFunc, user_data: P, notify: /*Unknown conversion*//*Unimplemented*/DestroyNotify) -> u32 { // unsafe { TODO: call ffi::gst_bus_add_watch_full() } //} - //fn async_signal_func>>(&self, message: &mut Message, data: P) -> bool { + //pub fn async_signal_func>>(&self, message: &mut Message, data: P) -> bool { // unsafe { TODO: call ffi::gst_bus_async_signal_func() } //} - //fn create_watch(&self) -> /*Ignored*/Option { + //pub fn create_watch(&self) -> /*Ignored*/Option { // unsafe { TODO: call ffi::gst_bus_create_watch() } //} - fn disable_sync_message_emission(&self) { + pub fn disable_sync_message_emission(&self) { unsafe { ffi::gst_bus_disable_sync_message_emission(self.to_glib_none().0); } } - fn enable_sync_message_emission(&self) { + pub fn enable_sync_message_emission(&self) { unsafe { ffi::gst_bus_enable_sync_message_emission(self.to_glib_none().0); } } - fn have_pending(&self) -> bool { + pub fn have_pending(&self) -> bool { unsafe { from_glib(ffi::gst_bus_have_pending(self.to_glib_none().0)) } } - fn peek(&self) -> Option { + pub fn peek(&self) -> Option { unsafe { from_glib_full(ffi::gst_bus_peek(self.to_glib_none().0)) } } - fn pop(&self) -> Option { + pub fn pop(&self) -> Option { unsafe { from_glib_full(ffi::gst_bus_pop(self.to_glib_none().0)) } } - fn post(&self, message: &mut Message) -> bool { + pub fn post(&self, message: &mut Message) -> bool { unsafe { from_glib(ffi::gst_bus_post(self.to_glib_none().0, message.to_glib_full())) } } - fn remove_signal_watch(&self) { + pub fn remove_signal_watch(&self) { unsafe { ffi::gst_bus_remove_signal_watch(self.to_glib_none().0); } } - fn set_flushing(&self, flushing: bool) { + pub fn set_flushing(&self, flushing: bool) { unsafe { ffi::gst_bus_set_flushing(self.to_glib_none().0, flushing.to_glib()); } } - //fn set_sync_handler<'a, P: Into>, Q: Into>>(&self, func: P, user_data: Q, notify: /*Unknown conversion*//*Unimplemented*/DestroyNotify) { + //pub fn set_sync_handler<'a, P: Into>, Q: Into>>(&self, func: P, user_data: Q, notify: /*Unknown conversion*//*Unimplemented*/DestroyNotify) { // unsafe { TODO: call ffi::gst_bus_set_sync_handler() } //} - //fn sync_signal_handler>>(&self, message: &mut Message, data: P) -> /*Ignored*/BusSyncReply { + //pub fn sync_signal_handler>>(&self, message: &mut Message, data: P) -> /*Ignored*/BusSyncReply { // unsafe { TODO: call ffi::gst_bus_sync_signal_handler() } //} - fn timed_pop(&self, timeout: ClockTime) -> Option { + pub fn timed_pop(&self, timeout: ClockTime) -> Option { unsafe { from_glib_full(ffi::gst_bus_timed_pop(self.to_glib_none().0, timeout)) } } - fn connect_message(&self, f: F) -> u64 { + pub fn connect_message(&self, f: F) -> u64 { unsafe { - let f: Box_> = Box_::new(Box_::new(f)); + let f: Box_> = Box_::new(Box_::new(f)); connect(self.to_glib_none().0, "message", - transmute(message_trampoline:: as usize), Box_::into_raw(f) as *mut _) + transmute(message_trampoline as usize), Box_::into_raw(f) as *mut _) } } - fn connect_sync_message(&self, f: F) -> u64 { + pub fn connect_sync_message(&self, f: F) -> u64 { unsafe { - let f: Box_> = Box_::new(Box_::new(f)); + let f: Box_> = Box_::new(Box_::new(f)); connect(self.to_glib_none().0, "sync-message", - transmute(sync_message_trampoline:: as usize), Box_::into_raw(f) as *mut _) + transmute(sync_message_trampoline as usize), Box_::into_raw(f) as *mut _) } } } -unsafe extern "C" fn message_trampoline

(this: *mut ffi::GstBus, message: *mut ffi::GstMessage, f: glib_ffi::gpointer) -where P: IsA { +unsafe impl Send for Bus {} +unsafe impl Sync for Bus {} + +unsafe extern "C" fn message_trampoline(this: *mut ffi::GstBus, message: *mut ffi::GstMessage, f: glib_ffi::gpointer) { callback_guard!(); - let f: &Box_ = transmute(f); - f(&Bus::from_glib_none(this).downcast_unchecked(), &from_glib_none(message)) + let f: &Box_ = transmute(f); + f(&from_glib_none(this), &from_glib_none(message)) } -unsafe extern "C" fn sync_message_trampoline

(this: *mut ffi::GstBus, message: *mut ffi::GstMessage, f: glib_ffi::gpointer) -where P: IsA { +unsafe extern "C" fn sync_message_trampoline(this: *mut ffi::GstBus, message: *mut ffi::GstMessage, f: glib_ffi::gpointer) { callback_guard!(); - let f: &Box_ = transmute(f); - f(&Bus::from_glib_none(this).downcast_unchecked(), &from_glib_none(message)) + let f: &Box_ = transmute(f); + f(&from_glib_none(this), &from_glib_none(message)) } diff --git a/gstreamer/src/auto/element.rs b/gstreamer/src/auto/element.rs index 2dbcf26d4..8c07ab191 100644 --- a/gstreamer/src/auto/element.rs +++ b/gstreamer/src/auto/element.rs @@ -11,6 +11,7 @@ use Message; use Object; use Pad; use PadTemplate; +use Plugin; use SeekFlags; use SeekType; use State; @@ -50,9 +51,13 @@ impl Element { } } - //pub fn register<'a, P: Into>>(plugin: P, name: &str, rank: u32, type_: glib::types::Type) -> bool { - // unsafe { TODO: call ffi::gst_element_register() } - //} + pub fn register<'a, P: Into>>(plugin: P, name: &str, rank: u32, type_: glib::types::Type) -> bool { + let plugin = plugin.into(); + let plugin = plugin.to_glib_none(); + unsafe { + from_glib(ffi::gst_element_register(plugin.0, name.to_glib_none().0, rank, type_.to_glib())) + } + } pub fn state_change_return_get_name(state_ret: StateChangeReturn) -> Option { unsafe { diff --git a/gstreamer/src/auto/element_factory.rs b/gstreamer/src/auto/element_factory.rs index 3b2d4c796..9cbca900c 100644 --- a/gstreamer/src/auto/element_factory.rs +++ b/gstreamer/src/auto/element_factory.rs @@ -7,7 +7,6 @@ use Object; use URIType; use ffi; use glib; -use glib::object::IsA; use glib::translate::*; glib_wrapper! { @@ -19,6 +18,82 @@ glib_wrapper! { } impl ElementFactory { + //pub fn can_sink_all_caps(&self, caps: /*Ignored*/&Caps) -> bool { + // unsafe { TODO: call ffi::gst_element_factory_can_sink_all_caps() } + //} + + //pub fn can_sink_any_caps(&self, caps: /*Ignored*/&Caps) -> bool { + // unsafe { TODO: call ffi::gst_element_factory_can_sink_any_caps() } + //} + + //pub fn can_src_all_caps(&self, caps: /*Ignored*/&Caps) -> bool { + // unsafe { TODO: call ffi::gst_element_factory_can_src_all_caps() } + //} + + //pub fn can_src_any_caps(&self, caps: /*Ignored*/&Caps) -> bool { + // unsafe { TODO: call ffi::gst_element_factory_can_src_any_caps() } + //} + + pub fn create<'a, P: Into>>(&self, name: P) -> Option { + let name = name.into(); + let name = name.to_glib_none(); + unsafe { + from_glib_none(ffi::gst_element_factory_create(self.to_glib_none().0, name.0)) + } + } + + pub fn get_element_type(&self) -> glib::types::Type { + unsafe { + from_glib(ffi::gst_element_factory_get_element_type(self.to_glib_none().0)) + } + } + + pub fn get_metadata(&self, key: &str) -> Option { + unsafe { + from_glib_none(ffi::gst_element_factory_get_metadata(self.to_glib_none().0, key.to_glib_none().0)) + } + } + + pub fn get_metadata_keys(&self) -> Vec { + unsafe { + FromGlibPtrContainer::from_glib_full(ffi::gst_element_factory_get_metadata_keys(self.to_glib_none().0)) + } + } + + pub fn get_num_pad_templates(&self) -> u32 { + unsafe { + ffi::gst_element_factory_get_num_pad_templates(self.to_glib_none().0) + } + } + + //pub fn get_static_pad_templates(&self) -> /*Ignored*/Vec { + // unsafe { TODO: call ffi::gst_element_factory_get_static_pad_templates() } + //} + + pub fn get_uri_protocols(&self) -> Vec { + unsafe { + FromGlibPtrContainer::from_glib_none(ffi::gst_element_factory_get_uri_protocols(self.to_glib_none().0)) + } + } + + pub fn get_uri_type(&self) -> URIType { + unsafe { + from_glib(ffi::gst_element_factory_get_uri_type(self.to_glib_none().0)) + } + } + + pub fn has_interface(&self, interfacename: &str) -> bool { + unsafe { + from_glib(ffi::gst_element_factory_has_interface(self.to_glib_none().0, interfacename.to_glib_none().0)) + } + } + + pub fn list_is_type(&self, type_: ElementFactoryListType) -> bool { + unsafe { + from_glib(ffi::gst_element_factory_list_is_type(self.to_glib_none().0, type_)) + } + } + pub fn find(name: &str) -> Option { unsafe { from_glib_full(ffi::gst_element_factory_find(name.to_glib_none().0)) @@ -44,111 +119,3 @@ impl ElementFactory { unsafe impl Send for ElementFactory {} unsafe impl Sync for ElementFactory {} - -pub trait ElementFactoryExt { - //fn can_sink_all_caps(&self, caps: /*Ignored*/&Caps) -> bool; - - //fn can_sink_any_caps(&self, caps: /*Ignored*/&Caps) -> bool; - - //fn can_src_all_caps(&self, caps: /*Ignored*/&Caps) -> bool; - - //fn can_src_any_caps(&self, caps: /*Ignored*/&Caps) -> bool; - - fn create<'a, P: Into>>(&self, name: P) -> Option; - - fn get_element_type(&self) -> glib::types::Type; - - fn get_metadata(&self, key: &str) -> Option; - - fn get_metadata_keys(&self) -> Vec; - - fn get_num_pad_templates(&self) -> u32; - - //fn get_static_pad_templates(&self) -> /*Ignored*/Vec; - - fn get_uri_protocols(&self) -> Vec; - - fn get_uri_type(&self) -> URIType; - - fn has_interface(&self, interfacename: &str) -> bool; - - fn list_is_type(&self, type_: ElementFactoryListType) -> bool; -} - -impl> ElementFactoryExt for O { - //fn can_sink_all_caps(&self, caps: /*Ignored*/&Caps) -> bool { - // unsafe { TODO: call ffi::gst_element_factory_can_sink_all_caps() } - //} - - //fn can_sink_any_caps(&self, caps: /*Ignored*/&Caps) -> bool { - // unsafe { TODO: call ffi::gst_element_factory_can_sink_any_caps() } - //} - - //fn can_src_all_caps(&self, caps: /*Ignored*/&Caps) -> bool { - // unsafe { TODO: call ffi::gst_element_factory_can_src_all_caps() } - //} - - //fn can_src_any_caps(&self, caps: /*Ignored*/&Caps) -> bool { - // unsafe { TODO: call ffi::gst_element_factory_can_src_any_caps() } - //} - - fn create<'a, P: Into>>(&self, name: P) -> Option { - let name = name.into(); - let name = name.to_glib_none(); - unsafe { - from_glib_none(ffi::gst_element_factory_create(self.to_glib_none().0, name.0)) - } - } - - fn get_element_type(&self) -> glib::types::Type { - unsafe { - from_glib(ffi::gst_element_factory_get_element_type(self.to_glib_none().0)) - } - } - - fn get_metadata(&self, key: &str) -> Option { - unsafe { - from_glib_none(ffi::gst_element_factory_get_metadata(self.to_glib_none().0, key.to_glib_none().0)) - } - } - - fn get_metadata_keys(&self) -> Vec { - unsafe { - FromGlibPtrContainer::from_glib_full(ffi::gst_element_factory_get_metadata_keys(self.to_glib_none().0)) - } - } - - fn get_num_pad_templates(&self) -> u32 { - unsafe { - ffi::gst_element_factory_get_num_pad_templates(self.to_glib_none().0) - } - } - - //fn get_static_pad_templates(&self) -> /*Ignored*/Vec { - // unsafe { TODO: call ffi::gst_element_factory_get_static_pad_templates() } - //} - - fn get_uri_protocols(&self) -> Vec { - unsafe { - FromGlibPtrContainer::from_glib_none(ffi::gst_element_factory_get_uri_protocols(self.to_glib_none().0)) - } - } - - fn get_uri_type(&self) -> URIType { - unsafe { - from_glib(ffi::gst_element_factory_get_uri_type(self.to_glib_none().0)) - } - } - - fn has_interface(&self, interfacename: &str) -> bool { - unsafe { - from_glib(ffi::gst_element_factory_has_interface(self.to_glib_none().0, interfacename.to_glib_none().0)) - } - } - - fn list_is_type(&self, type_: ElementFactoryListType) -> bool { - unsafe { - from_glib(ffi::gst_element_factory_list_is_type(self.to_glib_none().0, type_)) - } - } -} diff --git a/gstreamer/src/auto/functions.rs b/gstreamer/src/auto/functions.rs index 1ee2481aa..0c1435c7e 100644 --- a/gstreamer/src/auto/functions.rs +++ b/gstreamer/src/auto/functions.rs @@ -6,6 +6,7 @@ use ClockTime; use Element; use Error; use FlowReturn; +use Plugin; use ffi; use glib; use glib::translate::*; @@ -161,9 +162,11 @@ pub fn deinit() { } } -//pub fn dynamic_type_register(plugin: /*Ignored*/&Plugin, type_: glib::types::Type) -> bool { -// unsafe { TODO: call ffi::gst_dynamic_type_register() } -//} +pub fn dynamic_type_register(plugin: &Plugin, type_: glib::types::Type) -> bool { + unsafe { + from_glib(ffi::gst_dynamic_type_register(plugin.to_glib_none().0, type_.to_glib())) + } +} //pub fn error_get_message(domain: /*Ignored*/glib::Quark, code: i32) -> Option { // unsafe { TODO: call ffi::gst_error_get_message() } diff --git a/gstreamer/src/auto/mod.rs b/gstreamer/src/auto/mod.rs index 469335723..8393b68cd 100644 --- a/gstreamer/src/auto/mod.rs +++ b/gstreamer/src/auto/mod.rs @@ -7,7 +7,6 @@ pub use self::bin::BinExt; mod bus; pub use self::bus::Bus; -pub use self::bus::BusExt; mod clock; pub use self::clock::Clock; @@ -19,7 +18,6 @@ pub use self::element::ElementExt; mod element_factory; pub use self::element_factory::ElementFactory; -pub use self::element_factory::ElementFactoryExt; mod object; pub use self::object::Object; @@ -37,6 +35,9 @@ mod pipeline; pub use self::pipeline::Pipeline; pub use self::pipeline::PipelineExt; +mod plugin; +pub use self::plugin::Plugin; + mod u_r_i_handler; pub use self::u_r_i_handler::URIHandler; pub use self::u_r_i_handler::URIHandlerExt; @@ -116,10 +117,8 @@ pub mod functions; #[doc(hidden)] pub mod traits { pub use super::BinExt; - pub use super::BusExt; pub use super::ClockExt; pub use super::ElementExt; - pub use super::ElementFactoryExt; pub use super::ObjectExt; pub use super::PadExt; pub use super::PadTemplateExt; diff --git a/gstreamer/src/auto/plugin.rs b/gstreamer/src/auto/plugin.rs new file mode 100644 index 000000000..59e8cfaa9 --- /dev/null +++ b/gstreamer/src/auto/plugin.rs @@ -0,0 +1,125 @@ +// This file was generated by gir (33e9567) from gir-files (???) +// DO NOT EDIT + +use Error; +use Object; +use ffi; +use glib::translate::*; +use std::ptr; + +glib_wrapper! { + pub struct Plugin(Object): Object; + + match fn { + get_type => || ffi::gst_plugin_get_type(), + } +} + +impl Plugin { + //pub fn add_dependency<'a, 'b, 'c, P: Into>, Q: Into>, R: Into>>(&self, env_vars: P, paths: Q, names: R, flags: /*Ignored*/PluginDependencyFlags) { + // unsafe { TODO: call ffi::gst_plugin_add_dependency() } + //} + + //pub fn add_dependency_simple<'a, 'b, 'c, P: Into>, Q: Into>, R: Into>>(&self, env_vars: P, paths: Q, names: R, flags: /*Ignored*/PluginDependencyFlags) { + // unsafe { TODO: call ffi::gst_plugin_add_dependency_simple() } + //} + + //pub fn get_cache_data(&self) -> /*Ignored*/Option { + // unsafe { TODO: call ffi::gst_plugin_get_cache_data() } + //} + + pub fn get_description(&self) -> Option { + unsafe { + from_glib_none(ffi::gst_plugin_get_description(self.to_glib_none().0)) + } + } + + pub fn get_filename(&self) -> Option { + unsafe { + from_glib_none(ffi::gst_plugin_get_filename(self.to_glib_none().0)) + } + } + + pub fn get_license(&self) -> Option { + unsafe { + from_glib_none(ffi::gst_plugin_get_license(self.to_glib_none().0)) + } + } + + pub fn get_origin(&self) -> Option { + unsafe { + from_glib_none(ffi::gst_plugin_get_origin(self.to_glib_none().0)) + } + } + + pub fn get_package(&self) -> Option { + unsafe { + from_glib_none(ffi::gst_plugin_get_package(self.to_glib_none().0)) + } + } + + pub fn get_release_date_string(&self) -> Option { + unsafe { + from_glib_none(ffi::gst_plugin_get_release_date_string(self.to_glib_none().0)) + } + } + + pub fn get_source(&self) -> Option { + unsafe { + from_glib_none(ffi::gst_plugin_get_source(self.to_glib_none().0)) + } + } + + pub fn get_version(&self) -> Option { + unsafe { + from_glib_none(ffi::gst_plugin_get_version(self.to_glib_none().0)) + } + } + + pub fn is_loaded(&self) -> bool { + unsafe { + from_glib(ffi::gst_plugin_is_loaded(self.to_glib_none().0)) + } + } + + pub fn load(&self) -> Option { + unsafe { + from_glib_full(ffi::gst_plugin_load(self.to_glib_none().0)) + } + } + + //pub fn set_cache_data(&self, cache_data: /*Ignored*/&mut Structure) { + // unsafe { TODO: call ffi::gst_plugin_set_cache_data() } + //} + + pub fn list_free(list: &[Plugin]) { + unsafe { + ffi::gst_plugin_list_free(list.to_glib_full()); + } + } + + pub fn load_by_name(name: &str) -> Option { + unsafe { + from_glib_full(ffi::gst_plugin_load_by_name(name.to_glib_none().0)) + } + } + + pub fn load_file(filename: &str) -> Result { + unsafe { + let mut error = ptr::null_mut(); + let ret = ffi::gst_plugin_load_file(filename.to_glib_none().0, &mut error); + if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } + } + } + + //pub fn register_static(major_version: i32, minor_version: i32, name: &str, description: &str, init_func: /*Unknown conversion*//*Unimplemented*/PluginInitFunc, version: &str, license: &str, source: &str, package: &str, origin: &str) -> bool { + // unsafe { TODO: call ffi::gst_plugin_register_static() } + //} + + //pub fn register_static_full>>(major_version: i32, minor_version: i32, name: &str, description: &str, init_full_func: /*Unknown conversion*//*Unimplemented*/PluginInitFullFunc, version: &str, license: &str, source: &str, package: &str, origin: &str, user_data: P) -> bool { + // unsafe { TODO: call ffi::gst_plugin_register_static_full() } + //} +} + +unsafe impl Send for Plugin {} +unsafe impl Sync for Plugin {}