Commit cb8ca2c0 authored by Sebastian Dröge's avatar Sebastian Dröge 🍵

Add VideoFrame bindings

parent 18871110
......@@ -27,6 +27,7 @@ generate = [
"GstVideo.VideoMultiviewMode",
"GstVideo.VideoMultiviewFlags",
"GstVideo.VideoFieldOrder",
"GstVideo.VideoFrameFlags",
]
manual = [
......@@ -36,6 +37,7 @@ manual = [
"GstVideo.VideoFormatInfo",
"GstVideo.VideoColorimetry",
"GstVideo.VideoColorRange",
"GstVideo.VideoFrame",
]
[[object]]
......
......@@ -167,6 +167,59 @@ impl SetValue for VideoFormatFlags {
}
}
bitflags! {
pub struct VideoFrameFlags: u32 {
const VIDEO_FRAME_FLAG_NONE = 0;
const VIDEO_FRAME_FLAG_INTERLACED = 1;
const VIDEO_FRAME_FLAG_TFF = 2;
const VIDEO_FRAME_FLAG_RFF = 4;
const VIDEO_FRAME_FLAG_ONEFIELD = 8;
const VIDEO_FRAME_FLAG_MULTIPLE_VIEW = 16;
const VIDEO_FRAME_FLAG_FIRST_IN_BUNDLE = 32;
}
}
#[doc(hidden)]
impl ToGlib for VideoFrameFlags {
type GlibType = ffi::GstVideoFrameFlags;
fn to_glib(&self) -> ffi::GstVideoFrameFlags {
ffi::GstVideoFrameFlags::from_bits_truncate(self.bits())
}
}
#[doc(hidden)]
impl FromGlib<ffi::GstVideoFrameFlags> for VideoFrameFlags {
fn from_glib(value: ffi::GstVideoFrameFlags) -> VideoFrameFlags {
skip_assert_initialized!();
VideoFrameFlags::from_bits_truncate(value.bits())
}
}
impl StaticType for VideoFrameFlags {
fn static_type() -> Type {
unsafe { from_glib(ffi::gst_video_frame_flags_get_type()) }
}
}
impl<'a> FromValueOptional<'a> for VideoFrameFlags {
unsafe fn from_value_optional(value: &Value) -> Option<Self> {
Some(FromValue::from_value(value))
}
}
impl<'a> FromValue<'a> for VideoFrameFlags {
unsafe fn from_value(value: &Value) -> Self {
from_glib(ffi::GstVideoFrameFlags::from_bits_truncate(gobject_ffi::g_value_get_flags(value.to_glib_none().0)))
}
}
impl SetValue for VideoFrameFlags {
unsafe fn set_value(value: &mut Value, this: &Self) {
gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, this.to_glib().bits())
}
}
bitflags! {
pub struct VideoMultiviewFlags: u32 {
const VIDEO_MULTIVIEW_FLAGS_NONE = 0;
......
......@@ -37,6 +37,14 @@ pub use self::flags::VIDEO_FORMAT_FLAG_PALETTE;
pub use self::flags::VIDEO_FORMAT_FLAG_COMPLEX;
pub use self::flags::VIDEO_FORMAT_FLAG_UNPACK;
pub use self::flags::VIDEO_FORMAT_FLAG_TILED;
pub use self::flags::VideoFrameFlags;
pub use self::flags::VIDEO_FRAME_FLAG_NONE;
pub use self::flags::VIDEO_FRAME_FLAG_INTERLACED;
pub use self::flags::VIDEO_FRAME_FLAG_TFF;
pub use self::flags::VIDEO_FRAME_FLAG_RFF;
pub use self::flags::VIDEO_FRAME_FLAG_ONEFIELD;
pub use self::flags::VIDEO_FRAME_FLAG_MULTIPLE_VIEW;
pub use self::flags::VIDEO_FRAME_FLAG_FIRST_IN_BUNDLE;
pub use self::flags::VideoMultiviewFlags;
pub use self::flags::VIDEO_MULTIVIEW_FLAGS_NONE;
pub use self::flags::VIDEO_MULTIVIEW_FLAGS_RIGHT_VIEW_FIRST;
......
......@@ -38,3 +38,5 @@ mod video_format_info;
pub use video_format_info::*;
mod video_info;
pub use video_info::*;
mod video_frame;
pub use video_frame::VideoFrame;
This diff is collapsed.
......@@ -161,7 +161,7 @@ impl fmt::Display for ::VideoColorimetry {
}
}
pub struct VideoInfo(ffi::GstVideoInfo);
pub struct VideoInfo(pub(crate) ffi::GstVideoInfo);
pub struct VideoInfoBuilder<'a> {
format: ::VideoFormat,
......@@ -658,6 +658,61 @@ impl glib::translate::FromGlibPtrFull<*mut ffi::GstVideoInfo> for VideoInfo {
}
}
#[cfg(feature = "v1_12")]
impl ::VideoFieldOrder {
pub fn to_string(&self) -> String {
unsafe { from_glib_full(ffi::gst_video_field_order_to_string(self.to_glib())) }
}
pub fn from_string(s: &str) -> Option<Self> {
unsafe { from_glib(ffi::gst_video_field_order_from_string(s.to_glib_none().0)) }
}
}
#[cfg(feature = "v1_12")]
impl str::FromStr for ::VideoFieldOrder {
type Err = ();
fn from_str(s: &str) -> Result<Self, ()> {
Self::from_string(s).ok_or(())
}
}
#[cfg(feature = "v1_12")]
impl fmt::Display for ::VideoFieldOrder {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
f.write_str(&self.to_string())
}
}
impl ::VideoInterlaceMode {
pub fn to_string(&self) -> String {
unsafe { from_glib_full(ffi::gst_video_interlace_mode_to_string(self.to_glib())) }
}
pub fn from_string(s: &str) -> Self {
unsafe {
from_glib(ffi::gst_video_interlace_mode_from_string(
s.to_glib_none().0,
))
}
}
}
impl str::FromStr for ::VideoInterlaceMode {
type Err = ();
fn from_str(s: &str) -> Result<Self, ()> {
Ok(Self::from_string(s))
}
}
impl fmt::Display for ::VideoInterlaceMode {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
f.write_str(&self.to_string())
}
}
#[cfg(test)]
mod tests {
use super::*;
......
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