Commit 4a8e860a authored by Vivia Nikolaidou's avatar Vivia Nikolaidou 🦆 Committed by Sebastian Dröge

gstreamer-video: Expose VideoBufferPool

Closes gstreamer/gstreamer-rs#12
parent 6461a3ab
Pipeline #38486 passed with stages
in 19 minutes and 3 seconds
......@@ -37,11 +37,13 @@ generate = [
"GstVideo.VideoOverlayFormatFlags",
"GstVideo.VideoTimeCodeFlags",
"GstVideo.VideoCaptionType",
"GstVideo.VideoBufferPool",
]
manual = [
"GLib.DateTime",
"GObject.Object",
"Gst.BufferPool",
"Gst.Object",
"Gst.Element",
"Gst.Buffer",
......
......@@ -6,6 +6,9 @@ mod video_decoder;
pub use self::video_decoder::{VideoDecoder, VideoDecoderClass, NONE_VIDEO_DECODER};
pub use self::video_decoder::VideoDecoderExt;
mod video_buffer_pool;
pub use self::video_buffer_pool::{VideoBufferPool, VideoBufferPoolClass, NONE_VIDEO_BUFFER_POOL};
mod video_filter;
pub use self::video_filter::{VideoFilter, VideoFilterClass, NONE_VIDEO_FILTER};
......
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use glib::object::Cast;
use glib::translate::*;
use gst;
use gst_video_sys;
glib_wrapper! {
pub struct VideoBufferPool(Object<gst_video_sys::GstVideoBufferPool, gst_video_sys::GstVideoBufferPoolClass, VideoBufferPoolClass>) @extends gst::BufferPool, gst::Object;
match fn {
get_type => || gst_video_sys::gst_video_buffer_pool_get_type(),
}
}
impl VideoBufferPool {
pub fn new() -> VideoBufferPool {
assert_initialized_main_thread!();
unsafe {
gst::BufferPool::from_glib_full(gst_video_sys::gst_video_buffer_pool_new()).unsafe_cast()
}
}
}
impl Default for VideoBufferPool {
fn default() -> Self {
Self::new()
}
}
unsafe impl Send for VideoBufferPool {}
unsafe impl Sync for VideoBufferPool {}
pub const NONE_VIDEO_BUFFER_POOL: Option<&VideoBufferPool> = None;
......@@ -74,8 +74,9 @@ mod video_time_code_interval;
pub use video_time_code_interval::VideoTimeCodeInterval;
mod video_buffer_pool;
pub use video_buffer_pool::{
BUFFER_POOL_OPTION_VIDEO_AFFINE_TRANSFORMATION_META, BUFFER_POOL_OPTION_VIDEO_ALIGNMENT,
BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META, BUFFER_POOL_OPTION_VIDEO_META,
VideoAlignment, BUFFER_POOL_OPTION_VIDEO_AFFINE_TRANSFORMATION_META,
BUFFER_POOL_OPTION_VIDEO_ALIGNMENT, BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META,
BUFFER_POOL_OPTION_VIDEO_META,
};
mod video_codec_frame;
......@@ -92,6 +93,7 @@ pub mod prelude {
pub use gst::prelude::*;
pub use auto::traits::*;
pub use video_buffer_pool::VideoBufferPoolConfig;
pub use video_decoder::VideoDecoderExtManual;
pub use video_overlay::VideoOverlayExtManual;
}
......
// Copyright (C) 2019 Guillaume Desmottes <guillaume.desmottes@collabora.com>
// Copyright (C) 2019 Vivia Nikolaidou <vivia@ahiru.eu>
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
......@@ -7,6 +8,9 @@
// except according to those terms.
use std::ffi::CStr;
use std::mem;
use glib::translate::*;
lazy_static! {
pub static ref BUFFER_POOL_OPTION_VIDEO_AFFINE_TRANSFORMATION_META: &'static str = unsafe {
......@@ -30,3 +34,80 @@ lazy_static! {
.unwrap()
};
}
#[derive(Debug, Clone)]
pub struct VideoAlignment(gst_video_sys::GstVideoAlignment);
impl VideoAlignment {
pub fn get_padding_top(&self) -> u32 {
self.0.padding_top
}
pub fn get_padding_bottom(&self) -> u32 {
self.0.padding_bottom
}
pub fn get_padding_left(&self) -> u32 {
self.0.padding_left
}
pub fn get_padding_right(&self) -> u32 {
self.0.padding_right
}
pub fn get_stride_align(&self) -> &[u32; gst_video_sys::GST_VIDEO_MAX_PLANES as usize] {
&self.0.stride_align
}
pub fn new(
padding_top: u32,
padding_bottom: u32,
padding_left: u32,
padding_right: u32,
stride_align: &[u32; gst_video_sys::GST_VIDEO_MAX_PLANES as usize],
) -> Self {
assert_initialized_main_thread!();
let videoalignment = unsafe {
let mut videoalignment: gst_video_sys::GstVideoAlignment = mem::zeroed();
videoalignment.padding_top = padding_top;
videoalignment.padding_bottom = padding_bottom;
videoalignment.padding_left = padding_left;
videoalignment.padding_right = padding_right;
videoalignment.stride_align = *stride_align;
videoalignment
};
VideoAlignment(videoalignment)
}
}
pub trait VideoBufferPoolConfig {
fn get_video_alignment(&self) -> Option<VideoAlignment>;
fn set_video_alignment(&mut self, align: &VideoAlignment);
}
impl VideoBufferPoolConfig for gst::BufferPoolConfig {
fn get_video_alignment(&self) -> Option<VideoAlignment> {
unsafe {
let mut alignment: VideoAlignment = mem::zeroed();
let ret = from_glib(gst_video_sys::gst_buffer_pool_config_get_video_alignment(
self.as_ref().as_mut_ptr(),
&mut alignment.0,
));
if ret {
Some(alignment)
} else {
None
}
}
}
fn set_video_alignment(&mut self, align: &VideoAlignment) {
unsafe {
gst_video_sys::gst_buffer_pool_config_set_video_alignment(
self.as_mut().as_mut_ptr(),
&align.0 as *const _ as *mut _,
)
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment