gstreamer_allocators_sys/
lib.rs1#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)]
7#![allow(
8 clippy::approx_constant,
9 clippy::type_complexity,
10 clippy::unreadable_literal,
11 clippy::upper_case_acronyms
12)]
13#![cfg_attr(docsrs, feature(doc_cfg))]
14
15use glib_sys as glib;
16use gobject_sys as gobject;
17use gstreamer_sys as gst;
18
19#[cfg(unix)]
20#[allow(unused_imports)]
21use libc::{dev_t, gid_t, pid_t, socklen_t, uid_t};
22#[allow(unused_imports)]
23use libc::{intptr_t, off_t, size_t, ssize_t, time_t, uintptr_t, FILE};
24#[allow(unused_imports)]
25use std::ffi::{
26 c_char, c_double, c_float, c_int, c_long, c_short, c_uchar, c_uint, c_ulong, c_ushort, c_void,
27};
28
29#[allow(unused_imports)]
30use glib::{gboolean, gconstpointer, gpointer, GType};
31
32pub const GST_ALLOCATOR_DMABUF: &[u8] = b"dmabuf\0";
34pub const GST_ALLOCATOR_FD: &[u8] = b"fd\0";
35pub const GST_ALLOCATOR_SHM: &[u8] = b"shm\0";
36pub const GST_ALLOCATOR_UDMABUF: &[u8] = b"udmabuf\0";
37pub const GST_CAPS_FEATURE_MEMORY_DMABUF: &[u8] = b"memory:DMABuf\0";
38
39pub type GstFdMemoryFlags = c_uint;
41pub const GST_FD_MEMORY_FLAG_NONE: GstFdMemoryFlags = 0;
42pub const GST_FD_MEMORY_FLAG_KEEP_MAPPED: GstFdMemoryFlags = 1;
43pub const GST_FD_MEMORY_FLAG_MAP_PRIVATE: GstFdMemoryFlags = 2;
44pub const GST_FD_MEMORY_FLAG_DONT_CLOSE: GstFdMemoryFlags = 4;
45
46#[derive(Copy, Clone)]
48#[repr(C)]
49pub struct GstDRMDumbAllocatorClass {
50 pub parent_class: gst::GstAllocatorClass,
51}
52
53impl ::std::fmt::Debug for GstDRMDumbAllocatorClass {
54 fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
55 f.debug_struct(&format!("GstDRMDumbAllocatorClass @ {self:p}"))
56 .field("parent_class", &self.parent_class)
57 .finish()
58 }
59}
60
61#[derive(Copy, Clone)]
62#[repr(C)]
63pub struct GstDmaBufAllocatorClass {
64 pub parent_class: GstFdAllocatorClass,
65 pub _gst_reserved: [gpointer; 4],
66}
67
68impl ::std::fmt::Debug for GstDmaBufAllocatorClass {
69 fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
70 f.debug_struct(&format!("GstDmaBufAllocatorClass @ {self:p}"))
71 .field("parent_class", &self.parent_class)
72 .finish()
73 }
74}
75
76#[derive(Copy, Clone)]
77#[repr(C)]
78pub struct GstFdAllocatorClass {
79 pub parent_class: gst::GstAllocatorClass,
80}
81
82impl ::std::fmt::Debug for GstFdAllocatorClass {
83 fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
84 f.debug_struct(&format!("GstFdAllocatorClass @ {self:p}"))
85 .field("parent_class", &self.parent_class)
86 .finish()
87 }
88}
89
90#[derive(Copy, Clone)]
91#[repr(C)]
92pub struct GstPhysMemoryAllocatorInterface {
93 pub parent_iface: gobject::GTypeInterface,
94 pub get_phys_addr:
95 Option<unsafe extern "C" fn(*mut GstPhysMemoryAllocator, *mut gst::GstMemory) -> uintptr_t>,
96}
97
98impl ::std::fmt::Debug for GstPhysMemoryAllocatorInterface {
99 fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
100 f.debug_struct(&format!("GstPhysMemoryAllocatorInterface @ {self:p}"))
101 .field("get_phys_addr", &self.get_phys_addr)
102 .finish()
103 }
104}
105
106#[derive(Copy, Clone)]
107#[repr(C)]
108pub struct GstShmAllocatorClass {
109 pub parent_class: GstFdAllocatorClass,
110}
111
112impl ::std::fmt::Debug for GstShmAllocatorClass {
113 fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
114 f.debug_struct(&format!("GstShmAllocatorClass @ {self:p}"))
115 .field("parent_class", &self.parent_class)
116 .finish()
117 }
118}
119
120#[derive(Copy, Clone)]
121#[repr(C)]
122pub struct GstUdmabufAllocatorClass {
123 pub parent_class: GstDmaBufAllocatorClass,
124}
125
126impl ::std::fmt::Debug for GstUdmabufAllocatorClass {
127 fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
128 f.debug_struct(&format!("GstUdmabufAllocatorClass @ {self:p}"))
129 .field("parent_class", &self.parent_class)
130 .finish()
131 }
132}
133
134#[repr(C)]
136#[allow(dead_code)]
137pub struct GstDRMDumbAllocator {
138 _data: [u8; 0],
139 _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>,
140}
141
142impl ::std::fmt::Debug for GstDRMDumbAllocator {
143 fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
144 f.debug_struct(&format!("GstDRMDumbAllocator @ {self:p}"))
145 .finish()
146 }
147}
148
149#[derive(Copy, Clone)]
150#[repr(C)]
151pub struct GstDmaBufAllocator {
152 pub parent: GstFdAllocator,
153 pub _gst_reserved: [gpointer; 4],
154}
155
156impl ::std::fmt::Debug for GstDmaBufAllocator {
157 fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
158 f.debug_struct(&format!("GstDmaBufAllocator @ {self:p}"))
159 .field("parent", &self.parent)
160 .finish()
161 }
162}
163
164#[derive(Copy, Clone)]
165#[repr(C)]
166pub struct GstFdAllocator {
167 pub parent: gst::GstAllocator,
168}
169
170impl ::std::fmt::Debug for GstFdAllocator {
171 fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
172 f.debug_struct(&format!("GstFdAllocator @ {self:p}"))
173 .field("parent", &self.parent)
174 .finish()
175 }
176}
177
178#[derive(Copy, Clone)]
179#[repr(C)]
180pub struct GstShmAllocator {
181 pub parent_instance: GstFdAllocator,
182}
183
184impl ::std::fmt::Debug for GstShmAllocator {
185 fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
186 f.debug_struct(&format!("GstShmAllocator @ {self:p}"))
187 .field("parent_instance", &self.parent_instance)
188 .finish()
189 }
190}
191
192#[repr(C)]
193#[allow(dead_code)]
194pub struct GstUdmabufAllocator {
195 _data: [u8; 0],
196 _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>,
197}
198
199impl ::std::fmt::Debug for GstUdmabufAllocator {
200 fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
201 f.debug_struct(&format!("GstUdmabufAllocator @ {self:p}"))
202 .finish()
203 }
204}
205
206#[repr(C)]
208#[allow(dead_code)]
209pub struct GstPhysMemoryAllocator {
210 _data: [u8; 0],
211 _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>,
212}
213
214impl ::std::fmt::Debug for GstPhysMemoryAllocator {
215 fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
216 write!(f, "GstPhysMemoryAllocator @ {self:p}")
217 }
218}
219
220extern "C" {
221
222 #[cfg(feature = "v1_24")]
226 #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
227 pub fn gst_drm_dumb_allocator_get_type() -> GType;
228 #[cfg(feature = "v1_24")]
229 #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
230 pub fn gst_drm_dumb_allocator_new_with_device_path(
231 drm_device_path: *const c_char,
232 ) -> *mut gst::GstAllocator;
233 #[cfg(feature = "v1_24")]
234 #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
235 pub fn gst_drm_dumb_allocator_new_with_fd(drm_fd: c_int) -> *mut gst::GstAllocator;
236 #[cfg(feature = "v1_24")]
237 #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
238 pub fn gst_drm_dumb_allocator_alloc(
239 allocator: *mut GstDRMDumbAllocator,
240 drm_fourcc: u32,
241 width: u32,
242 height: u32,
243 out_pitch: *mut u32,
244 ) -> *mut gst::GstMemory;
245 #[cfg(feature = "v1_24")]
246 #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
247 pub fn gst_drm_dumb_allocator_has_prime_export(allocator: *mut GstDRMDumbAllocator)
248 -> gboolean;
249
250 pub fn gst_dmabuf_allocator_get_type() -> GType;
254 pub fn gst_dmabuf_allocator_new() -> *mut gst::GstAllocator;
255 pub fn gst_dmabuf_allocator_alloc(
256 allocator: *mut gst::GstAllocator,
257 fd: c_int,
258 size: size_t,
259 ) -> *mut gst::GstMemory;
260 #[cfg(feature = "v1_16")]
261 #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
262 pub fn gst_dmabuf_allocator_alloc_with_flags(
263 allocator: *mut gst::GstAllocator,
264 fd: c_int,
265 size: size_t,
266 flags: GstFdMemoryFlags,
267 ) -> *mut gst::GstMemory;
268
269 pub fn gst_fd_allocator_get_type() -> GType;
273 pub fn gst_fd_allocator_new() -> *mut gst::GstAllocator;
274 pub fn gst_fd_allocator_alloc(
275 allocator: *mut gst::GstAllocator,
276 fd: c_int,
277 size: size_t,
278 flags: GstFdMemoryFlags,
279 ) -> *mut gst::GstMemory;
280 #[cfg(feature = "v1_28")]
281 #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
282 pub fn gst_fd_allocator_alloc_full(
283 allocator: *mut gst::GstAllocator,
284 fd: c_int,
285 maxsize: size_t,
286 offset: size_t,
287 size: size_t,
288 flags: GstFdMemoryFlags,
289 ) -> *mut gst::GstMemory;
290
291 #[cfg(feature = "v1_24")]
295 #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
296 pub fn gst_shm_allocator_get_type() -> GType;
297 #[cfg(feature = "v1_24")]
298 #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
299 pub fn gst_shm_allocator_get() -> *mut gst::GstAllocator;
300 #[cfg(feature = "v1_24")]
301 #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
302 pub fn gst_shm_allocator_init_once();
303
304 #[cfg(feature = "v1_28")]
308 #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
309 pub fn gst_udmabuf_allocator_get_type() -> GType;
310 #[cfg(feature = "v1_28")]
311 #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
312 pub fn gst_udmabuf_allocator_get() -> *mut gst::GstAllocator;
313 #[cfg(feature = "v1_28")]
314 #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
315 pub fn gst_udmabuf_allocator_init_once();
316
317 pub fn gst_phys_memory_allocator_get_type() -> GType;
321
322 pub fn gst_dmabuf_memory_get_fd(mem: *mut gst::GstMemory) -> c_int;
326 #[cfg(feature = "v1_24")]
327 #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
328 pub fn gst_drm_dumb_memory_export_dmabuf(mem: *mut gst::GstMemory) -> *mut gst::GstMemory;
329 #[cfg(feature = "v1_24")]
330 #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
331 pub fn gst_drm_dumb_memory_get_handle(mem: *mut gst::GstMemory) -> u32;
332 pub fn gst_fd_memory_get_fd(mem: *mut gst::GstMemory) -> c_int;
333 pub fn gst_is_dmabuf_memory(mem: *mut gst::GstMemory) -> gboolean;
334 #[cfg(feature = "v1_24")]
335 #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
336 pub fn gst_is_drm_dumb_memory(mem: *mut gst::GstMemory) -> gboolean;
337 pub fn gst_is_fd_memory(mem: *mut gst::GstMemory) -> gboolean;
338 pub fn gst_is_phys_memory(mem: *mut gst::GstMemory) -> gboolean;
339 pub fn gst_phys_memory_get_phys_addr(mem: *mut gst::GstMemory) -> uintptr_t;
340
341}