2020-12-15 10:53:31 +00:00
|
|
|
// Take a look at the license at the top of the repository in the LICENSE file.
|
2019-05-23 13:07:02 +00:00
|
|
|
|
2023-01-15 18:38:13 +00:00
|
|
|
use std::{marker::PhantomData, mem};
|
2019-05-12 15:17:33 +00:00
|
|
|
|
2024-06-02 08:48:53 +00:00
|
|
|
use crate::ffi;
|
2019-05-12 15:17:33 +00:00
|
|
|
use glib::translate::*;
|
2020-01-22 17:38:13 +00:00
|
|
|
|
2023-01-15 18:38:13 +00:00
|
|
|
pub static BUFFER_POOL_OPTION_VIDEO_AFFINE_TRANSFORMATION_META: &glib::GStr = unsafe {
|
|
|
|
glib::GStr::from_utf8_with_nul_unchecked(
|
|
|
|
ffi::GST_BUFFER_POOL_OPTION_VIDEO_AFFINE_TRANSFORMATION_META,
|
|
|
|
)
|
|
|
|
};
|
|
|
|
pub static BUFFER_POOL_OPTION_VIDEO_ALIGNMENT: &glib::GStr = unsafe {
|
|
|
|
glib::GStr::from_utf8_with_nul_unchecked(ffi::GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT)
|
|
|
|
};
|
|
|
|
pub static BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META: &glib::GStr = unsafe {
|
|
|
|
glib::GStr::from_utf8_with_nul_unchecked(
|
|
|
|
ffi::GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META,
|
|
|
|
)
|
|
|
|
};
|
|
|
|
pub static BUFFER_POOL_OPTION_VIDEO_META: &glib::GStr =
|
|
|
|
unsafe { glib::GStr::from_utf8_with_nul_unchecked(ffi::GST_BUFFER_POOL_OPTION_VIDEO_META) };
|
2019-05-12 15:17:33 +00:00
|
|
|
|
|
|
|
#[derive(Debug, Clone)]
|
2021-06-01 13:15:59 +00:00
|
|
|
#[doc(alias = "GstVideoAlignment")]
|
2020-11-22 09:53:17 +00:00
|
|
|
pub struct VideoAlignment(pub(crate) ffi::GstVideoAlignment);
|
2019-05-12 15:17:33 +00:00
|
|
|
|
|
|
|
impl VideoAlignment {
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_padding_top")]
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn padding_top(&self) -> u32 {
|
2019-05-12 15:17:33 +00:00
|
|
|
self.0.padding_top
|
|
|
|
}
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_padding_bottom")]
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn padding_bottom(&self) -> u32 {
|
2019-05-12 15:17:33 +00:00
|
|
|
self.0.padding_bottom
|
|
|
|
}
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_padding_left")]
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn padding_left(&self) -> u32 {
|
2019-05-12 15:17:33 +00:00
|
|
|
self.0.padding_left
|
|
|
|
}
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_padding_right")]
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn padding_right(&self) -> u32 {
|
2019-05-12 15:17:33 +00:00
|
|
|
self.0.padding_right
|
|
|
|
}
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_stride_align")]
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn stride_align(&self) -> &[u32; ffi::GST_VIDEO_MAX_PLANES as usize] {
|
2019-05-12 15:17:33 +00:00
|
|
|
&self.0.stride_align
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn new(
|
|
|
|
padding_top: u32,
|
|
|
|
padding_bottom: u32,
|
|
|
|
padding_left: u32,
|
|
|
|
padding_right: u32,
|
2020-11-22 09:53:17 +00:00
|
|
|
stride_align: &[u32; ffi::GST_VIDEO_MAX_PLANES as usize],
|
2019-05-12 15:17:33 +00:00
|
|
|
) -> Self {
|
2022-12-25 10:47:02 +00:00
|
|
|
skip_assert_initialized!();
|
2019-05-12 15:17:33 +00:00
|
|
|
|
2021-01-10 13:30:58 +00:00
|
|
|
let videoalignment = ffi::GstVideoAlignment {
|
|
|
|
padding_top,
|
|
|
|
padding_bottom,
|
|
|
|
padding_left,
|
|
|
|
padding_right,
|
|
|
|
stride_align: *stride_align,
|
2019-05-12 15:17:33 +00:00
|
|
|
};
|
|
|
|
|
2021-04-29 20:49:40 +00:00
|
|
|
Self(videoalignment)
|
2019-05-12 15:17:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-03 10:37:19 +00:00
|
|
|
impl PartialEq for VideoAlignment {
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2021-04-29 20:49:40 +00:00
|
|
|
fn eq(&self, other: &Self) -> bool {
|
2021-04-11 19:39:50 +00:00
|
|
|
self.padding_top() == other.padding_top()
|
|
|
|
&& self.padding_bottom() == other.padding_bottom()
|
|
|
|
&& self.padding_left() == other.padding_left()
|
|
|
|
&& self.padding_right() == other.padding_right()
|
|
|
|
&& self.stride_align() == other.stride_align()
|
2020-12-03 10:37:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Eq for VideoAlignment {}
|
|
|
|
|
2021-01-04 22:45:29 +00:00
|
|
|
#[doc(hidden)]
|
|
|
|
impl<'a> ToGlibPtr<'a, *const ffi::GstVideoAlignment> for VideoAlignment {
|
2022-12-17 16:48:35 +00:00
|
|
|
type Storage = PhantomData<&'a Self>;
|
2021-01-04 22:45:29 +00:00
|
|
|
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2021-01-04 22:45:29 +00:00
|
|
|
fn to_glib_none(&'a self) -> Stash<*const ffi::GstVideoAlignment, Self> {
|
2022-12-17 16:48:35 +00:00
|
|
|
Stash(&self.0, PhantomData)
|
2021-01-04 22:45:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-12 15:17:33 +00:00
|
|
|
pub trait VideoBufferPoolConfig {
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_video_alignment")]
|
2021-04-11 19:39:50 +00:00
|
|
|
fn video_alignment(&self) -> Option<VideoAlignment>;
|
2019-05-12 15:17:33 +00:00
|
|
|
|
|
|
|
fn set_video_alignment(&mut self, align: &VideoAlignment);
|
|
|
|
}
|
|
|
|
|
2023-01-07 17:28:30 +00:00
|
|
|
impl VideoBufferPoolConfig for gst::BufferPoolConfigRef {
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_buffer_pool_config_get_video_alignment")]
|
2021-04-11 19:39:50 +00:00
|
|
|
fn video_alignment(&self) -> Option<VideoAlignment> {
|
2019-05-12 15:17:33 +00:00
|
|
|
unsafe {
|
2023-01-06 12:11:45 +00:00
|
|
|
let mut alignment = mem::MaybeUninit::uninit();
|
2020-11-22 09:53:17 +00:00
|
|
|
let ret = from_glib(ffi::gst_buffer_pool_config_get_video_alignment(
|
2019-05-12 15:17:33 +00:00
|
|
|
self.as_ref().as_mut_ptr(),
|
2019-07-11 13:02:46 +00:00
|
|
|
alignment.as_mut_ptr(),
|
2019-05-12 15:17:33 +00:00
|
|
|
));
|
|
|
|
if ret {
|
2019-07-11 13:02:46 +00:00
|
|
|
Some(VideoAlignment(alignment.assume_init()))
|
2019-05-12 15:17:33 +00:00
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_buffer_pool_config_set_video_alignment")]
|
2019-05-12 15:17:33 +00:00
|
|
|
fn set_video_alignment(&mut self, align: &VideoAlignment) {
|
|
|
|
unsafe {
|
2020-11-22 09:53:17 +00:00
|
|
|
ffi::gst_buffer_pool_config_set_video_alignment(
|
2019-05-12 15:17:33 +00:00
|
|
|
self.as_mut().as_mut_ptr(),
|
2023-11-29 09:24:47 +00:00
|
|
|
mut_override(&align.0),
|
2019-05-12 15:17:33 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|