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