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
|
|
|
|
2020-11-22 10:10:54 +00:00
|
|
|
use crate::auto::Discoverer;
|
2018-02-19 20:15:52 +00:00
|
|
|
|
2019-01-16 11:32:58 +00:00
|
|
|
use glib::object::{Cast, ObjectType};
|
|
|
|
use glib::signal::connect_raw;
|
2018-04-25 08:10:06 +00:00
|
|
|
use glib::signal::SignalHandlerId;
|
2018-02-19 20:15:52 +00:00
|
|
|
use glib::translate::*;
|
2018-04-25 08:10:06 +00:00
|
|
|
use glib::IsA;
|
|
|
|
use glib::Value;
|
2018-02-19 20:15:52 +00:00
|
|
|
|
|
|
|
use std::boxed::Box as Box_;
|
2020-04-13 16:18:57 +00:00
|
|
|
use std::mem::transmute;
|
2018-02-19 20:15:52 +00:00
|
|
|
|
|
|
|
impl Discoverer {
|
|
|
|
pub fn set_property_timeout(&self, timeout: gst::ClockTime) {
|
|
|
|
unsafe {
|
2020-11-22 10:10:54 +00:00
|
|
|
glib::gobject_ffi::g_object_set_property(
|
2019-01-16 11:32:58 +00:00
|
|
|
self.as_ptr() as *mut _,
|
2018-03-02 19:06:45 +00:00
|
|
|
"timeout".to_glib_none().0,
|
|
|
|
Value::from(&timeout).to_glib_none().0,
|
|
|
|
);
|
2018-02-19 20:15:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn property_timeout(&self) -> gst::ClockTime {
|
2018-02-19 20:15:52 +00:00
|
|
|
let mut value = Value::from(&0u64);
|
|
|
|
unsafe {
|
2020-11-22 10:10:54 +00:00
|
|
|
glib::gobject_ffi::g_object_get_property(
|
2019-01-16 11:32:58 +00:00
|
|
|
self.as_ptr() as *mut _,
|
2018-03-02 19:06:45 +00:00
|
|
|
"timeout".to_glib_none().0,
|
|
|
|
value.to_glib_none_mut().0,
|
|
|
|
);
|
2018-02-19 20:15:52 +00:00
|
|
|
}
|
2021-04-20 07:19:02 +00:00
|
|
|
value.get().expect("Discoverer::get_property_timeout")
|
2018-02-19 20:15:52 +00:00
|
|
|
}
|
|
|
|
|
2018-03-02 19:06:45 +00:00
|
|
|
pub fn connect_property_timeout_notify<F: Fn(&Self) + Send + Sync + 'static>(
|
|
|
|
&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);
|
2020-04-05 14:52:56 +00:00
|
|
|
f(&Discoverer::from_glib_borrow(this).unsafe_cast_ref())
|
2018-02-19 20:15:52 +00:00
|
|
|
}
|