diff --git a/gstreamer-audio/src/audio_ring_buffer_spec.rs b/gstreamer-audio/src/audio_ring_buffer_spec.rs index ce55f59f7..47f7ebbbd 100644 --- a/gstreamer-audio/src/audio_ring_buffer_spec.rs +++ b/gstreamer-audio/src/audio_ring_buffer_spec.rs @@ -87,6 +87,9 @@ impl Drop for AudioRingBufferSpec { } } +unsafe impl Send for AudioRingBufferSpec {} +unsafe impl Sync for AudioRingBufferSpec {} + impl fmt::Debug for AudioRingBufferSpec { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { f.debug_struct("AudioRingBufferSpec") diff --git a/gstreamer-base/src/base_parse_frame.rs b/gstreamer-base/src/base_parse_frame.rs index 49fd7781f..4154d981b 100644 --- a/gstreamer-base/src/base_parse_frame.rs +++ b/gstreamer-base/src/base_parse_frame.rs @@ -23,6 +23,9 @@ pub struct BaseParseFrame<'a>( PhantomData<&'a BaseParse>, ); +unsafe impl<'a> Send for BaseParseFrame<'a> {} +unsafe impl<'a> Sync for BaseParseFrame<'a> {} + #[derive(Debug)] pub enum Overhead { None, diff --git a/gstreamer-check/src/harness.rs b/gstreamer-check/src/harness.rs index 936326066..c082e7070 100644 --- a/gstreamer-check/src/harness.rs +++ b/gstreamer-check/src/harness.rs @@ -36,6 +36,7 @@ impl Drop for Harness { } unsafe impl Send for Harness {} +unsafe impl Sync for Harness {} impl Harness { pub fn add_element_full>( @@ -792,7 +793,7 @@ impl Harness { } #[derive(Debug)] -pub struct Ref<'a>(Option, PhantomData<&'a gst_check_sys::GstHarness>); +pub struct Ref<'a>(Option, PhantomData<&'a Harness>); impl<'a> ops::Deref for Ref<'a> { type Target = Harness; @@ -810,10 +811,7 @@ impl<'a> Drop for Ref<'a> { } #[derive(Debug)] -pub struct RefMut<'a>( - Option, - PhantomData<&'a mut gst_check_sys::GstHarness>, -); +pub struct RefMut<'a>(Option, PhantomData<&'a mut Harness>); impl<'a> ops::Deref for RefMut<'a> { type Target = Harness; diff --git a/gstreamer-gl/src/gl_sync_meta.rs b/gstreamer-gl/src/gl_sync_meta.rs index fb48a4062..5f0fd95d3 100644 --- a/gstreamer-gl/src/gl_sync_meta.rs +++ b/gstreamer-gl/src/gl_sync_meta.rs @@ -11,6 +11,9 @@ use GLContext; #[repr(C)] pub struct GLSyncMeta(gst_gl_sys::GstGLSyncMeta); +unsafe impl Send for GLSyncMeta {} +unsafe impl Sync for GLSyncMeta {} + impl GLSyncMeta { pub fn add<'a, C: IsA>( buffer: &'a mut gst::BufferRef, diff --git a/gstreamer-net/src/net_address_meta.rs b/gstreamer-net/src/net_address_meta.rs index 4e157742f..3e0c18dc6 100644 --- a/gstreamer-net/src/net_address_meta.rs +++ b/gstreamer-net/src/net_address_meta.rs @@ -10,6 +10,9 @@ use gst_net_sys; #[repr(C)] pub struct NetAddressMeta(gst_net_sys::GstNetAddressMeta); +unsafe impl Send for NetAddressMeta {} +unsafe impl Sync for NetAddressMeta {} + impl NetAddressMeta { pub fn add<'a, A: IsA>( buffer: &'a mut gst::BufferRef, diff --git a/gstreamer-rtp/src/rtp_buffer.rs b/gstreamer-rtp/src/rtp_buffer.rs index 0baa24375..9b0415e44 100644 --- a/gstreamer-rtp/src/rtp_buffer.rs +++ b/gstreamer-rtp/src/rtp_buffer.rs @@ -11,6 +11,9 @@ pub enum Writable {} #[repr(C)] pub struct RTPBuffer<'a, T>(gst_rtp_sys::GstRTPBuffer, &'a gst::Buffer, PhantomData); +unsafe impl<'a, T> Send for RTPBuffer<'a, T> {} +unsafe impl<'a, T> Sync for RTPBuffer<'a, T> {} + impl<'a> RTPBuffer<'a, Readable> { pub fn from_buffer_readable( buffer: &gst::Buffer, diff --git a/gstreamer-sdp/src/sdp_attribute.rs b/gstreamer-sdp/src/sdp_attribute.rs index 3d504280f..af78855cf 100644 --- a/gstreamer-sdp/src/sdp_attribute.rs +++ b/gstreamer-sdp/src/sdp_attribute.rs @@ -16,6 +16,9 @@ use gst_sdp_sys; #[repr(C)] pub struct SDPAttribute(pub(crate) gst_sdp_sys::GstSDPAttribute); +unsafe impl Send for SDPAttribute {} +unsafe impl Sync for SDPAttribute {} + impl SDPAttribute { pub fn new(key: &str, value: Option<&str>) -> Self { assert_initialized_main_thread!(); diff --git a/gstreamer-sdp/src/sdp_bandwidth.rs b/gstreamer-sdp/src/sdp_bandwidth.rs index 67149fd1e..f1e97c43d 100644 --- a/gstreamer-sdp/src/sdp_bandwidth.rs +++ b/gstreamer-sdp/src/sdp_bandwidth.rs @@ -16,6 +16,9 @@ use gst_sdp_sys; #[repr(C)] pub struct SDPBandwidth(pub(crate) gst_sdp_sys::GstSDPBandwidth); +unsafe impl Send for SDPBandwidth {} +unsafe impl Sync for SDPBandwidth {} + impl SDPBandwidth { pub fn new(bwtype: &str, bandwidth: u32) -> Self { assert_initialized_main_thread!(); diff --git a/gstreamer-sdp/src/sdp_connection.rs b/gstreamer-sdp/src/sdp_connection.rs index 45f2385d1..55eacae42 100644 --- a/gstreamer-sdp/src/sdp_connection.rs +++ b/gstreamer-sdp/src/sdp_connection.rs @@ -16,6 +16,9 @@ use gst_sdp_sys; #[repr(C)] pub struct SDPConnection(pub(crate) gst_sdp_sys::GstSDPConnection); +unsafe impl Send for SDPConnection {} +unsafe impl Sync for SDPConnection {} + impl SDPConnection { pub fn new(nettype: &str, addrtype: &str, address: &str, ttl: u32, addr_number: u32) -> Self { assert_initialized_main_thread!(); diff --git a/gstreamer-sdp/src/sdp_key.rs b/gstreamer-sdp/src/sdp_key.rs index f7c9867e9..737120fe6 100644 --- a/gstreamer-sdp/src/sdp_key.rs +++ b/gstreamer-sdp/src/sdp_key.rs @@ -14,6 +14,9 @@ use gst_sdp_sys; #[repr(C)] pub struct SDPKey(gst_sdp_sys::GstSDPKey); +unsafe impl Send for SDPKey {} +unsafe impl Sync for SDPKey {} + impl SDPKey { pub fn type_(&self) -> Option<&str> { unsafe { diff --git a/gstreamer-sdp/src/sdp_origin.rs b/gstreamer-sdp/src/sdp_origin.rs index beb5a8973..d016eb525 100644 --- a/gstreamer-sdp/src/sdp_origin.rs +++ b/gstreamer-sdp/src/sdp_origin.rs @@ -14,6 +14,9 @@ use gst_sdp_sys; #[repr(C)] pub struct SDPOrigin(pub(crate) gst_sdp_sys::GstSDPOrigin); +unsafe impl Send for SDPOrigin {} +unsafe impl Sync for SDPOrigin {} + impl SDPOrigin { pub fn username(&self) -> Option<&str> { unsafe { diff --git a/gstreamer-sdp/src/sdp_time.rs b/gstreamer-sdp/src/sdp_time.rs index f638064c2..5fc5d436f 100644 --- a/gstreamer-sdp/src/sdp_time.rs +++ b/gstreamer-sdp/src/sdp_time.rs @@ -18,6 +18,9 @@ use gst_sdp_sys; #[repr(C)] pub struct SDPTime(pub(crate) gst_sdp_sys::GstSDPTime); +unsafe impl Send for SDPTime {} +unsafe impl Sync for SDPTime {} + impl SDPTime { pub fn new(start: &str, stop: &str, repeat: &[&str]) -> Self { assert_initialized_main_thread!(); diff --git a/gstreamer-sdp/src/sdp_zone.rs b/gstreamer-sdp/src/sdp_zone.rs index fc6a673d1..8868058df 100644 --- a/gstreamer-sdp/src/sdp_zone.rs +++ b/gstreamer-sdp/src/sdp_zone.rs @@ -16,6 +16,9 @@ use gst_sdp_sys; #[repr(C)] pub struct SDPZone(pub(crate) gst_sdp_sys::GstSDPZone); +unsafe impl Send for SDPZone {} +unsafe impl Sync for SDPZone {} + impl SDPZone { pub fn new(time: &str, typed_time: &str) -> Self { assert_initialized_main_thread!(); diff --git a/gstreamer-video/src/video_frame.rs b/gstreamer-video/src/video_frame.rs index 0d9e83b71..cd3fe5bdc 100644 --- a/gstreamer-video/src/video_frame.rs +++ b/gstreamer-video/src/video_frame.rs @@ -663,6 +663,9 @@ impl<'a> ops::Deref for VideoFrameRef<&'a mut gst::BufferRef> { } } +unsafe impl Send for VideoFrameRef {} +unsafe impl Sync for VideoFrameRef {} + impl Drop for VideoFrameRef { fn drop(&mut self) { if !self.3 { diff --git a/gstreamer-video/src/video_meta.rs b/gstreamer-video/src/video_meta.rs index 35ee619d8..d7abd2403 100644 --- a/gstreamer-video/src/video_meta.rs +++ b/gstreamer-video/src/video_meta.rs @@ -18,6 +18,9 @@ use gst_video_sys; #[repr(C)] pub struct VideoMeta(gst_video_sys::GstVideoMeta); +unsafe impl Send for VideoMeta {} +unsafe impl Sync for VideoMeta {} + impl VideoMeta { pub fn add( buffer: &mut gst::BufferRef, @@ -134,6 +137,9 @@ impl fmt::Debug for VideoMeta { #[repr(C)] pub struct VideoOverlayCompositionMeta(gst_video_sys::GstVideoOverlayCompositionMeta); +unsafe impl Send for VideoOverlayCompositionMeta {} +unsafe impl Sync for VideoOverlayCompositionMeta {} + impl VideoOverlayCompositionMeta { pub fn add<'a>( buffer: &'a mut gst::BufferRef, @@ -186,6 +192,11 @@ impl fmt::Debug for VideoOverlayCompositionMeta { #[repr(C)] pub struct VideoCaptionMeta(gst_video_sys::GstVideoCaptionMeta); +#[cfg(any(feature = "v1_16", feature = "dox"))] +unsafe impl Send for VideoCaptionMeta {} +#[cfg(any(feature = "v1_16", feature = "dox"))] +unsafe impl Sync for VideoCaptionMeta {} + #[cfg(any(feature = "v1_16", feature = "dox"))] impl VideoCaptionMeta { pub fn add<'a>( diff --git a/gstreamer-video/src/video_time_code.rs b/gstreamer-video/src/video_time_code.rs index 9ea10cf93..227402767 100644 --- a/gstreamer-video/src/video_time_code.rs +++ b/gstreamer-video/src/video_time_code.rs @@ -525,6 +525,9 @@ impl From for VideoTimeCode { #[repr(C)] pub struct VideoTimeCodeMeta(gst_video_sys::GstVideoTimeCodeMeta); +unsafe impl Send for VideoTimeCodeMeta {} +unsafe impl Sync for VideoTimeCodeMeta {} + impl VideoTimeCodeMeta { pub fn add<'a>( buffer: &'a mut gst::BufferRef, diff --git a/gstreamer/src/allocation_params.rs b/gstreamer/src/allocation_params.rs index e5c6e7f6b..7fe794d04 100644 --- a/gstreamer/src/allocation_params.rs +++ b/gstreamer/src/allocation_params.rs @@ -15,6 +15,9 @@ use MemoryFlags; #[derive(Debug, Clone)] pub struct AllocationParams(gst_sys::GstAllocationParams); +unsafe impl Send for AllocationParams {} +unsafe impl Sync for AllocationParams {} + impl AllocationParams { pub fn get_flags(&self) -> MemoryFlags { from_glib(self.0.flags) diff --git a/gstreamer/src/buffer.rs b/gstreamer/src/buffer.rs index 325ce8949..b3c09a15e 100644 --- a/gstreamer/src/buffer.rs +++ b/gstreamer/src/buffer.rs @@ -604,6 +604,9 @@ macro_rules! define_iter( items: PhantomData<$mtyp>, } + unsafe impl<'a, T: MetaAPI> Send for $name<'a, T> { } + unsafe impl<'a, T: MetaAPI> Sync for $name<'a, T> { } + impl<'a, T: MetaAPI> $name<'a, T> { fn new(buffer: $typ) -> $name<'a, T> { skip_assert_initialized!(); @@ -778,6 +781,9 @@ impl<'a, T> Drop for BufferMap<'a, T> { } } +unsafe impl<'a, T> Send for BufferMap<'a, T> {} +unsafe impl<'a, T> Sync for BufferMap<'a, T> {} + impl MappedBuffer { pub fn as_slice(&self) -> &[u8] { unsafe { slice::from_raw_parts(self.map_info.data as *const u8, self.map_info.size) } @@ -860,6 +866,7 @@ impl PartialEq for MappedBuffer { impl Eq for MappedBuffer {} unsafe impl Send for MappedBuffer {} +unsafe impl Sync for MappedBuffer {} lazy_static! { pub static ref BUFFER_COPY_METADATA: ::BufferCopyFlags = diff --git a/gstreamer/src/buffer_pool.rs b/gstreamer/src/buffer_pool.rs index cf08b2e44..720e7995f 100644 --- a/gstreamer/src/buffer_pool.rs +++ b/gstreamer/src/buffer_pool.rs @@ -187,6 +187,9 @@ impl BufferPoolConfig { #[derive(Debug)] pub struct BufferPoolAcquireParams(gst_sys::GstBufferPoolAcquireParams); +unsafe impl Send for BufferPoolAcquireParams {} +unsafe impl Sync for BufferPoolAcquireParams {} + impl BufferPoolAcquireParams { pub fn with_flags(flags: ::BufferPoolAcquireFlags) -> Self { BufferPoolAcquireParams(gst_sys::GstBufferPoolAcquireParams { diff --git a/gstreamer/src/iterator.rs b/gstreamer/src/iterator.rs index 2e8d4dd16..a4bbad28d 100644 --- a/gstreamer/src/iterator.rs +++ b/gstreamer/src/iterator.rs @@ -326,6 +326,7 @@ where } unsafe impl Send for Iterator {} +unsafe impl Sync for Iterator {} unsafe extern "C" fn filter_trampoline(value: gconstpointer, func: gconstpointer) -> i32 where diff --git a/gstreamer/src/memory.rs b/gstreamer/src/memory.rs index 64b682511..1f6809d5d 100644 --- a/gstreamer/src/memory.rs +++ b/gstreamer/src/memory.rs @@ -380,6 +380,9 @@ impl<'a, T> Drop for MemoryMap<'a, T> { } } +unsafe impl<'a, T> Send for MemoryMap<'a, T> {} +unsafe impl<'a, T> Sync for MemoryMap<'a, T> {} + impl MappedMemory { pub fn as_slice(&self) -> &[u8] { unsafe { slice::from_raw_parts(self.map_info.data as *const u8, self.map_info.size) } @@ -462,3 +465,4 @@ impl PartialEq for MappedMemory { impl Eq for MappedMemory {} unsafe impl Send for MappedMemory {} +unsafe impl Sync for MappedMemory {} diff --git a/gstreamer/src/meta.rs b/gstreamer/src/meta.rs index cea0f18cf..1cebfee29 100644 --- a/gstreamer/src/meta.rs +++ b/gstreamer/src/meta.rs @@ -27,7 +27,7 @@ use glib::translate::{from_glib, from_glib_none, FromGlib, ToGlibPtr}; use glib_sys; use gst_sys; -pub unsafe trait MetaAPI: Sized { +pub unsafe trait MetaAPI: Sync + Send + Sized { type GstType; fn get_meta_api() -> glib::Type; @@ -210,6 +210,9 @@ impl<'a, U> MetaRefMut<'a, Meta, U> { #[repr(C)] pub struct Meta(gst_sys::GstMeta); +unsafe impl Send for Meta {} +unsafe impl Sync for Meta {} + impl Meta { fn get_api(&self) -> glib::Type { unsafe { glib::Type::from_glib((*self.0.info).api) } @@ -235,6 +238,9 @@ impl fmt::Debug for Meta { #[repr(C)] pub struct ParentBufferMeta(gst_sys::GstParentBufferMeta); +unsafe impl Send for ParentBufferMeta {} +unsafe impl Sync for ParentBufferMeta {} + impl ParentBufferMeta { pub fn add<'a>(buffer: &'a mut BufferRef, parent: &Buffer) -> MetaRefMut<'a, Self, Standalone> { unsafe { @@ -276,6 +282,11 @@ impl fmt::Debug for ParentBufferMeta { #[repr(C)] pub struct ReferenceTimestampMeta(gst_sys::GstReferenceTimestampMeta); +#[cfg(any(feature = "v1_14", feature = "dox"))] +unsafe impl Send for ReferenceTimestampMeta {} +#[cfg(any(feature = "v1_14", feature = "dox"))] +unsafe impl Sync for ReferenceTimestampMeta {} + #[cfg(any(feature = "v1_14", feature = "dox"))] impl ReferenceTimestampMeta { pub fn add<'a>( diff --git a/gstreamer/src/pad.rs b/gstreamer/src/pad.rs index 183947e0c..69da1d6ec 100644 --- a/gstreamer/src/pad.rs +++ b/gstreamer/src/pad.rs @@ -99,6 +99,9 @@ pub enum PadProbeData<'a> { __Unknown(*mut gst_sys::GstMiniObject), } +unsafe impl<'a> Send for PadProbeData<'a> {} +unsafe impl<'a> Sync for PadProbeData<'a> {} + #[derive(Debug)] pub struct StreamLock(Pad); impl Drop for StreamLock { diff --git a/gstreamer/src/parse_context.rs b/gstreamer/src/parse_context.rs index 63d2183c4..0badea107 100644 --- a/gstreamer/src/parse_context.rs +++ b/gstreamer/src/parse_context.rs @@ -25,6 +25,9 @@ glib_wrapper! { } } +unsafe impl Send for ParseContext {} +unsafe impl Sync for ParseContext {} + impl ParseContext { pub fn new() -> Self { unsafe { from_glib_full(gst_sys::gst_parse_context_new()) } diff --git a/gstreamer/src/segment.rs b/gstreamer/src/segment.rs index 6b880b16a..8e3482696 100644 --- a/gstreamer/src/segment.rs +++ b/gstreamer/src/segment.rs @@ -508,6 +508,7 @@ impl PartialEq for FormattedSegment { impl Eq for FormattedSegment {} unsafe impl Send for FormattedSegment {} +unsafe impl Sync for FormattedSegment {} impl Clone for FormattedSegment { fn clone(&self) -> Self { diff --git a/gstreamer/src/subclass/plugin_1_12.rs b/gstreamer/src/subclass/plugin_1_12.rs index 924604433..de804a9ff 100644 --- a/gstreamer/src/subclass/plugin_1_12.rs +++ b/gstreamer/src/subclass/plugin_1_12.rs @@ -25,6 +25,7 @@ macro_rules! gst_plugin_define( #[repr(C)] pub struct GstPluginDesc($crate::gst_sys::GstPluginDesc); + unsafe impl Send for GstPluginDesc {} unsafe impl Sync for GstPluginDesc {} #[no_mangle] diff --git a/gstreamer/src/subclass/plugin_1_14.rs b/gstreamer/src/subclass/plugin_1_14.rs index db2aedf77..7bccedf36 100644 --- a/gstreamer/src/subclass/plugin_1_14.rs +++ b/gstreamer/src/subclass/plugin_1_14.rs @@ -23,6 +23,7 @@ macro_rules! gst_plugin_define( #[repr(C)] pub struct GstPluginDesc($crate::gst_sys::GstPluginDesc); + unsafe impl Send for GstPluginDesc {} unsafe impl Sync for GstPluginDesc {} static GST_PLUGIN_DESC: GstPluginDesc = GstPluginDesc($crate::gst_sys::GstPluginDesc { diff --git a/gstreamer/src/typefind.rs b/gstreamer/src/typefind.rs index 7f2d168b3..a062fdec2 100644 --- a/gstreamer/src/typefind.rs +++ b/gstreamer/src/typefind.rs @@ -96,8 +96,6 @@ impl<'a> TypeFind<'a> { } } -unsafe impl<'a> Send for TypeFind<'a> {} - impl TypeFindFactory { pub fn call_function(&self, find: &mut dyn TypeFindImpl) { unsafe {