From 9e3a0fd52b8a2154bf3164a7b1b0a4f977a9d391 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 10 Dec 2024 13:41:35 +0200 Subject: [PATCH] gstreamer: Add support for new tracer use-structure-params API Part-of: --- gstreamer/src/subclass/tracer.rs | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/gstreamer/src/subclass/tracer.rs b/gstreamer/src/subclass/tracer.rs index 8536ef3bc..799018e4b 100644 --- a/gstreamer/src/subclass/tracer.rs +++ b/gstreamer/src/subclass/tracer.rs @@ -11,6 +11,13 @@ use crate::{ #[allow(unused_variables)] pub trait TracerImpl: GstObjectImpl + ObjectSubclass> { + // rustdoc-stripper-ignore-next + /// Whether to use `gst::Structure` style "params" and automatically pass + /// them to the corresponding properties during instantiation. + /// + /// Setting this to `true` requires GStreamer 1.26 + const USE_STRUCTURE_PARAMS: bool = false; + fn bin_add_post(&self, ts: u64, bin: &Bin, element: &Element, success: bool) {} fn bin_add_pre(&self, ts: u64, bin: &Bin, element: &Element) {} fn bin_remove_post(&self, ts: u64, bin: &Bin, success: bool) {} @@ -83,7 +90,28 @@ pub trait TracerImpl: GstObjectImpl + ObjectSubclass> { fn plugin_feature_loaded(&self, ts: u64, feature: &crate::PluginFeature) {} } -unsafe impl IsSubclassable for Tracer {} +unsafe impl IsSubclassable for Tracer { + fn class_init(class: &mut glib::Class) { + Self::parent_class_init::(class); + + #[cfg(feature = "v1_26")] + { + let class = class.as_mut(); + unsafe { + ffi::gst_tracer_class_set_use_structure_params( + class, + T::USE_STRUCTURE_PARAMS.into_glib(), + ); + } + } + #[cfg(not(feature = "v1_26"))] + { + if T::USE_STRUCTURE_PARAMS { + panic!("Can only use `USE_STRUCTURE_PARAMS` with GStreamer 1.26 and newer"); + } + } + } +} pub trait TracerImplExt: TracerImpl { // rustdoc-stripper-ignore-next