diff --git a/gstreamer-sdp/src/sdp_message.rs b/gstreamer-sdp/src/sdp_message.rs index f5f27ca60..295a1dc07 100644 --- a/gstreamer-sdp/src/sdp_message.rs +++ b/gstreamer-sdp/src/sdp_message.rs @@ -6,11 +6,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::borrow::{Borrow, BorrowMut, ToOwned}; use std::ffi::CStr; use std::fmt; use std::mem; use std::ops; -#[cfg(any(feature = "v1_8_1", feature = "dox"))] use std::ptr; use ffi; @@ -929,6 +929,30 @@ impl SDPMessageRef { } } +impl Borrow for SDPMessage { + fn borrow(&self) -> &SDPMessageRef { + &*self + } +} + +impl BorrowMut for SDPMessage { + fn borrow_mut(&mut self) -> &mut SDPMessageRef { + &mut *self + } +} + +impl ToOwned for SDPMessageRef { + type Owned = SDPMessage; + + fn to_owned(&self) -> SDPMessage { + unsafe { + let mut ptr = ptr::null_mut(); + ffi::gst_sdp_message_copy(&self.0, &mut ptr); + from_glib_full(ptr) + } + } +} + macro_rules! define_iter( ($name:ident, $typ:ty, $get_item:expr, $get_len:expr) => { #[derive(Debug)]