gstreamer-rs/gstreamer/src/pad_template.rs
2020-12-18 00:56:47 +02:00

30 lines
1.1 KiB
Rust

// Take a look at the license at the top of the repository in the LICENSE file.
use crate::PadTemplate;
#[cfg(any(feature = "v1_14", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))]
use crate::StaticPadTemplate;
#[cfg(any(feature = "v1_14", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))]
use glib::translate::*;
impl PadTemplate {
#[cfg(any(feature = "v1_14", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))]
pub fn from_static_pad_template_with_gtype(
pad_template: &StaticPadTemplate,
pad_type: glib::types::Type,
) -> Result<PadTemplate, glib::BoolError> {
assert_initialized_main_thread!();
unsafe {
Option::<_>::from_glib_none(
ffi::gst_pad_template_new_from_static_pad_template_with_gtype(
mut_override(pad_template.to_glib_none().0),
pad_type.to_glib(),
),
)
.ok_or_else(|| glib::bool_error!("Failed to create PadTemplate"))
}
}
}