gstreamer-rs/gstreamer/src/auto/pad_template.rs

111 lines
4.1 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)
// DO NOT EDIT
2017-07-10 21:02:08 +00:00
use Caps;
use Object;
use Pad;
use PadDirection;
2017-07-10 21:02:08 +00:00
use PadPresence;
use ffi;
2018-03-15 08:39:12 +00:00
#[cfg(any(feature = "v1_14", feature = "dox"))]
use glib;
use glib::GString;
use glib::StaticType;
use glib::Value;
use glib::object::IsA;
2019-01-16 11:32:39 +00:00
use glib::object::ObjectType;
2017-09-09 13:01:32 +00:00
use glib::signal::SignalHandlerId;
use glib::signal::connect_raw;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use std::boxed::Box as Box_;
use std::mem::transmute;
glib_wrapper! {
2019-01-16 11:32:39 +00:00
pub struct PadTemplate(Object<ffi::GstPadTemplate, ffi::GstPadTemplateClass, PadTemplateClass>) @extends Object;
match fn {
get_type => || ffi::gst_pad_template_get_type(),
}
}
impl PadTemplate {
2019-01-29 13:53:44 +00:00
pub fn new(name_template: &str, direction: PadDirection, presence: PadPresence, caps: &Caps) -> Option<PadTemplate> {
2017-07-10 21:02:08 +00:00
assert_initialized_main_thread!();
unsafe {
from_glib_none(ffi::gst_pad_template_new(name_template.to_glib_none().0, direction.to_glib(), presence.to_glib(), caps.to_glib_none().0))
}
}
2018-03-15 08:39:12 +00:00
#[cfg(any(feature = "v1_14", feature = "dox"))]
2019-01-29 13:53:44 +00:00
pub fn new_with_gtype(name_template: &str, direction: PadDirection, presence: PadPresence, caps: &Caps, pad_type: glib::types::Type) -> Option<PadTemplate> {
2018-03-15 08:39:12 +00:00
assert_initialized_main_thread!();
unsafe {
from_glib_none(ffi::gst_pad_template_new_with_gtype(name_template.to_glib_none().0, direction.to_glib(), presence.to_glib(), caps.to_glib_none().0, pad_type.to_glib()))
}
}
pub fn get_caps(&self) -> Option<Caps> {
2017-07-10 21:02:08 +00:00
unsafe {
from_glib_full(ffi::gst_pad_template_get_caps(self.to_glib_none().0))
}
}
pub fn pad_created<P: IsA<Pad>>(&self, pad: &P) {
unsafe {
2019-01-16 11:32:39 +00:00
ffi::gst_pad_template_pad_created(self.to_glib_none().0, pad.as_ref().to_glib_none().0);
}
}
pub fn get_property_direction(&self) -> PadDirection {
unsafe {
2018-02-06 14:42:34 +00:00
let mut value = Value::from_type(<PadDirection as StaticType>::static_type());
2019-01-16 11:32:39 +00:00
gobject_ffi::g_object_get_property(self.as_ptr() as *mut gobject_ffi::GObject, b"direction\0".as_ptr() as *const _, value.to_glib_none_mut().0);
value.get().unwrap()
}
}
2018-03-15 08:39:12 +00:00
#[cfg(any(feature = "v1_14", feature = "dox"))]
pub fn get_property_gtype(&self) -> glib::types::Type {
unsafe {
let mut value = Value::from_type(<glib::types::Type as StaticType>::static_type());
2019-01-16 11:32:39 +00:00
gobject_ffi::g_object_get_property(self.as_ptr() as *mut gobject_ffi::GObject, b"gtype\0".as_ptr() as *const _, value.to_glib_none_mut().0);
2018-03-15 08:39:12 +00:00
value.get().unwrap()
}
}
pub fn get_property_name_template(&self) -> Option<GString> {
unsafe {
let mut value = Value::from_type(<GString as StaticType>::static_type());
2019-01-16 11:32:39 +00:00
gobject_ffi::g_object_get_property(self.as_ptr() as *mut gobject_ffi::GObject, b"name-template\0".as_ptr() as *const _, value.to_glib_none_mut().0);
value.get()
}
}
pub fn get_property_presence(&self) -> PadPresence {
2017-07-10 21:02:08 +00:00
unsafe {
2018-02-06 14:42:34 +00:00
let mut value = Value::from_type(<PadPresence as StaticType>::static_type());
2019-01-16 11:32:39 +00:00
gobject_ffi::g_object_get_property(self.as_ptr() as *mut gobject_ffi::GObject, b"presence\0".as_ptr() as *const _, value.to_glib_none_mut().0);
value.get().unwrap()
2017-07-10 21:02:08 +00:00
}
}
2017-09-09 13:01:32 +00:00
pub fn connect_pad_created<F: Fn(&PadTemplate, &Pad) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
2019-01-29 13:53:44 +00:00
let f: Box_<F> = Box_::new(f);
2019-01-16 11:32:39 +00:00
connect_raw(self.as_ptr() as *mut _, b"pad-created\0".as_ptr() as *const _,
2019-01-29 13:53:44 +00:00
Some(transmute(pad_created_trampoline::<F> as usize)), Box_::into_raw(f))
}
}
}
unsafe impl Send for PadTemplate {}
unsafe impl Sync for PadTemplate {}
2019-01-29 13:53:44 +00:00
unsafe extern "C" fn pad_created_trampoline<F: Fn(&PadTemplate, &Pad) + Send + Sync + 'static>(this: *mut ffi::GstPadTemplate, pad: *mut ffi::GstPad, f: glib_ffi::gpointer) {
2019-02-22 09:51:17 +00:00
let f: &F = &*(f as *const F);
2017-09-09 13:01:32 +00:00
f(&from_glib_borrow(this), &from_glib_borrow(pad))
}