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