1 // Copyright (C) 2017 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 use glib::object::Cast; 10 use glib::object::IsA; 11 use glib::translate::*; 12 use gst_sys; 13 use GhostPad; 14 use Object; 15 use Pad; 16 use PadMode; 17 use PadTemplate; 18 19 impl GhostPad { new<Q: IsA<Pad>>(name: Option<&str>, target: &Q) -> Result<GhostPad, glib::BoolError>20 pub fn new<Q: IsA<Pad>>(name: Option<&str>, target: &Q) -> Result<GhostPad, glib::BoolError> { 21 skip_assert_initialized!(); 22 let name = name.to_glib_none(); 23 unsafe { 24 Option::<Pad>::from_glib_none(gst_sys::gst_ghost_pad_new( 25 name.0, 26 target.as_ref().to_glib_none().0, 27 )) 28 .map(|o| Cast::unsafe_cast(o)) 29 .ok_or_else(|| glib_bool_error!("Failed to create GhostPad")) 30 } 31 } 32 new_from_template<Q: IsA<Pad>>( name: Option<&str>, target: &Q, templ: &PadTemplate, ) -> Result<GhostPad, glib::BoolError>33 pub fn new_from_template<Q: IsA<Pad>>( 34 name: Option<&str>, 35 target: &Q, 36 templ: &PadTemplate, 37 ) -> Result<GhostPad, glib::BoolError> { 38 skip_assert_initialized!(); 39 let name = name.to_glib_none(); 40 unsafe { 41 Option::<Pad>::from_glib_none(gst_sys::gst_ghost_pad_new_from_template( 42 name.0, 43 target.as_ref().to_glib_none().0, 44 templ.to_glib_none().0, 45 )) 46 .map(|o| Cast::unsafe_cast(o)) 47 .ok_or_else(|| glib_bool_error!("Failed to create GhostPad")) 48 } 49 } 50 activate_mode_default<P: IsA<GhostPad>, Q: IsA<Object>>( pad: &P, parent: Option<&Q>, mode: PadMode, active: bool, ) -> Result<(), glib::BoolError>51 pub fn activate_mode_default<P: IsA<GhostPad>, Q: IsA<Object>>( 52 pad: &P, 53 parent: Option<&Q>, 54 mode: PadMode, 55 active: bool, 56 ) -> Result<(), glib::BoolError> { 57 skip_assert_initialized!(); 58 unsafe { 59 glib_result_from_gboolean!( 60 gst_sys::gst_ghost_pad_activate_mode_default( 61 pad.to_glib_none().0 as *mut gst_sys::GstPad, 62 parent.map(|p| p.as_ref()).to_glib_none().0, 63 mode.to_glib(), 64 active.to_glib(), 65 ), 66 "Failed to invoke the default activate mode function of the ghost pad" 67 ) 68 } 69 } 70 internal_activate_mode_default<P: IsA<GhostPad>, Q: IsA<Object>>( pad: &P, parent: Option<&Q>, mode: PadMode, active: bool, ) -> Result<(), glib::BoolError>71 pub fn internal_activate_mode_default<P: IsA<GhostPad>, Q: IsA<Object>>( 72 pad: &P, 73 parent: Option<&Q>, 74 mode: PadMode, 75 active: bool, 76 ) -> Result<(), glib::BoolError> { 77 skip_assert_initialized!(); 78 unsafe { 79 glib_result_from_gboolean!( 80 gst_sys::gst_ghost_pad_internal_activate_mode_default( 81 pad.to_glib_none().0 as *mut gst_sys::GstPad, 82 parent.map(|p| p.as_ref()).to_glib_none().0, 83 mode.to_glib(), 84 active.to_glib(), 85 ), 86 concat!( 87 "Failed to invoke the default activate mode function of a proxy pad ", 88 "that is owned by the ghost pad" 89 ) 90 ) 91 } 92 } 93 } 94