diff --git a/Gir_Gst.toml b/Gir_Gst.toml index e738e8f4a..27ddf3220 100644 --- a/Gir_Gst.toml +++ b/Gir_Gst.toml @@ -735,6 +735,7 @@ trait = false [[object]] name = "Gst.GhostPad" +subclassing = true status = "generate" [[object.function]] name = "set_target" diff --git a/gstreamer/src/auto/ghost_pad.rs b/gstreamer/src/auto/ghost_pad.rs index 1d85c71f7..ddcdeecf9 100644 --- a/gstreamer/src/auto/ghost_pad.rs +++ b/gstreamer/src/auto/ghost_pad.rs @@ -2,6 +2,7 @@ // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT +use GhostPadClass; use Object; use Pad; use PadDirection; @@ -18,7 +19,7 @@ use std::mem; use std::ptr; glib_wrapper! { - pub struct GhostPad(Object): ProxyPad, Pad, Object; + pub struct GhostPad(Object): ProxyPad, Pad, Object; match fn { get_type => || ffi::gst_ghost_pad_get_type(), diff --git a/gstreamer/src/ghost_pad.rs b/gstreamer/src/ghost_pad.rs index ac0d1f5fd..34f2e5667 100644 --- a/gstreamer/src/ghost_pad.rs +++ b/gstreamer/src/ghost_pad.rs @@ -8,7 +8,7 @@ use ffi; use glib::object::Downcast; -use glib::object::IsA; +use glib::object::{IsA, IsClassFor}; use glib::translate::*; use GhostPad; use Object; @@ -16,6 +16,8 @@ use Pad; use PadMode; use PadTemplate; +use std::ops; + impl GhostPad { pub fn new<'a, P: Into>, Q: IsA>(name: P, target: &Q) -> Option { skip_assert_initialized!(); @@ -93,3 +95,27 @@ impl GhostPad { } } } + +#[repr(C)] +pub struct GhostPadClass(ffi::GstGhostPadClass); + +unsafe impl IsClassFor for GhostPadClass { + type Instance = GhostPad; +} + +unsafe impl Send for GhostPadClass {} +unsafe impl Sync for GhostPadClass {} + +impl ops::Deref for GhostPadClass { + type Target = ::PadClass; + + fn deref(&self) -> &Self::Target { + self.upcast_ref() + } +} + +impl ops::DerefMut for GhostPadClass { + fn deref_mut(&mut self) -> &mut Self::Target { + self.upcast_ref_mut() + } +} diff --git a/gstreamer/src/lib.rs b/gstreamer/src/lib.rs index 754e76a97..a0a67ec02 100644 --- a/gstreamer/src/lib.rs +++ b/gstreamer/src/lib.rs @@ -180,6 +180,7 @@ mod device_monitor; mod device_provider; mod enums; mod ghost_pad; +pub use ghost_pad::GhostPadClass; mod gobject; mod iterator; mod object; diff --git a/gstreamer/src/subclass/ghost_pad.rs b/gstreamer/src/subclass/ghost_pad.rs new file mode 100644 index 000000000..9469ef820 --- /dev/null +++ b/gstreamer/src/subclass/ghost_pad.rs @@ -0,0 +1,26 @@ +// 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 ffi; + +use super::prelude::*; +use glib::subclass::prelude::*; + +use GhostPadClass; + +pub trait GhostPadImpl: PadImpl + Send + Sync + 'static {} + +unsafe impl IsSubclassable for GhostPadClass { + fn override_vfuncs(&mut self) { + <::PadClass as IsSubclassable>::override_vfuncs(self); + unsafe { + let _klass = &mut *(self as *const Self as *mut ffi::GstGhostPadClass); + // Nothing to do here + } + } +} diff --git a/gstreamer/src/subclass/mod.rs b/gstreamer/src/subclass/mod.rs index 1c5e264c5..eabd761d4 100644 --- a/gstreamer/src/subclass/mod.rs +++ b/gstreamer/src/subclass/mod.rs @@ -16,6 +16,7 @@ pub mod plugin; pub mod bin; pub mod child_proxy; pub mod element; +pub mod ghost_pad; pub mod pad; pub mod pipeline; pub mod uri_handler; @@ -24,6 +25,7 @@ pub mod prelude { pub use super::bin::BinImpl; pub use super::child_proxy::ChildProxyImpl; pub use super::element::{ElementClassSubclassExt, ElementImpl, ElementImplExt}; + pub use super::ghost_pad::GhostPadImpl; pub use super::pad::PadImpl; pub use super::pipeline::PipelineImpl; pub use super::uri_handler::URIHandlerImpl;