From e4ecc888253fbeb11d3b4798546d77aefb7d0501 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 11 Oct 2018 11:40:00 +0300 Subject: [PATCH] Remove some unneeded lifetime annotations from video meta code and pass more parameters by reference --- gstreamer-video/src/video_meta.rs | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/gstreamer-video/src/video_meta.rs b/gstreamer-video/src/video_meta.rs index 12950ea7d..dcc1cc043 100644 --- a/gstreamer-video/src/video_meta.rs +++ b/gstreamer-video/src/video_meta.rs @@ -11,7 +11,6 @@ use std::fmt; use ffi; use glib; use glib::translate::{from_glib, ToGlib}; -use glib_ffi; use gst; use gst::prelude::*; use gst_ffi; @@ -20,13 +19,13 @@ use gst_ffi; pub struct VideoMeta(ffi::GstVideoMeta); impl VideoMeta { - pub fn add<'a>( - buffer: &'a mut gst::BufferRef, + pub fn add( + buffer: &mut gst::BufferRef, flags: ::VideoFrameFlags, format: ::VideoFormat, width: u32, height: u32, - ) -> gst::MetaRefMut<'a, Self, gst::meta::Standalone> { + ) -> gst::MetaRefMut { let info = ::VideoInfo::new(format, width, height).build().unwrap(); assert!(buffer.get_size() >= info.size()); @@ -50,12 +49,12 @@ impl VideoMeta { width: u32, height: u32, n_planes: u32, - offset: [usize; 4], - stride: [i32; 4], + offset: &[usize; 4], + stride: &[i32; 4], ) -> gst::MetaRefMut<'a, Self, gst::meta::Standalone> { let info = ::VideoInfo::new(format, width, height) - .offset(&offset) - .stride(&stride) + .offset(offset) + .stride(stride) .build() .unwrap(); assert!(buffer.get_size() >= info.size()); @@ -138,7 +137,7 @@ pub struct VideoOverlayCompositionMeta(ffi::GstVideoOverlayCompositionMeta); impl VideoOverlayCompositionMeta { pub fn add<'a>( buffer: &'a mut gst::BufferRef, - overlay: ::VideoOverlayComposition, + overlay: &::VideoOverlayComposition, ) -> gst::MetaRefMut<'a, Self, gst::meta::Standalone> { unsafe { let meta = ffi::gst_buffer_add_video_overlay_composition_meta( @@ -154,18 +153,7 @@ impl VideoOverlayCompositionMeta { unsafe { ::VideoOverlayCompositionRef::from_ptr(self.0.overlay) } } - pub fn get_overlay_mut(&mut self) -> Option<&mut ::VideoOverlayCompositionRef> { - unsafe { - if gst_ffi::gst_mini_object_is_writable(self.0.overlay as *const _) == glib_ffi::GFALSE - { - return None; - } - - Some(::VideoOverlayCompositionRef::from_mut_ptr(self.0.overlay)) - } - } - - pub fn set_overlay(&mut self, overlay: ::VideoOverlayComposition) { + pub fn set_overlay(&mut self, overlay: &::VideoOverlayComposition) { unsafe { gst_ffi::gst_mini_object_unref(self.0.overlay as *mut _); self.0.overlay = gst_ffi::gst_mini_object_ref(overlay.as_mut_ptr() as *mut _) as *mut _;