1// Take a look at the license at the top of the repository in the LICENSE file.
23use glib::translate::*;
45use crate::{ffi, Plugin, PluginFeature, Registry};
67impl Registry {
8#[doc(alias = "gst_registry_update")]
9pub fn update() -> Result<(), glib::BoolError> {
10crate::auto::functions::update_registry()
11 }
1213/// Runs a filter against all features of the plugins in the registry
14 /// and returns a GList with the results.
15 /// If the first flag is set, only the first match is
16 /// returned (as a list with a single object).
17 /// ## `filter`
18 /// the filter to use
19 /// ## `first`
20 /// only return first match
21 ///
22 /// # Returns
23 ///
24 /// a `GList` of
25 /// [`PluginFeature`][crate::PluginFeature]. Use `gst_plugin_feature_list_free()` after usage.
26 ///
27 /// MT safe.
28#[doc(alias = "gst_registry_feature_filter")]
29pub fn features_filtered<P: FnMut(&PluginFeature) -> bool>(
30&self,
31 filter: P,
32 first: bool,
33 ) -> glib::List<PluginFeature> {
34let mut filter_data: P = filter;
35unsafe extern "C" fn filter_func<P: FnMut(&PluginFeature) -> bool>(
36 feature: *mut ffi::GstPluginFeature,
37 user_data: glib::ffi::gpointer,
38 ) -> glib::ffi::gboolean {
39let feature = from_glib_borrow(feature);
40let callback = user_data as *mut P;
41let res = (*callback)(&feature);
42 res.into_glib()
43 }
44let filter = Some(filter_func::<P> as _);
45let super_callback0: &mut P = &mut filter_data;
46unsafe {
47 FromGlibPtrContainer::from_glib_full(ffi::gst_registry_feature_filter(
48self.to_glib_none().0,
49 filter,
50 first.into_glib(),
51 super_callback0 as *mut _ as *mut _,
52 ))
53 }
54 }
5556/// Retrieves a `GList` of [`PluginFeature`][crate::PluginFeature] of `type_`.
57 /// ## `type_`
58 /// a `GType`.
59 ///
60 /// # Returns
61 ///
62 /// a `GList` of
63 /// [`PluginFeature`][crate::PluginFeature] of `type_`. Use `gst_plugin_feature_list_free()` after use
64 ///
65 /// MT safe.
66#[doc(alias = "gst_registry_get_feature_list")]
67 #[doc(alias = "get_feature_list")]
68pub fn features(&self, type_: glib::types::Type) -> glib::List<PluginFeature> {
69unsafe {
70 FromGlibPtrContainer::from_glib_full(ffi::gst_registry_get_feature_list(
71self.to_glib_none().0,
72 type_.into_glib(),
73 ))
74 }
75 }
7677/// Retrieves a `GList` of features of the plugin with name `name`.
78 /// ## `name`
79 /// a plugin name.
80 ///
81 /// # Returns
82 ///
83 /// a `GList` of
84 /// [`PluginFeature`][crate::PluginFeature]. Use `gst_plugin_feature_list_free()` after usage.
85#[doc(alias = "gst_registry_get_feature_list_by_plugin")]
86 #[doc(alias = "get_feature_list_by_plugin")]
87pub fn features_by_plugin(&self, name: &str) -> glib::List<PluginFeature> {
88unsafe {
89 FromGlibPtrContainer::from_glib_full(ffi::gst_registry_get_feature_list_by_plugin(
90self.to_glib_none().0,
91 name.to_glib_none().0,
92 ))
93 }
94 }
9596/// Get a copy of all plugins registered in the given registry. The refcount
97 /// of each element in the list in incremented.
98 ///
99 /// # Returns
100 ///
101 /// a `GList` of [`Plugin`][crate::Plugin].
102 /// Use `gst_plugin_list_free()` after usage.
103 ///
104 /// MT safe.
105#[doc(alias = "gst_registry_get_plugin_list")]
106 #[doc(alias = "get_plugin_list")]
107pub fn plugins(&self) -> glib::List<Plugin> {
108unsafe {
109 FromGlibPtrContainer::from_glib_full(ffi::gst_registry_get_plugin_list(
110self.to_glib_none().0,
111 ))
112 }
113 }
114115/// Runs a filter against all plugins in the registry and returns a `GList` with
116 /// the results. If the first flag is set, only the first match is
117 /// returned (as a list with a single object).
118 /// Every plugin is reffed; use `gst_plugin_list_free()` after use, which
119 /// will unref again.
120 /// ## `filter`
121 /// the filter to use
122 /// ## `first`
123 /// only return first match
124 ///
125 /// # Returns
126 ///
127 /// a `GList` of [`Plugin`][crate::Plugin].
128 /// Use `gst_plugin_list_free()` after usage.
129 ///
130 /// MT safe.
131#[doc(alias = "gst_registry_plugin_filter")]
132pub fn plugins_filtered<P: FnMut(&Plugin) -> bool>(
133&self,
134 filter: P,
135 first: bool,
136 ) -> glib::List<Plugin> {
137let mut filter_data: P = filter;
138unsafe extern "C" fn filter_func<P: FnMut(&Plugin) -> bool>(
139 plugin: *mut ffi::GstPlugin,
140 user_data: glib::ffi::gpointer,
141 ) -> glib::ffi::gboolean {
142let plugin = from_glib_borrow(plugin);
143let callback = user_data as *mut P;
144let res = (*callback)(&plugin);
145 res.into_glib()
146 }
147let filter = Some(filter_func::<P> as _);
148let super_callback0: &mut P = &mut filter_data;
149unsafe {
150 FromGlibPtrContainer::from_glib_full(ffi::gst_registry_plugin_filter(
151self.to_glib_none().0,
152 filter,
153 first.into_glib(),
154 super_callback0 as *mut _ as *mut _,
155 ))
156 }
157 }
158}