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-06-14 09:22:53 +00:00
|
|
|
use std::{boxed::Box as Box_, fmt, 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-06-14 09:22:53 +00:00
|
|
|
use crate::{auto::Discoverer, DiscovererInfo};
|
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
|
|
|
}
|
2023-06-14 09:22:53 +00:00
|
|
|
|
|
|
|
pub struct DebugInfo<'a>(&'a DiscovererInfo);
|
|
|
|
|
|
|
|
impl<'a> fmt::Debug for DebugInfo<'a> {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
|
|
let stream_info = self.0.stream_info();
|
|
|
|
let stream_list = self.0.stream_list();
|
|
|
|
let container_streams = self.0.container_streams();
|
|
|
|
let audio_streams = self.0.audio_streams();
|
|
|
|
let video_streams = self.0.video_streams();
|
|
|
|
let subtitle_streams = self.0.subtitle_streams();
|
|
|
|
|
|
|
|
f.debug_struct("DiscovererInfo")
|
|
|
|
.field("uri", &self.0.uri())
|
|
|
|
.field("result", &self.0.result())
|
|
|
|
.field("duration", &self.0.duration())
|
|
|
|
.field("is-live", &self.0.is_live())
|
|
|
|
.field("is-seekable", &self.0.is_seekable())
|
|
|
|
.field(
|
|
|
|
"stream-info",
|
|
|
|
&stream_info.as_ref().map(|info| info.debug()),
|
|
|
|
)
|
|
|
|
.field(
|
|
|
|
"stream-list",
|
|
|
|
&stream_list
|
|
|
|
.iter()
|
|
|
|
.map(|info| info.debug())
|
|
|
|
.collect::<Vec<_>>(),
|
|
|
|
)
|
|
|
|
.field(
|
|
|
|
"container-streams",
|
|
|
|
&container_streams
|
|
|
|
.iter()
|
|
|
|
.map(|info| info.debug())
|
|
|
|
.collect::<Vec<_>>(),
|
|
|
|
)
|
|
|
|
.field(
|
|
|
|
"audio-streams",
|
|
|
|
&audio_streams
|
|
|
|
.iter()
|
|
|
|
.map(|info| info.debug())
|
|
|
|
.collect::<Vec<_>>(),
|
|
|
|
)
|
|
|
|
.field(
|
|
|
|
"video-streams",
|
|
|
|
&video_streams
|
|
|
|
.iter()
|
|
|
|
.map(|info| info.debug())
|
|
|
|
.collect::<Vec<_>>(),
|
|
|
|
)
|
|
|
|
.field(
|
|
|
|
"subtitle-streams",
|
|
|
|
&subtitle_streams
|
|
|
|
.iter()
|
|
|
|
.map(|info| info.debug())
|
|
|
|
.collect::<Vec<_>>(),
|
|
|
|
)
|
|
|
|
.field("toc", &self.0.toc())
|
|
|
|
.field("misc", &self.0.misc())
|
|
|
|
.field(
|
|
|
|
"missing-elements-installer-details",
|
|
|
|
&self.0.missing_elements_installer_details(),
|
|
|
|
)
|
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl DiscovererInfo {
|
|
|
|
pub fn debug(&self) -> DebugInfo {
|
|
|
|
DebugInfo(self)
|
|
|
|
}
|
|
|
|
}
|