gstreamer: Add gst::MetaFlags and accessor on meta

This commit is contained in:
Sebastian Dröge 2021-11-16 13:05:47 +02:00
parent 1eba9b64e5
commit df36a7c57a
4 changed files with 91 additions and 0 deletions

View file

@ -2268,3 +2268,13 @@ status = "generate"
[[object.derive]]
name = "Debug, PartialEq, Eq, PartialOrd, Ord, Hash"
[[object]]
name = "Gst.MetaFlags"
status = "generate"
[[object.member]]
name = "none"
ignore = true
[[object.member]]
name = "last"
ignore = true

View file

@ -799,6 +799,68 @@ impl ToValue for MemoryFlags {
}
}
bitflags! {
#[doc(alias = "GstMetaFlags")]
pub struct MetaFlags: u32 {
#[doc(alias = "GST_META_FLAG_READONLY")]
const READONLY = ffi::GST_META_FLAG_READONLY as u32;
#[doc(alias = "GST_META_FLAG_POOLED")]
const POOLED = ffi::GST_META_FLAG_POOLED as u32;
#[doc(alias = "GST_META_FLAG_LOCKED")]
const LOCKED = ffi::GST_META_FLAG_LOCKED as u32;
}
}
#[doc(hidden)]
impl IntoGlib for MetaFlags {
type GlibType = ffi::GstMetaFlags;
fn into_glib(self) -> ffi::GstMetaFlags {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::GstMetaFlags> for MetaFlags {
unsafe fn from_glib(value: ffi::GstMetaFlags) -> Self {
skip_assert_initialized!();
Self::from_bits_truncate(value)
}
}
impl StaticType for MetaFlags {
fn static_type() -> Type {
unsafe { from_glib(ffi::gst_meta_flags_get_type()) }
}
}
impl glib::value::ValueType for MetaFlags {
type Type = Self;
}
unsafe impl<'a> FromValue<'a> for MetaFlags {
type Checker = glib::value::GenericValueTypeChecker<Self>;
unsafe fn from_value(value: &'a glib::Value) -> Self {
skip_assert_initialized!();
from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0))
}
}
impl ToValue for MetaFlags {
fn to_value(&self) -> glib::Value {
let mut value = glib::Value::for_value_type::<Self>();
unsafe {
glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib());
}
value
}
fn value_type(&self) -> glib::Type {
Self::static_type()
}
}
bitflags! {
#[doc(alias = "GstObjectFlags")]
pub struct ObjectFlags: u32 {

View file

@ -172,6 +172,7 @@ pub use self::flags::EventTypeFlags;
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))]
pub use self::flags::GapFlags;
pub use self::flags::MemoryFlags;
pub use self::flags::MetaFlags;
pub use self::flags::ObjectFlags;
pub use self::flags::PadFlags;
pub use self::flags::PadLinkCheck;

View file

@ -145,6 +145,13 @@ impl<'a, T> MetaRef<'a, T> {
}
}
pub fn flags(&self) -> crate::MetaFlags {
unsafe {
let meta = self.meta as *const _ as *const ffi::GstMeta;
from_glib((*meta).flags)
}
}
pub fn type_(&self) -> glib::Type {
unsafe {
let meta = self.meta as *const _ as *const ffi::GstMeta;
@ -207,6 +214,13 @@ impl<'a, T, U> MetaRefMut<'a, T, U> {
}
}
pub fn flags(&self) -> crate::MetaFlags {
unsafe {
let meta = self.meta as *const _ as *const ffi::GstMeta;
from_glib((*meta).flags)
}
}
pub fn type_(&self) -> glib::Type {
unsafe {
let meta = self.meta as *const _ as *const ffi::GstMeta;
@ -316,6 +330,10 @@ impl Meta {
fn api(&self) -> glib::Type {
unsafe { glib::Type::from_glib((*self.0.info).api) }
}
pub fn flags(&self) -> crate::MetaFlags {
unsafe { from_glib(self.0.flags) }
}
}
unsafe impl MetaAPI for Meta {