mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-22 17:41:05 +00:00
video: Add support for VideoCaptionMeta
This commit is contained in:
parent
e9edb8ddca
commit
6071c68ab6
4 changed files with 132 additions and 0 deletions
|
@ -35,6 +35,7 @@ generate = [
|
|||
"GstVideo.VideoFilter",
|
||||
"GstVideo.VideoOverlayFormatFlags",
|
||||
"GstVideo.VideoTimeCodeFlags",
|
||||
"GstVideo.VideoCaptionType",
|
||||
]
|
||||
|
||||
manual = [
|
||||
|
|
|
@ -12,6 +12,80 @@ use glib::value::Value;
|
|||
use gobject_sys;
|
||||
use gst_video_sys;
|
||||
|
||||
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
||||
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum VideoCaptionType {
|
||||
Unknown,
|
||||
Cea608Raw,
|
||||
Cea608S3341a,
|
||||
Cea708Raw,
|
||||
Cea708Cdp,
|
||||
#[doc(hidden)]
|
||||
__Unknown(i32),
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
||||
#[doc(hidden)]
|
||||
impl ToGlib for VideoCaptionType {
|
||||
type GlibType = gst_video_sys::GstVideoCaptionType;
|
||||
|
||||
fn to_glib(&self) -> gst_video_sys::GstVideoCaptionType {
|
||||
match *self {
|
||||
VideoCaptionType::Unknown => gst_video_sys::GST_VIDEO_CAPTION_TYPE_UNKNOWN,
|
||||
VideoCaptionType::Cea608Raw => gst_video_sys::GST_VIDEO_CAPTION_TYPE_CEA608_RAW,
|
||||
VideoCaptionType::Cea608S3341a => gst_video_sys::GST_VIDEO_CAPTION_TYPE_CEA608_S334_1A,
|
||||
VideoCaptionType::Cea708Raw => gst_video_sys::GST_VIDEO_CAPTION_TYPE_CEA708_RAW,
|
||||
VideoCaptionType::Cea708Cdp => gst_video_sys::GST_VIDEO_CAPTION_TYPE_CEA708_CDP,
|
||||
VideoCaptionType::__Unknown(value) => value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
||||
#[doc(hidden)]
|
||||
impl FromGlib<gst_video_sys::GstVideoCaptionType> for VideoCaptionType {
|
||||
fn from_glib(value: gst_video_sys::GstVideoCaptionType) -> Self {
|
||||
skip_assert_initialized!();
|
||||
match value {
|
||||
0 => VideoCaptionType::Unknown,
|
||||
1 => VideoCaptionType::Cea608Raw,
|
||||
2 => VideoCaptionType::Cea608S3341a,
|
||||
3 => VideoCaptionType::Cea708Raw,
|
||||
4 => VideoCaptionType::Cea708Cdp,
|
||||
value => VideoCaptionType::__Unknown(value),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
||||
impl StaticType for VideoCaptionType {
|
||||
fn static_type() -> Type {
|
||||
unsafe { from_glib(gst_video_sys::gst_video_caption_type_get_type()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
||||
impl<'a> FromValueOptional<'a> for VideoCaptionType {
|
||||
unsafe fn from_value_optional(value: &Value) -> Option<Self> {
|
||||
Some(FromValue::from_value(value))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
||||
impl<'a> FromValue<'a> for VideoCaptionType {
|
||||
unsafe fn from_value(value: &Value) -> Self {
|
||||
from_glib(gobject_sys::g_value_get_enum(value.to_glib_none().0))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
||||
impl SetValue for VideoCaptionType {
|
||||
unsafe fn set_value(value: &mut Value, this: &Self) {
|
||||
gobject_sys::g_value_set_enum(value.to_glib_none_mut().0, this.to_glib())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum VideoColorMatrix {
|
||||
|
|
|
@ -10,6 +10,8 @@ pub use self::video_overlay::{VideoOverlay, NONE_VIDEO_OVERLAY};
|
|||
pub use self::video_overlay::VideoOverlayExt;
|
||||
|
||||
mod enums;
|
||||
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
||||
pub use self::enums::VideoCaptionType;
|
||||
pub use self::enums::VideoColorMatrix;
|
||||
pub use self::enums::VideoColorPrimaries;
|
||||
#[cfg(any(feature = "v1_12", feature = "dox"))]
|
||||
|
|
|
@ -179,6 +179,61 @@ impl fmt::Debug for VideoOverlayCompositionMeta {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
||||
#[repr(C)]
|
||||
pub struct VideoCaptionMeta(gst_video_sys::GstVideoCaptionMeta);
|
||||
|
||||
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
||||
impl VideoCaptionMeta {
|
||||
pub fn add<'a>(
|
||||
buffer: &'a mut gst::BufferRef,
|
||||
caption_type: ::VideoCaptionType,
|
||||
data: &[u8],
|
||||
) -> gst::MetaRefMut<'a, Self, gst::meta::Standalone> {
|
||||
unsafe {
|
||||
let meta = gst_video_sys::gst_buffer_add_video_caption_meta(
|
||||
buffer.as_mut_ptr(),
|
||||
caption_type.to_glib(),
|
||||
data.as_ptr(),
|
||||
data.len(),
|
||||
);
|
||||
|
||||
Self::from_mut_ptr(buffer, meta)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_caption_type(&self) -> ::VideoCaptionType {
|
||||
from_glib(self.0.caption_type)
|
||||
}
|
||||
|
||||
pub fn get_data(&self) -> &[u8] {
|
||||
unsafe {
|
||||
use std::slice;
|
||||
|
||||
slice::from_raw_parts(self.0.data, self.0.size)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
||||
unsafe impl MetaAPI for VideoCaptionMeta {
|
||||
type GstType = gst_video_sys::GstVideoCaptionMeta;
|
||||
|
||||
fn get_meta_api() -> glib::Type {
|
||||
unsafe { from_glib(gst_video_sys::gst_video_caption_meta_api_get_type()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
||||
impl fmt::Debug for VideoCaptionMeta {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("VideoCaptionMeta")
|
||||
.field("caption_type", &self.get_caption_type())
|
||||
.field("data", &self.get_data())
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
Loading…
Reference in a new issue