gstreamer-rs/gstreamer/src/auto/device.rs

149 lines
4 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 glib;
2019-01-16 11:32:39 +00:00
use glib::object::Cast;
2017-07-04 22:47:33 +00:00
use glib::object::IsA;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
2017-07-04 22:47:33 +00:00
use glib::translate::*;
use glib::GString;
2019-03-19 07:40:05 +00:00
use glib_sys;
use gst_sys;
2017-07-04 22:47:33 +00:00
use std::boxed::Box as Box_;
use std::mem::transmute;
use Caps;
use Element;
use Object;
use Structure;
2017-07-04 22:47:33 +00:00
glib_wrapper! {
2019-03-19 07:40:05 +00:00
pub struct Device(Object<gst_sys::GstDevice, gst_sys::GstDeviceClass, DeviceClass>) @extends Object;
2017-07-04 22:47:33 +00:00
match fn {
2019-03-19 07:40:05 +00:00
get_type => || gst_sys::gst_device_get_type(),
2017-07-04 22:47:33 +00:00
}
}
unsafe impl Send for Device {}
unsafe impl Sync for Device {}
2019-01-16 11:32:39 +00:00
pub const NONE_DEVICE: Option<&Device> = None;
pub trait DeviceExt: 'static {
2019-03-19 07:40:05 +00:00
fn create_element(&self, name: Option<&str>) -> Option<Element>;
2017-07-04 22:47:33 +00:00
2017-07-10 21:02:08 +00:00
fn get_caps(&self) -> Option<Caps>;
2017-07-04 22:47:33 +00:00
fn get_device_class(&self) -> GString;
2017-07-04 22:47:33 +00:00
fn get_display_name(&self) -> GString;
2017-07-04 22:47:33 +00:00
2017-07-10 21:02:08 +00:00
fn get_properties(&self) -> Option<Structure>;
2017-07-04 22:47:33 +00:00
fn has_classes(&self, classes: &str) -> bool;
fn has_classesv(&self, classes: &[&str]) -> bool;
fn reconfigure_element<P: IsA<Element>>(
&self,
element: &P,
) -> Result<(), glib::error::BoolError>;
2017-07-04 22:47:33 +00:00
2017-09-09 13:01:32 +00:00
fn connect_removed<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
2017-07-04 22:47:33 +00:00
}
impl<O: IsA<Device>> DeviceExt for O {
2019-03-19 07:40:05 +00:00
fn create_element(&self, name: Option<&str>) -> Option<Element> {
2017-07-04 22:47:33 +00:00
unsafe {
from_glib_none(gst_sys::gst_device_create_element(
self.as_ref().to_glib_none().0,
name.to_glib_none().0,
))
2017-07-04 22:47:33 +00:00
}
}
2017-07-10 21:02:08 +00:00
fn get_caps(&self) -> Option<Caps> {
unsafe { from_glib_full(gst_sys::gst_device_get_caps(self.as_ref().to_glib_none().0)) }
2017-07-10 21:02:08 +00:00
}
2017-07-04 22:47:33 +00:00
fn get_device_class(&self) -> GString {
2017-07-04 22:47:33 +00:00
unsafe {
from_glib_full(gst_sys::gst_device_get_device_class(
self.as_ref().to_glib_none().0,
))
2017-07-04 22:47:33 +00:00
}
}
fn get_display_name(&self) -> GString {
2017-07-04 22:47:33 +00:00
unsafe {
from_glib_full(gst_sys::gst_device_get_display_name(
self.as_ref().to_glib_none().0,
))
2017-07-04 22:47:33 +00:00
}
}
2017-07-10 21:02:08 +00:00
fn get_properties(&self) -> Option<Structure> {
unsafe {
from_glib_full(gst_sys::gst_device_get_properties(
self.as_ref().to_glib_none().0,
))
2017-07-10 21:02:08 +00:00
}
}
2017-07-04 22:47:33 +00:00
fn has_classes(&self, classes: &str) -> bool {
unsafe {
from_glib(gst_sys::gst_device_has_classes(
self.as_ref().to_glib_none().0,
classes.to_glib_none().0,
))
2017-07-04 22:47:33 +00:00
}
}
fn has_classesv(&self, classes: &[&str]) -> bool {
unsafe {
from_glib(gst_sys::gst_device_has_classesv(
self.as_ref().to_glib_none().0,
classes.to_glib_none().0,
))
2017-07-04 22:47:33 +00:00
}
}
fn reconfigure_element<P: IsA<Element>>(
&self,
element: &P,
) -> Result<(), glib::error::BoolError> {
2017-07-04 22:47:33 +00:00
unsafe {
glib_result_from_gboolean!(
gst_sys::gst_device_reconfigure_element(
self.as_ref().to_glib_none().0,
element.as_ref().to_glib_none().0
),
"Failed to reconfigure the element to use this device"
)
2017-07-04 22:47:33 +00:00
}
}
2017-09-09 13:01:32 +00:00
fn connect_removed<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn removed_trampoline<P, F: Fn(&P) + Send + Sync + 'static>(
this: *mut gst_sys::GstDevice,
f: glib_sys::gpointer,
) where
P: IsA<Device>,
2019-06-18 10:10:46 +00:00
{
let f: &F = &*(f as *const F);
f(&Device::from_glib_borrow(this).unsafe_cast())
}
2017-07-04 22:47:33 +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"removed\0".as_ptr() as *const _,
Some(transmute(removed_trampoline::<Self, F> as usize)),
Box_::into_raw(f),
)
2017-07-04 22:47:33 +00:00
}
}
}