From c942a1d563d9bab5dcc469919747f0ec163cd165 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 4 Nov 2021 15:44:35 +0200 Subject: [PATCH] gstreamer: Implement `Element::request_pad_simple()` only once With < 1.20 it will use `gst_element_get_request_pad()` and otherwise `gst_element_request_pad_simple()`. It's not marked as deprecated in either case. Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/358 --- gstreamer/Gir.toml | 8 ++++++-- gstreamer/src/auto/element.rs | 16 ---------------- gstreamer/src/element.rs | 22 +++++++++++++++------- 3 files changed, 21 insertions(+), 25 deletions(-) diff --git a/gstreamer/Gir.toml b/gstreamer/Gir.toml index 693e55285..23293fe6d 100644 --- a/gstreamer/Gir.toml +++ b/gstreamer/Gir.toml @@ -875,9 +875,13 @@ manual_traits = ["ElementExtManual"] [[object.function]] name = "get_request_pad" # rename to more explicit name and avoid conflict with `request_pad` - # TODO: request_pad_simple is now _also_ in the 1.20 bindings! rename = "request_pad_simple" - # Renamed version only available in not(1.20) + # Renamed version is not deprecated + manual = true + + [[object.function]] + name = "request_pad_simple" + # see above manual = true [[object.function]] diff --git a/gstreamer/src/auto/element.rs b/gstreamer/src/auto/element.rs index 14bfb4d54..5bf1fefa3 100644 --- a/gstreamer/src/auto/element.rs +++ b/gstreamer/src/auto/element.rs @@ -212,11 +212,6 @@ pub trait ElementExt: 'static { caps: Option<&Caps>, ) -> Option; - #[cfg(any(feature = "v1_20", feature = "dox"))] - #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))] - #[doc(alias = "gst_element_request_pad_simple")] - fn request_pad_simple(&self, name: &str) -> Option; - #[doc(alias = "gst_element_set_base_time")] fn set_base_time(&self, time: ClockTime); @@ -637,17 +632,6 @@ impl> ElementExt for O { } } - #[cfg(any(feature = "v1_20", feature = "dox"))] - #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))] - fn request_pad_simple(&self, name: &str) -> Option { - unsafe { - from_glib_full(ffi::gst_element_request_pad_simple( - self.as_ref().to_glib_none().0, - name.to_glib_none().0, - )) - } - } - fn set_base_time(&self, time: ClockTime) { unsafe { ffi::gst_element_set_base_time(self.as_ref().to_glib_none().0, time.into_glib()); diff --git a/gstreamer/src/element.rs b/gstreamer/src/element.rs index 16528dbd0..f96cb0b66 100644 --- a/gstreamer/src/element.rs +++ b/gstreamer/src/element.rs @@ -270,10 +270,9 @@ pub trait ElementExtManual: 'static { #[doc(alias = "get_current_clock_time")] fn current_clock_time(&self) -> Option; - #[cfg(any(not(feature = "v1_20"), feature = "dox"))] - #[cfg_attr(feature = "dox", doc(cfg(not(feature = "v1_20"))))] #[doc(alias = "gst_element_get_request_pad")] #[doc(alias = "get_request_pad")] + #[doc(alias = "gst_element_request_pad_simple")] fn request_pad_simple(&self, name: &str) -> Option; } @@ -797,13 +796,22 @@ impl> ElementExtManual for O { } } - #[cfg(any(not(feature = "v1_20"), feature = "dox"))] fn request_pad_simple(&self, name: &str) -> Option { unsafe { - from_glib_full(ffi::gst_element_get_request_pad( - self.as_ref().to_glib_none().0, - name.to_glib_none().0, - )) + #[cfg(feature = "v1_20")] + { + from_glib_full(ffi::gst_element_request_pad_simple( + self.as_ref().to_glib_none().0, + name.to_glib_none().0, + )) + } + #[cfg(not(feature = "v1_20"))] + { + from_glib_full(ffi::gst_element_get_request_pad( + self.as_ref().to_glib_none().0, + name.to_glib_none().0, + )) + } } } }