From bc991708e52579b5006cbbcbadf2679b54dfddc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 1 Dec 2017 11:32:04 +0200 Subject: [PATCH] Implement ToOwned for Message/Event/QueryRef --- gstreamer/src/event.rs | 11 +++++++++++ gstreamer/src/message.rs | 11 +++++++++++ gstreamer/src/query.rs | 11 +++++++++++ 3 files changed, 33 insertions(+) diff --git a/gstreamer/src/event.rs b/gstreamer/src/event.rs index 4a1623bda..01da9adac 100644 --- a/gstreamer/src/event.rs +++ b/gstreamer/src/event.rs @@ -307,6 +307,17 @@ impl glib::types::StaticType 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/message.rs b/gstreamer/src/message.rs index 05a8f443d..86669676a 100644 --- a/gstreamer/src/message.rs +++ b/gstreamer/src/message.rs @@ -342,6 +342,17 @@ impl glib::types::StaticType 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/query.rs b/gstreamer/src/query.rs index 748523898..260740f5f 100644 --- a/gstreamer/src/query.rs +++ b/gstreamer/src/query.rs @@ -182,6 +182,17 @@ impl glib::types::StaticType for QueryRef { } } +impl ToOwned for QueryRef { + 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 QueryView { Position(Position), Duration(Duration),