1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
// DO NOT EDIT

use glib::{
    prelude::*,
    signal::{connect_raw, SignalHandlerId},
    translate::*,
};
use std::boxed::Box as Box_;

glib::wrapper! {
    ///
    ///
    /// ## Properties
    ///
    ///
    /// #### `timeout`
    ///  The timeout (in milliseconds) for the `GstDiscoverer` operations
    ///
    /// Readable | Writeable | Construct
    ///
    ///
    /// #### `use-cache`
    ///  Readable | Writeable | Construct
    ///
    /// ## Signals
    ///
    ///
    /// #### `discovered`
    ///
    ///
    ///
    /// #### `load-serialized-info`
    ///  Retrieves information about a URI from and external source of information,
    /// like a cache file. This is used by the discoverer to speed up the
    /// discovery.
    ///
    ///
    ///
    ///
    /// #### `source-setup`
    ///  Allows to setup the source element before the discoverer runs.
    ///
    ///
    ///
    /// # Implements
    ///
    /// [`trait@glib::ObjectExt`]
    #[doc(alias = "GESDiscovererManager")]
    pub struct DiscovererManager(Object<ffi::GESDiscovererManager, ffi::GESDiscovererManagerClass>);

    match fn {
        type_ => || ffi::ges_discoverer_manager_get_type(),
    }
}

impl DiscovererManager {
    ///
    /// # Returns
    ///
    /// The timeout to use for the discoverer
    #[doc(alias = "ges_discoverer_manager_get_timeout")]
    #[doc(alias = "get_timeout")]
    pub fn timeout(&self) -> Option<gst::ClockTime> {
        unsafe {
            from_glib(ffi::ges_discoverer_manager_get_timeout(
                self.to_glib_none().0,
            ))
        }
    }

    ///
    /// # Returns
    ///
    /// Whether to use the cache or not
    #[doc(alias = "ges_discoverer_manager_get_use_cache")]
    #[doc(alias = "get_use_cache")]
    pub fn uses_cache(&self) -> bool {
        unsafe {
            from_glib(ffi::ges_discoverer_manager_get_use_cache(
                self.to_glib_none().0,
            ))
        }
    }

    /// Sets the timeout to use for the discoverer
    /// ## `timeout`
    /// The timeout to set
    #[doc(alias = "ges_discoverer_manager_set_timeout")]
    pub fn set_timeout(&self, timeout: impl Into<Option<gst::ClockTime>>) {
        unsafe {
            ffi::ges_discoverer_manager_set_timeout(
                self.to_glib_none().0,
                timeout.into().into_glib(),
            );
        }
    }

    /// Sets whether to use the cache or not
    /// ## `use_cache`
    /// Whether to use the cache
    #[doc(alias = "ges_discoverer_manager_set_use_cache")]
    pub fn set_use_cache(&self, use_cache: bool) {
        unsafe {
            ffi::ges_discoverer_manager_set_use_cache(self.to_glib_none().0, use_cache.into_glib());
        }
    }

    #[doc(alias = "use-cache")]
    pub fn get_property_use_cache(&self) -> bool {
        ObjectExt::property(self, "use-cache")
    }

    #[doc(alias = "use-cache")]
    pub fn set_property_use_cache(&self, use_cache: bool) {
        ObjectExt::set_property(self, "use-cache", use_cache)
    }

    ///
    /// # Returns
    ///
    /// The default [`DiscovererManager`][crate::DiscovererManager]
    #[doc(alias = "ges_discoverer_manager_get_default")]
    #[doc(alias = "get_default")]
    #[allow(clippy::should_implement_trait)]
    pub fn default() -> DiscovererManager {
        assert_initialized_main_thread!();
        unsafe { from_glib_full(ffi::ges_discoverer_manager_get_default()) }
    }

    /// ## `info`
    /// The [`gst_pbutils::DiscovererInfo`][crate::gst_pbutils::DiscovererInfo] representing the discovered URI
    /// ## `error`
    /// The [`glib::Error`][crate::glib::Error] that occurred, or [`None`]
    #[cfg(feature = "v1_24")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
    #[doc(alias = "discovered")]
    pub fn connect_discovered<
        F: Fn(&Self, &gst_pbutils::DiscovererInfo, Option<&glib::Error>) + 'static,
    >(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn discovered_trampoline<
            F: Fn(&DiscovererManager, &gst_pbutils::DiscovererInfo, Option<&glib::Error>) + 'static,
        >(
            this: *mut ffi::GESDiscovererManager,
            info: *mut gst_pbutils::ffi::GstDiscovererInfo,
            error: *mut glib::ffi::GError,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(
                &from_glib_borrow(this),
                &from_glib_borrow(info),
                Option::<glib::Error>::from_glib_borrow(error)
                    .as_ref()
                    .as_ref(),
            )
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"discovered\0".as_ptr() as *const _,
                Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
                    discovered_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    /// Retrieves information about a URI from and external source of information,
    /// like a cache file. This is used by the discoverer to speed up the
    /// discovery.
    /// ## `uri`
    /// The URI to load the serialized info for
    ///
    /// # Returns
    ///
    /// The [`gst_pbutils::DiscovererInfo`][crate::gst_pbutils::DiscovererInfo] representing
    /// `uri`, or [`None`] if no information
    #[cfg(feature = "v1_24")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
    #[doc(alias = "load-serialized-info")]
    pub fn connect_load_serialized_info<
        F: Fn(&Self, &str) -> Option<gst_pbutils::DiscovererInfo> + 'static,
    >(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn load_serialized_info_trampoline<
            F: Fn(&DiscovererManager, &str) -> Option<gst_pbutils::DiscovererInfo> + 'static,
        >(
            this: *mut ffi::GESDiscovererManager,
            uri: *mut libc::c_char,
            f: glib::ffi::gpointer,
        ) -> *mut gst_pbutils::ffi::GstDiscovererInfo {
            let f: &F = &*(f as *const F);
            f(
                &from_glib_borrow(this),
                &glib::GString::from_glib_borrow(uri),
            )
            .to_glib_full()
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"load-serialized-info\0".as_ptr() as *const _,
                Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
                    load_serialized_info_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    /// Allows to setup the source element before the discoverer runs.
    /// ## `source`
    /// The source [`gst::Element`][crate::gst::Element] to setup
    #[cfg(feature = "v1_24")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
    #[doc(alias = "source-setup")]
    pub fn connect_source_setup<F: Fn(&Self, &gst::Element) + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn source_setup_trampoline<
            F: Fn(&DiscovererManager, &gst::Element) + 'static,
        >(
            this: *mut ffi::GESDiscovererManager,
            source: *mut gst::ffi::GstElement,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this), &from_glib_borrow(source))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"source-setup\0".as_ptr() as *const _,
                Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
                    source_setup_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[cfg(feature = "v1_24")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
    #[doc(alias = "timeout")]
    pub fn connect_timeout_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_timeout_trampoline<F: Fn(&DiscovererManager) + 'static>(
            this: *mut ffi::GESDiscovererManager,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::timeout\0".as_ptr() as *const _,
                Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
                    notify_timeout_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "use-cache")]
    pub fn connect_use_cache_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_use_cache_trampoline<F: Fn(&DiscovererManager) + 'static>(
            this: *mut ffi::GESDiscovererManager,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::use-cache\0".as_ptr() as *const _,
                Some(std::mem::transmute::<_, unsafe extern "C" fn()>(
                    notify_use_cache_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}