1 // Copyright (C) 2018 Sebastian Dröge <sebastian@centricular.com>
2 //
3 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
6 // option. This file may not be copied, modified, or distributed
7 // except according to those terms.
8 
9 #[cfg(any(feature = "v1_14", feature = "dox"))]
10 use glib::translate::*;
11 use PadTemplate;
12 #[cfg(any(feature = "v1_14", feature = "dox"))]
13 use StaticPadTemplate;
14 
15 #[cfg(any(feature = "v1_14", feature = "dox"))]
16 use glib;
17 #[cfg(any(feature = "v1_14", feature = "dox"))]
18 use gst_sys;
19 
20 impl PadTemplate {
21     #[cfg(any(feature = "v1_14", feature = "dox"))]
new_from_static_pad_template_with_gtype( pad_template: &StaticPadTemplate, pad_type: glib::types::Type, ) -> Result<PadTemplate, glib::BoolError>22     pub fn new_from_static_pad_template_with_gtype(
23         pad_template: &StaticPadTemplate,
24         pad_type: glib::types::Type,
25     ) -> Result<PadTemplate, glib::BoolError> {
26         assert_initialized_main_thread!();
27         unsafe {
28             Option::<_>::from_glib_none(
29                 gst_sys::gst_pad_template_new_from_static_pad_template_with_gtype(
30                     mut_override(pad_template.to_glib_none().0),
31                     pad_type.to_glib(),
32                 ),
33             )
34             .ok_or_else(|| glib_bool_error!("Failed to create PadTemplate"))
35         }
36     }
37 }
38