From 6bba3d8518ac4921e91979980cfb7de4e2723cf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sat, 8 Dec 2018 11:22:42 +0200 Subject: [PATCH] Add 'static trait bound to all ExtManual traits and get rid of trait bounds for their impls --- gstreamer-base/src/aggregator.rs | 2 +- gstreamer-base/src/aggregator_pad.rs | 2 +- gstreamer-base/src/base_sink.rs | 2 +- gstreamer-base/src/base_src.rs | 2 +- gstreamer-base/src/base_transform.rs | 2 +- .../src/timeline_element.rs | 2 +- gstreamer-gl/src/gl_context.rs | 2 +- gstreamer-rtsp-server/src/rtsp_address_pool.rs | 2 +- gstreamer-rtsp-server/src/rtsp_auth.rs | 2 +- gstreamer-rtsp-server/src/rtsp_client.rs | 2 +- .../src/rtsp_media_factory.rs | 2 +- gstreamer-rtsp-server/src/rtsp_server.rs | 2 +- gstreamer-rtsp-server/src/rtsp_session_pool.rs | 2 +- gstreamer-video/src/video_overlay.rs | 2 +- gstreamer/src/bin.rs | 2 +- gstreamer/src/buffer_pool.rs | 2 +- gstreamer/src/bus_unix.rs | 2 +- gstreamer/src/bus_windows.rs | 2 +- gstreamer/src/child_proxy.rs | 2 +- gstreamer/src/clock.rs | 4 ++-- gstreamer/src/device_provider.rs | 2 +- gstreamer/src/element.rs | 2 +- gstreamer/src/gobject.rs | 2 +- gstreamer/src/object.rs | 18 ++++++++---------- gstreamer/src/pad.rs | 2 +- gstreamer/src/tag_setter.rs | 2 +- 26 files changed, 34 insertions(+), 36 deletions(-) diff --git a/gstreamer-base/src/aggregator.rs b/gstreamer-base/src/aggregator.rs index 87aad8357..c07248733 100644 --- a/gstreamer-base/src/aggregator.rs +++ b/gstreamer-base/src/aggregator.rs @@ -14,7 +14,7 @@ use Aggregator; use std::ops; -pub trait AggregatorExtManual { +pub trait AggregatorExtManual: 'static { fn finish_buffer(&self, buffer: gst::Buffer) -> gst::FlowReturn; } diff --git a/gstreamer-base/src/aggregator_pad.rs b/gstreamer-base/src/aggregator_pad.rs index fc46ae7f1..1054368f4 100644 --- a/gstreamer-base/src/aggregator_pad.rs +++ b/gstreamer-base/src/aggregator_pad.rs @@ -15,7 +15,7 @@ use AggregatorPad; use std::ops; -pub trait AggregatorPadExtManual { +pub trait AggregatorPadExtManual: 'static { fn get_segment(&self) -> gst::Segment; } diff --git a/gstreamer-base/src/base_sink.rs b/gstreamer-base/src/base_sink.rs index d9dd5f04d..d39367bf5 100644 --- a/gstreamer-base/src/base_sink.rs +++ b/gstreamer-base/src/base_sink.rs @@ -13,7 +13,7 @@ use gst; use std::ops; use BaseSink; -pub trait BaseSinkExtManual { +pub trait BaseSinkExtManual: 'static { fn get_segment(&self) -> gst::Segment; } diff --git a/gstreamer-base/src/base_src.rs b/gstreamer-base/src/base_src.rs index 559fee7ca..ab7f3d92b 100644 --- a/gstreamer-base/src/base_src.rs +++ b/gstreamer-base/src/base_src.rs @@ -13,7 +13,7 @@ use gst; use std::ops; use BaseSrc; -pub trait BaseSrcExtManual { +pub trait BaseSrcExtManual: 'static { fn get_segment(&self) -> gst::Segment; } diff --git a/gstreamer-base/src/base_transform.rs b/gstreamer-base/src/base_transform.rs index 6254893e9..b740d65bd 100644 --- a/gstreamer-base/src/base_transform.rs +++ b/gstreamer-base/src/base_transform.rs @@ -13,7 +13,7 @@ use gst; use std::ops; use BaseTransform; -pub trait BaseTransformExtManual { +pub trait BaseTransformExtManual: 'static { fn get_segment(&self) -> gst::Segment; } diff --git a/gstreamer-editing-services/src/timeline_element.rs b/gstreamer-editing-services/src/timeline_element.rs index dd8b6e577..930eff1c7 100644 --- a/gstreamer-editing-services/src/timeline_element.rs +++ b/gstreamer-editing-services/src/timeline_element.rs @@ -13,7 +13,7 @@ use glib::translate::*; use std::ptr; use TimelineElement; -pub trait TimelineElementExtManual { +pub trait TimelineElementExtManual: 'static { fn get_child_property(&self, name: &str) -> Option; fn set_child_property(&self, name: &str, value: &glib::ToValue) -> Result<(), glib::BoolError>; } diff --git a/gstreamer-gl/src/gl_context.rs b/gstreamer-gl/src/gl_context.rs index d35cf0478..7324ea9df 100644 --- a/gstreamer-gl/src/gl_context.rs +++ b/gstreamer-gl/src/gl_context.rs @@ -31,7 +31,7 @@ impl GLContext { } } -pub trait GLContextExtManual { +pub trait GLContextExtManual: 'static { fn get_gl_context(&self) -> uintptr_t; fn get_proc_address(&self, name: &str) -> uintptr_t; diff --git a/gstreamer-rtsp-server/src/rtsp_address_pool.rs b/gstreamer-rtsp-server/src/rtsp_address_pool.rs index 1ef19f8f5..242a7b776 100644 --- a/gstreamer-rtsp-server/src/rtsp_address_pool.rs +++ b/gstreamer-rtsp-server/src/rtsp_address_pool.rs @@ -6,7 +6,7 @@ use RTSPAddress; use RTSPAddressPool; use RTSPAddressPoolResult; -pub trait RTSPAddressPoolExtManual { +pub trait RTSPAddressPoolExtManual: 'static { fn reserve_address( &self, ip_address: &str, diff --git a/gstreamer-rtsp-server/src/rtsp_auth.rs b/gstreamer-rtsp-server/src/rtsp_auth.rs index a8907b4ba..2d62befd1 100644 --- a/gstreamer-rtsp-server/src/rtsp_auth.rs +++ b/gstreamer-rtsp-server/src/rtsp_auth.rs @@ -4,7 +4,7 @@ use glib::translate::*; use RTSPAuth; use RTSPToken; -pub trait RTSPAuthExtManual { +pub trait RTSPAuthExtManual: 'static { fn set_default_token<'a, P: Into>>(&self, token: P); } diff --git a/gstreamer-rtsp-server/src/rtsp_client.rs b/gstreamer-rtsp-server/src/rtsp_client.rs index 3fe29dee3..2b05cb71f 100644 --- a/gstreamer-rtsp-server/src/rtsp_client.rs +++ b/gstreamer-rtsp-server/src/rtsp_client.rs @@ -5,7 +5,7 @@ use glib::source::SourceId; use glib::translate::*; use RTSPClient; -pub trait RTSPClientExtManual { +pub trait RTSPClientExtManual: 'static { fn attach<'a, P: Into>>(&self, context: P) -> SourceId; } diff --git a/gstreamer-rtsp-server/src/rtsp_media_factory.rs b/gstreamer-rtsp-server/src/rtsp_media_factory.rs index 115dce027..14cd50885 100644 --- a/gstreamer-rtsp-server/src/rtsp_media_factory.rs +++ b/gstreamer-rtsp-server/src/rtsp_media_factory.rs @@ -14,7 +14,7 @@ use glib::IsA; #[cfg(any(feature = "v1_14", feature = "dox"))] use gst; -pub trait RTSPMediaFactoryExtManual { +pub trait RTSPMediaFactoryExtManual: 'static { #[cfg(any(feature = "v1_14", feature = "dox"))] fn add_role_from_structure(&self, structure: &gst::StructureRef); } diff --git a/gstreamer-rtsp-server/src/rtsp_server.rs b/gstreamer-rtsp-server/src/rtsp_server.rs index 5af8077f7..a7cf7cc59 100644 --- a/gstreamer-rtsp-server/src/rtsp_server.rs +++ b/gstreamer-rtsp-server/src/rtsp_server.rs @@ -5,7 +5,7 @@ use glib::source::SourceId; use glib::translate::*; use RTSPServer; -pub trait RTSPServerExtManual { +pub trait RTSPServerExtManual: 'static { fn attach<'a, P: Into>>(&self, context: P) -> SourceId; } diff --git a/gstreamer-rtsp-server/src/rtsp_session_pool.rs b/gstreamer-rtsp-server/src/rtsp_session_pool.rs index 9d4c2c5de..06ac74069 100644 --- a/gstreamer-rtsp-server/src/rtsp_session_pool.rs +++ b/gstreamer-rtsp-server/src/rtsp_session_pool.rs @@ -31,7 +31,7 @@ fn into_raw_watch Continue + Send + 'static>(func: Box::into_raw(func) as gpointer } -pub trait RTSPSessionPoolExtManual { +pub trait RTSPSessionPoolExtManual: 'static { fn create_watch<'a, N: Into>, F>( &self, name: N, diff --git a/gstreamer-video/src/video_overlay.rs b/gstreamer-video/src/video_overlay.rs index d73915909..5b69dc8ba 100644 --- a/gstreamer-video/src/video_overlay.rs +++ b/gstreamer-video/src/video_overlay.rs @@ -15,7 +15,7 @@ use VideoOverlay; use glib::IsA; -pub trait VideoOverlayExtManual { +pub trait VideoOverlayExtManual: 'static { unsafe fn set_window_handle(&self, handle: uintptr_t); unsafe fn got_window_handle(&self, handle: uintptr_t); } diff --git a/gstreamer/src/bin.rs b/gstreamer/src/bin.rs index 694f92095..01225a901 100644 --- a/gstreamer/src/bin.rs +++ b/gstreamer/src/bin.rs @@ -18,7 +18,7 @@ use ffi; use std::ops; use std::path; -pub trait GstBinExtManual { +pub trait GstBinExtManual: 'static { fn add_many>(&self, elements: &[&E]) -> Result<(), glib::BoolError>; fn remove_many>(&self, elements: &[&E]) -> Result<(), glib::BoolError>; diff --git a/gstreamer/src/buffer_pool.rs b/gstreamer/src/buffer_pool.rs index 0cb71a9e5..69d960149 100644 --- a/gstreamer/src/buffer_pool.rs +++ b/gstreamer/src/buffer_pool.rs @@ -225,7 +225,7 @@ impl Default for BufferPool { } } -pub trait BufferPoolExtManual { +pub trait BufferPoolExtManual: 'static { fn get_config(&self) -> BufferPoolConfig; fn set_config(&self, config: BufferPoolConfig) -> Result<(), glib::error::BoolError>; diff --git a/gstreamer/src/bus_unix.rs b/gstreamer/src/bus_unix.rs index 0ddead618..9651a95ac 100644 --- a/gstreamer/src/bus_unix.rs +++ b/gstreamer/src/bus_unix.rs @@ -27,7 +27,7 @@ cfg_if! { use super::Bus; -pub trait UnixBusExtManual { +pub trait UnixBusExtManual: 'static { fn get_pollfd(&self) -> unix::io::RawFd; } diff --git a/gstreamer/src/bus_windows.rs b/gstreamer/src/bus_windows.rs index 92b1bcedf..9a38003a9 100644 --- a/gstreamer/src/bus_windows.rs +++ b/gstreamer/src/bus_windows.rs @@ -27,7 +27,7 @@ cfg_if! { use super::Bus; -pub trait WindowsBusExtManual { +pub trait WindowsBusExtManual: 'static { fn get_pollfd(&self) -> windows::io::RawHandle; } diff --git a/gstreamer/src/child_proxy.rs b/gstreamer/src/child_proxy.rs index a45e233bb..137166151 100644 --- a/gstreamer/src/child_proxy.rs +++ b/gstreamer/src/child_proxy.rs @@ -13,7 +13,7 @@ use glib::translate::*; use std::ptr; use ChildProxy; -pub trait ChildProxyExtManual { +pub trait ChildProxyExtManual: 'static { fn get_child_property(&self, name: &str) -> Option; fn set_child_property(&self, name: &str, value: &glib::ToValue) -> Result<(), glib::BoolError>; } diff --git a/gstreamer/src/clock.rs b/gstreamer/src/clock.rs index 045c1ec8c..e72399b91 100644 --- a/gstreamer/src/clock.rs +++ b/gstreamer/src/clock.rs @@ -163,7 +163,7 @@ impl Clock { } } -pub trait ClockExtManual { +pub trait ClockExtManual: 'static { fn new_periodic_id(&self, start_time: ClockTime, interval: ClockTime) -> Option; fn periodic_id_reinit( @@ -178,7 +178,7 @@ pub trait ClockExtManual { fn single_shot_id_reinit(&self, id: &ClockId, time: ClockTime) -> Result<(), glib::BoolError>; } -impl + IsA> ClockExtManual for O { +impl> ClockExtManual for O { fn new_periodic_id(&self, start_time: ClockTime, interval: ClockTime) -> Option { unsafe { from_glib_full(ffi::gst_clock_new_periodic_id( diff --git a/gstreamer/src/device_provider.rs b/gstreamer/src/device_provider.rs index 2fe858f74..444216f36 100644 --- a/gstreamer/src/device_provider.rs +++ b/gstreamer/src/device_provider.rs @@ -16,7 +16,7 @@ use std::ffi::CStr; use ffi; use gobject_ffi; -pub trait DeviceProviderExtManual { +pub trait DeviceProviderExtManual: 'static { fn get_metadata<'a>(&self, key: &str) -> Option<&'a str>; } diff --git a/gstreamer/src/element.rs b/gstreamer/src/element.rs index f87d25827..051df6d60 100644 --- a/gstreamer/src/element.rs +++ b/gstreamer/src/element.rs @@ -92,7 +92,7 @@ impl FromGlib for NotifyWatchId { } } -pub trait ElementExtManual { +pub trait ElementExtManual: 'static { fn get_element_class(&self) -> &ElementClass; fn query(&self, query: &mut QueryRef) -> bool; diff --git a/gstreamer/src/gobject.rs b/gstreamer/src/gobject.rs index 0bf005787..fb2bd321d 100644 --- a/gstreamer/src/gobject.rs +++ b/gstreamer/src/gobject.rs @@ -4,7 +4,7 @@ use glib::IsA; use ffi; -pub trait GObjectExtManualGst { +pub trait GObjectExtManualGst: 'static { fn set_property_from_str(&self, name: &str, value: &str); } diff --git a/gstreamer/src/object.rs b/gstreamer/src/object.rs index 562797b60..cb9a3dd89 100644 --- a/gstreamer/src/object.rs +++ b/gstreamer/src/object.rs @@ -9,12 +9,12 @@ use glib; use glib::object::{Downcast, ObjectExt}; use glib::signal::SignalHandlerId; -use glib::translate::{from_glib_none, ToGlibPtr}; +use glib::translate::{from_glib_borrow, from_glib_none, ToGlibPtr}; use glib::IsA; use gobject_ffi; -pub trait GstObjectExtManual { +pub trait GstObjectExtManual: 'static { fn connect_deep_notify< 'a, P: Into>, @@ -26,7 +26,7 @@ pub trait GstObjectExtManual { ) -> SignalHandlerId; } -impl + IsA + glib::value::SetValue> GstObjectExtManual for O { +impl> GstObjectExtManual for O { fn connect_deep_notify< 'a, P: Into>, @@ -43,13 +43,11 @@ impl + IsA + glib::value::SetValue> GstObjectExtM "deep-notify".into() }; - self.connect(signal_name.as_str(), false, move |values| { - let obj: O = unsafe { - values[0] - .get::() - .unwrap() - .downcast_unchecked() - }; + let obj: glib::Object = + unsafe { from_glib_borrow(self.to_glib_none().0 as *mut gobject_ffi::GObject) }; + + obj.connect(signal_name.as_str(), false, move |values| { + let obj: O = unsafe { values[0].get::<::Object>().unwrap().downcast_unchecked() }; let prop_obj: ::Object = values[1].get().unwrap(); let pspec = unsafe { diff --git a/gstreamer/src/pad.rs b/gstreamer/src/pad.rs index d08dae23f..019fda616 100644 --- a/gstreamer/src/pad.rs +++ b/gstreamer/src/pad.rs @@ -105,7 +105,7 @@ impl Drop for StreamLock { } } -pub trait PadExtManual { +pub trait PadExtManual: 'static { fn add_probe(&self, mask: PadProbeType, func: F) -> Option where F: Fn(&Pad, &mut PadProbeInfo) -> PadProbeReturn + Send + Sync + 'static; diff --git a/gstreamer/src/tag_setter.rs b/gstreamer/src/tag_setter.rs index 38257bc14..9c76f32bb 100644 --- a/gstreamer/src/tag_setter.rs +++ b/gstreamer/src/tag_setter.rs @@ -14,7 +14,7 @@ use tags::*; use TagMergeMode; use TagSetter; -pub trait TagSetterExtManual { +pub trait TagSetterExtManual: 'static { fn add<'a, T: Tag<'a>>(&self, value: T::TagType, mode: TagMergeMode) where T::TagType: ToSendValue;