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
|
|
|
|
2023-01-15 18:38:13 +00:00
|
|
|
use std::{fmt, marker::PhantomData, ptr};
|
2017-10-15 08:08:56 +00:00
|
|
|
|
2024-02-03 08:13:51 +00:00
|
|
|
use glib::{prelude::*, translate::*};
|
2017-10-15 08:08:56 +00:00
|
|
|
|
2023-01-03 18:58:25 +00:00
|
|
|
use crate::Caps;
|
2018-04-01 08:29:15 +00:00
|
|
|
|
2021-06-01 13:15:59 +00:00
|
|
|
#[doc(alias = "GstStaticCaps")]
|
2023-01-02 17:03:08 +00:00
|
|
|
#[derive(Clone, Copy)]
|
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 {
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_static_caps_get")]
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2017-10-15 08:08:56 +00:00
|
|
|
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 {
|
2023-01-15 18:38:13 +00:00
|
|
|
glib::GStr::from_ptr(self.0.as_ref().string)
|
2019-01-22 15:43:29 +00:00
|
|
|
})
|
|
|
|
.finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-03 08:13:51 +00:00
|
|
|
impl StaticType for StaticCaps {
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2017-10-15 08:08:56 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-20 07:19:02 +00:00
|
|
|
impl glib::value::ValueType for StaticCaps {
|
|
|
|
type Type = Self;
|
|
|
|
}
|
|
|
|
|
2023-01-02 17:03:08 +00:00
|
|
|
unsafe impl glib::translate::TransparentPtrType for StaticCaps {}
|
|
|
|
|
2017-10-15 08:08:56 +00:00
|
|
|
#[doc(hidden)]
|
2021-04-20 07:19:02 +00:00
|
|
|
unsafe impl<'a> glib::value::FromValue<'a> for StaticCaps {
|
|
|
|
type Checker = glib::value::GenericValueTypeOrNoneChecker<Self>;
|
|
|
|
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2021-04-20 07:19:02 +00:00
|
|
|
unsafe fn from_value(value: &'a glib::Value) -> Self {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
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)]
|
2021-04-20 07:19:02 +00:00
|
|
|
impl glib::value::ToValue for StaticCaps {
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2021-04-20 07:19:02 +00:00
|
|
|
fn to_value(&self) -> glib::Value {
|
2021-04-25 16:46:18 +00:00
|
|
|
let mut value = glib::Value::for_value_type::<Self>();
|
2021-04-20 07:19:02 +00:00
|
|
|
unsafe {
|
|
|
|
glib::gobject_ffi::g_value_set_boxed(
|
|
|
|
value.to_glib_none_mut().0,
|
|
|
|
self.to_glib_none().0 as *mut _,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
value
|
|
|
|
}
|
|
|
|
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2021-04-20 07:19:02 +00:00
|
|
|
fn value_type(&self) -> glib::Type {
|
|
|
|
Self::static_type()
|
2017-10-15 08:08:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-26 11:56:53 +00:00
|
|
|
impl From<StaticCaps> for glib::Value {
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2022-11-26 11:56:53 +00:00
|
|
|
fn from(v: StaticCaps) -> glib::Value {
|
|
|
|
skip_assert_initialized!();
|
|
|
|
glib::value::ToValue::to_value(&v)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-15 08:08:56 +00:00
|
|
|
#[doc(hidden)]
|
2021-04-20 07:19:02 +00:00
|
|
|
impl glib::value::ToValueOptional for StaticCaps {
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2021-04-20 07:19:02 +00:00
|
|
|
fn to_value_optional(s: Option<&Self>) -> glib::Value {
|
|
|
|
skip_assert_initialized!();
|
2021-04-25 16:46:18 +00:00
|
|
|
let mut value = glib::Value::for_value_type::<Self>();
|
2021-04-20 07:19:02 +00:00
|
|
|
unsafe {
|
|
|
|
glib::gobject_ffi::g_value_set_boxed(
|
|
|
|
value.to_glib_none_mut().0,
|
|
|
|
s.to_glib_none().0 as *mut _,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
value
|
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 {
|
2022-12-17 16:48:35 +00:00
|
|
|
type Storage = PhantomData<&'a StaticCaps>;
|
2017-10-15 08:08:56 +00:00
|
|
|
|
2022-12-18 08:18:31 +00:00
|
|
|
#[inline]
|
2020-11-21 13:46:48 +00:00
|
|
|
fn to_glib_none(&'a self) -> glib::translate::Stash<'a, *const ffi::GstStaticCaps, Self> {
|
2022-12-17 16:48:35 +00:00
|
|
|
glib::translate::Stash(self.0.as_ptr(), PhantomData)
|
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 {
|
2022-12-25 10:47:02 +00:00
|
|
|
debug_assert!(!ptr.is_null());
|
2018-04-01 08:29:15 +00:00
|
|
|
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 {
|
2022-12-25 10:47:02 +00:00
|
|
|
debug_assert!(!ptr.is_null());
|
2018-04-01 08:29:15 +00:00
|
|
|
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> {
|
2022-12-25 10:47:02 +00:00
|
|
|
debug_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
|
|
|
}
|
|
|
|
}
|