mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-12-28 11:00:34 +00:00
video: Generate VideoBufferFlags and add a extension trait for setting/getting them on buffers
This commit is contained in:
parent
36b0cafc5e
commit
e3282c27f1
5 changed files with 88 additions and 1 deletions
|
@ -39,6 +39,7 @@ generate = [
|
|||
"GstVideo.VideoCaptionType",
|
||||
"GstVideo.VideoBufferPool",
|
||||
"GstVideo.VideoPackFlags",
|
||||
"GstVideo.VideoBufferFlags",
|
||||
]
|
||||
|
||||
manual = [
|
||||
|
|
|
@ -12,6 +12,61 @@ use glib::Type;
|
|||
use gobject_sys;
|
||||
use gst_video_sys;
|
||||
|
||||
bitflags! {
|
||||
pub struct VideoBufferFlags: u32 {
|
||||
const INTERLACED = 1048576;
|
||||
const TFF = 2097152;
|
||||
const RFF = 4194304;
|
||||
const ONEFIELD = 8388608;
|
||||
const MULTIPLE_VIEW = 16777216;
|
||||
const FIRST_IN_BUNDLE = 33554432;
|
||||
const TOP_FIELD = 10485760;
|
||||
const BOTTOM_FIELD = 8388608;
|
||||
const LAST = 268435456;
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
impl ToGlib for VideoBufferFlags {
|
||||
type GlibType = gst_video_sys::GstVideoBufferFlags;
|
||||
|
||||
fn to_glib(&self) -> gst_video_sys::GstVideoBufferFlags {
|
||||
self.bits()
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
impl FromGlib<gst_video_sys::GstVideoBufferFlags> for VideoBufferFlags {
|
||||
fn from_glib(value: gst_video_sys::GstVideoBufferFlags) -> VideoBufferFlags {
|
||||
skip_assert_initialized!();
|
||||
VideoBufferFlags::from_bits_truncate(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl StaticType for VideoBufferFlags {
|
||||
fn static_type() -> Type {
|
||||
unsafe { from_glib(gst_video_sys::gst_video_buffer_flags_get_type()) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> FromValueOptional<'a> for VideoBufferFlags {
|
||||
unsafe fn from_value_optional(value: &Value) -> Option<Self> {
|
||||
Some(FromValue::from_value(value))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> FromValue<'a> for VideoBufferFlags {
|
||||
unsafe fn from_value(value: &Value) -> Self {
|
||||
from_glib(gobject_sys::g_value_get_flags(value.to_glib_none().0))
|
||||
}
|
||||
}
|
||||
|
||||
impl SetValue for VideoBufferFlags {
|
||||
unsafe fn set_value(value: &mut Value, this: &Self) {
|
||||
gobject_sys::g_value_set_flags(value.to_glib_none_mut().0, this.to_glib())
|
||||
}
|
||||
}
|
||||
|
||||
bitflags! {
|
||||
pub struct VideoChromaSite: u32 {
|
||||
const UNKNOWN = 0;
|
||||
|
|
|
@ -35,6 +35,7 @@ pub use self::enums::VideoTileMode;
|
|||
pub use self::enums::VideoTransferFunction;
|
||||
|
||||
mod flags;
|
||||
pub use self::flags::VideoBufferFlags;
|
||||
pub use self::flags::VideoChromaSite;
|
||||
pub use self::flags::VideoCodecFrameFlags;
|
||||
pub use self::flags::VideoFlags;
|
||||
|
|
|
@ -50,7 +50,7 @@ pub use video_format_info::*;
|
|||
mod video_info;
|
||||
pub use video_info::*;
|
||||
pub mod video_frame;
|
||||
pub use video_frame::{VideoFrame, VideoFrameRef};
|
||||
pub use video_frame::{VideoBufferExt, VideoFrame, VideoFrameRef};
|
||||
mod video_overlay;
|
||||
pub use video_overlay::*;
|
||||
mod video_event;
|
||||
|
@ -96,6 +96,7 @@ pub mod prelude {
|
|||
pub use video_buffer_pool::VideoBufferPoolConfig;
|
||||
pub use video_decoder::VideoDecoderExtManual;
|
||||
pub use video_encoder::VideoEncoderExtManual;
|
||||
pub use video_frame::VideoBufferExt;
|
||||
pub use video_overlay::VideoOverlayExtManual;
|
||||
}
|
||||
|
||||
|
|
|
@ -673,6 +673,35 @@ impl<T> Drop for VideoFrameRef<T> {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait VideoBufferExt {
|
||||
fn get_video_flags(&self) -> ::VideoBufferFlags;
|
||||
fn set_video_flags(&mut self, flags: ::VideoBufferFlags);
|
||||
fn unset_video_flags(&mut self, flags: ::VideoBufferFlags);
|
||||
}
|
||||
|
||||
impl VideoBufferExt for gst::BufferRef {
|
||||
fn get_video_flags(&self) -> ::VideoBufferFlags {
|
||||
unsafe {
|
||||
let ptr = self.as_mut_ptr();
|
||||
::VideoBufferFlags::from_bits_truncate((*ptr).mini_object.flags)
|
||||
}
|
||||
}
|
||||
|
||||
fn set_video_flags(&mut self, flags: ::VideoBufferFlags) {
|
||||
unsafe {
|
||||
let ptr = self.as_mut_ptr();
|
||||
(*ptr).mini_object.flags |= flags.bits();
|
||||
}
|
||||
}
|
||||
|
||||
fn unset_video_flags(&mut self, flags: ::VideoBufferFlags) {
|
||||
unsafe {
|
||||
let ptr = self.as_mut_ptr();
|
||||
(*ptr).mini_object.flags &= !flags.bits();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
Loading…
Reference in a new issue