From 192844c17363aedceffb32d2b726a5642bb8183e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 23 Sep 2024 13:00:45 +0300 Subject: [PATCH] rtsp-server: media: Take pipeline by reference instead of value And remove <1.18 workaround if building for 1.18 or newer. Part-of: --- gstreamer-rtsp-server/src/rtsp_media.rs | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/gstreamer-rtsp-server/src/rtsp_media.rs b/gstreamer-rtsp-server/src/rtsp_media.rs index c80e53209..3466b9cbf 100644 --- a/gstreamer-rtsp-server/src/rtsp_media.rs +++ b/gstreamer-rtsp-server/src/rtsp_media.rs @@ -11,14 +11,25 @@ mod sealed { pub trait RTSPMediaExtManual: sealed::Sealed + IsA + 'static { #[doc(alias = "gst_rtsp_media_take_pipeline")] - fn take_pipeline(&self, pipeline: impl IsA) { + fn take_pipeline(&self, pipeline: &impl IsA) { unsafe { - let pipeline = pipeline.upcast().into_glib_ptr(); - // See https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/merge_requests/109 - glib::gobject_ffi::g_object_force_floating(pipeline as *mut _); - ffi::gst_rtsp_media_take_pipeline(self.as_ref().to_glib_none().0, pipeline); - if glib::gobject_ffi::g_object_is_floating(pipeline as *mut _) != glib::ffi::GFALSE { - glib::gobject_ffi::g_object_ref_sink(pipeline as *mut _); + #[cfg(feature = "v1_18")] + { + ffi::gst_rtsp_media_take_pipeline( + self.as_ref().to_glib_none().0, + pipeline.upcast_ref().to_glib_none().0, + ); + } + #[cfg(not(feature = "v1_18"))] + { + let pipeline = pipeline.upcast_ref().to_glib_full(); + // See https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/merge_requests/109 + glib::gobject_ffi::g_object_force_floating(pipeline as *mut _); + ffi::gst_rtsp_media_take_pipeline(self.as_ref().to_glib_none().0, pipeline); + if glib::gobject_ffi::g_object_is_floating(pipeline as *mut _) != glib::ffi::GFALSE + { + glib::gobject_ffi::g_object_ref_sink(pipeline as *mut _); + } } } }