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::object::Downcast;
|
|
|
|
use glib::object::IsA;
|
2017-09-09 13:01:32 +00:00
|
|
|
use glib::signal::SignalHandlerId;
|
2017-07-04 22:47:33 +00:00
|
|
|
use glib::signal::connect;
|
|
|
|
use glib::translate::*;
|
|
|
|
use glib_ffi;
|
2017-07-19 18:41:25 +00:00
|
|
|
use gobject_ffi;
|
2017-07-04 22:47:33 +00:00
|
|
|
use libc;
|
|
|
|
use std::boxed::Box as Box_;
|
2017-07-19 18:41:25 +00:00
|
|
|
use std::mem;
|
2017-07-04 22:47:33 +00:00
|
|
|
use std::mem::transmute;
|
2017-07-19 18:41:25 +00:00
|
|
|
use std::ptr;
|
2017-07-04 22:47:33 +00:00
|
|
|
|
|
|
|
glib_wrapper! {
|
2017-11-09 11:33:40 +00:00
|
|
|
pub struct DeviceProvider(Object<ffi::GstDeviceProvider, ffi::GstDeviceProviderClass>): Object;
|
2017-07-04 22:47:33 +00:00
|
|
|
|
|
|
|
match fn {
|
|
|
|
get_type => || ffi::gst_device_provider_get_type(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl DeviceProvider {
|
2018-11-04 13:56:34 +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> {
|
2017-07-10 09:36:15 +00:00
|
|
|
assert_initialized_main_thread!();
|
2017-07-04 22:47:33 +00:00
|
|
|
let plugin = plugin.into();
|
|
|
|
let plugin = plugin.to_glib_none();
|
|
|
|
unsafe {
|
2018-11-04 13:56:34 +00:00
|
|
|
glib::error::BoolError::from_glib(ffi::gst_device_provider_register(plugin.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 {}
|
|
|
|
|
|
|
|
pub trait DeviceProviderExt {
|
|
|
|
fn can_monitor(&self) -> bool;
|
|
|
|
|
|
|
|
fn device_add(&self, device: &Device);
|
|
|
|
|
|
|
|
fn device_remove(&self, device: &Device);
|
|
|
|
|
2017-12-17 16:29:22 +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<String>;
|
|
|
|
|
|
|
|
fn hide_provider(&self, name: &str);
|
|
|
|
|
2017-12-18 07:44:32 +00:00
|
|
|
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> + IsA<glib::object::Object>> DeviceProviderExt for O {
|
|
|
|
fn can_monitor(&self) -> bool {
|
|
|
|
unsafe {
|
|
|
|
from_glib(ffi::gst_device_provider_can_monitor(self.to_glib_none().0))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn device_add(&self, device: &Device) {
|
|
|
|
unsafe {
|
|
|
|
ffi::gst_device_provider_device_add(self.to_glib_none().0, device.to_glib_none().0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn device_remove(&self, device: &Device) {
|
|
|
|
unsafe {
|
|
|
|
ffi::gst_device_provider_device_remove(self.to_glib_none().0, device.to_glib_none().0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-17 16:29:22 +00:00
|
|
|
fn get_bus(&self) -> Bus {
|
2017-07-04 22:47:33 +00:00
|
|
|
unsafe {
|
|
|
|
from_glib_full(ffi::gst_device_provider_get_bus(self.to_glib_none().0))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn get_devices(&self) -> Vec<Device> {
|
|
|
|
unsafe {
|
|
|
|
FromGlibPtrContainer::from_glib_full(ffi::gst_device_provider_get_devices(self.to_glib_none().0))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn get_factory(&self) -> Option<DeviceProviderFactory> {
|
|
|
|
unsafe {
|
|
|
|
from_glib_none(ffi::gst_device_provider_get_factory(self.to_glib_none().0))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn get_hidden_providers(&self) -> Vec<String> {
|
|
|
|
unsafe {
|
|
|
|
FromGlibPtrContainer::from_glib_full(ffi::gst_device_provider_get_hidden_providers(self.to_glib_none().0))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn hide_provider(&self, name: &str) {
|
|
|
|
unsafe {
|
|
|
|
ffi::gst_device_provider_hide_provider(self.to_glib_none().0, name.to_glib_none().0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-18 07:44:32 +00:00
|
|
|
fn start(&self) -> Result<(), glib::error::BoolError> {
|
2017-07-04 22:47:33 +00:00
|
|
|
unsafe {
|
2017-12-18 07:44:32 +00:00
|
|
|
glib::error::BoolError::from_glib(ffi::gst_device_provider_start(self.to_glib_none().0), "Failed to start")
|
2017-07-04 22:47:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn stop(&self) {
|
|
|
|
unsafe {
|
|
|
|
ffi::gst_device_provider_stop(self.to_glib_none().0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn unhide_provider(&self, name: &str) {
|
|
|
|
unsafe {
|
|
|
|
ffi::gst_device_provider_unhide_provider(self.to_glib_none().0, name.to_glib_none().0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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));
|
|
|
|
connect(self.to_glib_none().0, "provider-hidden",
|
|
|
|
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));
|
|
|
|
connect(self.to_glib_none().0, "provider-unhidden",
|
|
|
|
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> {
|
2017-08-03 18:56:39 +00:00
|
|
|
let f: &&(Fn(&P, &str) + Send + Sync + 'static) = transmute(f);
|
2017-09-09 13:01:32 +00:00
|
|
|
f(&DeviceProvider::from_glib_borrow(this).downcast_unchecked(), &String::from_glib_none(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> {
|
2017-08-03 18:56:39 +00:00
|
|
|
let f: &&(Fn(&P, &str) + Send + Sync + 'static) = transmute(f);
|
2017-09-09 13:01:32 +00:00
|
|
|
f(&DeviceProvider::from_glib_borrow(this).downcast_unchecked(), &String::from_glib_none(object))
|
2017-07-04 22:47:33 +00:00
|
|
|
}
|