| 1 | // Take a look at the license at the top of the repository in the LICENSE file. |
| 2 | |
| 3 | use glib::translate::*; |
| 4 | |
| 5 | use crate::{ffi, Plugin, PluginFeature, Registry}; |
| 6 | |
| 7 | impl Registry { |
| 8 | #[doc (alias = "gst_registry_update" )] |
| 9 | pub fn update() -> Result<(), glib::BoolError> { |
| 10 | crate::auto::functions::update_registry() |
| 11 | } |
| 12 | |
| 13 | #[doc (alias = "gst_registry_feature_filter" )] |
| 14 | pub fn features_filtered<P: FnMut(&PluginFeature) -> bool>( |
| 15 | &self, |
| 16 | filter: P, |
| 17 | first: bool, |
| 18 | ) -> glib::List<PluginFeature> { |
| 19 | let mut filter_data: P = filter; |
| 20 | unsafe extern "C" fn filter_func<P: FnMut(&PluginFeature) -> bool>( |
| 21 | feature: *mut ffi::GstPluginFeature, |
| 22 | user_data: glib::ffi::gpointer, |
| 23 | ) -> glib::ffi::gboolean { |
| 24 | let feature = from_glib_borrow(feature); |
| 25 | let callback = user_data as *mut P; |
| 26 | let res = (*callback)(&feature); |
| 27 | res.into_glib() |
| 28 | } |
| 29 | let filter = Some(filter_func::<P> as _); |
| 30 | let super_callback0: &mut P = &mut filter_data; |
| 31 | unsafe { |
| 32 | FromGlibPtrContainer::from_glib_full(ffi::gst_registry_feature_filter( |
| 33 | self.to_glib_none().0, |
| 34 | filter, |
| 35 | first.into_glib(), |
| 36 | super_callback0 as *mut _ as *mut _, |
| 37 | )) |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | #[doc (alias = "gst_registry_get_feature_list" )] |
| 42 | #[doc (alias = "get_feature_list" )] |
| 43 | pub fn features(&self, type_: glib::types::Type) -> glib::List<PluginFeature> { |
| 44 | unsafe { |
| 45 | FromGlibPtrContainer::from_glib_full(ffi::gst_registry_get_feature_list( |
| 46 | self.to_glib_none().0, |
| 47 | type_.into_glib(), |
| 48 | )) |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | #[doc (alias = "gst_registry_get_feature_list_by_plugin" )] |
| 53 | #[doc (alias = "get_feature_list_by_plugin" )] |
| 54 | pub fn features_by_plugin(&self, name: &str) -> glib::List<PluginFeature> { |
| 55 | unsafe { |
| 56 | FromGlibPtrContainer::from_glib_full(ffi::gst_registry_get_feature_list_by_plugin( |
| 57 | self.to_glib_none().0, |
| 58 | name.to_glib_none().0, |
| 59 | )) |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | #[doc (alias = "gst_registry_get_plugin_list" )] |
| 64 | #[doc (alias = "get_plugin_list" )] |
| 65 | pub fn plugins(&self) -> glib::List<Plugin> { |
| 66 | unsafe { |
| 67 | FromGlibPtrContainer::from_glib_full(ffi::gst_registry_get_plugin_list( |
| 68 | self.to_glib_none().0, |
| 69 | )) |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | #[doc (alias = "gst_registry_plugin_filter" )] |
| 74 | pub fn plugins_filtered<P: FnMut(&Plugin) -> bool>( |
| 75 | &self, |
| 76 | filter: P, |
| 77 | first: bool, |
| 78 | ) -> glib::List<Plugin> { |
| 79 | let mut filter_data: P = filter; |
| 80 | unsafe extern "C" fn filter_func<P: FnMut(&Plugin) -> bool>( |
| 81 | plugin: *mut ffi::GstPlugin, |
| 82 | user_data: glib::ffi::gpointer, |
| 83 | ) -> glib::ffi::gboolean { |
| 84 | let plugin = from_glib_borrow(plugin); |
| 85 | let callback = user_data as *mut P; |
| 86 | let res = (*callback)(&plugin); |
| 87 | res.into_glib() |
| 88 | } |
| 89 | let filter = Some(filter_func::<P> as _); |
| 90 | let super_callback0: &mut P = &mut filter_data; |
| 91 | unsafe { |
| 92 | FromGlibPtrContainer::from_glib_full(ffi::gst_registry_plugin_filter( |
| 93 | self.to_glib_none().0, |
| 94 | filter, |
| 95 | first.into_glib(), |
| 96 | super_callback0 as *mut _ as *mut _, |
| 97 | )) |
| 98 | } |
| 99 | } |
| 100 | } |
| 101 | |