From c61d913ec65800da13bd00d7e170dfabfc84b69a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 29 Jun 2022 10:13:59 +0300 Subject: [PATCH] tracer: Add support for the 1.20 "plugin-feature-loaded" hook --- gstreamer/src/subclass/tracer.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/gstreamer/src/subclass/tracer.rs b/gstreamer/src/subclass/tracer.rs index 0b06a0825..ebd427cb1 100644 --- a/gstreamer/src/subclass/tracer.rs +++ b/gstreamer/src/subclass/tracer.rs @@ -58,6 +58,9 @@ pub trait TracerImpl: TracerImplExt + GstObjectImpl + Send + Sync { fn pad_query_pre(&self, ts: u64, pad: &Pad, query: &Query) {} fn pad_unlink_post(&self, ts: u64, src: &Pad, sink: &Pad, success: bool) {} fn pad_unlink_pre(&self, ts: u64, src: &Pad, sink: &Pad) {} + #[cfg(any(feature = "v1_20", feature = "dox"))] + #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))] + fn plugin_feature_loaded(&self, ts: u64, feature: &crate::PluginFeature) {} } unsafe impl IsSubclassable for Tracer {} @@ -71,15 +74,15 @@ pub trait TracerImplExt: ObjectSubclass { } macro_rules! define_tracer_hooks { - ($($name: ident($quark: literal) = |$this: ident, $ts: ident, $($cb_arg: ident: $cb_arg_ty: ty),*| $impl: block;)*) => { + ($($(#[$attr:meta])* $name: ident($quark: literal) = |$this: ident, $ts: ident, $($cb_arg: ident: $cb_arg_ty: ty),*| $impl: block;)*) => { pub enum TracerHook { - $($name),* + $($(#[$attr])* $name),* } impl TracerImplExt for T { fn register_hook(&self, hook: TracerHook) { use TracerHook::*; let (hook_type, callback) = match hook { - $($name => { + $($(#[$attr])* $name => { #[allow(non_snake_case)] unsafe extern "C" fn callback( $this: *mut ffi::GstTracer, @@ -268,4 +271,10 @@ define_tracer_hooks! { let sink = Pad::from_glib_borrow(sink); this.pad_unlink_pre(ts, &src, &sink) }; + #[cfg(any(feature = "v1_20", feature = "dox"))] + #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))] + PluginFeatureLoaded("plugin-feature-loaded") = |this, ts, feature: *mut ffi::GstPluginFeature| { + let feature = crate::PluginFeature::from_glib_borrow(feature); + this.plugin_feature_loaded(ts, &feature) + }; }