1 // This file was generated by gir (https://github.com/gtk-rs/gir) 2 // from gir-files (https://github.com/gtk-rs/gir-files) 3 // DO NOT EDIT 4 5 use glib; 6 use glib::object::IsA; 7 use glib::object::ObjectType as ObjectType_; 8 use glib::signal::connect_raw; 9 use glib::signal::SignalHandlerId; 10 use glib::translate::*; 11 use glib_sys; 12 use gst_sys; 13 use std; 14 use std::boxed::Box as Box_; 15 use std::mem::transmute; 16 use Object; 17 use Plugin; 18 use PluginFeature; 19 20 glib_wrapper! { 21 pub struct Registry(Object<gst_sys::GstRegistry, gst_sys::GstRegistryClass, RegistryClass>) @extends Object; 22 23 match fn { 24 get_type => || gst_sys::gst_registry_get_type(), 25 } 26 } 27 28 impl Registry { add_feature<P: IsA<PluginFeature>>( &self, feature: &P, ) -> Result<(), glib::error::BoolError>29 pub fn add_feature<P: IsA<PluginFeature>>( 30 &self, 31 feature: &P, 32 ) -> Result<(), glib::error::BoolError> { 33 unsafe { 34 glib_result_from_gboolean!( 35 gst_sys::gst_registry_add_feature( 36 self.to_glib_none().0, 37 feature.as_ref().to_glib_none().0 38 ), 39 "Failed to add feature" 40 ) 41 } 42 } 43 add_plugin(&self, plugin: &Plugin) -> Result<(), glib::error::BoolError>44 pub fn add_plugin(&self, plugin: &Plugin) -> Result<(), glib::error::BoolError> { 45 unsafe { 46 glib_result_from_gboolean!( 47 gst_sys::gst_registry_add_plugin(self.to_glib_none().0, plugin.to_glib_none().0), 48 "Failed to add plugin" 49 ) 50 } 51 } 52 check_feature_version( &self, feature_name: &str, min_major: u32, min_minor: u32, min_micro: u32, ) -> bool53 pub fn check_feature_version( 54 &self, 55 feature_name: &str, 56 min_major: u32, 57 min_minor: u32, 58 min_micro: u32, 59 ) -> bool { 60 unsafe { 61 from_glib(gst_sys::gst_registry_check_feature_version( 62 self.to_glib_none().0, 63 feature_name.to_glib_none().0, 64 min_major, 65 min_minor, 66 min_micro, 67 )) 68 } 69 } 70 feature_filter<P: FnMut(&PluginFeature) -> bool>( &self, filter: P, first: bool, ) -> Vec<PluginFeature>71 pub fn feature_filter<P: FnMut(&PluginFeature) -> bool>( 72 &self, 73 filter: P, 74 first: bool, 75 ) -> Vec<PluginFeature> { 76 let filter_data: P = filter; 77 unsafe extern "C" fn filter_func<P: FnMut(&PluginFeature) -> bool>( 78 feature: *mut gst_sys::GstPluginFeature, 79 user_data: glib_sys::gpointer, 80 ) -> glib_sys::gboolean { 81 let feature = from_glib_borrow(feature); 82 let callback: *mut P = user_data as *const _ as usize as *mut P; 83 let res = (*callback)(&feature); 84 res.to_glib() 85 } 86 let filter = Some(filter_func::<P> as _); 87 let super_callback0: &P = &filter_data; 88 unsafe { 89 FromGlibPtrContainer::from_glib_full(gst_sys::gst_registry_feature_filter( 90 self.to_glib_none().0, 91 filter, 92 first.to_glib(), 93 super_callback0 as *const _ as usize as *mut _, 94 )) 95 } 96 } 97 find_feature(&self, name: &str, type_: glib::types::Type) -> Option<PluginFeature>98 pub fn find_feature(&self, name: &str, type_: glib::types::Type) -> Option<PluginFeature> { 99 unsafe { 100 from_glib_full(gst_sys::gst_registry_find_feature( 101 self.to_glib_none().0, 102 name.to_glib_none().0, 103 type_.to_glib(), 104 )) 105 } 106 } 107 find_plugin(&self, name: &str) -> Option<Plugin>108 pub fn find_plugin(&self, name: &str) -> Option<Plugin> { 109 unsafe { 110 from_glib_full(gst_sys::gst_registry_find_plugin( 111 self.to_glib_none().0, 112 name.to_glib_none().0, 113 )) 114 } 115 } 116 get_feature_list(&self, type_: glib::types::Type) -> Vec<PluginFeature>117 pub fn get_feature_list(&self, type_: glib::types::Type) -> Vec<PluginFeature> { 118 unsafe { 119 FromGlibPtrContainer::from_glib_full(gst_sys::gst_registry_get_feature_list( 120 self.to_glib_none().0, 121 type_.to_glib(), 122 )) 123 } 124 } 125 get_feature_list_by_plugin(&self, name: &str) -> Vec<PluginFeature>126 pub fn get_feature_list_by_plugin(&self, name: &str) -> Vec<PluginFeature> { 127 unsafe { 128 FromGlibPtrContainer::from_glib_full(gst_sys::gst_registry_get_feature_list_by_plugin( 129 self.to_glib_none().0, 130 name.to_glib_none().0, 131 )) 132 } 133 } 134 get_feature_list_cookie(&self) -> u32135 pub fn get_feature_list_cookie(&self) -> u32 { 136 unsafe { gst_sys::gst_registry_get_feature_list_cookie(self.to_glib_none().0) } 137 } 138 get_plugin_list(&self) -> Vec<Plugin>139 pub fn get_plugin_list(&self) -> Vec<Plugin> { 140 unsafe { 141 FromGlibPtrContainer::from_glib_full(gst_sys::gst_registry_get_plugin_list( 142 self.to_glib_none().0, 143 )) 144 } 145 } 146 lookup(&self, filename: &str) -> Option<Plugin>147 pub fn lookup(&self, filename: &str) -> Option<Plugin> { 148 unsafe { 149 from_glib_full(gst_sys::gst_registry_lookup( 150 self.to_glib_none().0, 151 filename.to_glib_none().0, 152 )) 153 } 154 } 155 lookup_feature(&self, name: &str) -> Option<PluginFeature>156 pub fn lookup_feature(&self, name: &str) -> Option<PluginFeature> { 157 unsafe { 158 from_glib_full(gst_sys::gst_registry_lookup_feature( 159 self.to_glib_none().0, 160 name.to_glib_none().0, 161 )) 162 } 163 } 164 plugin_filter<P: FnMut(&Plugin) -> bool>(&self, filter: P, first: bool) -> Vec<Plugin>165 pub fn plugin_filter<P: FnMut(&Plugin) -> bool>(&self, filter: P, first: bool) -> Vec<Plugin> { 166 let filter_data: P = filter; 167 unsafe extern "C" fn filter_func<P: FnMut(&Plugin) -> bool>( 168 plugin: *mut gst_sys::GstPlugin, 169 user_data: glib_sys::gpointer, 170 ) -> glib_sys::gboolean { 171 let plugin = from_glib_borrow(plugin); 172 let callback: *mut P = user_data as *const _ as usize as *mut P; 173 let res = (*callback)(&plugin); 174 res.to_glib() 175 } 176 let filter = Some(filter_func::<P> as _); 177 let super_callback0: &P = &filter_data; 178 unsafe { 179 FromGlibPtrContainer::from_glib_full(gst_sys::gst_registry_plugin_filter( 180 self.to_glib_none().0, 181 filter, 182 first.to_glib(), 183 super_callback0 as *const _ as usize as *mut _, 184 )) 185 } 186 } 187 remove_feature<P: IsA<PluginFeature>>(&self, feature: &P)188 pub fn remove_feature<P: IsA<PluginFeature>>(&self, feature: &P) { 189 unsafe { 190 gst_sys::gst_registry_remove_feature( 191 self.to_glib_none().0, 192 feature.as_ref().to_glib_none().0, 193 ); 194 } 195 } 196 remove_plugin(&self, plugin: &Plugin)197 pub fn remove_plugin(&self, plugin: &Plugin) { 198 unsafe { 199 gst_sys::gst_registry_remove_plugin(self.to_glib_none().0, plugin.to_glib_none().0); 200 } 201 } 202 scan_path<P: AsRef<std::path::Path>>(&self, path: P) -> bool203 pub fn scan_path<P: AsRef<std::path::Path>>(&self, path: P) -> bool { 204 unsafe { 205 from_glib(gst_sys::gst_registry_scan_path( 206 self.to_glib_none().0, 207 path.as_ref().to_glib_none().0, 208 )) 209 } 210 } 211 get() -> Registry212 pub fn get() -> Registry { 213 assert_initialized_main_thread!(); 214 unsafe { from_glib_none(gst_sys::gst_registry_get()) } 215 } 216 connect_feature_added<F: Fn(&Registry, &PluginFeature) + Send + Sync + 'static>( &self, f: F, ) -> SignalHandlerId217 pub fn connect_feature_added<F: Fn(&Registry, &PluginFeature) + Send + Sync + 'static>( 218 &self, 219 f: F, 220 ) -> SignalHandlerId { 221 unsafe extern "C" fn feature_added_trampoline< 222 F: Fn(&Registry, &PluginFeature) + Send + Sync + 'static, 223 >( 224 this: *mut gst_sys::GstRegistry, 225 feature: *mut gst_sys::GstPluginFeature, 226 f: glib_sys::gpointer, 227 ) { 228 let f: &F = &*(f as *const F); 229 f(&from_glib_borrow(this), &from_glib_borrow(feature)) 230 } 231 unsafe { 232 let f: Box_<F> = Box_::new(f); 233 connect_raw( 234 self.as_ptr() as *mut _, 235 b"feature-added\0".as_ptr() as *const _, 236 Some(transmute(feature_added_trampoline::<F> as usize)), 237 Box_::into_raw(f), 238 ) 239 } 240 } 241 connect_plugin_added<F: Fn(&Registry, &Plugin) + Send + Sync + 'static>( &self, f: F, ) -> SignalHandlerId242 pub fn connect_plugin_added<F: Fn(&Registry, &Plugin) + Send + Sync + 'static>( 243 &self, 244 f: F, 245 ) -> SignalHandlerId { 246 unsafe extern "C" fn plugin_added_trampoline< 247 F: Fn(&Registry, &Plugin) + Send + Sync + 'static, 248 >( 249 this: *mut gst_sys::GstRegistry, 250 plugin: *mut gst_sys::GstPlugin, 251 f: glib_sys::gpointer, 252 ) { 253 let f: &F = &*(f as *const F); 254 f(&from_glib_borrow(this), &from_glib_borrow(plugin)) 255 } 256 unsafe { 257 let f: Box_<F> = Box_::new(f); 258 connect_raw( 259 self.as_ptr() as *mut _, 260 b"plugin-added\0".as_ptr() as *const _, 261 Some(transmute(plugin_added_trampoline::<F> as usize)), 262 Box_::into_raw(f), 263 ) 264 } 265 } 266 } 267 268 unsafe impl Send for Registry {} 269 unsafe impl Sync for Registry {} 270