From 6b0d286c879ef3abb287e14a74aa083f6da4c379 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 2 May 2024 18:13:27 +0300 Subject: [PATCH] Fix various new 1.78 clippy warnings Quite a bit of API was accidentally not exported but apparently nobody was using it. Part-of: --- examples/src/bin/rtsp-server-subclass.rs | 4 - gstreamer-allocators/src/lib.rs | 2 + gstreamer-pbutils/src/encoding_profile.rs | 96 ++++++++++++------- gstreamer-video/src/subclass/mod.rs | 2 +- .../src/subclass/video_aggregator_pad.rs | 2 +- gstreamer-webrtc/src/lib.rs | 4 + gstreamer/src/iterator.rs | 10 +- gstreamer/src/lib.rs | 2 + 8 files changed, 75 insertions(+), 47 deletions(-) diff --git a/examples/src/bin/rtsp-server-subclass.rs b/examples/src/bin/rtsp-server-subclass.rs index 46d542574..c9db8eb8b 100644 --- a/examples/src/bin/rtsp-server-subclass.rs +++ b/examples/src/bin/rtsp-server-subclass.rs @@ -19,10 +19,6 @@ mod examples_common; #[display(fmt = "Could not get mount points")] struct NoMountPoints; -#[derive(Debug, Display, Error)] -#[display(fmt = "Usage: {_0} LAUNCH_LINE")] -struct UsageError(#[error(not(source))] String); - fn main_loop() -> Result<(), Error> { let main_loop = glib::MainLoop::new(None, false); let server = server::Server::default(); diff --git a/gstreamer-allocators/src/lib.rs b/gstreamer-allocators/src/lib.rs index cc80e99f7..db0ad174e 100644 --- a/gstreamer-allocators/src/lib.rs +++ b/gstreamer-allocators/src/lib.rs @@ -56,6 +56,8 @@ pub use phys_memory::*; pub mod prelude { #[doc(hidden)] pub use gst::prelude::*; + + pub use crate::auto::traits::*; } pub mod subclass; diff --git a/gstreamer-pbutils/src/encoding_profile.rs b/gstreamer-pbutils/src/encoding_profile.rs index baf49aa01..bbed3ad09 100644 --- a/gstreamer-pbutils/src/encoding_profile.rs +++ b/gstreamer-pbutils/src/encoding_profile.rs @@ -153,11 +153,6 @@ impl> EncodingProfileBuilderCommon for O { } } -// Split the trait as only the getter is public -trait EncodingProfileHasRestrictionSetter { - fn set_restriction(&self, restriction: Option); -} - pub trait EncodingProfileHasRestrictionGetter { #[doc(alias = "get_restriction")] #[doc(alias = "gst_encoding_profile_get_restriction")] @@ -166,25 +161,6 @@ pub trait EncodingProfileHasRestrictionGetter { macro_rules! declare_encoding_profile_has_restriction( ($name:ident) => { - impl EncodingProfileHasRestrictionSetter for $name { - // checker-ignore-item - fn set_restriction(&self, restriction: Option) { - let profile: &EncodingProfile = glib::object::Cast::upcast_ref(self); - - unsafe { - let restriction = match restriction { - Some(restriction) => restriction.into_glib_ptr(), - None => gst::ffi::gst_caps_new_any(), - }; - - ffi::gst_encoding_profile_set_restriction( - profile.to_glib_none().0, - restriction, - ); - } - } - } - impl EncodingProfileHasRestrictionGetter for $name { // checker-ignore-item fn restriction(&self) -> Option { @@ -370,20 +346,37 @@ pub trait EncodingProfileBuilder<'a>: Sized { #[doc(alias = "gst_encoding_profile_set_presence")] #[must_use] fn presence(self, presence: u32) -> Self; + #[doc(alias = "gst_encoding_profile_set_presence")] + #[must_use] + fn presence_if_some(self, presence: Option) -> Self; #[doc(alias = "gst_encoding_profile_set_allow_dynamic_output")] #[must_use] fn allow_dynamic_output(self, allow: bool) -> Self; + #[doc(alias = "gst_encoding_profile_set_allow_dynamic_output")] + #[must_use] + fn allow_dynamic_output_if_some(self, allow_dynamic_output: Option) -> Self; #[doc(alias = "gst_encoding_profile_set_enabled")] #[must_use] fn enabled(self, enabled: bool) -> Self; + #[doc(alias = "gst_encoding_profile_set_enabled")] + #[must_use] + fn enabled_if_some(self, enabled: Option) -> Self; #[cfg(feature = "v1_18")] #[doc(alias = "gst_encoding_profile_set_single_segment")] #[must_use] fn single_segment(self, single_segment: bool) -> Self; + #[cfg(feature = "v1_18")] + #[doc(alias = "gst_encoding_profile_set_single_segment")] + #[must_use] + fn single_segment_if_some(self, single_segment: Option) -> Self; #[cfg(feature = "v1_20")] #[doc(alias = "gst_encoding_profile_set_element_properties")] #[must_use] fn element_properties(self, element_properties: ElementProperties) -> Self; + #[cfg(feature = "v1_20")] + #[doc(alias = "gst_encoding_profile_set_element_properties")] + #[must_use] + fn element_properties_if_some(self, element_properties: Option) -> Self; } macro_rules! declare_encoding_profile_builder_common( @@ -414,27 +407,69 @@ macro_rules! declare_encoding_profile_builder_common( self } + fn presence_if_some(self, presence: Option) -> $name<'a> { + if let Some(presence) = presence { + self.presence(presence) + } else { + self + } + } + fn allow_dynamic_output(mut self, allow: bool) -> $name<'a> { self.base.allow_dynamic_output = allow; self } + fn allow_dynamic_output_if_some(self, allow_dynamic_output: Option) -> $name<'a> { + if let Some(allow_dynamic_output) = allow_dynamic_output { + self.allow_dynamic_output(allow_dynamic_output) + } else { + self + } + } + fn enabled(mut self, enabled: bool) -> $name<'a> { self.base.enabled = enabled; self } + fn enabled_if_some(self, enabled: Option) -> $name<'a> { + if let Some(enabled) = enabled { + self.enabled(enabled) + } else { + self + } + } + #[cfg(feature = "v1_18")] fn single_segment(mut self, single_segment: bool) -> $name<'a> { self.base.single_segment = single_segment; self } + #[cfg(feature = "v1_18")] + fn single_segment_if_some(self, single_segment: Option) -> $name<'a> { + if let Some(single_segment) = single_segment { + self.single_segment(single_segment) + } else { + self + } + } + #[cfg(feature = "v1_20")] fn element_properties(mut self, element_properties: ElementProperties) -> $name<'a> { self.base.element_properties = Some(element_properties); self } + + #[cfg(feature = "v1_20")] + fn element_properties_if_some(self, element_properties: Option) -> $name<'a> { + if let Some(element_properties) = element_properties { + self.element_properties(element_properties) + } else { + self + } + } } } ); @@ -444,6 +479,7 @@ fn set_common_fields( base_data: EncodingProfileBuilderCommonData, ) { skip_assert_initialized!(); + profile.set_format(base_data.format); profile.set_name(base_data.name); profile.set_description(base_data.description); profile.set_preset(base_data.preset); @@ -663,12 +699,6 @@ mod tests { assert_eq!(audio_profile.presence(), PRESENCE); assert_eq!(audio_profile.allows_dynamic_output(), ALLOW_DYNAMIC_OUTPUT); assert_eq!(audio_profile.is_enabled(), ENABLED); - - let restriction = gst_audio::AudioCapsBuilder::new() - .format(gst_audio::AudioFormat::S32be) - .build(); - audio_profile.set_restriction(Some(restriction.clone())); - assert_eq!(audio_profile.restriction().unwrap(), restriction); } #[test] @@ -711,12 +741,6 @@ mod tests { glib::object::Cast::downcast(video_profile).ok().unwrap(); assert_eq!(video_profile.is_variableframerate(), VARIABLE_FRAMERATE); assert_eq!(video_profile.pass(), PASS); - - let restriction = gst_video::VideoCapsBuilder::new() - .format(gst_video::VideoFormat::Nv12) - .build(); - video_profile.set_restriction(Some(restriction.clone())); - assert_eq!(video_profile.restriction().unwrap(), restriction); } #[test] diff --git a/gstreamer-video/src/subclass/mod.rs b/gstreamer-video/src/subclass/mod.rs index 50046723d..7a0cd684c 100644 --- a/gstreamer-video/src/subclass/mod.rs +++ b/gstreamer-video/src/subclass/mod.rs @@ -35,7 +35,7 @@ pub mod prelude { #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))] pub use super::video_aggregator_pad::{VideoAggregatorPadImpl, VideoAggregatorPadImplExt}; pub use super::{ - navigation::NavigationImpl, + navigation::{NavigationImpl, NavigationImplExt}, video_decoder::{VideoDecoderImpl, VideoDecoderImplExt}, video_encoder::{VideoEncoderImpl, VideoEncoderImplExt}, video_filter::{VideoFilterImpl, VideoFilterImplExt}, diff --git a/gstreamer-video/src/subclass/video_aggregator_pad.rs b/gstreamer-video/src/subclass/video_aggregator_pad.rs index 48cd78030..1e0083554 100644 --- a/gstreamer-video/src/subclass/video_aggregator_pad.rs +++ b/gstreamer-video/src/subclass/video_aggregator_pad.rs @@ -36,7 +36,7 @@ mod sealed { impl Sealed for T {} } -pub trait VideoAggregatorPadImplExt: ObjectSubclass { +pub trait VideoAggregatorPadImplExt: ObjectSubclass + sealed::Sealed { fn parent_update_conversion_info(&self) { unsafe { let data = Self::type_data(); diff --git a/gstreamer-webrtc/src/lib.rs b/gstreamer-webrtc/src/lib.rs index e6e62ba68..0376fe4bc 100644 --- a/gstreamer-webrtc/src/lib.rs +++ b/gstreamer-webrtc/src/lib.rs @@ -34,4 +34,8 @@ pub mod prelude { pub use crate::web_rtcice::WebRTCICEExtManual; #[doc(hidden)] pub use gst_sdp::prelude::*; + + #[cfg(feature = "v1_22")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_22")))] + pub use crate::auto::traits::*; } diff --git a/gstreamer/src/iterator.rs b/gstreamer/src/iterator.rs index 755bb5f81..6f1518f36 100644 --- a/gstreamer/src/iterator.rs +++ b/gstreamer/src/iterator.rs @@ -318,13 +318,13 @@ where unsafe impl Send for Iterator {} unsafe impl Sync for Iterator {} -unsafe extern "C" fn filter_trampoline bool + Send + Sync + 'static>( +unsafe extern "C" fn filter_trampoline< + T: for<'a> FromValue<'a> + StaticType + 'static, + F: Fn(T) -> bool + Send + Sync + 'static, +>( value: gconstpointer, func: gconstpointer, -) -> i32 -where - for<'a> T: FromValue<'a> + 'static, -{ +) -> i32 { let value = value as *const glib::gobject_ffi::GValue; let func = func as *const glib::gobject_ffi::GValue; diff --git a/gstreamer/src/lib.rs b/gstreamer/src/lib.rs index 71e06f3d6..31e269134 100644 --- a/gstreamer/src/lib.rs +++ b/gstreamer/src/lib.rs @@ -332,6 +332,8 @@ pub mod prelude { buffer_pool::BufferPoolExtManual, child_proxy::ChildProxyExtManual, clock::ClockExtManual, + control_binding::ControlBindingExtManual, + control_source::ControlSourceExtManual, device_monitor::DeviceMonitorExtManual, device_provider::{DeviceProviderClassExt, DeviceProviderExtManual}, element::{ElementClassExt, ElementExtManual},