diff --git a/gstreamer/src/buffer.rs b/gstreamer/src/buffer.rs index fedb51deb..74768cd68 100644 --- a/gstreamer/src/buffer.rs +++ b/gstreamer/src/buffer.rs @@ -21,19 +21,19 @@ use ClockTime; use ffi; use glib; -use glib::translate::{from_glib, from_glib_full, ToGlib}; +use glib::translate::{from_glib, from_glib_full, from_glib_none, ToGlib, ToGlibPtr}; use glib_ffi; pub enum Readable {} pub enum Writable {} -#[repr(C)] -pub struct BufferRef(ffi::GstBuffer); -pub type Buffer = GstRc; - -unsafe impl MiniObject for BufferRef { - type GstType = ffi::GstBuffer; -} +gst_define_mini_object_wrapper!( + Buffer, + BufferRef, + ffi::GstBuffer, + [Debug, PartialEq, Eq,], + || ffi::gst_buffer_get_type() +); pub struct BufferMap<'a, T> { buffer: &'a BufferRef, @@ -47,7 +47,7 @@ pub struct MappedBuffer { phantom: PhantomData, } -impl GstRc { +impl Buffer { pub fn new() -> Self { assert_initialized_main_thread!(); @@ -161,7 +161,7 @@ impl GstRc { } } -impl Default for GstRc { +impl Default for Buffer { fn default() -> Self { Self::new() } @@ -369,23 +369,6 @@ impl BufferRef { } } -unsafe impl Sync for BufferRef {} -unsafe impl Send for BufferRef {} - -impl glib::types::StaticType for BufferRef { - fn static_type() -> glib::types::Type { - unsafe { from_glib(ffi::gst_buffer_get_type()) } - } -} - -impl ToOwned for BufferRef { - type Owned = GstRc; - - fn to_owned(&self) -> GstRc { - unsafe { from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _) as *mut _) } - } -} - impl fmt::Debug for BufferRef { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("Buffer") diff --git a/gstreamer/src/bufferlist.rs b/gstreamer/src/bufferlist.rs index af5efe7f3..83d9762c0 100644 --- a/gstreamer/src/bufferlist.rs +++ b/gstreamer/src/bufferlist.rs @@ -8,22 +8,23 @@ use ffi; use glib; -use glib::translate::{from_glib, from_glib_full}; -use glib::StaticType; +use glib::translate::{from_glib, from_glib_full, from_glib_none, ToGlibPtr}; +use glib_ffi; use std::fmt; use miniobject::*; use Buffer; use BufferRef; -pub type BufferList = GstRc; -pub struct BufferListRef(ffi::GstBufferList); +gst_define_mini_object_wrapper!( + BufferList, + BufferListRef, + ffi::GstBufferList, + [Debug,], + || ffi::gst_buffer_list_get_type() +); -unsafe impl MiniObject for BufferListRef { - type GstType = ffi::GstBufferList; -} - -impl GstRc { +impl BufferList { pub fn new() -> Self { assert_initialized_main_thread!(); unsafe { from_glib_full(ffi::gst_buffer_list_new()) } @@ -95,23 +96,12 @@ impl BufferListRef { } } -impl Default for GstRc { +impl Default for BufferList { fn default() -> Self { Self::new() } } -impl ToOwned for BufferListRef { - type Owned = GstRc; - - fn to_owned(&self) -> GstRc { - #[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))] - unsafe { - from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _) as *mut _) - } - } -} - impl fmt::Debug for BufferListRef { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let size = self.iter().map(|b| b.get_size()).sum::(); @@ -130,15 +120,6 @@ impl fmt::Debug for BufferListRef { } } -impl StaticType for BufferListRef { - fn static_type() -> glib::Type { - unsafe { from_glib(ffi::gst_buffer_list_get_type()) } - } -} - -unsafe impl Sync for BufferListRef {} -unsafe impl Send for BufferListRef {} - pub struct Iter<'a> { list: &'a BufferListRef, idx: u32, diff --git a/gstreamer/src/caps.rs b/gstreamer/src/caps.rs index 09353258d..ec096934b 100644 --- a/gstreamer/src/caps.rs +++ b/gstreamer/src/caps.rs @@ -17,19 +17,15 @@ use CapsIntersectMode; use ffi; use glib; -use glib::translate::{from_glib, from_glib_full, ToGlib, ToGlibPtr}; +use glib::translate::{from_glib, from_glib_full, from_glib_none, ToGlib, ToGlibPtr}; use glib::value::ToSendValue; +use glib_ffi; -#[repr(C)] -pub struct CapsRef(ffi::GstCaps); +gst_define_mini_object_wrapper!(Caps, CapsRef, ffi::GstCaps, [Debug, PartialEq, Eq,], || { + ffi::gst_caps_get_type() +}); -pub type Caps = GstRc; - -unsafe impl MiniObject for CapsRef { - type GstType = ffi::GstCaps; -} - -impl GstRc { +impl Caps { pub fn builder(name: &str) -> Builder { assert_initialized_main_thread!(); Builder::new(name) @@ -340,12 +336,6 @@ impl CapsRef { } } -impl glib::types::StaticType for CapsRef { - fn static_type() -> glib::types::Type { - unsafe { from_glib(ffi::gst_caps_get_type()) } - } -} - macro_rules! define_iter( ($name:ident, $typ:ty, $styp:ty, $get_item:expr) => { pub struct $name<'a> { @@ -500,17 +490,6 @@ impl PartialEq for CapsRef { impl Eq for CapsRef {} -impl ToOwned for CapsRef { - type Owned = GstRc; - - fn to_owned(&self) -> GstRc { - unsafe { from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _) as *mut _) } - } -} - -unsafe impl Sync for CapsRef {} -unsafe impl Send for CapsRef {} - pub struct Builder<'a> { s: ::Structure, features: Option<&'a [&'a str]>, diff --git a/gstreamer/src/context.rs b/gstreamer/src/context.rs index b8242947a..277881ae8 100644 --- a/gstreamer/src/context.rs +++ b/gstreamer/src/context.rs @@ -12,20 +12,17 @@ use std::fmt; use ffi; use glib; -use glib::translate::{from_glib, from_glib_full, ToGlib, ToGlibPtr}; -use glib::StaticType; +use glib::translate::{from_glib, from_glib_full, from_glib_none, ToGlib, ToGlibPtr}; +use glib_ffi; use miniobject::*; use StructureRef; -pub type Context = GstRc; -pub struct ContextRef(ffi::GstContext); +gst_define_mini_object_wrapper!(Context, ContextRef, ffi::GstContext, [Debug,], || { + ffi::gst_context_get_type() +}); -unsafe impl MiniObject for ContextRef { - type GstType = ffi::GstContext; -} - -impl GstRc { +impl Context { pub fn new(context_type: &str, persistent: bool) -> Self { assert_initialized_main_thread!(); unsafe { @@ -71,12 +68,6 @@ impl ContextRef { } } -impl StaticType for ContextRef { - fn static_type() -> glib::Type { - unsafe { from_glib(ffi::gst_context_get_type()) } - } -} - impl fmt::Debug for ContextRef { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("Context") @@ -85,17 +76,3 @@ impl fmt::Debug for ContextRef { .finish() } } - -impl ToOwned for ContextRef { - type Owned = GstRc; - - fn to_owned(&self) -> GstRc { - #[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))] - unsafe { - from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _) as *mut _) - } - } -} - -unsafe impl Sync for ContextRef {} -unsafe impl Send for ContextRef {} diff --git a/gstreamer/src/event.rs b/gstreamer/src/event.rs index 800d293cc..7bee1328e 100644 --- a/gstreamer/src/event.rs +++ b/gstreamer/src/event.rs @@ -19,8 +19,9 @@ use std::ops::Deref; use std::ptr; use glib; -use glib::translate::{from_glib, from_glib_full, FromGlib, ToGlib, ToGlibPtr}; +use glib::translate::{from_glib, from_glib_full, from_glib_none, FromGlib, ToGlib, ToGlibPtr}; use glib::value::ToSendValue; +use glib_ffi; #[cfg(any(feature = "v1_10", feature = "dox"))] use glib::translate::FromGlibPtrContainer; @@ -110,18 +111,6 @@ impl FromGlib for GroupId { } } -#[repr(C)] -pub struct EventRef(ffi::GstEvent); - -pub type Event = GstRc; - -unsafe impl Sync for EventRef {} -unsafe impl Send for EventRef {} - -unsafe impl MiniObject for EventRef { - type GstType = ffi::GstEvent; -} - impl EventType { pub fn is_upstream(self) -> bool { (self.to_glib() as u32) & ffi::GST_EVENT_TYPE_UPSTREAM != 0 @@ -176,6 +165,10 @@ impl PartialOrd for EventType { } } +gst_define_mini_object_wrapper!(Event, EventRef, ffi::GstEvent, [Debug,], || { + ffi::gst_event_get_type() +}); + impl EventRef { pub fn get_seqnum(&self) -> Seqnum { unsafe { from_glib(ffi::gst_event_get_seqnum(self.as_mut_ptr())) } @@ -266,7 +259,7 @@ impl EventRef { } } -impl GstRc { +impl Event { pub fn new_flush_start<'a>() -> FlushStartBuilder<'a> { assert_initialized_main_thread!(); FlushStartBuilder::new() @@ -452,12 +445,6 @@ impl GstRc { } } -impl glib::types::StaticType for EventRef { - fn static_type() -> glib::types::Type { - unsafe { from_glib(ffi::gst_event_get_type()) } - } -} - impl fmt::Debug for EventRef { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("Event") @@ -471,14 +458,6 @@ impl fmt::Debug for EventRef { } } -impl ToOwned for EventRef { - type Owned = GstRc; - - fn to_owned(&self) -> GstRc { - unsafe { from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _) as *mut _) } - } -} - pub enum EventView<'a> { FlushStart(FlushStart<'a>), FlushStop(FlushStop<'a>), diff --git a/gstreamer/src/lib.rs b/gstreamer/src/lib.rs index f0f752a16..8896ec6b5 100644 --- a/gstreamer/src/lib.rs +++ b/gstreamer/src/lib.rs @@ -71,6 +71,7 @@ pub use log::*; mod error; pub use error::*; +#[macro_use] pub mod miniobject; pub use miniobject::{GstRc, MiniObject}; pub mod message; diff --git a/gstreamer/src/message.rs b/gstreamer/src/message.rs index 51f53efb6..f548b4360 100644 --- a/gstreamer/src/message.rs +++ b/gstreamer/src/message.rs @@ -27,18 +27,11 @@ use glib::translate::{from_glib, from_glib_full, from_glib_none, mut_override, T use glib::value::ToSendValue; use glib::Cast; use glib::IsA; +use glib_ffi; -#[repr(C)] -pub struct MessageRef(ffi::GstMessage); - -pub type Message = GstRc; - -unsafe impl Sync for MessageRef {} -unsafe impl Send for MessageRef {} - -unsafe impl MiniObject for MessageRef { - type GstType = ffi::GstMessage; -} +gst_define_mini_object_wrapper!(Message, MessageRef, ffi::GstMessage, [Debug,], || { + ffi::gst_message_get_type() +}); impl MessageRef { pub fn get_src(&self) -> Option { @@ -113,7 +106,7 @@ impl MessageRef { } } -impl GstRc { +impl Message { pub fn new_eos<'a>() -> EosBuilder<'a> { assert_initialized_main_thread!(); EosBuilder::new() @@ -348,12 +341,6 @@ impl GstRc { } } -impl glib::types::StaticType for MessageRef { - fn static_type() -> glib::types::Type { - unsafe { from_glib(ffi::gst_message_get_type()) } - } -} - impl fmt::Debug for MessageRef { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("Message") @@ -368,14 +355,6 @@ impl fmt::Debug for MessageRef { } } -impl ToOwned for MessageRef { - type Owned = GstRc; - - fn to_owned(&self) -> GstRc { - unsafe { from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _) as *mut _) } - } -} - pub enum MessageView<'a> { Eos(Eos<'a>), Error(Error<'a>), diff --git a/gstreamer/src/miniobject.rs b/gstreamer/src/miniobject.rs index 82f677e19..7e5136a3c 100644 --- a/gstreamer/src/miniobject.rs +++ b/gstreamer/src/miniobject.rs @@ -501,15 +501,15 @@ macro_rules! gst_define_mini_object_wrapper( impl $name { pub unsafe fn from_glib_none(ptr: *const $ffi_name) -> Self { - $name(from_glib_none(ptr)) + $name(glib::translate::from_glib_none(ptr)) } pub unsafe fn from_glib_full(ptr: *const $ffi_name) -> Self { - $name(from_glib_full(ptr)) + $name(glib::translate::from_glib_full(ptr)) } pub unsafe fn from_glib_borrow(ptr: *const $ffi_name) -> Self { - $name(from_glib_borrow(ptr)) + $name(glib::translate::from_glib_borrow(ptr)) } pub unsafe fn into_ptr(self) -> *mut $ffi_name { @@ -517,6 +517,18 @@ macro_rules! gst_define_mini_object_wrapper( } } + impl From<$crate::GstRc<$ref_name>> for $name { + fn from(rc: $crate::GstRc<$ref_name>) -> $name { + $name(rc) + } + } + + impl Into<$crate::GstRc<$ref_name>> for $name { + fn into(self) -> $crate::GstRc<$ref_name> { + self.0 + } + } + impl ::std::ops::Deref for $name { type Target = $crate::GstRc<$ref_name>; @@ -595,7 +607,7 @@ macro_rules! gst_define_mini_object_wrapper( skip_assert_initialized!(); let v: Vec<_> = t.iter().map(|s| s.to_glib_none()).collect(); let mut v_ptr: Vec<_> = v.iter().map(|s| s.0).collect(); - v_ptr.push(ptr::null_mut() as *mut $ffi_name); + v_ptr.push(::std::ptr::null_mut() as *mut $ffi_name); (v_ptr.as_ptr() as *mut *mut $ffi_name, (v, Some(v_ptr))) } @@ -605,11 +617,11 @@ macro_rules! gst_define_mini_object_wrapper( let v: Vec<_> = t.iter().map(|s| s.to_glib_none()).collect(); let v_ptr = unsafe { - let v_ptr = glib_ffi::g_malloc0(mem::size_of::<*mut $ffi_name>() * t.len() + 1) + let v_ptr = glib_ffi::g_malloc0(::std::mem::size_of::<*mut $ffi_name>() * t.len() + 1) as *mut *mut $ffi_name; for (i, s) in v.iter().enumerate() { - ptr::write(v_ptr.offset(i as isize), s.0); + ::std::ptr::write(v_ptr.offset(i as isize), s.0); } v_ptr @@ -621,11 +633,11 @@ macro_rules! gst_define_mini_object_wrapper( fn to_glib_full_from_slice(t: &[$name]) -> *mut *mut $ffi_name { skip_assert_initialized!(); unsafe { - let v_ptr = glib_ffi::g_malloc0(mem::size_of::<*mut $ffi_name>() * t.len() + 1) + let v_ptr = glib_ffi::g_malloc0(::std::mem::size_of::<*mut $ffi_name>() * t.len() + 1) as *mut *mut $ffi_name; for (i, s) in t.iter().enumerate() { - ptr::write(v_ptr.offset(i as isize), s.to_glib_full()); + ::std::ptr::write(v_ptr.offset(i as isize), s.to_glib_full()); } v_ptr @@ -708,7 +720,7 @@ macro_rules! gst_define_mini_object_wrapper( let mut res = Vec::with_capacity(num); for i in 0..num { - res.push(from_glib_none(ptr::read(ptr.offset(i as isize)))); + res.push(from_glib_none(::std::ptr::read(ptr.offset(i as isize)))); } res } @@ -726,7 +738,7 @@ macro_rules! gst_define_mini_object_wrapper( let mut res = Vec::with_capacity(num); for i in 0..num { - res.push(from_glib_full(ptr::read(ptr.offset(i as isize)))); + res.push(from_glib_full(::std::ptr::read(ptr.offset(i as isize)))); } glib_ffi::g_free(ptr as *mut _); res @@ -788,19 +800,19 @@ macro_rules! gst_define_mini_object_wrapper( for $name { unsafe fn from_value_optional(v: &'a glib::Value) -> Option { - as glib::value::FromValueOptional>::from_value_optional(v).map($name) + <$crate::GstRc<$ref_name> as glib::value::FromValueOptional>::from_value_optional(v).map($name) } } impl glib::value::SetValue for $name { unsafe fn set_value(v: &mut glib::Value, s: &Self) { - as glib::value::SetValue>::set_value(v, &s.0) + <$crate::GstRc<$ref_name> as glib::value::SetValue>::set_value(v, &s.0) } } impl glib::value::SetValueOptional for $name { unsafe fn set_value_optional(v: &mut glib::Value, s: Option<&Self>) { - as glib::value::SetValueOptional>::set_value_optional(v, s.map(|s| &s.0)) + <$crate::GstRc<$ref_name> as glib::value::SetValueOptional>::set_value_optional(v, s.map(|s| &s.0)) } } diff --git a/gstreamer/src/query.rs b/gstreamer/src/query.rs index 023e8e4dd..0ccf7478f 100644 --- a/gstreamer/src/query.rs +++ b/gstreamer/src/query.rs @@ -19,20 +19,13 @@ use std::ptr; use glib; use glib::translate::*; +use glib_ffi; -#[repr(C)] -pub struct QueryRef(ffi::GstQuery); +gst_define_mini_object_wrapper!(Query, QueryRef, ffi::GstQuery, [Debug,], || { + ffi::gst_query_get_type() +}); -unsafe impl Send for QueryRef {} -unsafe impl Sync for QueryRef {} - -pub type Query = GstRc; - -unsafe impl MiniObject for QueryRef { - type GstType = ffi::GstQuery; -} - -impl GstRc { +impl Query { pub fn new_position(fmt: ::Format) -> Position { assert_initialized_main_thread!(); unsafe { Position::(from_glib_full(ffi::gst_query_new_position(fmt.to_glib()))) } @@ -199,12 +192,6 @@ impl QueryRef { } } -impl glib::types::StaticType for QueryRef { - fn static_type() -> glib::types::Type { - unsafe { from_glib(ffi::gst_query_get_type()) } - } -} - impl fmt::Debug for QueryRef { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("Query") diff --git a/gstreamer/src/sample.rs b/gstreamer/src/sample.rs index c443e0bbe..cabd774f3 100644 --- a/gstreamer/src/sample.rs +++ b/gstreamer/src/sample.rs @@ -13,7 +13,7 @@ use ffi; use glib; use glib::translate::{from_glib, from_glib_full, from_glib_none, mut_override, ToGlibPtr}; -use glib::StaticType; +use glib_ffi; use miniobject::*; use Buffer; @@ -25,14 +25,11 @@ use Segment; use Structure; use StructureRef; -pub type Sample = GstRc; -pub struct SampleRef(ffi::GstSample); +gst_define_mini_object_wrapper!(Sample, SampleRef, ffi::GstSample, [Debug,], || { + ffi::gst_sample_get_type() +}); -unsafe impl MiniObject for SampleRef { - type GstType = ffi::GstSample; -} - -impl GstRc { +impl Sample { pub fn new( buffer: Option<&Buffer>, caps: Option<&Caps>, @@ -96,23 +93,6 @@ impl SampleRef { } } -impl StaticType for SampleRef { - fn static_type() -> glib::Type { - unsafe { from_glib(ffi::gst_sample_get_type()) } - } -} - -impl ToOwned for SampleRef { - type Owned = GstRc; - - fn to_owned(&self) -> GstRc { - #[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))] - unsafe { - from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _) as *mut _) - } - } -} - impl fmt::Debug for SampleRef { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("Sample") @@ -124,9 +104,6 @@ impl fmt::Debug for SampleRef { } } -unsafe impl Sync for SampleRef {} -unsafe impl Send for SampleRef {} - #[cfg(test)] mod tests { diff --git a/gstreamer/src/tags.rs b/gstreamer/src/tags.rs index 05c755e0a..f74b05ff0 100644 --- a/gstreamer/src/tags.rs +++ b/gstreamer/src/tags.rs @@ -13,9 +13,9 @@ use std::mem; use ffi; use glib; -use glib::translate::{from_glib, from_glib_full, ToGlib, ToGlibPtr, ToGlibPtrMut}; +use glib::translate::{from_glib, from_glib_full, from_glib_none, ToGlib, ToGlibPtr, ToGlibPtrMut}; use glib::value::{FromValueOptional, SendValue, SetValue, ToSendValue, TypedValue}; -use glib::StaticType; +use glib_ffi; use miniobject::*; @@ -337,21 +337,22 @@ impl_tag!( ); impl_tag!(PrivateData, Sample, TAG_PRIVATE_DATA, GST_TAG_PRIVATE_DATA); -pub type TagList = GstRc; -pub struct TagListRef(ffi::GstTagList); +gst_define_mini_object_wrapper!( + TagList, + TagListRef, + ffi::GstTagList, + [Debug, PartialEq, Eq,], + || ffi::gst_tag_list_get_type() +); -unsafe impl MiniObject for TagListRef { - type GstType = ffi::GstTagList; -} - -impl GstRc { +impl TagList { pub fn new() -> Self { assert_initialized_main_thread!(); unsafe { from_glib_full(ffi::gst_tag_list_new_empty()) } } } -impl Default for GstRc { +impl Default for TagList { fn default() -> Self { Self::new() } @@ -508,23 +509,6 @@ impl PartialEq for TagListRef { impl Eq for TagListRef {} -impl ToOwned for TagListRef { - type Owned = GstRc; - - fn to_owned(&self) -> GstRc { - unsafe { from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _) as *mut _) } - } -} - -impl StaticType for TagListRef { - fn static_type() -> glib::Type { - unsafe { from_glib(ffi::gst_tag_list_get_type()) } - } -} - -unsafe impl Sync for TagListRef {} -unsafe impl Send for TagListRef {} - pub struct TagIterator<'a, T: Tag<'a>> { taglist: &'a TagListRef, idx: u32, diff --git a/gstreamer/src/toc.rs b/gstreamer/src/toc.rs index 5ae0f28c2..69f6804a8 100644 --- a/gstreamer/src/toc.rs +++ b/gstreamer/src/toc.rs @@ -16,6 +16,7 @@ use glib; use glib::translate::{ from_glib, from_glib_full, from_glib_none, FromGlibPtrContainer, ToGlib, ToGlibPtr, }; +use glib_ffi; use miniobject::*; use TagList; @@ -24,14 +25,15 @@ use TocEntryType; use TocLoopType; use TocScope; -pub type Toc = GstRc; -pub struct TocRef(ffi::GstToc); +gst_define_mini_object_wrapper!( + Toc, + TocRef, + ffi::GstToc, + [Debug,], + || ffi::gst_toc_get_type() +); -unsafe impl MiniObject for TocRef { - type GstType = ffi::GstToc; -} - -impl GstRc { +impl Toc { pub fn new(scope: TocScope) -> Self { assert_initialized_main_thread!(); unsafe { from_glib_full(ffi::gst_toc_new(scope.to_glib())) } @@ -80,23 +82,6 @@ impl TocRef { } } -impl glib::types::StaticType for TocRef { - fn static_type() -> glib::types::Type { - unsafe { from_glib(ffi::gst_toc_get_type()) } - } -} - -impl ToOwned for TocRef { - type Owned = GstRc; - - fn to_owned(&self) -> GstRc { - #[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))] - unsafe { - from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _) as *mut _) - } - } -} - impl fmt::Debug for TocRef { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("Toc") @@ -107,17 +92,11 @@ impl fmt::Debug for TocRef { } } -unsafe impl Sync for TocRef {} -unsafe impl Send for TocRef {} +gst_define_mini_object_wrapper!(TocEntry, TocEntryRef, ffi::GstTocEntry, [Debug,], || { + ffi::gst_toc_entry_get_type() +}); -pub type TocEntry = GstRc; -pub struct TocEntryRef(ffi::GstTocEntry); - -unsafe impl MiniObject for TocEntryRef { - type GstType = ffi::GstTocEntry; -} - -impl GstRc { +impl TocEntry { pub fn new(type_: TocEntryType, uid: &str) -> Self { assert_initialized_main_thread!(); unsafe { @@ -228,23 +207,6 @@ impl TocEntryRef { } } -impl glib::types::StaticType for TocEntryRef { - fn static_type() -> glib::types::Type { - unsafe { from_glib(ffi::gst_toc_entry_get_type()) } - } -} - -impl ToOwned for TocEntryRef { - type Owned = GstRc; - - fn to_owned(&self) -> GstRc { - #[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))] - unsafe { - from_glib_full(ffi::gst_mini_object_copy(self.as_ptr() as *const _) as *mut _) - } - } -} - impl fmt::Debug for TocEntryRef { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("TocEntry") @@ -260,9 +222,6 @@ impl fmt::Debug for TocEntryRef { } } -unsafe impl Sync for TocEntryRef {} -unsafe impl Send for TocEntryRef {} - #[cfg(test)] mod tests { use super::*;