1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
use glib::prelude::*;
use glib::translate::*;
use gst::Memory;
use crate::GLAllocationParams;
use crate::GLBaseMemoryAllocator;
use ffi::GstGLBaseMemory;
use gst::MemoryRef;
gst::memory_object_wrapper!(
GLBaseMemory,
GLBaseMemoryRef,
GstGLBaseMemory,
|mem: &MemoryRef| { unsafe { from_glib(ffi::gst_is_gl_base_memory(mem.as_mut_ptr())) } },
Memory,
MemoryRef
);
impl std::fmt::Debug for GLBaseMemory {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
GLBaseMemoryRef::fmt(self, f)
}
}
impl std::fmt::Debug for GLBaseMemoryRef {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
gst::MemoryRef::fmt(self, f)
}
}
impl GLBaseMemoryRef {
#[doc(alias = "gst_gl_base_memory_memcpy")]
pub unsafe fn memcpy(
&self,
dest: &mut GLBaseMemory,
offset: isize,
size: isize,
) -> Result<(), glib::BoolError> {
Self::init_once();
glib::result_from_gboolean!(
ffi::gst_gl_base_memory_memcpy(
mut_override(&self.0),
dest.to_glib_none_mut().0,
offset,
size,
),
"Failed to copy memory"
)
}
#[doc(alias = "gst_gl_base_memory_alloc")]
pub fn alloc<P: IsA<GLBaseMemoryAllocator>>(
allocator: &P,
params: &GLAllocationParams,
) -> Result<GLBaseMemory, glib::BoolError> {
skip_assert_initialized!();
Self::init_once();
unsafe {
Option::<_>::from_glib_full(ffi::gst_gl_base_memory_alloc(
allocator.as_ref().to_glib_none().0,
mut_override(params.to_glib_none().0),
))
.ok_or_else(|| glib::bool_error!("Failed to allocate memory"))
}
}
#[doc(alias = "gst_gl_base_memory_init_once")]
fn init_once() {
assert_initialized_main_thread!();
unsafe {
ffi::gst_gl_base_memory_init_once();
}
}
pub fn context(&self) -> &crate::GLContext {
unsafe {
&*(&(*self.as_ptr()).context as *const *mut ffi::GstGLContext
as *const crate::GLContext)
}
}
}