2020-12-15 10:53:31 +00:00
|
|
|
// Take a look at the license at the top of the repository in the LICENSE file.
|
2017-10-15 08:08:56 +00:00
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
use crate::Caps;
|
2017-10-15 08:08:56 +00:00
|
|
|
|
2020-04-05 14:52:56 +00:00
|
|
|
use glib::translate::*;
|
2017-10-15 08:08:56 +00:00
|
|
|
|
2019-01-22 15:43:29 +00:00
|
|
|
use std::ffi::CStr;
|
|
|
|
use std::fmt;
|
2018-04-01 08:29:15 +00:00
|
|
|
use std::ptr;
|
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
pub struct StaticCaps(ptr::NonNull<ffi::GstStaticCaps>);
|
2017-10-15 08:08:56 +00:00
|
|
|
|
|
|
|
impl StaticCaps {
|
|
|
|
pub fn get(&self) -> Caps {
|
2020-11-21 13:46:48 +00:00
|
|
|
unsafe { from_glib_full(ffi::gst_static_caps_get(self.0.as_ptr())) }
|
2017-10-15 08:08:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe impl Send for StaticCaps {}
|
|
|
|
unsafe impl Sync for StaticCaps {}
|
|
|
|
|
2019-01-22 15:43:29 +00:00
|
|
|
impl fmt::Debug for StaticCaps {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
|
|
f.debug_struct("StaticCaps")
|
|
|
|
.field("str", &unsafe {
|
|
|
|
CStr::from_ptr(self.0.as_ref().string).to_str()
|
|
|
|
})
|
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-15 08:08:56 +00:00
|
|
|
impl glib::types::StaticType for StaticCaps {
|
|
|
|
fn static_type() -> glib::types::Type {
|
2020-11-21 13:46:48 +00:00
|
|
|
unsafe { glib::translate::from_glib(ffi::gst_static_caps_get_type()) }
|
2017-10-15 08:08:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[doc(hidden)]
|
|
|
|
impl<'a> glib::value::FromValueOptional<'a> for StaticCaps {
|
|
|
|
unsafe fn from_value_optional(value: &glib::Value) -> Option<Self> {
|
2020-11-21 13:46:48 +00:00
|
|
|
Option::<StaticCaps>::from_glib_none(glib::gobject_ffi::g_value_get_boxed(
|
|
|
|
value.to_glib_none().0,
|
|
|
|
) as *mut ffi::GstStaticCaps)
|
2017-10-15 08:08:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[doc(hidden)]
|
|
|
|
impl glib::value::SetValue for StaticCaps {
|
|
|
|
unsafe fn set_value(value: &mut glib::Value, this: &Self) {
|
2020-11-21 13:46:48 +00:00
|
|
|
glib::gobject_ffi::g_value_set_boxed(
|
2017-10-15 08:08:56 +00:00
|
|
|
value.to_glib_none_mut().0,
|
2020-11-21 13:46:48 +00:00
|
|
|
glib::translate::ToGlibPtr::<*const ffi::GstStaticCaps>::to_glib_none(this).0
|
|
|
|
as glib::ffi::gpointer,
|
2017-10-15 08:08:56 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[doc(hidden)]
|
|
|
|
impl glib::value::SetValueOptional for StaticCaps {
|
|
|
|
unsafe fn set_value_optional(value: &mut glib::Value, this: Option<&Self>) {
|
2020-11-21 13:46:48 +00:00
|
|
|
glib::gobject_ffi::g_value_set_boxed(
|
2017-10-15 08:08:56 +00:00
|
|
|
value.to_glib_none_mut().0,
|
2020-11-21 13:46:48 +00:00
|
|
|
glib::translate::ToGlibPtr::<*const ffi::GstStaticCaps>::to_glib_none(&this).0
|
|
|
|
as glib::ffi::gpointer,
|
2017-10-15 08:08:56 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[doc(hidden)]
|
|
|
|
impl glib::translate::GlibPtrDefault for StaticCaps {
|
2020-11-21 13:46:48 +00:00
|
|
|
type GlibType = *mut ffi::GstStaticCaps;
|
2017-10-15 08:08:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[doc(hidden)]
|
2020-11-21 13:46:48 +00:00
|
|
|
impl<'a> glib::translate::ToGlibPtr<'a, *const ffi::GstStaticCaps> for StaticCaps {
|
2017-10-15 08:08:56 +00:00
|
|
|
type Storage = &'a StaticCaps;
|
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
fn to_glib_none(&'a self) -> glib::translate::Stash<'a, *const ffi::GstStaticCaps, Self> {
|
2018-04-01 08:29:15 +00:00
|
|
|
glib::translate::Stash(self.0.as_ptr(), self)
|
2017-10-15 08:08:56 +00:00
|
|
|
}
|
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
fn to_glib_full(&self) -> *const ffi::GstStaticCaps {
|
2017-10-15 08:08:56 +00:00
|
|
|
unimplemented!()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[doc(hidden)]
|
2020-11-21 13:46:48 +00:00
|
|
|
impl glib::translate::FromGlibPtrNone<*const ffi::GstStaticCaps> for StaticCaps {
|
2017-10-15 08:08:56 +00:00
|
|
|
#[inline]
|
2020-11-21 13:46:48 +00:00
|
|
|
unsafe fn from_glib_none(ptr: *const ffi::GstStaticCaps) -> Self {
|
2018-04-01 08:29:15 +00:00
|
|
|
assert!(!ptr.is_null());
|
|
|
|
StaticCaps(ptr::NonNull::new_unchecked(ptr as *mut _))
|
2017-10-15 08:08:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[doc(hidden)]
|
2020-11-21 13:46:48 +00:00
|
|
|
impl glib::translate::FromGlibPtrNone<*mut ffi::GstStaticCaps> for StaticCaps {
|
2017-10-15 08:08:56 +00:00
|
|
|
#[inline]
|
2020-11-21 13:46:48 +00:00
|
|
|
unsafe fn from_glib_none(ptr: *mut ffi::GstStaticCaps) -> Self {
|
2018-04-01 08:29:15 +00:00
|
|
|
assert!(!ptr.is_null());
|
|
|
|
StaticCaps(ptr::NonNull::new_unchecked(ptr))
|
2017-10-15 08:08:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[doc(hidden)]
|
2020-11-21 13:46:48 +00:00
|
|
|
impl glib::translate::FromGlibPtrBorrow<*mut ffi::GstStaticCaps> for StaticCaps {
|
2017-10-15 08:08:56 +00:00
|
|
|
#[inline]
|
2020-11-21 13:46:48 +00:00
|
|
|
unsafe fn from_glib_borrow(ptr: *mut ffi::GstStaticCaps) -> Borrowed<Self> {
|
2018-04-01 08:29:15 +00:00
|
|
|
assert!(!ptr.is_null());
|
2020-04-05 14:52:56 +00:00
|
|
|
Borrowed::new(StaticCaps(ptr::NonNull::new_unchecked(ptr)))
|
2017-10-15 08:08:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[doc(hidden)]
|
2020-11-21 13:46:48 +00:00
|
|
|
impl glib::translate::FromGlibPtrFull<*mut ffi::GstStaticCaps> for StaticCaps {
|
2017-10-15 08:08:56 +00:00
|
|
|
#[inline]
|
2020-11-21 13:46:48 +00:00
|
|
|
unsafe fn from_glib_full(_ptr: *mut ffi::GstStaticCaps) -> Self {
|
2017-10-15 08:27:08 +00:00
|
|
|
unimplemented!();
|
2017-10-15 08:08:56 +00:00
|
|
|
}
|
|
|
|
}
|