gstreamer-rs/gstreamer-pbutils/src/auto/discoverer.rs

271 lines
8.7 KiB
Rust
Raw Normal View History

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)
// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
// DO NOT EDIT
2020-11-22 10:08:08 +00:00
use crate::DiscovererInfo;
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::{boxed::Box as Box_, mem::transmute, ptr};
2020-12-17 22:34:53 +00:00
glib::wrapper! {
#[doc(alias = "GstDiscoverer")]
2020-11-22 10:08:08 +00:00
pub struct Discoverer(Object<ffi::GstDiscoverer, ffi::GstDiscovererClass>);
match fn {
type_ => || ffi::gst_discoverer_get_type(),
}
}
impl Discoverer {
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_discoverer_new")]
2019-11-10 16:55:02 +00:00
pub fn new(timeout: gst::ClockTime) -> Result<Discoverer, glib::Error> {
assert_initialized_main_thread!();
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::gst_discoverer_new(timeout.into_glib(), &mut error);
if error.is_null() {
Ok(from_glib_full(ret))
} else {
Err(from_glib_full(error))
}
}
}
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_discoverer_discover_uri")]
2019-11-10 16:55:02 +00:00
pub fn discover_uri(&self, uri: &str) -> Result<DiscovererInfo, glib::Error> {
unsafe {
let mut error = ptr::null_mut();
2020-11-22 10:08:08 +00:00
let ret = ffi::gst_discoverer_discover_uri(
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))
}
}
}
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_discoverer_discover_uri_async")]
pub fn discover_uri_async(&self, uri: &str) -> Result<(), glib::error::BoolError> {
unsafe {
2020-12-17 22:34:53 +00:00
glib::result_from_gboolean!(
2020-11-22 10:08:08 +00:00
ffi::gst_discoverer_discover_uri_async(self.to_glib_none().0, uri.to_glib_none().0),
"Failed to add URI to list of discovers"
)
}
}
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_discoverer_start")]
pub fn start(&self) {
unsafe {
2020-11-22 10:08:08 +00:00
ffi::gst_discoverer_start(self.to_glib_none().0);
}
}
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_discoverer_stop")]
pub fn stop(&self) {
unsafe {
2020-11-22 10:08:08 +00:00
ffi::gst_discoverer_stop(self.to_glib_none().0);
}
}
#[cfg(feature = "v1_16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
#[doc(alias = "use-cache")]
2021-04-11 19:38:18 +00:00
pub fn uses_cache(&self) -> bool {
2021-11-06 17:31:52 +00:00
glib::ObjectExt::property(self, "use-cache")
2019-04-23 14:32:09 +00:00
}
#[cfg(feature = "v1_16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
#[doc(alias = "use-cache")]
2021-04-11 19:38:18 +00:00
pub fn set_use_cache(&self, use_cache: bool) {
glib::ObjectExt::set_property(self, "use-cache", use_cache)
2019-04-23 14:32:09 +00:00
}
#[doc(alias = "discovered")]
pub fn connect_discovered<
F: Fn(&Self, &DiscovererInfo, Option<&glib::Error>) + Send + Sync + 'static,
>(
&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,
>(
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:10:46 +00:00
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(),
)
2019-06-18 10:10:46 +00:00
}
unsafe {
2019-01-29 13:53:44 +00:00
let f: Box_<F> = Box_::new(f);
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 (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "finished")]
pub fn connect_finished<F: Fn(&Self) + 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:10:46 +00:00
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
2019-01-29 13:53:44 +00:00
let f: Box_<F> = Box_::new(f);
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 (),
)),
Box_::into_raw(f),
)
}
}
#[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<DiscovererInfo> + Send + Sync + 'static,
>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn load_serialized_info_trampoline<
F: Fn(&Discoverer, &str) -> Option<DiscovererInfo> + Send + Sync + 'static,
>(
this: *mut ffi::GstDiscoverer,
uri: *mut libc::c_char,
f: glib::ffi::gpointer,
) -> *mut 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(transmute::<_, unsafe extern "C" fn()>(
load_serialized_info_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "source-setup")]
pub fn connect_source_setup<F: Fn(&Self, &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:10:46 +00:00
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this), &from_glib_borrow(source))
}
unsafe {
2019-01-29 13:53:44 +00:00
let f: Box_<F> = Box_::new(f);
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 (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "starting")]
pub fn connect_starting<F: Fn(&Self) + 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:10:46 +00:00
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
2019-01-29 13:53:44 +00:00
let f: Box_<F> = Box_::new(f);
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 (),
)),
Box_::into_raw(f),
)
}
}
2019-04-23 14:32:09 +00:00
#[cfg(feature = "v1_16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
#[doc(alias = "use-cache")]
pub fn connect_use_cache_notify<F: Fn(&Self) + 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: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);
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 (),
)),
Box_::into_raw(f),
)
2019-04-23 14:32:09 +00:00
}
}
}
unsafe impl Send for Discoverer {}
unsafe impl Sync for Discoverer {}