forked from mirrors/gstreamer-rs
Remove some unneeded lifetime annotations from video meta code and pass more parameters by reference
This commit is contained in:
parent
7189a6a7c1
commit
e4ecc88825
1 changed files with 9 additions and 21 deletions
|
@ -11,7 +11,6 @@ use std::fmt;
|
||||||
use ffi;
|
use ffi;
|
||||||
use glib;
|
use glib;
|
||||||
use glib::translate::{from_glib, ToGlib};
|
use glib::translate::{from_glib, ToGlib};
|
||||||
use glib_ffi;
|
|
||||||
use gst;
|
use gst;
|
||||||
use gst::prelude::*;
|
use gst::prelude::*;
|
||||||
use gst_ffi;
|
use gst_ffi;
|
||||||
|
@ -20,13 +19,13 @@ use gst_ffi;
|
||||||
pub struct VideoMeta(ffi::GstVideoMeta);
|
pub struct VideoMeta(ffi::GstVideoMeta);
|
||||||
|
|
||||||
impl VideoMeta {
|
impl VideoMeta {
|
||||||
pub fn add<'a>(
|
pub fn add(
|
||||||
buffer: &'a mut gst::BufferRef,
|
buffer: &mut gst::BufferRef,
|
||||||
flags: ::VideoFrameFlags,
|
flags: ::VideoFrameFlags,
|
||||||
format: ::VideoFormat,
|
format: ::VideoFormat,
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
) -> gst::MetaRefMut<'a, Self, gst::meta::Standalone> {
|
) -> gst::MetaRefMut<Self, gst::meta::Standalone> {
|
||||||
let info = ::VideoInfo::new(format, width, height).build().unwrap();
|
let info = ::VideoInfo::new(format, width, height).build().unwrap();
|
||||||
assert!(buffer.get_size() >= info.size());
|
assert!(buffer.get_size() >= info.size());
|
||||||
|
|
||||||
|
@ -50,12 +49,12 @@ impl VideoMeta {
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
n_planes: u32,
|
n_planes: u32,
|
||||||
offset: [usize; 4],
|
offset: &[usize; 4],
|
||||||
stride: [i32; 4],
|
stride: &[i32; 4],
|
||||||
) -> gst::MetaRefMut<'a, Self, gst::meta::Standalone> {
|
) -> gst::MetaRefMut<'a, Self, gst::meta::Standalone> {
|
||||||
let info = ::VideoInfo::new(format, width, height)
|
let info = ::VideoInfo::new(format, width, height)
|
||||||
.offset(&offset)
|
.offset(offset)
|
||||||
.stride(&stride)
|
.stride(stride)
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert!(buffer.get_size() >= info.size());
|
assert!(buffer.get_size() >= info.size());
|
||||||
|
@ -138,7 +137,7 @@ pub struct VideoOverlayCompositionMeta(ffi::GstVideoOverlayCompositionMeta);
|
||||||
impl VideoOverlayCompositionMeta {
|
impl VideoOverlayCompositionMeta {
|
||||||
pub fn add<'a>(
|
pub fn add<'a>(
|
||||||
buffer: &'a mut gst::BufferRef,
|
buffer: &'a mut gst::BufferRef,
|
||||||
overlay: ::VideoOverlayComposition,
|
overlay: &::VideoOverlayComposition,
|
||||||
) -> gst::MetaRefMut<'a, Self, gst::meta::Standalone> {
|
) -> gst::MetaRefMut<'a, Self, gst::meta::Standalone> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let meta = ffi::gst_buffer_add_video_overlay_composition_meta(
|
let meta = ffi::gst_buffer_add_video_overlay_composition_meta(
|
||||||
|
@ -154,18 +153,7 @@ impl VideoOverlayCompositionMeta {
|
||||||
unsafe { ::VideoOverlayCompositionRef::from_ptr(self.0.overlay) }
|
unsafe { ::VideoOverlayCompositionRef::from_ptr(self.0.overlay) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_overlay_mut(&mut self) -> Option<&mut ::VideoOverlayCompositionRef> {
|
pub fn set_overlay(&mut self, overlay: &::VideoOverlayComposition) {
|
||||||
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) {
|
|
||||||
unsafe {
|
unsafe {
|
||||||
gst_ffi::gst_mini_object_unref(self.0.overlay as *mut _);
|
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 _;
|
self.0.overlay = gst_ffi::gst_mini_object_ref(overlay.as_mut_ptr() as *mut _) as *mut _;
|
||||||
|
|
Loading…
Reference in a new issue