gstreamer/
registry.rs

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