diff --git a/gst-plugin/src/ghost_pad.rs b/gst-plugin/src/ghost_pad.rs new file mode 100644 index 00000000..b052a718 --- /dev/null +++ b/gst-plugin/src/ghost_pad.rs @@ -0,0 +1,89 @@ +// Copyright (C) 2018 Sebastian Dröge +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::mem; +use std::ptr; + +use glib_ffi; +use gobject_ffi; +use gst_ffi; + +use glib; +use glib::translate::*; +use gst; +use gst::prelude::*; + +use gobject_subclass::anyimpl::*; +use gobject_subclass::object::*; + +use pad::*; + +pub trait GhostPadImpl: + AnyImpl + ObjectImpl + PadImpl + Send + Sync + 'static +{ +} + +any_impl!(GhostPadBase, GhostPadImpl); + +pub unsafe trait GhostPadBase: IsA + IsA + ObjectType {} + +pub unsafe trait GhostPadClassExt +where + T::ImplType: GhostPadImpl, +{ + fn override_vfuncs(&mut self, _: &ClassInitToken) {} +} + +glib_wrapper! { + pub struct GhostPad(Object>): + [gst::GhostPad => gst_ffi::GstGhostPad, + gst::ProxyPad => gst_ffi::GstProxyPad, + gst::Pad => gst_ffi::GstPad, + gst::Object => gst_ffi::GstObject]; + + match fn { + get_type => || get_type::(), + } +} + +unsafe impl + IsA + ObjectType> GhostPadBase for T {} +pub type GhostPadClass = ClassStruct; + +// FIXME: Boilerplate +unsafe impl GhostPadClassExt for GhostPadClass {} +unsafe impl PadClassExt for GhostPadClass {} +unsafe impl ObjectClassExt for GhostPadClass {} + +unsafe impl Send for GhostPad {} +unsafe impl Sync for GhostPad {} + +#[macro_export] +macro_rules! box_ghost_pad_impl( + ($name:ident) => { + box_pad_impl!($name); + + impl GhostPadImpl for Box<$name> + { + } + }; +); +box_ghost_pad_impl!(GhostPadImpl); + +impl ObjectType for GhostPad { + const NAME: &'static str = "RsGhostPad"; + type ParentType = gst::GhostPad; + type ImplType = Box>; + type InstanceStructType = InstanceStruct; + + fn class_init(token: &ClassInitToken, klass: &mut GhostPadClass) { + PadClassExt::override_vfuncs(klass, token); + GhostPadClassExt::override_vfuncs(klass, token); + } + + object_type_fns!(); +} diff --git a/gst-plugin/src/lib.rs b/gst-plugin/src/lib.rs index 659f17c3..152ee91b 100644 --- a/gst-plugin/src/lib.rs +++ b/gst-plugin/src/lib.rs @@ -51,3 +51,5 @@ pub mod uri_handler; #[macro_use] pub mod pad; +#[macro_use] +pub mod ghost_pad;