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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
// DO NOT EDIT

#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)]
#![allow(
    clippy::approx_constant,
    clippy::type_complexity,
    clippy::unreadable_literal,
    clippy::upper_case_acronyms
)]
#![cfg_attr(docsrs, feature(doc_cfg))]

use glib_sys as glib;
use gobject_sys as gobject;
use gstreamer_sys as gst;

#[allow(unused_imports)]
use libc::{
    c_char, c_double, c_float, c_int, c_long, c_short, c_uchar, c_uint, c_ulong, c_ushort, c_void,
    intptr_t, size_t, ssize_t, uintptr_t, FILE,
};

#[allow(unused_imports)]
use glib::{gboolean, gconstpointer, gpointer, GType};

// Constants
pub const GST_ALLOCATOR_DMABUF: &[u8] = b"dmabuf\0";
pub const GST_ALLOCATOR_FD: &[u8] = b"fd\0";
pub const GST_ALLOCATOR_SHM: &[u8] = b"shm\0";
pub const GST_CAPS_FEATURE_MEMORY_DMABUF: &[u8] = b"memory:DMABuf\0";

// Flags
pub type GstFdMemoryFlags = c_uint;
pub const GST_FD_MEMORY_FLAG_NONE: GstFdMemoryFlags = 0;
pub const GST_FD_MEMORY_FLAG_KEEP_MAPPED: GstFdMemoryFlags = 1;
pub const GST_FD_MEMORY_FLAG_MAP_PRIVATE: GstFdMemoryFlags = 2;
pub const GST_FD_MEMORY_FLAG_DONT_CLOSE: GstFdMemoryFlags = 4;

// Records
#[derive(Copy, Clone)]
#[repr(C)]
pub struct GstDRMDumbAllocatorClass {
    pub parent_class: gst::GstAllocatorClass,
}

impl ::std::fmt::Debug for GstDRMDumbAllocatorClass {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstDRMDumbAllocatorClass @ {self:p}"))
            .field("parent_class", &self.parent_class)
            .finish()
    }
}

#[derive(Copy, Clone)]
#[repr(C)]
pub struct GstDmaBufAllocatorClass {
    pub parent_class: GstFdAllocatorClass,
    pub _gst_reserved: [gpointer; 4],
}

impl ::std::fmt::Debug for GstDmaBufAllocatorClass {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstDmaBufAllocatorClass @ {self:p}"))
            .field("parent_class", &self.parent_class)
            .finish()
    }
}

#[derive(Copy, Clone)]
#[repr(C)]
pub struct GstFdAllocatorClass {
    pub parent_class: gst::GstAllocatorClass,
}

impl ::std::fmt::Debug for GstFdAllocatorClass {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstFdAllocatorClass @ {self:p}"))
            .field("parent_class", &self.parent_class)
            .finish()
    }
}

#[derive(Copy, Clone)]
#[repr(C)]
pub struct GstPhysMemoryAllocatorInterface {
    pub parent_iface: gobject::GTypeInterface,
    pub get_phys_addr:
        Option<unsafe extern "C" fn(*mut GstPhysMemoryAllocator, *mut gst::GstMemory) -> uintptr_t>,
}

impl ::std::fmt::Debug for GstPhysMemoryAllocatorInterface {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstPhysMemoryAllocatorInterface @ {self:p}"))
            .field("get_phys_addr", &self.get_phys_addr)
            .finish()
    }
}

#[derive(Copy, Clone)]
#[repr(C)]
pub struct GstShmAllocatorClass {
    pub parent_class: GstFdAllocatorClass,
}

impl ::std::fmt::Debug for GstShmAllocatorClass {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstShmAllocatorClass @ {self:p}"))
            .field("parent_class", &self.parent_class)
            .finish()
    }
}

// Classes
#[repr(C)]
pub struct GstDRMDumbAllocator {
    _data: [u8; 0],
    _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>,
}

impl ::std::fmt::Debug for GstDRMDumbAllocator {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstDRMDumbAllocator @ {self:p}"))
            .finish()
    }
}

#[derive(Copy, Clone)]
#[repr(C)]
pub struct GstDmaBufAllocator {
    pub parent: GstFdAllocator,
    pub _gst_reserved: [gpointer; 4],
}

impl ::std::fmt::Debug for GstDmaBufAllocator {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstDmaBufAllocator @ {self:p}"))
            .field("parent", &self.parent)
            .finish()
    }
}

#[derive(Copy, Clone)]
#[repr(C)]
pub struct GstFdAllocator {
    pub parent: gst::GstAllocator,
}

impl ::std::fmt::Debug for GstFdAllocator {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstFdAllocator @ {self:p}"))
            .field("parent", &self.parent)
            .finish()
    }
}

#[repr(C)]
pub struct GstShmAllocator {
    _data: [u8; 0],
    _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>,
}

impl ::std::fmt::Debug for GstShmAllocator {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstShmAllocator @ {self:p}"))
            .finish()
    }
}

// Interfaces
#[repr(C)]
pub struct GstPhysMemoryAllocator {
    _data: [u8; 0],
    _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>,
}

impl ::std::fmt::Debug for GstPhysMemoryAllocator {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        write!(f, "GstPhysMemoryAllocator @ {self:p}")
    }
}

#[link(name = "gstallocators-1.0")]
extern "C" {

    //=========================================================================
    // GstDRMDumbAllocator
    //=========================================================================
    #[cfg(feature = "v1_24")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
    pub fn gst_drm_dumb_allocator_get_type() -> GType;
    #[cfg(feature = "v1_24")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
    pub fn gst_drm_dumb_allocator_new_with_device_path(
        drm_device_path: *const c_char,
    ) -> *mut gst::GstAllocator;
    #[cfg(feature = "v1_24")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
    pub fn gst_drm_dumb_allocator_new_with_fd(drm_fd: c_int) -> *mut gst::GstAllocator;
    #[cfg(feature = "v1_24")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
    pub fn gst_drm_dumb_allocator_alloc(
        allocator: *mut GstDRMDumbAllocator,
        drm_fourcc: u32,
        width: u32,
        height: u32,
        out_pitch: *mut u32,
    ) -> *mut gst::GstMemory;
    #[cfg(feature = "v1_24")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
    pub fn gst_drm_dumb_allocator_has_prime_export(allocator: *mut GstDRMDumbAllocator)
        -> gboolean;

    //=========================================================================
    // GstDmaBufAllocator
    //=========================================================================
    pub fn gst_dmabuf_allocator_get_type() -> GType;
    pub fn gst_dmabuf_allocator_new() -> *mut gst::GstAllocator;
    pub fn gst_dmabuf_allocator_alloc(
        allocator: *mut gst::GstAllocator,
        fd: c_int,
        size: size_t,
    ) -> *mut gst::GstMemory;
    #[cfg(feature = "v1_16")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
    pub fn gst_dmabuf_allocator_alloc_with_flags(
        allocator: *mut gst::GstAllocator,
        fd: c_int,
        size: size_t,
        flags: GstFdMemoryFlags,
    ) -> *mut gst::GstMemory;

    //=========================================================================
    // GstFdAllocator
    //=========================================================================
    pub fn gst_fd_allocator_get_type() -> GType;
    pub fn gst_fd_allocator_new() -> *mut gst::GstAllocator;
    pub fn gst_fd_allocator_alloc(
        allocator: *mut gst::GstAllocator,
        fd: c_int,
        size: size_t,
        flags: GstFdMemoryFlags,
    ) -> *mut gst::GstMemory;

    //=========================================================================
    // GstShmAllocator
    //=========================================================================
    #[cfg(feature = "v1_24")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
    pub fn gst_shm_allocator_get_type() -> GType;
    #[cfg(feature = "v1_24")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
    pub fn gst_shm_allocator_get() -> *mut gst::GstAllocator;
    #[cfg(feature = "v1_24")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
    pub fn gst_shm_allocator_init_once();

    //=========================================================================
    // GstPhysMemoryAllocator
    //=========================================================================
    pub fn gst_phys_memory_allocator_get_type() -> GType;

    //=========================================================================
    // Other functions
    //=========================================================================
    pub fn gst_dmabuf_memory_get_fd(mem: *mut gst::GstMemory) -> c_int;
    #[cfg(feature = "v1_24")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
    pub fn gst_drm_dumb_memory_export_dmabuf(mem: *mut gst::GstMemory) -> *mut gst::GstMemory;
    #[cfg(feature = "v1_24")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
    pub fn gst_drm_dumb_memory_get_handle(mem: *mut gst::GstMemory) -> u32;
    pub fn gst_fd_memory_get_fd(mem: *mut gst::GstMemory) -> c_int;
    pub fn gst_is_dmabuf_memory(mem: *mut gst::GstMemory) -> gboolean;
    #[cfg(feature = "v1_24")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
    pub fn gst_is_drm_dumb_memory(mem: *mut gst::GstMemory) -> gboolean;
    pub fn gst_is_fd_memory(mem: *mut gst::GstMemory) -> gboolean;
    pub fn gst_is_phys_memory(mem: *mut gst::GstMemory) -> gboolean;
    pub fn gst_phys_memory_get_phys_addr(mem: *mut gst::GstMemory) -> uintptr_t;

}