From 86e969d964f683f8df83803b016e03a9c8033271 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 23 May 2019 21:19:24 +0300 Subject: [PATCH] Remove various Into> trait bounds from functions In autogenerated code these were already replaced but some manual code still kept them. --- examples/src/bin/rtpfecclient.rs | 4 +- examples/src/bin/rtpfecserver.rs | 4 +- gstreamer-base/src/functions.rs | 10 +-- gstreamer-check/src/harness.rs | 89 +++++-------------- gstreamer-net/src/net_client_clock.rs | 5 +- gstreamer-net/src/net_time_provider.rs | 7 +- gstreamer-net/src/ntp_clock.rs | 5 +- gstreamer-net/src/ptp_clock.rs | 3 +- gstreamer-pbutils/src/encoding_profile.rs | 59 +++++------- ...player_g_main_context_signal_dispatcher.rs | 5 +- gstreamer-rtsp-server/src/rtsp_auth.rs | 5 +- gstreamer-rtsp-server/src/rtsp_client.rs | 5 +- gstreamer-rtsp-server/src/rtsp_server.rs | 5 +- .../src/rtsp_session_pool.rs | 15 +--- gstreamer-sdp/src/sdp_media.rs | 3 +- gstreamer-sdp/src/sdp_message.rs | 4 +- gstreamer/src/buffer_pool.rs | 30 +++---- gstreamer/src/bus.rs | 8 +- gstreamer/src/device_monitor.rs | 14 ++- gstreamer/src/element.rs | 18 ++-- gstreamer/src/error.rs | 14 +-- gstreamer/src/functions.rs | 15 ++-- gstreamer/src/ghost_pad.rs | 28 ++---- gstreamer/src/log.rs | 11 +-- gstreamer/src/object.rs | 17 +--- gstreamer/src/pad.rs | 41 ++------- gstreamer/src/proxy_pad.rs | 20 ++--- gstreamer/src/query.rs | 3 +- gstreamer/src/stream.rs | 8 +- gstreamer/src/stream_collection.rs | 3 +- gstreamer/src/typefind.rs | 21 ++--- 31 files changed, 143 insertions(+), 336 deletions(-) diff --git a/examples/src/bin/rtpfecclient.rs b/examples/src/bin/rtpfecclient.rs index e989e89d4..0d3f9975d 100644 --- a/examples/src/bin/rtpfecclient.rs +++ b/examples/src/bin/rtpfecclient.rs @@ -45,9 +45,9 @@ struct ErrorMessage { cause: glib::Error, } -fn make_element<'a, P: Into>>( +fn make_element( factory_name: &'static str, - element_name: P, + element_name: Option<&str>, ) -> Result { match gst::ElementFactory::make(factory_name, element_name.into()) { Some(elem) => Ok(elem), diff --git a/examples/src/bin/rtpfecserver.rs b/examples/src/bin/rtpfecserver.rs index 1cc78de64..2b44fc266 100644 --- a/examples/src/bin/rtpfecserver.rs +++ b/examples/src/bin/rtpfecserver.rs @@ -42,9 +42,9 @@ struct ErrorMessage { cause: glib::Error, } -fn make_element<'a, P: Into>>( +fn make_element( factory_name: &'static str, - element_name: P, + element_name: Option<&str>, ) -> Result { match gst::ElementFactory::make(factory_name, element_name.into()) { Some(elem) => Ok(elem), diff --git a/gstreamer-base/src/functions.rs b/gstreamer-base/src/functions.rs index 61449df20..b2928e8d1 100644 --- a/gstreamer-base/src/functions.rs +++ b/gstreamer-base/src/functions.rs @@ -12,17 +12,11 @@ use gst; use gst_base_sys; use std::mem; -pub fn type_find_helper_for_data< - 'a, - P: IsA + 'a, - Q: Into>, - R: AsRef<[u8]>, ->( - obj: Q, +pub fn type_find_helper_for_data, R: AsRef<[u8]>>( + obj: Option<&P>, data: R, ) -> (Option, gst::TypeFindProbability) { assert_initialized_main_thread!(); - let obj = obj.into(); unsafe { let mut prob = mem::uninitialized(); let data = data.as_ref(); diff --git a/gstreamer-check/src/harness.rs b/gstreamer-check/src/harness.rs index 195dc39c8..14c258485 100644 --- a/gstreamer-check/src/harness.rs +++ b/gstreamer-check/src/harness.rs @@ -38,29 +38,15 @@ impl Drop for Harness { unsafe impl Send for Harness {} impl Harness { - pub fn add_element_full< - 'a, - 'b, - 'c, - 'd, - P: IsA, - Q: Into>, - R: Into>, - S: Into>, - T: Into>, - >( + pub fn add_element_full>( &mut self, element: &P, - hsrc: Q, - element_sinkpad_name: R, - hsink: S, - element_srcpad_name: T, + hsrc: Option<&gst::StaticPadTemplate>, + element_sinkpad_name: Option<&str>, + hsink: Option<&gst::StaticPadTemplate>, + element_srcpad_name: Option<&str>, ) { - let hsrc = hsrc.into(); - let element_sinkpad_name = element_sinkpad_name.into(); let element_sinkpad_name = element_sinkpad_name.to_glib_none(); - let hsink = hsink.into(); - let element_srcpad_name = element_srcpad_name.into(); let element_srcpad_name = element_srcpad_name.to_glib_none(); unsafe { gst_check_sys::gst_harness_add_element_full( @@ -115,10 +101,10 @@ impl Harness { } #[cfg(any(feature = "v1_16", feature = "dox"))] - pub fn add_propose_allocation_meta<'a, P: Into>>( + pub fn add_propose_allocation_meta( &mut self, api: glib::types::Type, - params: P, + params: Option<&gst::StructureRef>, ) { let params = params.into(); unsafe { @@ -390,7 +376,7 @@ impl Harness { } } - //pub fn set_propose_allocator<'a, 'b, P: Into>, Q: Into>>(&mut self, allocator: P, params: Q) { + //pub fn set_propose_allocator>(&mut self, allocator: Option<&P>, params: Option<&gst::AllocationParams>) { // unsafe { TODO: call gst_check_sys::gst_harness_set_propose_allocator() } //} @@ -589,29 +575,15 @@ impl Harness { unsafe { Self::from_glib_full(gst_check_sys::gst_harness_new_empty()) } } - pub fn new_full< - 'a, - 'b, - 'c, - 'd, - P: IsA, - Q: Into>, - R: Into>, - S: Into>, - T: Into>, - >( + pub fn new_full>( element: &P, - hsrc: Q, - element_sinkpad_name: R, - hsink: S, - element_srcpad_name: T, + hsrc: Option<&gst::StaticPadTemplate>, + element_sinkpad_name: Option<&str>, + hsink: Option<&gst::StaticPadTemplate>, + element_srcpad_name: Option<&str>, ) -> Harness { assert_initialized_main_thread!(); - let hsrc = hsrc.into(); - let element_sinkpad_name = element_sinkpad_name.into(); let element_sinkpad_name = element_sinkpad_name.to_glib_none(); - let hsink = hsink.into(); - let element_srcpad_name = element_srcpad_name.into(); let element_srcpad_name = element_srcpad_name.to_glib_none(); unsafe { Self::from_glib_full(gst_check_sys::gst_harness_new_full( @@ -633,21 +605,13 @@ impl Harness { } } - pub fn new_with_element< - 'a, - 'b, - P: IsA, - Q: Into>, - R: Into>, - >( + pub fn new_with_element>( element: &P, - element_sinkpad_name: Q, - element_srcpad_name: R, + element_sinkpad_name: Option<&str>, + element_srcpad_name: Option<&str>, ) -> Harness { assert_initialized_main_thread!(); - let element_sinkpad_name = element_sinkpad_name.into(); let element_sinkpad_name = element_sinkpad_name.to_glib_none(); - let element_srcpad_name = element_srcpad_name.into(); let element_srcpad_name = element_srcpad_name.to_glib_none(); unsafe { Self::from_glib_full(gst_check_sys::gst_harness_new_with_element( @@ -658,15 +622,13 @@ impl Harness { } } - pub fn new_with_padnames<'a, 'b, P: Into>, Q: Into>>( + pub fn new_with_padnames( element_name: &str, - element_sinkpad_name: P, - element_srcpad_name: Q, + element_sinkpad_name: Option<&str>, + element_srcpad_name: Option<&str>, ) -> Harness { assert_initialized_main_thread!(); - let element_sinkpad_name = element_sinkpad_name.into(); let element_sinkpad_name = element_sinkpad_name.to_glib_none(); - let element_srcpad_name = element_srcpad_name.into(); let element_srcpad_name = element_srcpad_name.to_glib_none(); unsafe { Self::from_glib_full(gst_check_sys::gst_harness_new_with_padnames( @@ -677,19 +639,12 @@ impl Harness { } } - pub fn new_with_templates< - 'a, - 'b, - P: Into>, - Q: Into>, - >( + pub fn new_with_templates( element_name: &str, - hsrc: P, - hsink: Q, + hsrc: Option<&gst::StaticPadTemplate>, + hsink: Option<&gst::StaticPadTemplate>, ) -> Harness { assert_initialized_main_thread!(); - let hsrc = hsrc.into(); - let hsink = hsink.into(); unsafe { Self::from_glib_full(gst_check_sys::gst_harness_new_with_templates( element_name.to_glib_none().0, diff --git a/gstreamer-net/src/net_client_clock.rs b/gstreamer-net/src/net_client_clock.rs index c15b8191b..d869e5608 100644 --- a/gstreamer-net/src/net_client_clock.rs +++ b/gstreamer-net/src/net_client_clock.rs @@ -14,14 +14,13 @@ use glib::translate::*; use gst; impl NetClientClock { - pub fn new<'a, P: Into>>( - name: P, + pub fn new( + name: Option<&str>, remote_address: &str, remote_port: i32, base_time: gst::ClockTime, ) -> NetClientClock { assert_initialized_main_thread!(); - let name = name.into(); let name = name.to_glib_none(); let (major, minor, _, _) = gst::version(); if (major, minor) > (1, 12) { diff --git a/gstreamer-net/src/net_time_provider.rs b/gstreamer-net/src/net_time_provider.rs index a216bf573..6f22ab6fb 100644 --- a/gstreamer-net/src/net_time_provider.rs +++ b/gstreamer-net/src/net_time_provider.rs @@ -14,13 +14,8 @@ use glib::IsA; use gst; impl NetTimeProvider { - pub fn new<'a, P: IsA, Q: Into>>( - clock: &P, - address: Q, - port: i32, - ) -> NetTimeProvider { + pub fn new>(clock: &P, address: Option<&str>, port: i32) -> NetTimeProvider { assert_initialized_main_thread!(); - let address = address.into(); let address = address.to_glib_none(); let (major, minor, _, _) = gst::version(); diff --git a/gstreamer-net/src/ntp_clock.rs b/gstreamer-net/src/ntp_clock.rs index b60d340f3..22a9ff0be 100644 --- a/gstreamer-net/src/ntp_clock.rs +++ b/gstreamer-net/src/ntp_clock.rs @@ -14,14 +14,13 @@ use glib::translate::*; use gst; impl NtpClock { - pub fn new<'a, P: Into>>( - name: P, + pub fn new( + name: Option<&str>, remote_address: &str, remote_port: i32, base_time: gst::ClockTime, ) -> NtpClock { assert_initialized_main_thread!(); - let name = name.into(); let name = name.to_glib_none(); let (major, minor, _, _) = gst::version(); if (major, minor) > (1, 12) { diff --git a/gstreamer-net/src/ptp_clock.rs b/gstreamer-net/src/ptp_clock.rs index 82cb0e77a..d786729fb 100644 --- a/gstreamer-net/src/ptp_clock.rs +++ b/gstreamer-net/src/ptp_clock.rs @@ -14,9 +14,8 @@ use glib::translate::*; use gst; impl PtpClock { - pub fn new<'a, P: Into>>(name: P, domain: u32) -> PtpClock { + pub fn new(name: Option<&str>, domain: u32) -> PtpClock { assert_initialized_main_thread!(); - let name = name.into(); let name = name.to_glib_none(); let (major, minor, _, _) = gst::version(); if (major, minor) > (1, 12) { diff --git a/gstreamer-pbutils/src/encoding_profile.rs b/gstreamer-pbutils/src/encoding_profile.rs index a105de4be..5fe57bf98 100644 --- a/gstreamer-pbutils/src/encoding_profile.rs +++ b/gstreamer-pbutils/src/encoding_profile.rs @@ -26,21 +26,21 @@ use auto::EncodingVideoProfile; trait EncodingProfileBuilderCommon { fn set_allow_dynamic_output(&self, allow_dynamic_output: bool); - fn set_description<'a, P: Into>>(&self, description: P); + fn set_description(&self, description: Option<&str>); fn set_enabled(&self, enabled: bool); fn set_format(&self, format: &gst::Caps); - fn set_name<'a, P: Into>>(&self, name: P); + fn set_name(&self, name: Option<&str>); fn set_presence(&self, presence: u32); - fn set_preset<'a, P: Into>>(&self, preset: P); + fn set_preset(&self, preset: Option<&str>); - fn set_preset_name<'a, P: Into>>(&self, preset_name: P); + fn set_preset_name(&self, preset_name: Option<&str>); - fn set_restriction<'a, P: Into>>(&self, restriction: P); + fn set_restriction(&self, restriction: Option<&gst::Caps>); } impl> EncodingProfileBuilderCommon for O { @@ -53,8 +53,7 @@ impl> EncodingProfileBuilderCommon for O { } } - fn set_description<'a, P: Into>>(&self, description: P) { - let description = description.into(); + fn set_description(&self, description: Option<&str>) { let description = description.to_glib_none(); unsafe { gst_pbutils_sys::gst_encoding_profile_set_description( @@ -82,8 +81,7 @@ impl> EncodingProfileBuilderCommon for O { } } - fn set_name<'a, P: Into>>(&self, name: P) { - let name = name.into(); + fn set_name(&self, name: Option<&str>) { let name = name.to_glib_none(); unsafe { gst_pbutils_sys::gst_encoding_profile_set_name(self.as_ref().to_glib_none().0, name.0); @@ -99,8 +97,7 @@ impl> EncodingProfileBuilderCommon for O { } } - fn set_preset<'a, P: Into>>(&self, preset: P) { - let preset = preset.into(); + fn set_preset(&self, preset: Option<&str>) { let preset = preset.to_glib_none(); unsafe { gst_pbutils_sys::gst_encoding_profile_set_preset( @@ -110,8 +107,7 @@ impl> EncodingProfileBuilderCommon for O { } } - fn set_preset_name<'a, P: Into>>(&self, preset_name: P) { - let preset_name = preset_name.into(); + fn set_preset_name(&self, preset_name: Option<&str>) { let preset_name = preset_name.to_glib_none(); unsafe { gst_pbutils_sys::gst_encoding_profile_set_preset_name( @@ -121,8 +117,7 @@ impl> EncodingProfileBuilderCommon for O { } } - fn set_restriction<'a, P: Into>>(&self, restriction: P) { - let restriction = restriction.into(); + fn set_restriction(&self, restriction: Option<&gst::Caps>) { unsafe { let restriction = match restriction { Some(restriction) => restriction.to_glib_full(), @@ -138,16 +133,14 @@ impl> EncodingProfileBuilderCommon for O { } impl EncodingAudioProfile { - fn new<'a, 'b, P: Into>, Q: Into>>( + fn new( format: &gst::Caps, - preset: P, - restriction: Q, + preset: Option<&str>, + restriction: Option<&gst::Caps>, presence: u32, ) -> EncodingAudioProfile { assert_initialized_main_thread!(); - let preset = preset.into(); let preset = preset.to_glib_none(); - let restriction = restriction.into(); let restriction = restriction.to_glib_none(); unsafe { from_glib_full(gst_pbutils_sys::gst_encoding_audio_profile_new( @@ -161,16 +154,14 @@ impl EncodingAudioProfile { } impl EncodingVideoProfile { - fn new<'a, 'b, P: Into>, Q: Into>>( + fn new( format: &gst::Caps, - preset: P, - restriction: Q, + preset: Option<&str>, + restriction: Option<&gst::Caps>, presence: u32, ) -> EncodingVideoProfile { assert_initialized_main_thread!(); - let preset = preset.into(); let preset = preset.to_glib_none(); - let restriction = restriction.into(); let restriction = restriction.to_glib_none(); unsafe { from_glib_full(gst_pbutils_sys::gst_encoding_video_profile_new( @@ -199,25 +190,15 @@ impl EncodingVideoProfile { } impl EncodingContainerProfile { - fn new< - 'a, - 'b, - 'c, - P: Into>, - Q: Into>, - R: Into>, - >( - name: P, - description: Q, + fn new( + name: Option<&str>, + description: Option<&str>, format: &gst::Caps, - preset: R, + preset: Option<&str>, ) -> EncodingContainerProfile { assert_initialized_main_thread!(); - let name = name.into(); let name = name.to_glib_none(); - let description = description.into(); let description = description.to_glib_none(); - let preset = preset.into(); let preset = preset.to_glib_none(); unsafe { from_glib_full(gst_pbutils_sys::gst_encoding_container_profile_new( diff --git a/gstreamer-player/src/player_g_main_context_signal_dispatcher.rs b/gstreamer-player/src/player_g_main_context_signal_dispatcher.rs index 0de94c73e..5016fb27e 100644 --- a/gstreamer-player/src/player_g_main_context_signal_dispatcher.rs +++ b/gstreamer-player/src/player_g_main_context_signal_dispatcher.rs @@ -12,11 +12,10 @@ use gst_player_sys; use PlayerGMainContextSignalDispatcher; impl PlayerGMainContextSignalDispatcher { - pub fn new<'a, P: Into>>( - application_context: P, + pub fn new( + application_context: Option<&glib::MainContext>, ) -> PlayerGMainContextSignalDispatcher { assert_initialized_main_thread!(); - let application_context = application_context.into(); let application_context = application_context.to_glib_none(); unsafe { from_glib_full( diff --git a/gstreamer-rtsp-server/src/rtsp_auth.rs b/gstreamer-rtsp-server/src/rtsp_auth.rs index 4fcd404b3..0dbcf9b45 100644 --- a/gstreamer-rtsp-server/src/rtsp_auth.rs +++ b/gstreamer-rtsp-server/src/rtsp_auth.rs @@ -12,7 +12,7 @@ use RTSPAuth; use RTSPToken; pub trait RTSPAuthExtManual: 'static { - fn set_default_token<'a, P: Into>>(&self, token: P); + fn set_default_token(&self, token: Option<&mut RTSPToken>); fn connect_accept_certificate< F: Fn( @@ -31,8 +31,7 @@ pub trait RTSPAuthExtManual: 'static { } impl> RTSPAuthExtManual for O { - fn set_default_token<'a, P: Into>>(&self, token: P) { - let mut token = token.into(); + fn set_default_token(&self, mut token: Option<&mut RTSPToken>) { unsafe { gst_rtsp_server_sys::gst_rtsp_auth_set_default_token( self.as_ref().to_glib_none().0, diff --git a/gstreamer-rtsp-server/src/rtsp_client.rs b/gstreamer-rtsp-server/src/rtsp_client.rs index b4675da17..e3effef85 100644 --- a/gstreamer-rtsp-server/src/rtsp_client.rs +++ b/gstreamer-rtsp-server/src/rtsp_client.rs @@ -6,12 +6,11 @@ use gst_rtsp_server_sys; use RTSPClient; pub trait RTSPClientExtManual: 'static { - fn attach<'a, P: Into>>(&self, context: P) -> SourceId; + fn attach(&self, context: Option<&glib::MainContext>) -> SourceId; } impl> RTSPClientExtManual for O { - fn attach<'a, P: Into>>(&self, context: P) -> SourceId { - let context = context.into(); + fn attach(&self, context: Option<&glib::MainContext>) -> SourceId { unsafe { from_glib(gst_rtsp_server_sys::gst_rtsp_client_attach( self.as_ref().to_glib_none().0, diff --git a/gstreamer-rtsp-server/src/rtsp_server.rs b/gstreamer-rtsp-server/src/rtsp_server.rs index 5c8ea432c..bdd8f0a9b 100644 --- a/gstreamer-rtsp-server/src/rtsp_server.rs +++ b/gstreamer-rtsp-server/src/rtsp_server.rs @@ -6,12 +6,11 @@ use gst_rtsp_server_sys; use RTSPServer; pub trait RTSPServerExtManual: 'static { - fn attach<'a, P: Into>>(&self, context: P) -> SourceId; + fn attach(&self, context: Option<&glib::MainContext>) -> SourceId; } impl> RTSPServerExtManual for O { - fn attach<'a, P: Into>>(&self, context: P) -> SourceId { - let context = context.into(); + fn attach(&self, context: Option<&glib::MainContext>) -> SourceId { unsafe { from_glib(gst_rtsp_server_sys::gst_rtsp_server_attach( self.as_ref().to_glib_none().0, diff --git a/gstreamer-rtsp-server/src/rtsp_session_pool.rs b/gstreamer-rtsp-server/src/rtsp_session_pool.rs index 1342f5f2f..2a83f0321 100644 --- a/gstreamer-rtsp-server/src/rtsp_session_pool.rs +++ b/gstreamer-rtsp-server/src/rtsp_session_pool.rs @@ -32,23 +32,13 @@ fn into_raw_watch Continue + Send + 'static>(func: } pub trait RTSPSessionPoolExtManual: 'static { - fn create_watch<'a, N: Into>, F>( - &self, - name: N, - priority: Priority, - func: F, - ) -> glib::Source + fn create_watch(&self, name: Option<&str>, priority: Priority, func: F) -> glib::Source where F: FnMut(&RTSPSessionPool) -> Continue + Send + 'static; } impl> RTSPSessionPoolExtManual for O { - fn create_watch<'a, N: Into>, F>( - &self, - name: N, - priority: Priority, - func: F, - ) -> glib::Source + fn create_watch(&self, name: Option<&str>, priority: Priority, func: F) -> glib::Source where F: FnMut(&RTSPSessionPool) -> Continue + Send + 'static, { @@ -65,7 +55,6 @@ impl> RTSPSessionPoolExtManual for O { ); glib_sys::g_source_set_priority(source, priority.to_glib()); - let name = name.into(); if let Some(name) = name { glib_sys::g_source_set_name(source, name.to_glib_none().0); } diff --git a/gstreamer-sdp/src/sdp_media.rs b/gstreamer-sdp/src/sdp_media.rs index 1e322a429..0732ded4c 100644 --- a/gstreamer-sdp/src/sdp_media.rs +++ b/gstreamer-sdp/src/sdp_media.rs @@ -130,8 +130,7 @@ unsafe impl Send for SDPMediaRef {} unsafe impl Sync for SDPMediaRef {} impl SDPMediaRef { - pub fn add_attribute<'a, P: Into>>(&mut self, key: &str, value: P) { - let value = value.into(); + pub fn add_attribute(&mut self, key: &str, value: Option<&str>) { let value = value.to_glib_none(); unsafe { gst_sdp_sys::gst_sdp_media_add_attribute(&mut self.0, key.to_glib_none().0, value.0) diff --git a/gstreamer-sdp/src/sdp_message.rs b/gstreamer-sdp/src/sdp_message.rs index f99100c93..646a61633 100644 --- a/gstreamer-sdp/src/sdp_message.rs +++ b/gstreamer-sdp/src/sdp_message.rs @@ -169,12 +169,12 @@ unsafe impl Send for SDPMessageRef {} unsafe impl Sync for SDPMessageRef {} impl SDPMessageRef { - pub fn add_attribute<'a, P: Into>>(&mut self, key: &str, value: P) { + pub fn add_attribute(&mut self, key: &str, value: Option<&str>) { unsafe { gst_sdp_sys::gst_sdp_message_add_attribute( &mut self.0, key.to_glib_none().0, - value.into().to_glib_none().0, + value.to_glib_none().0, ); } } diff --git a/gstreamer/src/buffer_pool.rs b/gstreamer/src/buffer_pool.rs index 5e9338a26..b3fa9515a 100644 --- a/gstreamer/src/buffer_pool.rs +++ b/gstreamer/src/buffer_pool.rs @@ -83,15 +83,13 @@ impl BufferPoolConfig { } } - pub fn set_params<'a, T: Into>>( + pub fn set_params( &mut self, - caps: T, + caps: Option<&::Caps>, size: u32, min_buffers: u32, max_buffers: u32, ) { - let caps = caps.into(); - unsafe { gst_sys::gst_buffer_pool_config_set_params( self.0.to_glib_none_mut().0, @@ -125,15 +123,13 @@ impl BufferPoolConfig { } } - pub fn validate_params<'a, T: Into>>( + pub fn validate_params( &self, - caps: T, + caps: Option<&::Caps>, size: u32, min_buffers: u32, max_buffers: u32, ) -> Result<(), glib::BoolError> { - let caps = caps.into(); - unsafe { glib_result_from_gboolean!( gst_sys::gst_buffer_pool_config_validate_params( @@ -256,9 +252,9 @@ pub trait BufferPoolExtManual: 'static { fn is_flushing(&self) -> bool; - fn acquire_buffer<'a, P: Into>>( + fn acquire_buffer( &self, - params: P, + params: Option<&BufferPoolAcquireParams>, ) -> Result<::Buffer, ::FlowError>; fn release_buffer(&self, buffer: ::Buffer); } @@ -292,11 +288,11 @@ impl> BufferPoolExtManual for O { } } - fn acquire_buffer<'a, P: Into>>( + fn acquire_buffer( &self, - params: P, + params: Option<&BufferPoolAcquireParams>, ) -> Result<::Buffer, ::FlowError> { - let params_ptr = params.into().to_glib_none().0 as *mut _; + let params_ptr = params.to_glib_none().0 as *mut _; unsafe { let mut buffer = ptr::null_mut(); @@ -338,13 +334,13 @@ mod tests { let params = ::BufferPoolAcquireParams::with_flags(::BufferPoolAcquireFlags::DONTWAIT); - let _buf1 = pool.acquire_buffer(¶ms).unwrap(); - let buf2 = pool.acquire_buffer(¶ms).unwrap(); + let _buf1 = pool.acquire_buffer(Some(¶ms)).unwrap(); + let buf2 = pool.acquire_buffer(Some(¶ms)).unwrap(); - assert!(pool.acquire_buffer(¶ms).is_err()); + assert!(pool.acquire_buffer(Some(¶ms)).is_err()); drop(buf2); - let _buf2 = pool.acquire_buffer(¶ms).unwrap(); + let _buf2 = pool.acquire_buffer(Some(¶ms)).unwrap(); pool.set_active(false).unwrap(); } diff --git a/gstreamer/src/bus.rs b/gstreamer/src/bus.rs index 444b41f39..fefc12f81 100644 --- a/gstreamer/src/bus.rs +++ b/gstreamer/src/bus.rs @@ -81,12 +81,7 @@ impl Bus { } } - pub fn create_watch<'a, N: Into>, F>( - &self, - name: N, - priority: Priority, - func: F, - ) -> glib::Source + pub fn create_watch(&self, name: Option<&str>, priority: Priority, func: F) -> glib::Source where F: FnMut(&Bus, &Message) -> Continue + Send + 'static, { @@ -101,7 +96,6 @@ impl Bus { ); glib_sys::g_source_set_priority(source, priority.to_glib()); - let name = name.into(); if let Some(name) = name { glib_sys::g_source_set_name(source, name.to_glib_none().0); } diff --git a/gstreamer/src/device_monitor.rs b/gstreamer/src/device_monitor.rs index cbb1f4e0e..1c86b2eee 100644 --- a/gstreamer/src/device_monitor.rs +++ b/gstreamer/src/device_monitor.rs @@ -54,10 +54,10 @@ impl FromGlib for DeviceMonitorFilterId { } pub trait DeviceMonitorExtManual: 'static { - fn add_filter<'a, 'b, P: Into>, Q: Into>>( + fn add_filter( &self, - classes: P, - caps: Q, + classes: Option<&str>, + caps: Option<&Caps>, ) -> Option; fn remove_filter(&self, filter_id: DeviceMonitorFilterId) @@ -65,13 +65,11 @@ pub trait DeviceMonitorExtManual: 'static { } impl> DeviceMonitorExtManual for O { - fn add_filter<'a, 'b, P: Into>, Q: Into>>( + fn add_filter( &self, - classes: P, - caps: Q, + classes: Option<&str>, + caps: Option<&Caps>, ) -> Option { - let classes = classes.into(); - let caps = caps.into(); let id = unsafe { gst_sys::gst_device_monitor_add_filter( self.as_ref().to_glib_none().0, diff --git a/gstreamer/src/element.rs b/gstreamer/src/element.rs index dd0020eef..8f1e98b73 100644 --- a/gstreamer/src/element.rs +++ b/gstreamer/src/element.rs @@ -170,16 +170,16 @@ pub trait ElementExtManual: 'static { fn get_src_pads(&self) -> Vec; #[cfg(any(feature = "v1_10", feature = "dox"))] - fn add_property_deep_notify_watch<'a, P: Into>>( + fn add_property_deep_notify_watch( &self, - property_name: P, + property_name: Option<&str>, include_value: bool, ) -> NotifyWatchId; #[cfg(any(feature = "v1_10", feature = "dox"))] - fn add_property_notify_watch<'a, P: Into>>( + fn add_property_notify_watch( &self, - property_name: P, + property_name: Option<&str>, include_value: bool, ) -> NotifyWatchId; @@ -479,12 +479,11 @@ impl> ElementExtManual for O { } #[cfg(any(feature = "v1_10", feature = "dox"))] - fn add_property_deep_notify_watch<'a, P: Into>>( + fn add_property_deep_notify_watch( &self, - property_name: P, + property_name: Option<&str>, include_value: bool, ) -> NotifyWatchId { - let property_name = property_name.into(); let property_name = property_name.to_glib_none(); unsafe { from_glib(gst_sys::gst_element_add_property_deep_notify_watch( @@ -496,12 +495,11 @@ impl> ElementExtManual for O { } #[cfg(any(feature = "v1_10", feature = "dox"))] - fn add_property_notify_watch<'a, P: Into>>( + fn add_property_notify_watch( &self, - property_name: P, + property_name: Option<&str>, include_value: bool, ) -> NotifyWatchId { - let property_name = property_name.into(); let property_name = property_name.to_glib_none(); unsafe { from_glib(gst_sys::gst_element_add_property_notify_watch( diff --git a/gstreamer/src/error.rs b/gstreamer/src/error.rs index 51261570f..276ba2a45 100644 --- a/gstreamer/src/error.rs +++ b/gstreamer/src/error.rs @@ -62,24 +62,16 @@ pub struct ErrorMessage { } impl ErrorMessage { - pub fn new< - 'a, - 'b, - T: ::MessageErrorDomain, - U: Into>, - V: Into>, - >( + pub fn new( error: &T, - message: U, - debug: V, + message: Option<&str>, + debug: Option<&str>, filename: &'static str, function: &'static str, line: u32, ) -> ErrorMessage { let error_domain = T::domain(); let error_code = error.code(); - let message = message.into(); - let debug = debug.into(); ErrorMessage { error_domain, diff --git a/gstreamer/src/functions.rs b/gstreamer/src/functions.rs index aa707cd92..4ab358440 100644 --- a/gstreamer/src/functions.rs +++ b/gstreamer/src/functions.rs @@ -15,14 +15,13 @@ use Error; use ParseContext; use ParseFlags; -pub fn parse_bin_from_description_full<'a, P: Into>>( +pub fn parse_bin_from_description_full( bin_description: &str, ghost_unlinked_pads: bool, - context: P, + mut context: Option<&mut ParseContext>, flags: ParseFlags, ) -> Result { assert_initialized_main_thread!(); - let mut context = context.into(); unsafe { let mut error = ptr::null_mut(); let ret = gst_sys::gst_parse_bin_from_description_full( @@ -40,13 +39,12 @@ pub fn parse_bin_from_description_full<'a, P: Into> } } -pub fn parse_launch_full<'a, P: Into>>( +pub fn parse_launch_full( pipeline_description: &str, - context: P, + mut context: Option<&mut ParseContext>, flags: ParseFlags, ) -> Result { assert_initialized_main_thread!(); - let mut context = context.into(); unsafe { let mut error = ptr::null_mut(); let ret = gst_sys::gst_parse_launch_full( @@ -63,13 +61,12 @@ pub fn parse_launch_full<'a, P: Into>>( } } -pub fn parse_launchv_full<'a, P: Into>>( +pub fn parse_launchv_full( argv: &[&str], - context: P, + mut context: Option<&mut ParseContext>, flags: ParseFlags, ) -> Result { assert_initialized_main_thread!(); - let mut context = context.into(); unsafe { let mut error = ptr::null_mut(); let ret = gst_sys::gst_parse_launchv_full( diff --git a/gstreamer/src/ghost_pad.rs b/gstreamer/src/ghost_pad.rs index 298f28186..4626f58e7 100644 --- a/gstreamer/src/ghost_pad.rs +++ b/gstreamer/src/ghost_pad.rs @@ -17,9 +17,8 @@ use PadMode; use PadTemplate; impl GhostPad { - pub fn new<'a, P: Into>, Q: IsA>(name: P, target: &Q) -> Option { + pub fn new>(name: Option<&str>, target: &Q) -> Option { skip_assert_initialized!(); - let name = name.into(); let name = name.to_glib_none(); unsafe { Option::::from_glib_none(gst_sys::gst_ghost_pad_new( @@ -30,13 +29,12 @@ impl GhostPad { } } - pub fn new_from_template<'a, P: Into>, Q: IsA>( - name: P, + pub fn new_from_template>( + name: Option<&str>, target: &Q, templ: &PadTemplate, ) -> Option { skip_assert_initialized!(); - let name = name.into(); let name = name.to_glib_none(); unsafe { Option::::from_glib_none(gst_sys::gst_ghost_pad_new_from_template( @@ -48,19 +46,13 @@ impl GhostPad { } } - pub fn activate_mode_default< - 'a, - P: IsA, - Q: IsA + 'a, - R: Into>, - >( + pub fn activate_mode_default, Q: IsA>( pad: &P, - parent: R, + parent: Option<&Q>, mode: PadMode, active: bool, ) -> Result<(), glib::BoolError> { skip_assert_initialized!(); - let parent = parent.into(); unsafe { glib_result_from_gboolean!( gst_sys::gst_ghost_pad_activate_mode_default( @@ -74,19 +66,13 @@ impl GhostPad { } } - pub fn internal_activate_mode_default< - 'a, - P: IsA, - Q: IsA + 'a, - R: Into>, - >( + pub fn internal_activate_mode_default, Q: IsA>( pad: &P, - parent: R, + parent: Option<&Q>, mode: PadMode, active: bool, ) -> Result<(), glib::BoolError> { skip_assert_initialized!(); - let parent = parent.into(); unsafe { glib_result_from_gboolean!( gst_sys::gst_ghost_pad_internal_activate_mode_default( diff --git a/gstreamer/src/log.rs b/gstreamer/src/log.rs index dba6d872f..31190affd 100644 --- a/gstreamer/src/log.rs +++ b/gstreamer/src/log.rs @@ -21,11 +21,7 @@ use glib::IsA; pub struct DebugCategory(ptr::NonNull); impl DebugCategory { - pub fn new<'a, P: Into>>( - name: &str, - color: ::DebugColorFlags, - description: P, - ) -> DebugCategory { + pub fn new(name: &str, color: ::DebugColorFlags, description: Option<&str>) -> DebugCategory { extern "C" { fn _gst_debug_category_new( name: *const c_char, @@ -33,7 +29,6 @@ impl DebugCategory { description: *const c_char, ) -> *mut gst_sys::GstDebugCategory; } - let description = description.into(); // Gets the category if it exists already unsafe { @@ -149,7 +144,7 @@ lazy_static! { pub static ref CAT_RUST: DebugCategory = DebugCategory::new( "GST_RUST", ::DebugColorFlags::UNDERLINE, - "GStreamer's Rust binding core", + Some("GStreamer's Rust binding core"), ); } @@ -307,7 +302,7 @@ mod tests { let cat = DebugCategory::new( "test-cat", ::DebugColorFlags::empty(), - "some debug category", + Some("some debug category"), ); gst_error!(cat, "meh"); diff --git a/gstreamer/src/object.rs b/gstreamer/src/object.rs index 6fddd06c8..0841ec089 100644 --- a/gstreamer/src/object.rs +++ b/gstreamer/src/object.rs @@ -17,13 +17,9 @@ use gobject_sys; use ObjectFlags; pub trait GstObjectExtManual: 'static { - fn connect_deep_notify< - 'a, - P: Into>, - F: Fn(&Self, &::Object, &glib::ParamSpec) + Send + Sync + 'static, - >( + fn connect_deep_notify( &self, - name: P, + name: Option<&str>, f: F, ) -> SignalHandlerId; @@ -35,16 +31,11 @@ pub trait GstObjectExtManual: 'static { } impl> GstObjectExtManual for O { - fn connect_deep_notify< - 'a, - P: Into>, - F: Fn(&Self, &::Object, &glib::ParamSpec) + Send + Sync + 'static, - >( + fn connect_deep_notify( &self, - name: P, + name: Option<&str>, f: F, ) -> SignalHandlerId { - let name = name.into(); let signal_name = if let Some(name) = name { format!("deep-notify::{}", name) } else { diff --git a/gstreamer/src/pad.rs b/gstreamer/src/pad.rs index 422c7db50..a447e6307 100644 --- a/gstreamer/src/pad.rs +++ b/gstreamer/src/pad.rs @@ -49,12 +49,8 @@ use libc; use gst_sys; impl Pad { - pub fn new_from_static_template<'a, P: Into>>( - templ: &StaticPadTemplate, - name: P, - ) -> Pad { + pub fn new_from_static_template(templ: &StaticPadTemplate, name: Option<&str>) -> Pad { assert_initialized_main_thread!(); - let name = name.into(); unsafe { from_glib_none(gst_sys::gst_pad_new_from_static_template( mut_override(templ.to_glib_none().0), @@ -131,28 +127,20 @@ pub trait PadExtManual: 'static { fn peer_query(&self, query: &mut QueryRef) -> bool; fn query(&self, query: &mut QueryRef) -> bool; - fn query_default<'a, P: IsA<::Object> + 'a, Q: Into>>( - &self, - parent: Q, - query: &mut QueryRef, - ) -> bool; + fn query_default>(&self, parent: Option<&P>, query: &mut QueryRef) -> bool; fn proxy_query_caps(&self, query: &mut QueryRef) -> bool; fn proxy_query_accept_caps(&self, query: &mut QueryRef) -> bool; - fn event_default<'a, P: IsA<::Object> + 'a, Q: Into>>( - &self, - parent: Q, - event: Event, - ) -> bool; + fn event_default>(&self, parent: Option<&P>, event: Event) -> bool; fn push_event(&self, event: Event) -> bool; fn send_event(&self, event: Event) -> bool; fn get_last_flow_return(&self) -> Result; fn iterate_internal_links(&self) -> ::Iterator; - fn iterate_internal_links_default<'a, P: IsA<::Object> + 'a, Q: Into>>( + fn iterate_internal_links_default>( &self, - parent: Q, + parent: Option<&P>, ) -> ::Iterator; fn link>(&self, sinkpad: &P) -> Result; @@ -389,13 +377,8 @@ impl> PadExtManual for O { } } - fn query_default<'a, P: IsA<::Object> + 'a, Q: Into>>( - &self, - parent: Q, - query: &mut QueryRef, - ) -> bool { + fn query_default>(&self, parent: Option<&P>, query: &mut QueryRef) -> bool { skip_assert_initialized!(); - let parent = parent.into(); unsafe { from_glib(gst_sys::gst_pad_query_default( self.as_ref().to_glib_none().0, @@ -423,13 +406,8 @@ impl> PadExtManual for O { } } - fn event_default<'a, P: IsA<::Object> + 'a, Q: Into>>( - &self, - parent: Q, - event: Event, - ) -> bool { + fn event_default>(&self, parent: Option<&P>, event: Event) -> bool { skip_assert_initialized!(); - let parent = parent.into(); unsafe { from_glib(gst_sys::gst_pad_event_default( self.as_ref().to_glib_none().0, @@ -474,11 +452,10 @@ impl> PadExtManual for O { } } - fn iterate_internal_links_default<'a, P: IsA<::Object> + 'a, Q: Into>>( + fn iterate_internal_links_default>( &self, - parent: Q, + parent: Option<&P>, ) -> ::Iterator { - let parent = parent.into(); unsafe { from_glib_full(gst_sys::gst_pad_iterate_internal_links_default( self.as_ref().to_glib_none().0, diff --git a/gstreamer/src/proxy_pad.rs b/gstreamer/src/proxy_pad.rs index 31771bf90..6a01348e6 100644 --- a/gstreamer/src/proxy_pad.rs +++ b/gstreamer/src/proxy_pad.rs @@ -22,13 +22,12 @@ use glib::translate::{from_glib, from_glib_full, ToGlibPtr}; use gst_sys; impl ProxyPad { - pub fn chain_default<'a, P: IsA, Q: IsA + 'a, R: Into>>( + pub fn chain_default, Q: IsA>( pad: &P, - parent: R, + parent: Option<&Q>, buffer: Buffer, ) -> Result { skip_assert_initialized!(); - let parent = parent.into(); let ret: FlowReturn = unsafe { from_glib(gst_sys::gst_proxy_pad_chain_default( pad.as_ptr() as *mut gst_sys::GstPad, @@ -39,13 +38,12 @@ impl ProxyPad { ret.into_result() } - pub fn chain_list_default<'a, P: IsA, Q: IsA + 'a, R: Into>>( + pub fn chain_list_default, Q: IsA>( pad: &P, - parent: R, + parent: Option<&Q>, list: BufferList, ) -> Result { skip_assert_initialized!(); - let parent = parent.into(); let ret: FlowReturn = unsafe { from_glib(gst_sys::gst_proxy_pad_chain_list_default( pad.as_ptr() as *mut gst_sys::GstPad, @@ -76,17 +74,11 @@ impl ProxyPad { } } - pub fn iterate_internal_links_default< - 'a, - P: IsA, - Q: IsA + 'a, - R: Into>, - >( + pub fn iterate_internal_links_default, Q: IsA>( pad: &P, - parent: R, + parent: Option<&Q>, ) -> Option<::Iterator> { skip_assert_initialized!(); - let parent = parent.into(); unsafe { from_glib_full(gst_sys::gst_proxy_pad_iterate_internal_links_default( pad.as_ptr() as *mut gst_sys::GstPad, diff --git a/gstreamer/src/query.rs b/gstreamer/src/query.rs index 198f5af43..e6a852eec 100644 --- a/gstreamer/src/query.rs +++ b/gstreamer/src/query.rs @@ -135,9 +135,8 @@ impl Query { } } - pub fn new_caps<'a, P: Into>>(filter: P) -> Caps { + pub fn new_caps(filter: Option<&::Caps>) -> Caps { assert_initialized_main_thread!(); - let filter = filter.into(); unsafe { Caps::(from_glib_full(gst_sys::gst_query_new_caps( filter.to_glib_none().0, diff --git a/gstreamer/src/stream.rs b/gstreamer/src/stream.rs index 35b01c760..efaaeac1d 100644 --- a/gstreamer/src/stream.rs +++ b/gstreamer/src/stream.rs @@ -15,16 +15,14 @@ use StreamType; impl Stream { #[cfg(any(feature = "v1_10", feature = "dox"))] - pub fn new<'a, 'b, P: Into>, Q: Into>>( - stream_id: P, - caps: Q, + pub fn new( + stream_id: Option<&str>, + caps: Option<&Caps>, type_: StreamType, flags: StreamFlags, ) -> Stream { assert_initialized_main_thread!(); - let stream_id = stream_id.into(); let stream_id = stream_id.to_glib_none(); - let caps = caps.into(); let caps = caps.to_glib_none(); let (major, minor, _, _) = ::version(); diff --git a/gstreamer/src/stream_collection.rs b/gstreamer/src/stream_collection.rs index 7b4497269..2f82f4675 100644 --- a/gstreamer/src/stream_collection.rs +++ b/gstreamer/src/stream_collection.rs @@ -69,9 +69,8 @@ impl<'a> DoubleEndedIterator for Iter<'a> { impl<'a> ExactSizeIterator for Iter<'a> {} impl StreamCollection { - pub fn new<'a, P: Into>>(upstream_id: P) -> StreamCollection { + pub fn new(upstream_id: Option<&str>) -> StreamCollection { assert_initialized_main_thread!(); - let upstream_id = upstream_id.into(); let upstream_id = upstream_id.to_glib_none(); let (major, minor, _, _) = ::version(); if (major, minor) > (1, 12) { diff --git a/gstreamer/src/typefind.rs b/gstreamer/src/typefind.rs index 5042500bb..6706eb5f4 100644 --- a/gstreamer/src/typefind.rs +++ b/gstreamer/src/typefind.rs @@ -32,28 +32,17 @@ pub trait TypeFindImpl { } impl<'a> TypeFind<'a> { - pub fn register< - 'b, - 'c, - 'd, - P: Into>, - R: Into>, - S: Into>, - F, - >( - plugin: P, + pub fn register( + plugin: Option<&Plugin>, name: &str, rank: u32, - extensions: R, - possible_caps: S, + extensions: Option<&str>, + possible_caps: Option<&Caps>, func: F, ) -> Result<(), glib::error::BoolError> where F: Fn(&mut TypeFind) + Send + Sync + 'static, { - let plugin = plugin.into(); - let extensions = extensions.into(); - let possible_caps = possible_caps.into(); unsafe { let func: Box = Box::new(func); let func = Box::into_raw(func); @@ -278,7 +267,7 @@ mod tests { "test_typefind", ::Rank::Primary.to_glib() as u32, None, - &Caps::new_simple("test/test", &[]), + Some(&Caps::new_simple("test/test", &[])), |typefind| { let mut found = false; if let Some(data) = typefind.peek(0, 8) {