From fcb46ee5bf8895831811c1d322b93bce2b058c17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Laignel?= Date: Sat, 2 Feb 2019 17:37:02 +0100 Subject: [PATCH] gstreamer: add parent_xxx impl for all vfunc --- gstreamer/src/subclass/element.rs | 51 +++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/gstreamer/src/subclass/element.rs b/gstreamer/src/subclass/element.rs index a7cf1b930..965448674 100644 --- a/gstreamer/src/subclass/element.rs +++ b/gstreamer/src/subclass/element.rs @@ -39,15 +39,17 @@ pub trait ElementImpl: ObjectImpl + Send + Sync + 'static { fn request_new_pad( &self, - _element: &::Element, - _templ: &::PadTemplate, - _name: Option, - _caps: Option<&::CapsRef>, + element: &::Element, + templ: &::PadTemplate, + name: Option, + caps: Option<&::CapsRef>, ) -> Option<::Pad> { - None + self.parent_request_new_pad(element, templ, name, caps) } - fn release_pad(&self, _element: &::Element, _pad: &::Pad) {} + fn release_pad(&self, element: &::Element, pad: &::Pad) { + self.parent_release_pad(element, pad) + } fn send_event(&self, element: &::Element, event: Event) -> bool { self.parent_send_event(element, event) @@ -78,6 +80,43 @@ pub trait ElementImpl: ObjectImpl + Send + Sync + 'static { } } + fn parent_request_new_pad( + &self, + element: &::Element, + templ: &::PadTemplate, + name: Option, + caps: Option<&::CapsRef>, + ) -> Option<::Pad> { + unsafe { + let data = self.get_type_data(); + let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstElementClass; + + (*parent_class) + .request_new_pad + .map(|f| { + from_glib_none(f( + element.to_glib_none().0, + templ.to_glib_none().0, + name.to_glib_full(), + caps.map(|caps| caps.as_ptr()).unwrap_or(std::ptr::null()), + )) + }) + .unwrap_or(None) + } + } + + fn parent_release_pad(&self, element: &::Element, pad: &::Pad) { + unsafe { + let data = self.get_type_data(); + let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstElementClass; + + (*parent_class) + .release_pad + .map(|f| f(element.to_glib_none().0, pad.to_glib_none().0)) + .unwrap_or(()) + } + } + fn parent_send_event(&self, element: &::Element, event: Event) -> bool { unsafe { let data = self.get_type_data();