diff --git a/gstreamer-sdp/src/sdp_media.rs b/gstreamer-sdp/src/sdp_media.rs index c2ceda0b9..2a814c292 100644 --- a/gstreamer-sdp/src/sdp_media.rs +++ b/gstreamer-sdp/src/sdp_media.rs @@ -6,6 +6,7 @@ // // 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; @@ -632,6 +633,30 @@ impl SDPMediaRef { } } +impl Borrow for SDPMedia { + fn borrow(&self) -> &SDPMediaRef { + &*self + } +} + +impl BorrowMut for SDPMedia { + fn borrow_mut(&mut self) -> &mut SDPMediaRef { + &mut *self + } +} + +impl ToOwned for SDPMediaRef { + type Owned = SDPMedia; + + fn to_owned(&self) -> SDPMedia { + unsafe { + let mut ptr = ptr::null_mut(); + ffi::gst_sdp_media_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)]