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
use glib::prelude::*;
use glib::translate::*;
use crate::GLAllocationParams;
use crate::GLBaseMemoryAllocator;
use ffi::GstGLBaseMemory;
use gst::ffi::GstMemory;
use gst::MemoryRef;
use gst::{result_from_gboolean, LoggableError, CAT_RUST};
gst::mini_object_wrapper!(
GLBaseMemory,
GLBaseMemoryRef,
GstGLBaseMemory,
ffi::gst_gl_base_memory_get_type
);
impl std::ops::Deref for GLBaseMemoryRef {
type Target = MemoryRef;
fn deref(&self) -> &Self::Target {
unsafe { &*(&self.0.mem as *const GstMemory).cast::<Self::Target>() }
}
}
impl std::ops::DerefMut for GLBaseMemoryRef {
fn deref_mut(&mut self) -> &mut Self::Target {
unsafe { &mut *(&mut self.0.mem as *mut GstMemory).cast::<Self::Target>() }
}
}
impl GLBaseMemoryRef {
#[doc(alias = "gst_gl_base_memory_memcpy")]
pub unsafe fn memcpy(
&self,
dest: &mut GLBaseMemory,
offset: isize,
size: isize,
) -> Result<(), LoggableError> {
Self::init_once();
result_from_gboolean!(
ffi::gst_gl_base_memory_memcpy(
mut_override(&self.0),
dest.to_glib_none_mut().0,
offset,
size,
),
CAT_RUST,
"Failed to copy memory"
)
}
#[doc(alias = "gst_gl_base_memory_alloc")]
pub fn alloc<P: IsA<GLBaseMemoryAllocator>>(
allocator: &P,
params: &GLAllocationParams,
) -> Option<GLBaseMemory> {
skip_assert_initialized!();
Self::init_once();
unsafe {
from_glib_full(ffi::gst_gl_base_memory_alloc(
allocator.as_ref().to_glib_none().0,
mut_override(params.to_glib_none().0),
))
}
}
#[doc(alias = "gst_gl_base_memory_init_once")]
fn init_once() {
assert_initialized_main_thread!();
unsafe {
ffi::gst_gl_base_memory_init_once();
}
}
}