From 1264eb10ac507d6e799b4fff7769045ba8300145 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 21 Nov 2022 11:11:24 +0200 Subject: [PATCH] gstreamer: Add `PartialEq` impls between owned/borrowed miniobjects/structures Part-of: --- gstreamer-audio/src/functions.rs | 4 ++-- gstreamer-video/src/functions.rs | 2 +- gstreamer/src/buffer.rs | 11 +++++++++++ gstreamer/src/caps.rs | 12 ++++++++++++ gstreamer/src/structure.rs | 20 +++++++++++++------- gstreamer/src/tags.rs | 12 ++++++++++++ 6 files changed, 51 insertions(+), 10 deletions(-) diff --git a/gstreamer-audio/src/functions.rs b/gstreamer-audio/src/functions.rs index 154eff2e7..8811ef7a4 100644 --- a/gstreamer-audio/src/functions.rs +++ b/gstreamer-audio/src/functions.rs @@ -82,7 +82,7 @@ mod tests { #[cfg(feature = "v1_18")] { - use glib::translate::{from_glib_full, IntoGlib}; + use glib::translate::IntoGlib; /* audio_make_raw_caps() is a re-implementation so ensure it returns the same caps as the C API */ let c_caps = unsafe { @@ -96,7 +96,7 @@ mod tests { formats.len() as u32, ffi::GST_AUDIO_LAYOUT_INTERLEAVED, ); - from_glib_full(caps) + gst::Caps::from_glib_full(caps) }; assert_eq!(caps, c_caps); } diff --git a/gstreamer-video/src/functions.rs b/gstreamer-video/src/functions.rs index 459471588..7a1bf6d9d 100644 --- a/gstreamer-video/src/functions.rs +++ b/gstreamer-video/src/functions.rs @@ -307,7 +307,7 @@ mod tests { .map(|f| f.into_glib()) .collect(); let caps = ffi::gst_video_make_raw_caps(formats.as_ptr(), formats.len() as u32); - from_glib_full(caps) + gst::Caps::from_glib_full(caps) }; assert_eq!(caps, c_caps); } diff --git a/gstreamer/src/buffer.rs b/gstreamer/src/buffer.rs index 1d33f48cd..2a39ba1d8 100644 --- a/gstreamer/src/buffer.rs +++ b/gstreamer/src/buffer.rs @@ -1035,6 +1035,17 @@ impl PartialEq for Buffer { impl Eq for Buffer {} +impl PartialEq for Buffer { + fn eq(&self, other: &BufferRef) -> bool { + BufferRef::eq(self, other) + } +} +impl PartialEq for BufferRef { + fn eq(&self, other: &Buffer) -> bool { + BufferRef::eq(other, self) + } +} + impl fmt::Debug for BufferRef { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { use crate::utils::Displayable; diff --git a/gstreamer/src/caps.rs b/gstreamer/src/caps.rs index 0eef0c216..022d73d2e 100644 --- a/gstreamer/src/caps.rs +++ b/gstreamer/src/caps.rs @@ -827,6 +827,18 @@ impl PartialEq for Caps { impl Eq for Caps {} +impl PartialEq for Caps { + fn eq(&self, other: &CapsRef) -> bool { + CapsRef::eq(self, other) + } +} + +impl PartialEq for CapsRef { + fn eq(&self, other: &Caps) -> bool { + CapsRef::eq(other, self) + } +} + impl fmt::Debug for CapsRef { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { if self.is_any() { diff --git a/gstreamer/src/structure.rs b/gstreamer/src/structure.rs index 8d5baa2bb..056101ce1 100644 --- a/gstreamer/src/structure.rs +++ b/gstreamer/src/structure.rs @@ -153,18 +153,24 @@ impl fmt::Display for Structure { impl PartialEq for Structure { fn eq(&self, other: &Structure) -> bool { - self.as_ref().eq(other) - } -} - -impl PartialEq for Structure { - fn eq(&self, other: &StructureRef) -> bool { - self.as_ref().eq(other) + StructureRef::eq(self, other) } } impl Eq for Structure {} +impl PartialEq for Structure { + fn eq(&self, other: &StructureRef) -> bool { + StructureRef::eq(self, other) + } +} + +impl PartialEq for StructureRef { + fn eq(&self, other: &Structure) -> bool { + StructureRef::eq(other, self) + } +} + impl str::FromStr for Structure { type Err = glib::BoolError; diff --git a/gstreamer/src/tags.rs b/gstreamer/src/tags.rs index 611d28f01..cefbadec3 100644 --- a/gstreamer/src/tags.rs +++ b/gstreamer/src/tags.rs @@ -584,6 +584,18 @@ impl PartialEq for TagList { impl Eq for TagList {} +impl PartialEq for TagList { + fn eq(&self, other: &TagListRef) -> bool { + TagListRef::eq(self, other) + } +} + +impl PartialEq for TagListRef { + fn eq(&self, other: &TagList) -> bool { + TagListRef::eq(other, self) + } +} + impl fmt::Debug for TagListRef { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let mut debug = f.debug_struct("TagList");