gstreamer-rs/gstreamer/src/auto/device_provider.rs

169 lines
5.6 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)
2017-07-04 22:47:33 +00:00
// DO NOT EDIT
use Bus;
use Device;
use DeviceProviderFactory;
use Object;
use Plugin;
use ffi;
use glib;
use glib::GString;
2019-01-16 11:32:39 +00:00
use glib::object::Cast;
2017-07-04 22:47:33 +00:00
use glib::object::IsA;
2017-09-09 13:01:32 +00:00
use glib::signal::SignalHandlerId;
use glib::signal::connect_raw;
2017-07-04 22:47:33 +00:00
use glib::translate::*;
use glib_ffi;
use libc;
use std::boxed::Box as Box_;
use std::mem::transmute;
glib_wrapper! {
2019-01-16 11:32:39 +00:00
pub struct DeviceProvider(Object<ffi::GstDeviceProvider, ffi::GstDeviceProviderClass, DeviceProviderClass>) @extends Object;
2017-07-04 22:47:33 +00:00
match fn {
get_type => || ffi::gst_device_provider_get_type(),
}
}
impl DeviceProvider {
2019-01-21 20:00:48 +00:00
pub fn register<'a, P: Into<Option<&'a Plugin>>>(plugin: P, name: &str, rank: u32, type_: glib::types::Type) -> Result<(), glib::error::BoolError> {
assert_initialized_main_thread!();
2017-07-04 22:47:33 +00:00
let plugin = plugin.into();
unsafe {
2019-01-21 20:00:48 +00:00
glib_result_from_gboolean!(ffi::gst_device_provider_register(plugin.to_glib_none().0, name.to_glib_none().0, rank, type_.to_glib()), "Failed to register device provider factory")
2017-07-04 22:47:33 +00:00
}
}
}
unsafe impl Send for DeviceProvider {}
unsafe impl Sync for DeviceProvider {}
2019-01-16 11:32:39 +00:00
pub const NONE_DEVICE_PROVIDER: Option<&DeviceProvider> = None;
pub trait DeviceProviderExt: 'static {
2017-07-04 22:47:33 +00:00
fn can_monitor(&self) -> bool;
2019-01-16 11:32:39 +00:00
fn device_add<P: IsA<Device>>(&self, device: &P);
2017-07-04 22:47:33 +00:00
2019-01-16 11:32:39 +00:00
fn device_remove<P: IsA<Device>>(&self, device: &P);
2017-07-04 22:47:33 +00:00
fn get_bus(&self) -> Bus;
2017-07-04 22:47:33 +00:00
fn get_devices(&self) -> Vec<Device>;
fn get_factory(&self) -> Option<DeviceProviderFactory>;
fn get_hidden_providers(&self) -> Vec<GString>;
2017-07-04 22:47:33 +00:00
fn hide_provider(&self, name: &str);
fn start(&self) -> Result<(), glib::error::BoolError>;
2017-07-04 22:47:33 +00:00
fn stop(&self);
fn unhide_provider(&self, name: &str);
2017-09-09 13:01:32 +00:00
fn connect_provider_hidden<F: Fn(&Self, &str) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
2017-07-04 22:47:33 +00:00
2017-09-09 13:01:32 +00:00
fn connect_provider_unhidden<F: Fn(&Self, &str) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
2017-07-04 22:47:33 +00:00
}
impl<O: IsA<DeviceProvider>> DeviceProviderExt for O {
2017-07-04 22:47:33 +00:00
fn can_monitor(&self) -> bool {
unsafe {
2019-01-16 11:32:39 +00:00
from_glib(ffi::gst_device_provider_can_monitor(self.as_ref().to_glib_none().0))
2017-07-04 22:47:33 +00:00
}
}
2019-01-16 11:32:39 +00:00
fn device_add<P: IsA<Device>>(&self, device: &P) {
2017-07-04 22:47:33 +00:00
unsafe {
2019-01-16 11:32:39 +00:00
ffi::gst_device_provider_device_add(self.as_ref().to_glib_none().0, device.as_ref().to_glib_none().0);
2017-07-04 22:47:33 +00:00
}
}
2019-01-16 11:32:39 +00:00
fn device_remove<P: IsA<Device>>(&self, device: &P) {
2017-07-04 22:47:33 +00:00
unsafe {
2019-01-16 11:32:39 +00:00
ffi::gst_device_provider_device_remove(self.as_ref().to_glib_none().0, device.as_ref().to_glib_none().0);
2017-07-04 22:47:33 +00:00
}
}
fn get_bus(&self) -> Bus {
2017-07-04 22:47:33 +00:00
unsafe {
2019-01-16 11:32:39 +00:00
from_glib_full(ffi::gst_device_provider_get_bus(self.as_ref().to_glib_none().0))
2017-07-04 22:47:33 +00:00
}
}
fn get_devices(&self) -> Vec<Device> {
unsafe {
2019-01-16 11:32:39 +00:00
FromGlibPtrContainer::from_glib_full(ffi::gst_device_provider_get_devices(self.as_ref().to_glib_none().0))
2017-07-04 22:47:33 +00:00
}
}
fn get_factory(&self) -> Option<DeviceProviderFactory> {
unsafe {
2019-01-16 11:32:39 +00:00
from_glib_none(ffi::gst_device_provider_get_factory(self.as_ref().to_glib_none().0))
2017-07-04 22:47:33 +00:00
}
}
fn get_hidden_providers(&self) -> Vec<GString> {
2017-07-04 22:47:33 +00:00
unsafe {
2019-01-16 11:32:39 +00:00
FromGlibPtrContainer::from_glib_full(ffi::gst_device_provider_get_hidden_providers(self.as_ref().to_glib_none().0))
2017-07-04 22:47:33 +00:00
}
}
fn hide_provider(&self, name: &str) {
unsafe {
2019-01-16 11:32:39 +00:00
ffi::gst_device_provider_hide_provider(self.as_ref().to_glib_none().0, name.to_glib_none().0);
2017-07-04 22:47:33 +00:00
}
}
fn start(&self) -> Result<(), glib::error::BoolError> {
2017-07-04 22:47:33 +00:00
unsafe {
2019-01-16 11:32:39 +00:00
glib_result_from_gboolean!(ffi::gst_device_provider_start(self.as_ref().to_glib_none().0), "Failed to start")
2017-07-04 22:47:33 +00:00
}
}
fn stop(&self) {
unsafe {
2019-01-16 11:32:39 +00:00
ffi::gst_device_provider_stop(self.as_ref().to_glib_none().0);
2017-07-04 22:47:33 +00:00
}
}
fn unhide_provider(&self, name: &str) {
unsafe {
2019-01-16 11:32:39 +00:00
ffi::gst_device_provider_unhide_provider(self.as_ref().to_glib_none().0, name.to_glib_none().0);
2017-07-04 22:47:33 +00:00
}
}
2017-09-09 13:01:32 +00:00
fn connect_provider_hidden<F: Fn(&Self, &str) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
2017-07-04 22:47:33 +00:00
unsafe {
let f: Box_<Box_<Fn(&Self, &str) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
2019-01-16 11:32:39 +00:00
connect_raw(self.as_ptr() as *mut _, b"provider-hidden\0".as_ptr() as *const _,
2017-07-04 22:47:33 +00:00
transmute(provider_hidden_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
2017-09-09 13:01:32 +00:00
fn connect_provider_unhidden<F: Fn(&Self, &str) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
2017-07-04 22:47:33 +00:00
unsafe {
let f: Box_<Box_<Fn(&Self, &str) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
2019-01-16 11:32:39 +00:00
connect_raw(self.as_ptr() as *mut _, b"provider-unhidden\0".as_ptr() as *const _,
2017-07-04 22:47:33 +00:00
transmute(provider_unhidden_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
}
unsafe extern "C" fn provider_hidden_trampoline<P>(this: *mut ffi::GstDeviceProvider, object: *mut libc::c_char, f: glib_ffi::gpointer)
where P: IsA<DeviceProvider> {
let f: &&(Fn(&P, &str) + Send + Sync + 'static) = transmute(f);
2019-01-16 11:32:39 +00:00
f(&DeviceProvider::from_glib_borrow(this).unsafe_cast(), &GString::from_glib_borrow(object))
2017-07-04 22:47:33 +00:00
}
unsafe extern "C" fn provider_unhidden_trampoline<P>(this: *mut ffi::GstDeviceProvider, object: *mut libc::c_char, f: glib_ffi::gpointer)
where P: IsA<DeviceProvider> {
let f: &&(Fn(&P, &str) + Send + Sync + 'static) = transmute(f);
2019-01-16 11:32:39 +00:00
f(&DeviceProvider::from_glib_borrow(this).unsafe_cast(), &GString::from_glib_borrow(object))
2017-07-04 22:47:33 +00:00
}