2020-12-15 10:53:31 +00:00
|
|
|
// Take a look at the license at the top of the repository in the LICENSE file.
|
2019-05-11 15:00:03 +00:00
|
|
|
|
|
|
|
use std::mem;
|
|
|
|
|
|
|
|
use glib::translate::*;
|
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
use crate::MemoryFlags;
|
2019-05-11 15:00:03 +00:00
|
|
|
|
|
|
|
#[derive(Debug, Clone)]
|
2021-06-01 13:15:59 +00:00
|
|
|
#[doc(alias = "GstAllocationParams")]
|
2020-11-21 13:46:48 +00:00
|
|
|
pub struct AllocationParams(ffi::GstAllocationParams);
|
2019-05-11 15:00:03 +00:00
|
|
|
|
2019-12-18 15:04:42 +00:00
|
|
|
unsafe impl Send for AllocationParams {}
|
|
|
|
unsafe impl Sync for AllocationParams {}
|
|
|
|
|
2019-05-11 15:00:03 +00:00
|
|
|
impl AllocationParams {
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_flags")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn flags(&self) -> MemoryFlags {
|
2020-12-08 14:07:12 +00:00
|
|
|
unsafe { from_glib(self.0.flags) }
|
2019-05-11 15:00:03 +00:00
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_align")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn align(&self) -> usize {
|
2019-05-11 15:00:03 +00:00
|
|
|
self.0.align
|
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_prefix")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn prefix(&self) -> usize {
|
2019-05-11 15:00:03 +00:00
|
|
|
self.0.prefix
|
|
|
|
}
|
|
|
|
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_padding")]
|
2021-04-11 19:39:50 +00:00
|
|
|
pub fn padding(&self) -> usize {
|
2019-05-11 15:00:03 +00:00
|
|
|
self.0.padding
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn new(flags: MemoryFlags, align: usize, prefix: usize, padding: usize) -> Self {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
let allocationparams = unsafe {
|
2021-01-10 13:30:58 +00:00
|
|
|
ffi::GstAllocationParams {
|
2021-04-27 15:15:46 +00:00
|
|
|
flags: flags.into_glib(),
|
2021-01-10 13:30:58 +00:00
|
|
|
align,
|
|
|
|
prefix,
|
|
|
|
padding,
|
|
|
|
..mem::zeroed()
|
|
|
|
}
|
2019-05-11 15:00:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
AllocationParams(allocationparams)
|
|
|
|
}
|
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
pub fn as_ptr(&self) -> *const ffi::GstAllocationParams {
|
2019-05-11 15:00:03 +00:00
|
|
|
&self.0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
impl From<ffi::GstAllocationParams> for AllocationParams {
|
|
|
|
fn from(params: ffi::GstAllocationParams) -> Self {
|
2020-03-22 14:18:47 +00:00
|
|
|
skip_assert_initialized!();
|
2019-05-11 15:00:03 +00:00
|
|
|
AllocationParams(params)
|
|
|
|
}
|
|
|
|
}
|
2021-01-10 13:27:24 +00:00
|
|
|
|
|
|
|
#[doc(hidden)]
|
|
|
|
impl<'a> ToGlibPtr<'a, *const ffi::GstAllocationParams> for AllocationParams {
|
|
|
|
type Storage = &'a Self;
|
|
|
|
|
|
|
|
fn to_glib_none(&'a self) -> Stash<'a, *const ffi::GstAllocationParams, Self> {
|
|
|
|
Stash(&self.0, self)
|
|
|
|
}
|
|
|
|
}
|
2021-10-12 14:46:41 +00:00
|
|
|
|
|
|
|
impl FromGlib<ffi::GstAllocationParams> for AllocationParams {
|
|
|
|
#[allow(unused_unsafe)]
|
|
|
|
unsafe fn from_glib(value: ffi::GstAllocationParams) -> Self {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
AllocationParams(value)
|
|
|
|
}
|
|
|
|
}
|