From 1e293e5cb860b4bd02134309215c2b5f9007b5da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 2 May 2024 16:34:15 +0300 Subject: [PATCH 1/2] ci: Update to Rust 1.78.0 Part-of: --- ci/images_template.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/images_template.yml b/ci/images_template.yml index 00b24e6e3..fc61b6c58 100644 --- a/ci/images_template.yml +++ b/ci/images_template.yml @@ -1,6 +1,6 @@ variables: GST_RS_IMG_TAG: "2024-04-30.0" - GST_RS_STABLE: "1.77.2" + GST_RS_STABLE: "1.78.0" GST_RS_MSRV: "1.70.0" # The branch we use to build GStreamer from in the docker images # Ex. main, 1.24, my-test-branch From 2a9d0d035f2fe67ff2a4637958527ef9730c93f9 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 2/2] 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 | 127 +++++++++--------- 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(+), 78 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 406da3994..bbed3ad09 100644 --- a/gstreamer-pbutils/src/encoding_profile.rs +++ b/gstreamer-pbutils/src/encoding_profile.rs @@ -33,40 +33,16 @@ impl> EncodingProfileExtManual for O {} trait EncodingProfileBuilderCommon { fn set_allow_dynamic_output(&self, allow_dynamic_output: bool); - fn set_allow_dynamic_output_if_some(&self, allow_dynamic_output: Option) { - if let Some(allow_dynamic_output) = allow_dynamic_output { - self.set_allow_dynamic_output(allow_dynamic_output) - } - } - fn set_description(&self, description: Option<&str>); fn set_enabled(&self, enabled: bool); - fn set_enabled_if_some(&self, enabled: Option) { - if let Some(enabled) = enabled { - self.set_enabled(enabled) - } - } - fn set_format(&self, format: &gst::Caps); - fn set_format_if_some(&self, format: Option<&gst::Caps>) { - if let Some(format) = format { - self.set_format(format) - } - } - fn set_name(&self, name: Option<&str>); fn set_presence(&self, presence: u32); - fn set_presence_if_some(&self, presence: Option) { - if let Some(presence) = presence { - self.set_presence(presence); - } - } - fn set_preset(&self, preset: Option<&str>); fn set_preset_name(&self, preset_name: Option<&str>); @@ -76,13 +52,6 @@ trait EncodingProfileBuilderCommon { #[cfg(feature = "v1_20")] fn set_element_properties(&self, element_properties: ElementProperties); - - #[cfg(feature = "v1_20")] - fn set_element_properties_if_some(&self, element_properties: Option) { - if let Some(element_properties) = element_properties { - self.set_element_properties(element_properties); - } - } } impl> EncodingProfileBuilderCommon for O { @@ -184,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")] @@ -197,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 { @@ -401,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( @@ -445,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 + } + } } } ); @@ -475,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); @@ -694,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] @@ -742,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 d3cf22f01..ca2401f9e 100644 --- a/gstreamer/src/lib.rs +++ b/gstreamer/src/lib.rs @@ -335,6 +335,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},