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, Plugin, PluginFeature}; |
7 | use glib::{ |
8 | prelude::*, |
9 | signal::{connect_raw, SignalHandlerId}, |
10 | translate::*, |
11 | }; |
12 | use std::{boxed::Box as Box_, mem::transmute}; |
13 | |
14 | glib::wrapper! { |
15 | #[doc (alias = "GstRegistry" )] |
16 | pub struct Registry(Object<ffi::GstRegistry, ffi::GstRegistryClass>) @extends Object; |
17 | |
18 | match fn { |
19 | type_ => || ffi::gst_registry_get_type(), |
20 | } |
21 | } |
22 | |
23 | impl Registry { |
24 | #[doc (alias = "gst_registry_add_feature" )] |
25 | pub fn add_feature( |
26 | &self, |
27 | feature: &impl IsA<PluginFeature>, |
28 | ) -> Result<(), glib::error::BoolError> { |
29 | unsafe { |
30 | glib::result_from_gboolean!( |
31 | ffi::gst_registry_add_feature( |
32 | self.to_glib_none().0, |
33 | feature.as_ref().to_glib_none().0 |
34 | ), |
35 | "Failed to add feature" |
36 | ) |
37 | } |
38 | } |
39 | |
40 | #[doc (alias = "gst_registry_add_plugin" )] |
41 | pub fn add_plugin(&self, plugin: &Plugin) -> Result<(), glib::error::BoolError> { |
42 | unsafe { |
43 | glib::result_from_gboolean!( |
44 | ffi::gst_registry_add_plugin(self.to_glib_none().0, plugin.to_glib_none().0), |
45 | "Failed to add plugin" |
46 | ) |
47 | } |
48 | } |
49 | |
50 | #[doc (alias = "gst_registry_check_feature_version" )] |
51 | pub fn check_feature_version( |
52 | &self, |
53 | feature_name: &str, |
54 | min_major: u32, |
55 | min_minor: u32, |
56 | min_micro: u32, |
57 | ) -> bool { |
58 | unsafe { |
59 | from_glib(ffi::gst_registry_check_feature_version( |
60 | self.to_glib_none().0, |
61 | feature_name.to_glib_none().0, |
62 | min_major, |
63 | min_minor, |
64 | min_micro, |
65 | )) |
66 | } |
67 | } |
68 | |
69 | #[doc (alias = "gst_registry_find_feature" )] |
70 | pub fn find_feature(&self, name: &str, type_: glib::types::Type) -> Option<PluginFeature> { |
71 | unsafe { |
72 | from_glib_full(ffi::gst_registry_find_feature( |
73 | self.to_glib_none().0, |
74 | name.to_glib_none().0, |
75 | type_.into_glib(), |
76 | )) |
77 | } |
78 | } |
79 | |
80 | #[doc (alias = "gst_registry_find_plugin" )] |
81 | pub fn find_plugin(&self, name: &str) -> Option<Plugin> { |
82 | unsafe { |
83 | from_glib_full(ffi::gst_registry_find_plugin( |
84 | self.to_glib_none().0, |
85 | name.to_glib_none().0, |
86 | )) |
87 | } |
88 | } |
89 | |
90 | #[doc (alias = "gst_registry_get_feature_list_cookie" )] |
91 | #[doc (alias = "get_feature_list_cookie" )] |
92 | pub fn feature_list_cookie(&self) -> u32 { |
93 | unsafe { ffi::gst_registry_get_feature_list_cookie(self.to_glib_none().0) } |
94 | } |
95 | |
96 | #[doc (alias = "gst_registry_lookup" )] |
97 | pub fn lookup(&self, filename: &str) -> Option<Plugin> { |
98 | unsafe { |
99 | from_glib_full(ffi::gst_registry_lookup( |
100 | self.to_glib_none().0, |
101 | filename.to_glib_none().0, |
102 | )) |
103 | } |
104 | } |
105 | |
106 | #[doc (alias = "gst_registry_lookup_feature" )] |
107 | pub fn lookup_feature(&self, name: &str) -> Option<PluginFeature> { |
108 | unsafe { |
109 | from_glib_full(ffi::gst_registry_lookup_feature( |
110 | self.to_glib_none().0, |
111 | name.to_glib_none().0, |
112 | )) |
113 | } |
114 | } |
115 | |
116 | #[doc (alias = "gst_registry_remove_feature" )] |
117 | pub fn remove_feature(&self, feature: &impl IsA<PluginFeature>) { |
118 | unsafe { |
119 | ffi::gst_registry_remove_feature( |
120 | self.to_glib_none().0, |
121 | feature.as_ref().to_glib_none().0, |
122 | ); |
123 | } |
124 | } |
125 | |
126 | #[doc (alias = "gst_registry_remove_plugin" )] |
127 | pub fn remove_plugin(&self, plugin: &Plugin) { |
128 | unsafe { |
129 | ffi::gst_registry_remove_plugin(self.to_glib_none().0, plugin.to_glib_none().0); |
130 | } |
131 | } |
132 | |
133 | #[doc (alias = "gst_registry_scan_path" )] |
134 | pub fn scan_path(&self, path: impl AsRef<std::path::Path>) -> bool { |
135 | unsafe { |
136 | from_glib(ffi::gst_registry_scan_path( |
137 | self.to_glib_none().0, |
138 | path.as_ref().to_glib_none().0, |
139 | )) |
140 | } |
141 | } |
142 | |
143 | #[doc (alias = "gst_registry_get" )] |
144 | pub fn get() -> Registry { |
145 | assert_initialized_main_thread!(); |
146 | unsafe { from_glib_none(ffi::gst_registry_get()) } |
147 | } |
148 | |
149 | #[doc (alias = "feature-added" )] |
150 | pub fn connect_feature_added<F: Fn(&Self, &PluginFeature) + Send + Sync + 'static>( |
151 | &self, |
152 | f: F, |
153 | ) -> SignalHandlerId { |
154 | unsafe extern "C" fn feature_added_trampoline< |
155 | F: Fn(&Registry, &PluginFeature) + Send + Sync + 'static, |
156 | >( |
157 | this: *mut ffi::GstRegistry, |
158 | feature: *mut ffi::GstPluginFeature, |
159 | f: glib::ffi::gpointer, |
160 | ) { |
161 | let f: &F = &*(f as *const F); |
162 | f(&from_glib_borrow(this), &from_glib_borrow(feature)) |
163 | } |
164 | unsafe { |
165 | let f: Box_<F> = Box_::new(f); |
166 | connect_raw( |
167 | self.as_ptr() as *mut _, |
168 | b"feature-added \0" .as_ptr() as *const _, |
169 | Some(transmute::<_, unsafe extern "C" fn()>( |
170 | feature_added_trampoline::<F> as *const (), |
171 | )), |
172 | Box_::into_raw(f), |
173 | ) |
174 | } |
175 | } |
176 | |
177 | #[doc (alias = "plugin-added" )] |
178 | pub fn connect_plugin_added<F: Fn(&Self, &Plugin) + Send + Sync + 'static>( |
179 | &self, |
180 | f: F, |
181 | ) -> SignalHandlerId { |
182 | unsafe extern "C" fn plugin_added_trampoline< |
183 | F: Fn(&Registry, &Plugin) + Send + Sync + 'static, |
184 | >( |
185 | this: *mut ffi::GstRegistry, |
186 | plugin: *mut ffi::GstPlugin, |
187 | f: glib::ffi::gpointer, |
188 | ) { |
189 | let f: &F = &*(f as *const F); |
190 | f(&from_glib_borrow(this), &from_glib_borrow(plugin)) |
191 | } |
192 | unsafe { |
193 | let f: Box_<F> = Box_::new(f); |
194 | connect_raw( |
195 | self.as_ptr() as *mut _, |
196 | b"plugin-added \0" .as_ptr() as *const _, |
197 | Some(transmute::<_, unsafe extern "C" fn()>( |
198 | plugin_added_trampoline::<F> as *const (), |
199 | )), |
200 | Box_::into_raw(f), |
201 | ) |
202 | } |
203 | } |
204 | } |
205 | |
206 | unsafe impl Send for Registry {} |
207 | unsafe impl Sync for Registry {} |
208 | |