2019-05-11 15:00:03 +00:00
|
|
|
// Copyright (C) 2019 Vivia Nikolaidou <vivia@ahiru.eu>
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
|
|
|
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)]
|
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 {
|
|
|
|
pub fn get_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
|
|
|
}
|
|
|
|
|
|
|
|
pub fn get_align(&self) -> usize {
|
|
|
|
self.0.align
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn get_prefix(&self) -> usize {
|
|
|
|
self.0.prefix
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn get_padding(&self) -> usize {
|
|
|
|
self.0.padding
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn new(flags: MemoryFlags, align: usize, prefix: usize, padding: usize) -> Self {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
let allocationparams = unsafe {
|
2020-11-21 13:46:48 +00:00
|
|
|
let mut allocationparams: ffi::GstAllocationParams = mem::zeroed();
|
2019-05-11 15:00:03 +00:00
|
|
|
|
|
|
|
allocationparams.flags = flags.to_glib();
|
|
|
|
allocationparams.align = align;
|
|
|
|
allocationparams.prefix = prefix;
|
|
|
|
allocationparams.padding = padding;
|
|
|
|
|
|
|
|
allocationparams
|
|
|
|
};
|
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|