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

160 lines
5.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)
// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
// DO NOT EDIT
2020-11-21 13:46:33 +00:00
use crate::Caps;
use crate::Object;
use crate::Pad;
use crate::PadDirection;
use crate::PadPresence;
use glib::object::IsA;
2019-06-18 10:10:46 +00:00
use glib::object::ObjectType as ObjectType_;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use glib::StaticType;
use std::boxed::Box as Box_;
2020-04-13 16:11:33 +00:00
use std::mem::transmute;
2020-12-17 22:34:53 +00:00
glib::wrapper! {
#[doc(alias = "GstPadTemplate")]
2020-11-21 13:46:33 +00:00
pub struct PadTemplate(Object<ffi::GstPadTemplate, ffi::GstPadTemplateClass>) @extends Object;
match fn {
type_ => || ffi::gst_pad_template_get_type(),
}
}
impl PadTemplate {
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_pad_template_new")]
pub fn new(
name_template: &str,
direction: PadDirection,
presence: PadPresence,
caps: &Caps,
) -> Result<PadTemplate, glib::BoolError> {
2017-07-10 21:02:08 +00:00
assert_initialized_main_thread!();
unsafe {
2020-11-21 13:46:33 +00:00
Option::<_>::from_glib_none(ffi::gst_pad_template_new(
name_template.to_glib_none().0,
direction.into_glib(),
presence.into_glib(),
caps.to_glib_none().0,
))
2020-12-17 22:34:53 +00:00
.ok_or_else(|| glib::bool_error!("Failed to create pad template"))
2017-07-10 21:02:08 +00:00
}
}
2020-11-27 13:37:24 +00:00
#[cfg(any(feature = "v1_14", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))]
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_pad_template_new_with_gtype")]
#[doc(alias = "new_with_gtype")]
2020-06-11 10:27:43 +00:00
pub fn with_gtype(
name_template: &str,
direction: PadDirection,
presence: PadPresence,
caps: &Caps,
pad_type: glib::types::Type,
) -> Result<PadTemplate, glib::BoolError> {
2018-03-15 08:39:12 +00:00
assert_initialized_main_thread!();
unsafe {
2020-11-21 13:46:33 +00:00
Option::<_>::from_glib_none(ffi::gst_pad_template_new_with_gtype(
name_template.to_glib_none().0,
direction.into_glib(),
presence.into_glib(),
caps.to_glib_none().0,
pad_type.into_glib(),
))
2020-12-17 22:34:53 +00:00
.ok_or_else(|| glib::bool_error!("Failed to create pad template"))
2018-03-15 08:39:12 +00:00
}
}
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_pad_template_get_caps")]
#[doc(alias = "get_caps")]
2021-04-11 19:38:18 +00:00
pub fn caps(&self) -> Caps {
2020-11-21 13:46:33 +00:00
unsafe { from_glib_full(ffi::gst_pad_template_get_caps(self.to_glib_none().0)) }
2017-07-10 21:02:08 +00:00
}
2020-11-27 13:37:24 +00:00
#[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_pad_template_get_documentation_caps")]
#[doc(alias = "get_documentation_caps")]
2021-04-11 19:38:18 +00:00
pub fn documentation_caps(&self) -> Caps {
2020-07-06 08:37:14 +00:00
unsafe {
2020-11-21 13:46:33 +00:00
from_glib_full(ffi::gst_pad_template_get_documentation_caps(
2020-07-06 08:37:14 +00:00
self.to_glib_none().0,
))
}
}
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_pad_template_pad_created")]
pub fn pad_created(&self, pad: &impl IsA<Pad>) {
unsafe {
2020-11-21 13:46:33 +00:00
ffi::gst_pad_template_pad_created(self.to_glib_none().0, pad.as_ref().to_glib_none().0);
}
}
2020-11-27 13:37:24 +00:00
#[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_pad_template_set_documentation_caps")]
2020-07-06 08:37:14 +00:00
pub fn set_documentation_caps(&self, caps: &Caps) {
unsafe {
2020-11-21 13:46:33 +00:00
ffi::gst_pad_template_set_documentation_caps(
2020-07-06 08:37:14 +00:00
self.to_glib_none().0,
2020-12-01 19:22:33 +00:00
caps.to_glib_full(),
2020-07-06 08:37:14 +00:00
);
}
}
2021-04-11 19:38:18 +00:00
pub fn direction(&self) -> PadDirection {
2021-11-06 17:31:52 +00:00
glib::ObjectExt::property(self, "direction")
}
2020-11-27 13:37:24 +00:00
#[cfg(any(feature = "v1_14", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))]
2021-04-11 19:38:18 +00:00
pub fn gtype(&self) -> glib::types::Type {
2021-11-06 17:31:52 +00:00
glib::ObjectExt::property(self, "gtype")
2018-03-15 08:39:12 +00:00
}
#[doc(alias = "name-template")]
2021-04-11 19:38:18 +00:00
pub fn name_template(&self) -> Option<glib::GString> {
2021-11-06 17:31:52 +00:00
glib::ObjectExt::property(self, "name-template")
}
2021-04-11 19:38:18 +00:00
pub fn presence(&self) -> PadPresence {
2021-11-06 17:31:52 +00:00
glib::ObjectExt::property(self, "presence")
2017-07-10 21:02:08 +00:00
}
#[doc(alias = "pad-created")]
pub fn connect_pad_created<F: Fn(&Self, &Pad) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn pad_created_trampoline<
F: Fn(&PadTemplate, &Pad) + Send + Sync + 'static,
>(
2020-11-21 13:46:33 +00:00
this: *mut ffi::GstPadTemplate,
pad: *mut ffi::GstPad,
f: glib::ffi::gpointer,
) {
2019-06-18 10:10:46 +00:00
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this), &from_glib_borrow(pad))
}
unsafe {
2019-01-29 13:53:44 +00:00
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"pad-created\0".as_ptr() as *const _,
2020-04-13 16:11:33 +00:00
Some(transmute::<_, unsafe extern "C" fn()>(
pad_created_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
unsafe impl Send for PadTemplate {}
unsafe impl Sync for PadTemplate {}