mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-10-31 22:59:14 +00:00
gstreamer: meta: Add as_meta_ref()
to MetaRefMut
This reduces code duplication between `MetaRef` and `MetaRefMut`. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1338>
This commit is contained in:
parent
86d470e82c
commit
eb6d3a6c6c
1 changed files with 15 additions and 28 deletions
|
@ -255,28 +255,17 @@ impl<'a, T, U> MetaRefMut<'a, T, U> {
|
||||||
#[doc(alias = "get_api")]
|
#[doc(alias = "get_api")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn api(&self) -> glib::Type {
|
pub fn api(&self) -> glib::Type {
|
||||||
unsafe {
|
self.as_meta_ref().api()
|
||||||
let meta = self.meta as *const _ as *const ffi::GstMeta;
|
|
||||||
let info = (*meta).info;
|
|
||||||
glib::Type::from_glib((*info).api)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn flags(&self) -> crate::MetaFlags {
|
pub fn flags(&self) -> crate::MetaFlags {
|
||||||
unsafe {
|
self.as_meta_ref().flags()
|
||||||
let meta = self.meta as *const _ as *const ffi::GstMeta;
|
|
||||||
from_glib((*meta).flags)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn type_(&self) -> glib::Type {
|
pub fn type_(&self) -> glib::Type {
|
||||||
unsafe {
|
self.as_meta_ref().type_()
|
||||||
let meta = self.meta as *const _ as *const ffi::GstMeta;
|
|
||||||
let info = (*meta).info;
|
|
||||||
glib::Type::from_glib((*info).type_)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "v1_16")]
|
#[cfg(feature = "v1_16")]
|
||||||
|
@ -284,30 +273,20 @@ impl<'a, T, U> MetaRefMut<'a, T, U> {
|
||||||
#[doc(alias = "get_seqnum")]
|
#[doc(alias = "get_seqnum")]
|
||||||
#[doc(alias = "gst_meta_get_seqnum")]
|
#[doc(alias = "gst_meta_get_seqnum")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn seqnum(&self) -> u64 {
|
pub fn seqnum(&self) -> MetaSeqnum {
|
||||||
unsafe {
|
self.as_meta_ref().seqnum()
|
||||||
let meta = self.meta as *const _ as *const ffi::GstMeta;
|
|
||||||
ffi::gst_meta_get_seqnum(meta)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[doc(alias = "gst_meta_api_type_has_tag")]
|
#[doc(alias = "gst_meta_api_type_has_tag")]
|
||||||
pub fn has_tag(&self, tag: glib::Quark) -> bool {
|
pub fn has_tag(&self, tag: glib::Quark) -> bool {
|
||||||
unsafe {
|
self.as_meta_ref().has_tag(tag)
|
||||||
from_glib(ffi::gst_meta_api_type_has_tag(
|
|
||||||
self.api().into_glib(),
|
|
||||||
tag.into_glib(),
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[doc(alias = "gst_meta_api_type_get_tags")]
|
#[doc(alias = "gst_meta_api_type_get_tags")]
|
||||||
pub fn tags<'b>(&self) -> &'b [glib::GStringPtr] {
|
pub fn tags<'b>(&self) -> &'b [glib::GStringPtr] {
|
||||||
unsafe {
|
self.as_meta_ref().tags()
|
||||||
glib::StrV::from_glib_borrow(ffi::gst_meta_api_type_get_tags(self.api().into_glib()))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -320,6 +299,14 @@ impl<'a, T, U> MetaRefMut<'a, T, U> {
|
||||||
unsafe { &mut *(self as *mut MetaRefMut<'a, T, U> as *mut MetaRefMut<'a, Meta, U>) }
|
unsafe { &mut *(self as *mut MetaRefMut<'a, T, U> as *mut MetaRefMut<'a, Meta, U>) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn as_meta_ref(&self) -> MetaRef<T> {
|
||||||
|
MetaRef {
|
||||||
|
meta: self.meta,
|
||||||
|
buffer: self.buffer,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn as_ptr(&self) -> *const T::GstType
|
pub fn as_ptr(&self) -> *const T::GstType
|
||||||
where
|
where
|
||||||
|
|
Loading…
Reference in a new issue