gstreamer-rs/gstreamer-pbutils/src/auto/discoverer.rs
Thiago Santos 382138b75a More encoding_profile binding improvements
- enable is_equal function again (unsure why it was disabled)
- remove restriction-caps property, encoding-profile objects are
immutable
- remove cast need by using IsA<EncodingProfile> in parameters and
returning the correct type of encodingprofile subclass from the build()
functions. It used a internal hack for storing those IsA objects in
order to keep the API clean and ready to be used, this should be sorted
out as soon as we figure out how to store them in the buidlers.
- encodebin example: remove Result error propagation when it is caused
by programming mistakes. A panic will happen in those cases.
- run rustfmt
2018-10-08 09:06:46 +03:00

150 lines
6 KiB
Rust

// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use DiscovererInfo;
use Error;
use ffi;
use glib;
use glib::signal::SignalHandlerId;
use glib::signal::connect;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use gst;
use gst_ffi;
use std::boxed::Box as Box_;
use std::mem;
use std::mem::transmute;
use std::ptr;
glib_wrapper! {
/// The `Discoverer` is a utility object which allows to get as much
/// information as possible from one or many URIs.
///
/// It provides two APIs, allowing usage in blocking or non-blocking mode.
///
/// The blocking mode just requires calling `Discoverer::discover_uri`
/// with the URI one wishes to discover.
///
/// The non-blocking mode requires a running `glib::MainLoop` iterating a
/// `glib::MainContext`, where one connects to the various signals, appends the
/// URIs to be processed (through `Discoverer::discover_uri_async`) and then
/// asks for the discovery to begin (through `Discoverer::start`).
/// By default this will use the GLib default main context unless you have
/// set a custom context using `glib::MainContext::push_thread_default`.
///
/// All the information is returned in a `DiscovererInfo` structure.
///
/// # Implements
///
/// [`glib::object::ObjectExt`](../glib/object/trait.ObjectExt.html)
pub struct Discoverer(Object<ffi::GstDiscoverer, ffi::GstDiscovererClass>);
match fn {
get_type => || ffi::gst_discoverer_get_type(),
}
}
impl Discoverer {
/// Creates a new `Discoverer` with the provided timeout.
/// ## `timeout`
/// timeout per file, in nanoseconds. Allowed are values between
/// one second (`GST_SECOND`) and one hour (3600 * `GST_SECOND`)
///
/// # Returns
///
/// The new `Discoverer`.
/// If an error occurred when creating the discoverer, `err` will be set
/// accordingly and `None` will be returned. If `err` is set, the caller must
/// free it when no longer needed using `glib::Error::free`.
pub fn new(timeout: gst::ClockTime) -> Result<Discoverer, Error> {
assert_initialized_main_thread!();
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::gst_discoverer_new(timeout.to_glib(), &mut error);
if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }
}
}
pub fn discover_uri(&self, uri: &str) -> Result<DiscovererInfo, Error> {
unsafe {
let mut error = ptr::null_mut();
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)) }
}
}
pub fn discover_uri_async(&self, uri: &str) -> Result<(), glib::error::BoolError> {
unsafe {
glib::error::BoolError::from_glib(ffi::gst_discoverer_discover_uri_async(self.to_glib_none().0, uri.to_glib_none().0), "Failed to add URI to list of discovers")
}
}
pub fn start(&self) {
unsafe {
ffi::gst_discoverer_start(self.to_glib_none().0);
}
}
pub fn stop(&self) {
unsafe {
ffi::gst_discoverer_stop(self.to_glib_none().0);
}
}
pub fn connect_discovered<F: Fn(&Discoverer, &DiscovererInfo, &Option<Error>) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Discoverer, &DiscovererInfo, &Option<Error>) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "discovered",
transmute(discovered_trampoline as usize), Box_::into_raw(f) as *mut _)
}
}
pub fn connect_finished<F: Fn(&Discoverer) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Discoverer) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "finished",
transmute(finished_trampoline as usize), Box_::into_raw(f) as *mut _)
}
}
pub fn connect_source_setup<F: Fn(&Discoverer, &gst::Element) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Discoverer, &gst::Element) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "source-setup",
transmute(source_setup_trampoline as usize), Box_::into_raw(f) as *mut _)
}
}
pub fn connect_starting<F: Fn(&Discoverer) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Discoverer) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "starting",
transmute(starting_trampoline as usize), Box_::into_raw(f) as *mut _)
}
}
}
unsafe impl Send for Discoverer {}
unsafe impl Sync for Discoverer {}
unsafe extern "C" fn discovered_trampoline(this: *mut ffi::GstDiscoverer, info: *mut ffi::GstDiscovererInfo, error: *mut glib_ffi::GError, f: glib_ffi::gpointer) {
let f: &&(Fn(&Discoverer, &DiscovererInfo, &Option<Error>) + Send + Sync + 'static) = transmute(f);
f(&from_glib_borrow(this), &from_glib_borrow(info), &from_glib_borrow(error))
}
unsafe extern "C" fn finished_trampoline(this: *mut ffi::GstDiscoverer, f: glib_ffi::gpointer) {
let f: &&(Fn(&Discoverer) + Send + Sync + 'static) = transmute(f);
f(&from_glib_borrow(this))
}
unsafe extern "C" fn source_setup_trampoline(this: *mut ffi::GstDiscoverer, source: *mut gst_ffi::GstElement, f: glib_ffi::gpointer) {
let f: &&(Fn(&Discoverer, &gst::Element) + Send + Sync + 'static) = transmute(f);
f(&from_glib_borrow(this), &from_glib_borrow(source))
}
unsafe extern "C" fn starting_trampoline(this: *mut ffi::GstDiscoverer, f: glib_ffi::gpointer) {
let f: &&(Fn(&Discoverer) + Send + Sync + 'static) = transmute(f);
f(&from_glib_borrow(this))
}