Skip to main content

gstreamer_editing_services/auto/
discoverer_manager.rs

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
6use crate::ffi;
7use glib::{
8    object::ObjectType as _,
9    prelude::*,
10    signal::{SignalHandlerId, connect_raw},
11    translate::*,
12};
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16    ///
17    ///
18    /// ## Properties
19    ///
20    ///
21    /// #### `timeout`
22    ///  The timeout (in milliseconds) for the `GstDiscoverer` operations
23    ///
24    /// Readable | Writeable | Construct
25    ///
26    ///
27    /// #### `use-cache`
28    ///  Readable | Writeable | Construct
29    ///
30    /// ## Signals
31    ///
32    ///
33    /// #### `discovered`
34    ///
35    ///
36    ///
37    /// #### `load-serialized-info`
38    ///  Retrieves information about a URI from and external source of information,
39    /// like a cache file. This is used by the discoverer to speed up the
40    /// discovery.
41    ///
42    ///
43    ///
44    ///
45    /// #### `source-setup`
46    ///  Allows to setup the source element before the discoverer runs.
47    ///
48    ///
49    ///
50    /// # Implements
51    ///
52    /// [`trait@glib::ObjectExt`]
53    #[doc(alias = "GESDiscovererManager")]
54    pub struct DiscovererManager(Object<ffi::GESDiscovererManager, ffi::GESDiscovererManagerClass>);
55
56    match fn {
57        type_ => || ffi::ges_discoverer_manager_get_type(),
58    }
59}
60
61impl DiscovererManager {
62    ///
63    /// # Returns
64    ///
65    /// The timeout to use for the discoverer
66    #[doc(alias = "ges_discoverer_manager_get_timeout")]
67    #[doc(alias = "get_timeout")]
68    pub fn timeout(&self) -> Option<gst::ClockTime> {
69        unsafe {
70            from_glib(ffi::ges_discoverer_manager_get_timeout(
71                self.to_glib_none().0,
72            ))
73        }
74    }
75
76    ///
77    /// # Returns
78    ///
79    /// Whether to use the cache or not
80    #[doc(alias = "ges_discoverer_manager_get_use_cache")]
81    #[doc(alias = "get_use_cache")]
82    #[doc(alias = "use-cache")]
83    pub fn uses_cache(&self) -> bool {
84        unsafe {
85            from_glib(ffi::ges_discoverer_manager_get_use_cache(
86                self.to_glib_none().0,
87            ))
88        }
89    }
90
91    /// Sets the timeout to use for the discoverer
92    /// ## `timeout`
93    /// The timeout to set
94    #[doc(alias = "ges_discoverer_manager_set_timeout")]
95    #[doc(alias = "timeout")]
96    pub fn set_timeout(&self, timeout: impl Into<Option<gst::ClockTime>>) {
97        unsafe {
98            ffi::ges_discoverer_manager_set_timeout(
99                self.to_glib_none().0,
100                timeout.into().into_glib(),
101            );
102        }
103    }
104
105    /// Sets whether to use the cache or not
106    /// ## `use_cache`
107    /// Whether to use the cache
108    #[doc(alias = "ges_discoverer_manager_set_use_cache")]
109    #[doc(alias = "use-cache")]
110    pub fn set_use_cache(&self, use_cache: bool) {
111        unsafe {
112            ffi::ges_discoverer_manager_set_use_cache(self.to_glib_none().0, use_cache.into_glib());
113        }
114    }
115
116    #[cfg(not(feature = "v1_24"))]
117    #[cfg_attr(docsrs, doc(cfg(not(feature = "v1_24"))))]
118    #[doc(alias = "use-cache")]
119    pub fn uses_cache(&self) -> bool {
120        ObjectExt::property(self, "use-cache")
121    }
122
123    #[cfg(not(feature = "v1_24"))]
124    #[cfg_attr(docsrs, doc(cfg(not(feature = "v1_24"))))]
125    #[doc(alias = "use-cache")]
126    pub fn set_use_cache(&self, use_cache: bool) {
127        ObjectExt::set_property(self, "use-cache", use_cache)
128    }
129
130    ///
131    /// # Returns
132    ///
133    /// The default [`DiscovererManager`][crate::DiscovererManager]
134    #[doc(alias = "ges_discoverer_manager_get_default")]
135    #[doc(alias = "get_default")]
136    #[allow(clippy::should_implement_trait)]
137    pub fn default() -> DiscovererManager {
138        assert_initialized_main_thread!();
139        unsafe { from_glib_full(ffi::ges_discoverer_manager_get_default()) }
140    }
141
142    /// ## `info`
143    /// The [`gst_pbutils::DiscovererInfo`][crate::gst_pbutils::DiscovererInfo] representing the discovered URI
144    /// ## `error`
145    /// The [`glib::Error`][crate::glib::Error] that occurred, or [`None`]
146    #[cfg(feature = "v1_24")]
147    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
148    #[doc(alias = "discovered")]
149    pub fn connect_discovered<
150        F: Fn(&Self, &gst_pbutils::DiscovererInfo, Option<&glib::Error>) + 'static,
151    >(
152        &self,
153        f: F,
154    ) -> SignalHandlerId {
155        unsafe extern "C" fn discovered_trampoline<
156            F: Fn(&DiscovererManager, &gst_pbutils::DiscovererInfo, Option<&glib::Error>) + 'static,
157        >(
158            this: *mut ffi::GESDiscovererManager,
159            info: *mut gst_pbutils::ffi::GstDiscovererInfo,
160            error: *mut glib::ffi::GError,
161            f: glib::ffi::gpointer,
162        ) {
163            unsafe {
164                let f: &F = &*(f as *const F);
165                f(
166                    &from_glib_borrow(this),
167                    &from_glib_borrow(info),
168                    Option::<glib::Error>::from_glib_borrow(error)
169                        .as_ref()
170                        .as_ref(),
171                )
172            }
173        }
174        unsafe {
175            let f: Box_<F> = Box_::new(f);
176            connect_raw(
177                self.as_ptr() as *mut _,
178                c"discovered".as_ptr(),
179                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
180                    discovered_trampoline::<F> as *const (),
181                )),
182                Box_::into_raw(f),
183            )
184        }
185    }
186
187    /// Retrieves information about a URI from and external source of information,
188    /// like a cache file. This is used by the discoverer to speed up the
189    /// discovery.
190    /// ## `uri`
191    /// The URI to load the serialized info for
192    ///
193    /// # Returns
194    ///
195    /// The [`gst_pbutils::DiscovererInfo`][crate::gst_pbutils::DiscovererInfo] representing
196    /// `uri`, or [`None`] if no information
197    #[cfg(feature = "v1_24")]
198    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
199    #[doc(alias = "load-serialized-info")]
200    pub fn connect_load_serialized_info<
201        F: Fn(&Self, &str) -> Option<gst_pbutils::DiscovererInfo> + 'static,
202    >(
203        &self,
204        f: F,
205    ) -> SignalHandlerId {
206        unsafe extern "C" fn load_serialized_info_trampoline<
207            F: Fn(&DiscovererManager, &str) -> Option<gst_pbutils::DiscovererInfo> + 'static,
208        >(
209            this: *mut ffi::GESDiscovererManager,
210            uri: *mut std::ffi::c_char,
211            f: glib::ffi::gpointer,
212        ) -> *mut gst_pbutils::ffi::GstDiscovererInfo {
213            unsafe {
214                let f: &F = &*(f as *const F);
215                f(
216                    &from_glib_borrow(this),
217                    &glib::GString::from_glib_borrow(uri),
218                )
219                .to_glib_full()
220            }
221        }
222        unsafe {
223            let f: Box_<F> = Box_::new(f);
224            connect_raw(
225                self.as_ptr() as *mut _,
226                c"load-serialized-info".as_ptr(),
227                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
228                    load_serialized_info_trampoline::<F> as *const (),
229                )),
230                Box_::into_raw(f),
231            )
232        }
233    }
234
235    /// Allows to setup the source element before the discoverer runs.
236    /// ## `source`
237    /// The source [`gst::Element`][crate::gst::Element] to setup
238    #[cfg(feature = "v1_24")]
239    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
240    #[doc(alias = "source-setup")]
241    pub fn connect_source_setup<F: Fn(&Self, &gst::Element) + 'static>(
242        &self,
243        f: F,
244    ) -> SignalHandlerId {
245        unsafe extern "C" fn source_setup_trampoline<
246            F: Fn(&DiscovererManager, &gst::Element) + 'static,
247        >(
248            this: *mut ffi::GESDiscovererManager,
249            source: *mut gst::ffi::GstElement,
250            f: glib::ffi::gpointer,
251        ) {
252            unsafe {
253                let f: &F = &*(f as *const F);
254                f(&from_glib_borrow(this), &from_glib_borrow(source))
255            }
256        }
257        unsafe {
258            let f: Box_<F> = Box_::new(f);
259            connect_raw(
260                self.as_ptr() as *mut _,
261                c"source-setup".as_ptr(),
262                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
263                    source_setup_trampoline::<F> as *const (),
264                )),
265                Box_::into_raw(f),
266            )
267        }
268    }
269
270    #[cfg(feature = "v1_24")]
271    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
272    #[doc(alias = "timeout")]
273    pub fn connect_timeout_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
274        unsafe extern "C" fn notify_timeout_trampoline<F: Fn(&DiscovererManager) + 'static>(
275            this: *mut ffi::GESDiscovererManager,
276            _param_spec: glib::ffi::gpointer,
277            f: glib::ffi::gpointer,
278        ) {
279            unsafe {
280                let f: &F = &*(f as *const F);
281                f(&from_glib_borrow(this))
282            }
283        }
284        unsafe {
285            let f: Box_<F> = Box_::new(f);
286            connect_raw(
287                self.as_ptr() as *mut _,
288                c"notify::timeout".as_ptr(),
289                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
290                    notify_timeout_trampoline::<F> as *const (),
291                )),
292                Box_::into_raw(f),
293            )
294        }
295    }
296
297    #[doc(alias = "use-cache")]
298    pub fn connect_use_cache_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
299        unsafe extern "C" fn notify_use_cache_trampoline<F: Fn(&DiscovererManager) + 'static>(
300            this: *mut ffi::GESDiscovererManager,
301            _param_spec: glib::ffi::gpointer,
302            f: glib::ffi::gpointer,
303        ) {
304            unsafe {
305                let f: &F = &*(f as *const F);
306                f(&from_glib_borrow(this))
307            }
308        }
309        unsafe {
310            let f: Box_<F> = Box_::new(f);
311            connect_raw(
312                self.as_ptr() as *mut _,
313                c"notify::use-cache".as_ptr(),
314                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
315                    notify_use_cache_trampoline::<F> as *const (),
316                )),
317                Box_::into_raw(f),
318            )
319        }
320    }
321}