diff --git a/gstreamer-audio/src/audio_format_info.rs b/gstreamer-audio/src/audio_format_info.rs index 6b6c7d314..260c69c48 100644 --- a/gstreamer-audio/src/audio_format_info.rs +++ b/gstreamer-audio/src/audio_format_info.rs @@ -42,6 +42,7 @@ impl IntoGlib for AudioEndianness { } #[doc(alias = "GstAudioFormatInfo")] +#[derive(Copy, Clone)] pub struct AudioFormatInfo(&'static ffi::GstAudioFormatInfo); impl AudioFormatInfo { @@ -379,6 +380,9 @@ impl glib::translate::GlibPtrDefault for AudioFormatInfo { type GlibType = *mut ffi::GstAudioFormatInfo; } +#[doc(hidden)] +unsafe impl glib::translate::TransparentPtrType for AudioFormatInfo {} + #[doc(hidden)] impl<'a> glib::translate::ToGlibPtr<'a, *const ffi::GstAudioFormatInfo> for AudioFormatInfo { type Storage = PhantomData<&'a Self>; diff --git a/gstreamer-video/src/video_format_info.rs b/gstreamer-video/src/video_format_info.rs index 03d751653..7b349a32b 100644 --- a/gstreamer-video/src/video_format_info.rs +++ b/gstreamer-video/src/video_format_info.rs @@ -512,6 +512,9 @@ impl glib::translate::GlibPtrDefault for VideoFormatInfo { type GlibType = *mut ffi::GstVideoFormatInfo; } +#[doc(hidden)] +unsafe impl glib::translate::TransparentPtrType for VideoFormatInfo {} + #[doc(hidden)] impl<'a> glib::translate::ToGlibPtr<'a, *const ffi::GstVideoFormatInfo> for VideoFormatInfo { type Storage = PhantomData<&'a Self>; diff --git a/gstreamer-video/src/video_time_code.rs b/gstreamer-video/src/video_time_code.rs index 1909e3da8..ff1ad7f66 100644 --- a/gstreamer-video/src/video_time_code.rs +++ b/gstreamer-video/src/video_time_code.rs @@ -351,6 +351,11 @@ macro_rules! generic_impl { type GlibType = *mut ffi::GstVideoTimeCode; } + #[doc(hidden)] + unsafe impl TransparentType for $name { + type GlibType = ffi::GstVideoTimeCode; + } + #[doc(hidden)] impl<'a> ToGlibPtr<'a, *const ffi::GstVideoTimeCode> for $name { type Storage = PhantomData<&'a Self>; diff --git a/gstreamer-video/src/video_time_code_interval.rs b/gstreamer-video/src/video_time_code_interval.rs index de1f637c5..50f91be19 100644 --- a/gstreamer-video/src/video_time_code_interval.rs +++ b/gstreamer-video/src/video_time_code_interval.rs @@ -136,6 +136,11 @@ impl GlibPtrDefault for VideoTimeCodeInterval { type GlibType = *mut ffi::GstVideoTimeCodeInterval; } +#[doc(hidden)] +unsafe impl TransparentType for VideoTimeCodeInterval { + type GlibType = ffi::GstVideoTimeCodeInterval; +} + #[doc(hidden)] impl<'a> ToGlibPtr<'a, *const ffi::GstVideoTimeCodeInterval> for VideoTimeCodeInterval { type Storage = PhantomData<&'a Self>; diff --git a/gstreamer/src/caps_features.rs b/gstreamer/src/caps_features.rs index a0fe1d319..04e14ee21 100644 --- a/gstreamer/src/caps_features.rs +++ b/gstreamer/src/caps_features.rs @@ -300,6 +300,8 @@ impl GlibPtrDefault for CapsFeatures { type GlibType = *mut ffi::GstCapsFeatures; } +unsafe impl TransparentPtrType for CapsFeatures {} + #[repr(transparent)] #[doc(alias = "GstCapsFeatures")] pub struct CapsFeaturesRef(ffi::GstCapsFeatures); diff --git a/gstreamer/src/element.rs b/gstreamer/src/element.rs index d0c0193a4..149f1137c 100644 --- a/gstreamer/src/element.rs +++ b/gstreamer/src/element.rs @@ -996,7 +996,7 @@ pub unsafe trait ElementClassExt { unsafe { let klass = self as *const _ as *const ffi::GstElementClass; - glib::List::from_glib_none_static(ffi::gst_element_class_get_pad_template_list( + glib::List::from_glib_none(ffi::gst_element_class_get_pad_template_list( klass as *mut _, )) } diff --git a/gstreamer/src/element_factory.rs b/gstreamer/src/element_factory.rs index f546395db..a3a2364e1 100644 --- a/gstreamer/src/element_factory.rs +++ b/gstreamer/src/element_factory.rs @@ -101,9 +101,9 @@ impl ElementFactory { #[doc(alias = "get_static_pad_templates")] pub fn static_pad_templates(&self) -> glib::List { unsafe { - glib::List::from_glib_none_static(ffi::gst_element_factory_get_static_pad_templates( + glib::List::from_glib_none(ffi::gst_element_factory_get_static_pad_templates( self.to_glib_none().0, - ) as *mut _) + )) } } diff --git a/gstreamer/src/iterator.rs b/gstreamer/src/iterator.rs index 9e43d5a07..9e27f0806 100644 --- a/gstreamer/src/iterator.rs +++ b/gstreamer/src/iterator.rs @@ -568,6 +568,9 @@ impl glib::translate::GlibPtrDefault for Iterator { type GlibType = *mut ffi::GstIterator; } +#[doc(hidden)] +unsafe impl TransparentPtrType for Iterator {} + #[doc(hidden)] impl<'a, T: 'static> glib::translate::ToGlibPtr<'a, *const ffi::GstIterator> for Iterator { type Storage = PhantomData<&'a Iterator>; diff --git a/gstreamer/src/log.rs b/gstreamer/src/log.rs index 975cb5ba8..817c71297 100644 --- a/gstreamer/src/log.rs +++ b/gstreamer/src/log.rs @@ -394,7 +394,7 @@ impl DebugCategory { #[doc(alias = "get_all_categories")] #[doc(alias = "gst_debug_get_all_categories")] pub fn all_categories() -> glib::SList { - unsafe { glib::SList::from_glib_container_static(ffi::gst_debug_get_all_categories()) } + unsafe { glib::SList::from_glib_container(ffi::gst_debug_get_all_categories()) } } #[cfg(any(feature = "v1_18", feature = "dox"))] @@ -438,6 +438,8 @@ impl GlibPtrDefault for DebugCategory { type GlibType = *mut ffi::GstDebugCategory; } +unsafe impl TransparentPtrType for DebugCategory {} + impl FromGlibPtrNone<*mut ffi::GstDebugCategory> for DebugCategory { unsafe fn from_glib_none(ptr: *mut ffi::GstDebugCategory) -> Self { assert!(!ptr.is_null()); @@ -1216,7 +1218,9 @@ mod tests { fn all() { crate::init().unwrap(); - assert!(DebugCategory::all_categories().any(|c| c.name() == "GST_PERFORMANCE")); + assert!(DebugCategory::all_categories() + .iter() + .any(|c| c.name() == "GST_PERFORMANCE")); } #[test] diff --git a/gstreamer/src/miniobject.rs b/gstreamer/src/miniobject.rs index 3af6e2ea1..2f890ccb2 100644 --- a/gstreamer/src/miniobject.rs +++ b/gstreamer/src/miniobject.rs @@ -387,6 +387,8 @@ macro_rules! mini_object_wrapper ( type GlibType = *mut $ffi_name; } + unsafe impl $crate::glib::translate::TransparentPtrType for $name {} + impl $ref_name { pub fn as_ptr(&self) -> *const $ffi_name { self as *const Self as *const $ffi_name diff --git a/gstreamer/src/segment.rs b/gstreamer/src/segment.rs index 60a7f4617..dcad50d26 100644 --- a/gstreamer/src/segment.rs +++ b/gstreamer/src/segment.rs @@ -656,6 +656,11 @@ impl glib::translate::GlibPtrDefault for FormattedSe type GlibType = *mut ffi::GstSegment; } +#[doc(hidden)] +unsafe impl TransparentType for FormattedSegment { + type GlibType = ffi::GstSegment; +} + #[doc(hidden)] impl<'a, T: FormattedValueIntrinsic> glib::translate::ToGlibPtr<'a, *const ffi::GstSegment> for FormattedSegment diff --git a/gstreamer/src/static_caps.rs b/gstreamer/src/static_caps.rs index 5aab794e5..ae28d7740 100644 --- a/gstreamer/src/static_caps.rs +++ b/gstreamer/src/static_caps.rs @@ -11,6 +11,7 @@ use std::marker::PhantomData; use std::ptr; #[doc(alias = "GstStaticCaps")] +#[derive(Clone, Copy)] pub struct StaticCaps(ptr::NonNull); impl StaticCaps { @@ -43,6 +44,8 @@ impl glib::value::ValueType for StaticCaps { type Type = Self; } +unsafe impl glib::translate::TransparentPtrType for StaticCaps {} + #[doc(hidden)] unsafe impl<'a> glib::value::FromValue<'a> for StaticCaps { type Checker = glib::value::GenericValueTypeOrNoneChecker; diff --git a/gstreamer/src/static_pad_template.rs b/gstreamer/src/static_pad_template.rs index 9b399953d..aa5751e14 100644 --- a/gstreamer/src/static_pad_template.rs +++ b/gstreamer/src/static_pad_template.rs @@ -12,6 +12,7 @@ use std::marker::PhantomData; use std::ptr; #[doc(alias = "GstStaticPadTemplate")] +#[derive(Clone, Copy)] pub struct StaticPadTemplate(ptr::NonNull); impl StaticPadTemplate { @@ -43,6 +44,8 @@ impl StaticPadTemplate { } } +unsafe impl glib::translate::TransparentPtrType for StaticPadTemplate {} + unsafe impl Send for StaticPadTemplate {} unsafe impl Sync for StaticPadTemplate {} diff --git a/gstreamer/src/structure.rs b/gstreamer/src/structure.rs index 5aa9a9f26..e67127cd9 100644 --- a/gstreamer/src/structure.rs +++ b/gstreamer/src/structure.rs @@ -368,6 +368,8 @@ impl GlibPtrDefault for Structure { type GlibType = *mut ffi::GstStructure; } +unsafe impl TransparentPtrType for Structure {} + #[repr(transparent)] #[doc(alias = "GstStructure")] pub struct StructureRef(ffi::GstStructure); diff --git a/gstreamer/src/typefind.rs b/gstreamer/src/typefind.rs index 60560bb87..cf5bb5c7f 100644 --- a/gstreamer/src/typefind.rs +++ b/gstreamer/src/typefind.rs @@ -254,6 +254,7 @@ mod tests { crate::init().unwrap(); let xml_factory = TypeFindFactory::factories() + .into_iter() .find(|f| { f.caps() .map(|c| {