2020-12-15 10:53:31 +00:00
|
|
|
// Take a look at the license at the top of the repository in the LICENSE file.
|
2018-02-19 20:15:52 +00:00
|
|
|
|
2023-01-03 18:58:25 +00:00
|
|
|
use std::{boxed::Box as Box_, mem::transmute};
|
2018-02-19 20:15:52 +00:00
|
|
|
|
2023-01-03 18:58:25 +00:00
|
|
|
use glib::{
|
|
|
|
prelude::*,
|
|
|
|
signal::{connect_raw, SignalHandlerId},
|
|
|
|
translate::*,
|
|
|
|
};
|
2018-02-19 20:15:52 +00:00
|
|
|
|
2023-01-03 18:58:25 +00:00
|
|
|
use crate::auto::Discoverer;
|
2018-02-19 20:15:52 +00:00
|
|
|
|
|
|
|
impl Discoverer {
|
2021-05-03 18:40:21 +00:00
|
|
|
pub fn set_timeout(&self, timeout: gst::ClockTime) {
|
2023-04-20 13:42:39 +00:00
|
|
|
self.set_property("timeout", timeout);
|
2018-02-19 20:15:52 +00:00
|
|
|
}
|
|
|
|
|
2021-05-03 18:40:21 +00:00
|
|
|
pub fn timeout(&self) -> gst::ClockTime {
|
2021-11-06 17:09:27 +00:00
|
|
|
self.property("timeout")
|
2018-02-19 20:15:52 +00:00
|
|
|
}
|
|
|
|
|
2021-05-03 18:40:21 +00:00
|
|
|
#[doc(alias = "timeout")]
|
|
|
|
pub fn connect_timeout_notify<F: Fn(&Self) + Send + Sync + 'static>(
|
2018-03-02 19:06:45 +00:00
|
|
|
&self,
|
|
|
|
f: F,
|
|
|
|
) -> SignalHandlerId {
|
2018-02-19 20:15:52 +00:00
|
|
|
unsafe {
|
2019-01-29 16:22:05 +00:00
|
|
|
let f: Box_<F> = Box_::new(f);
|
2019-01-16 11:32:58 +00:00
|
|
|
connect_raw(
|
|
|
|
self.as_ptr() as *mut _,
|
|
|
|
b"notify::timeout\0".as_ptr() as *const _,
|
2020-04-13 16:18:57 +00:00
|
|
|
Some(transmute::<_, unsafe extern "C" fn()>(
|
|
|
|
notify_timeout_trampoline::<Self, F> as *const (),
|
|
|
|
)),
|
2019-01-29 16:22:05 +00:00
|
|
|
Box_::into_raw(f),
|
2018-03-02 19:06:45 +00:00
|
|
|
)
|
2018-02-19 20:15:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-29 16:22:05 +00:00
|
|
|
unsafe extern "C" fn notify_timeout_trampoline<P, F: Fn(&P) + Send + Sync + 'static>(
|
2020-11-22 10:10:54 +00:00
|
|
|
this: *mut ffi::GstDiscoverer,
|
|
|
|
_param_spec: glib::ffi::gpointer,
|
|
|
|
f: glib::ffi::gpointer,
|
2018-03-02 19:06:45 +00:00
|
|
|
) where
|
|
|
|
P: IsA<Discoverer>,
|
|
|
|
{
|
2019-02-21 17:30:36 +00:00
|
|
|
let f: &F = &*(f as *const F);
|
2021-07-30 10:19:24 +00:00
|
|
|
f(Discoverer::from_glib_borrow(this).unsafe_cast_ref())
|
2018-02-19 20:15:52 +00:00
|
|
|
}
|