2018-04-23 17:34:22 +00:00
|
|
|
// This file was generated by gir (https://github.com/gtk-rs/gir)
|
|
|
|
// from gir-files (https://github.com/gtk-rs/gir-files)
|
2018-02-19 20:15:52 +00:00
|
|
|
// DO NOT EDIT
|
|
|
|
|
2020-11-22 10:08:08 +00:00
|
|
|
use crate::DiscovererInfo;
|
2019-06-18 10:12:00 +00:00
|
|
|
use glib::object::ObjectType as ObjectType_;
|
|
|
|
use glib::signal::connect_raw;
|
|
|
|
use glib::signal::SignalHandlerId;
|
|
|
|
use glib::translate::*;
|
2019-04-23 14:32:09 +00:00
|
|
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
2020-11-19 09:16:33 +00:00
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
|
2019-04-23 14:32:09 +00:00
|
|
|
use glib::StaticType;
|
|
|
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
2020-11-19 09:16:33 +00:00
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
|
2019-04-23 14:32:09 +00:00
|
|
|
use glib::Value;
|
2018-02-19 20:15:52 +00:00
|
|
|
use std::boxed::Box as Box_;
|
2020-04-13 16:11:33 +00:00
|
|
|
use std::mem::transmute;
|
2018-02-19 20:15:52 +00:00
|
|
|
use std::ptr;
|
|
|
|
|
2020-11-22 10:08:08 +00:00
|
|
|
glib::glib_wrapper! {
|
|
|
|
pub struct Discoverer(Object<ffi::GstDiscoverer, ffi::GstDiscovererClass>);
|
2018-02-19 20:15:52 +00:00
|
|
|
|
|
|
|
match fn {
|
2020-11-22 10:08:08 +00:00
|
|
|
get_type => || ffi::gst_discoverer_get_type(),
|
2018-02-19 20:15:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Discoverer {
|
2019-11-10 16:55:02 +00:00
|
|
|
pub fn new(timeout: gst::ClockTime) -> Result<Discoverer, glib::Error> {
|
2018-02-19 20:15:52 +00:00
|
|
|
assert_initialized_main_thread!();
|
|
|
|
unsafe {
|
|
|
|
let mut error = ptr::null_mut();
|
2020-11-22 10:08:08 +00:00
|
|
|
let ret = ffi::gst_discoverer_new(timeout.to_glib(), &mut error);
|
2019-06-18 10:12:00 +00:00
|
|
|
if error.is_null() {
|
|
|
|
Ok(from_glib_full(ret))
|
|
|
|
} else {
|
|
|
|
Err(from_glib_full(error))
|
|
|
|
}
|
2018-02-19 20:15:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-10 16:55:02 +00:00
|
|
|
pub fn discover_uri(&self, uri: &str) -> Result<DiscovererInfo, glib::Error> {
|
2018-02-19 20:15:52 +00:00
|
|
|
unsafe {
|
|
|
|
let mut error = ptr::null_mut();
|
2020-11-22 10:08:08 +00:00
|
|
|
let ret = ffi::gst_discoverer_discover_uri(
|
2019-06-18 10:12:00 +00:00
|
|
|
self.to_glib_none().0,
|
|
|
|
uri.to_glib_none().0,
|
|
|
|
&mut error,
|
|
|
|
);
|
|
|
|
if error.is_null() {
|
|
|
|
Ok(from_glib_full(ret))
|
|
|
|
} else {
|
|
|
|
Err(from_glib_full(error))
|
|
|
|
}
|
2018-02-19 20:15:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn discover_uri_async(&self, uri: &str) -> Result<(), glib::error::BoolError> {
|
|
|
|
unsafe {
|
2020-11-22 10:08:08 +00:00
|
|
|
glib::glib_result_from_gboolean!(
|
|
|
|
ffi::gst_discoverer_discover_uri_async(self.to_glib_none().0, uri.to_glib_none().0),
|
2019-06-18 10:12:00 +00:00
|
|
|
"Failed to add URI to list of discovers"
|
|
|
|
)
|
2018-02-19 20:15:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn start(&self) {
|
|
|
|
unsafe {
|
2020-11-22 10:08:08 +00:00
|
|
|
ffi::gst_discoverer_start(self.to_glib_none().0);
|
2018-02-19 20:15:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn stop(&self) {
|
|
|
|
unsafe {
|
2020-11-22 10:08:08 +00:00
|
|
|
ffi::gst_discoverer_stop(self.to_glib_none().0);
|
2018-02-19 20:15:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-23 14:32:09 +00:00
|
|
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
2020-11-19 09:16:33 +00:00
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
|
2019-04-23 14:32:09 +00:00
|
|
|
pub fn get_property_use_cache(&self) -> bool {
|
|
|
|
unsafe {
|
|
|
|
let mut value = Value::from_type(<bool as StaticType>::static_type());
|
2020-11-22 10:08:08 +00:00
|
|
|
glib::gobject_ffi::g_object_get_property(
|
|
|
|
self.as_ptr() as *mut glib::gobject_ffi::GObject,
|
2019-06-18 10:12:00 +00:00
|
|
|
b"use-cache\0".as_ptr() as *const _,
|
|
|
|
value.to_glib_none_mut().0,
|
|
|
|
);
|
2019-08-10 17:32:57 +00:00
|
|
|
value
|
|
|
|
.get()
|
|
|
|
.expect("Return Value for property `use-cache` getter")
|
|
|
|
.unwrap()
|
2019-04-23 14:32:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
2020-11-19 09:16:33 +00:00
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
|
2019-04-23 14:32:09 +00:00
|
|
|
pub fn set_property_use_cache(&self, use_cache: bool) {
|
|
|
|
unsafe {
|
2020-11-22 10:08:08 +00:00
|
|
|
glib::gobject_ffi::g_object_set_property(
|
|
|
|
self.as_ptr() as *mut glib::gobject_ffi::GObject,
|
2019-06-18 10:12:00 +00:00
|
|
|
b"use-cache\0".as_ptr() as *const _,
|
|
|
|
Value::from(&use_cache).to_glib_none().0,
|
|
|
|
);
|
2019-04-23 14:32:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-18 10:12:00 +00:00
|
|
|
pub fn connect_discovered<
|
2019-11-10 16:55:02 +00:00
|
|
|
F: Fn(&Discoverer, &DiscovererInfo, Option<&glib::Error>) + Send + Sync + 'static,
|
2019-06-18 10:12:00 +00:00
|
|
|
>(
|
|
|
|
&self,
|
|
|
|
f: F,
|
|
|
|
) -> SignalHandlerId {
|
|
|
|
unsafe extern "C" fn discovered_trampoline<
|
2019-11-10 16:55:02 +00:00
|
|
|
F: Fn(&Discoverer, &DiscovererInfo, Option<&glib::Error>) + Send + Sync + 'static,
|
2019-06-18 10:12:00 +00:00
|
|
|
>(
|
2020-11-22 10:08:08 +00:00
|
|
|
this: *mut ffi::GstDiscoverer,
|
|
|
|
info: *mut ffi::GstDiscovererInfo,
|
|
|
|
error: *mut glib::ffi::GError,
|
|
|
|
f: glib::ffi::gpointer,
|
2019-06-18 10:12:00 +00:00
|
|
|
) {
|
2019-06-18 10:10:46 +00:00
|
|
|
let f: &F = &*(f as *const F);
|
2019-06-18 10:12:00 +00:00
|
|
|
f(
|
|
|
|
&from_glib_borrow(this),
|
|
|
|
&from_glib_borrow(info),
|
2020-04-05 14:52:56 +00:00
|
|
|
Option::<glib::Error>::from_glib_borrow(error)
|
|
|
|
.as_ref()
|
|
|
|
.as_ref(),
|
2019-06-18 10:12:00 +00:00
|
|
|
)
|
2019-06-18 10:10:46 +00:00
|
|
|
}
|
2018-02-19 20:15:52 +00:00
|
|
|
unsafe {
|
2019-01-29 13:53:44 +00:00
|
|
|
let f: Box_<F> = Box_::new(f);
|
2019-06-18 10:12:00 +00:00
|
|
|
connect_raw(
|
|
|
|
self.as_ptr() as *mut _,
|
|
|
|
b"discovered\0".as_ptr() as *const _,
|
2020-04-13 16:11:33 +00:00
|
|
|
Some(transmute::<_, unsafe extern "C" fn()>(
|
|
|
|
discovered_trampoline::<F> as *const (),
|
|
|
|
)),
|
2019-06-18 10:12:00 +00:00
|
|
|
Box_::into_raw(f),
|
|
|
|
)
|
2018-02-19 20:15:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-18 10:12:00 +00:00
|
|
|
pub fn connect_finished<F: Fn(&Discoverer) + Send + Sync + 'static>(
|
|
|
|
&self,
|
|
|
|
f: F,
|
|
|
|
) -> SignalHandlerId {
|
|
|
|
unsafe extern "C" fn finished_trampoline<F: Fn(&Discoverer) + Send + Sync + 'static>(
|
2020-11-22 10:08:08 +00:00
|
|
|
this: *mut ffi::GstDiscoverer,
|
|
|
|
f: glib::ffi::gpointer,
|
2019-06-18 10:12:00 +00:00
|
|
|
) {
|
2019-06-18 10:10:46 +00:00
|
|
|
let f: &F = &*(f as *const F);
|
|
|
|
f(&from_glib_borrow(this))
|
|
|
|
}
|
2018-02-19 20:15:52 +00:00
|
|
|
unsafe {
|
2019-01-29 13:53:44 +00:00
|
|
|
let f: Box_<F> = Box_::new(f);
|
2019-06-18 10:12:00 +00:00
|
|
|
connect_raw(
|
|
|
|
self.as_ptr() as *mut _,
|
|
|
|
b"finished\0".as_ptr() as *const _,
|
2020-04-13 16:11:33 +00:00
|
|
|
Some(transmute::<_, unsafe extern "C" fn()>(
|
|
|
|
finished_trampoline::<F> as *const (),
|
|
|
|
)),
|
2019-06-18 10:12:00 +00:00
|
|
|
Box_::into_raw(f),
|
|
|
|
)
|
2018-02-19 20:15:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-18 10:12:00 +00:00
|
|
|
pub fn connect_source_setup<F: Fn(&Discoverer, &gst::Element) + Send + Sync + 'static>(
|
|
|
|
&self,
|
|
|
|
f: F,
|
|
|
|
) -> SignalHandlerId {
|
|
|
|
unsafe extern "C" fn source_setup_trampoline<
|
|
|
|
F: Fn(&Discoverer, &gst::Element) + Send + Sync + 'static,
|
|
|
|
>(
|
2020-11-22 10:08:08 +00:00
|
|
|
this: *mut ffi::GstDiscoverer,
|
|
|
|
source: *mut gst::ffi::GstElement,
|
|
|
|
f: glib::ffi::gpointer,
|
2019-06-18 10:12:00 +00:00
|
|
|
) {
|
2019-06-18 10:10:46 +00:00
|
|
|
let f: &F = &*(f as *const F);
|
|
|
|
f(&from_glib_borrow(this), &from_glib_borrow(source))
|
|
|
|
}
|
2018-02-19 20:15:52 +00:00
|
|
|
unsafe {
|
2019-01-29 13:53:44 +00:00
|
|
|
let f: Box_<F> = Box_::new(f);
|
2019-06-18 10:12:00 +00:00
|
|
|
connect_raw(
|
|
|
|
self.as_ptr() as *mut _,
|
|
|
|
b"source-setup\0".as_ptr() as *const _,
|
2020-04-13 16:11:33 +00:00
|
|
|
Some(transmute::<_, unsafe extern "C" fn()>(
|
|
|
|
source_setup_trampoline::<F> as *const (),
|
|
|
|
)),
|
2019-06-18 10:12:00 +00:00
|
|
|
Box_::into_raw(f),
|
|
|
|
)
|
2018-02-19 20:15:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-18 10:12:00 +00:00
|
|
|
pub fn connect_starting<F: Fn(&Discoverer) + Send + Sync + 'static>(
|
|
|
|
&self,
|
|
|
|
f: F,
|
|
|
|
) -> SignalHandlerId {
|
|
|
|
unsafe extern "C" fn starting_trampoline<F: Fn(&Discoverer) + Send + Sync + 'static>(
|
2020-11-22 10:08:08 +00:00
|
|
|
this: *mut ffi::GstDiscoverer,
|
|
|
|
f: glib::ffi::gpointer,
|
2019-06-18 10:12:00 +00:00
|
|
|
) {
|
2019-06-18 10:10:46 +00:00
|
|
|
let f: &F = &*(f as *const F);
|
|
|
|
f(&from_glib_borrow(this))
|
|
|
|
}
|
2018-02-19 20:15:52 +00:00
|
|
|
unsafe {
|
2019-01-29 13:53:44 +00:00
|
|
|
let f: Box_<F> = Box_::new(f);
|
2019-06-18 10:12:00 +00:00
|
|
|
connect_raw(
|
|
|
|
self.as_ptr() as *mut _,
|
|
|
|
b"starting\0".as_ptr() as *const _,
|
2020-04-13 16:11:33 +00:00
|
|
|
Some(transmute::<_, unsafe extern "C" fn()>(
|
|
|
|
starting_trampoline::<F> as *const (),
|
|
|
|
)),
|
2019-06-18 10:12:00 +00:00
|
|
|
Box_::into_raw(f),
|
|
|
|
)
|
2018-02-19 20:15:52 +00:00
|
|
|
}
|
|
|
|
}
|
2019-04-23 14:32:09 +00:00
|
|
|
|
|
|
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
2020-11-19 09:16:33 +00:00
|
|
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
|
2019-06-18 10:12:00 +00:00
|
|
|
pub fn connect_property_use_cache_notify<F: Fn(&Discoverer) + Send + Sync + 'static>(
|
|
|
|
&self,
|
|
|
|
f: F,
|
|
|
|
) -> SignalHandlerId {
|
|
|
|
unsafe extern "C" fn notify_use_cache_trampoline<
|
|
|
|
F: Fn(&Discoverer) + Send + Sync + 'static,
|
|
|
|
>(
|
2020-11-22 10:08:08 +00:00
|
|
|
this: *mut ffi::GstDiscoverer,
|
|
|
|
_param_spec: glib::ffi::gpointer,
|
|
|
|
f: glib::ffi::gpointer,
|
2019-06-18 10:12:00 +00:00
|
|
|
) {
|
2019-06-18 10:10:46 +00:00
|
|
|
let f: &F = &*(f as *const F);
|
|
|
|
f(&from_glib_borrow(this))
|
|
|
|
}
|
2019-04-23 14:32:09 +00:00
|
|
|
unsafe {
|
|
|
|
let f: Box_<F> = Box_::new(f);
|
2019-06-18 10:12:00 +00:00
|
|
|
connect_raw(
|
|
|
|
self.as_ptr() as *mut _,
|
|
|
|
b"notify::use-cache\0".as_ptr() as *const _,
|
2020-04-13 16:11:33 +00:00
|
|
|
Some(transmute::<_, unsafe extern "C" fn()>(
|
|
|
|
notify_use_cache_trampoline::<F> as *const (),
|
|
|
|
)),
|
2019-06-18 10:12:00 +00:00
|
|
|
Box_::into_raw(f),
|
|
|
|
)
|
2019-04-23 14:32:09 +00:00
|
|
|
}
|
|
|
|
}
|
2018-02-19 20:15:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsafe impl Send for Discoverer {}
|
|
|
|
unsafe impl Sync for Discoverer {}
|