gstreamer_allocators/
phys_memory.rs
1use std::fmt;
2
3use crate::ffi;
4use glib::translate::*;
5use gst::{Memory, MemoryRef};
6
7gst::memory_object_wrapper!(
8 PhysMemory,
9 PhysMemoryRef,
10 gst::ffi::GstMemory,
11 |mem: &gst::MemoryRef| { unsafe { from_glib(ffi::gst_is_phys_memory(mem.as_mut_ptr())) } },
12 Memory,
13 MemoryRef,
14);
15
16impl fmt::Debug for PhysMemory {
17 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18 PhysMemoryRef::fmt(self, f)
19 }
20}
21
22impl fmt::Debug for PhysMemoryRef {
23 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
24 f.debug_struct("FdMemory")
25 .field("ptr", &self.as_ptr())
26 .field("allocator", &self.allocator())
27 .field("parent", &self.parent())
28 .field("maxsize", &self.maxsize())
29 .field("align", &self.align())
30 .field("offset", &self.offset())
31 .field("size", &self.size())
32 .field("flags", &self.flags())
33 .field("phys_addr", &format!("{:x}", self.phys_addr()))
34 .finish()
35 }
36}
37
38impl PhysMemoryRef {
39 #[doc(alias = "gst_phys_memory_get_phys_addr")]
40 pub fn phys_addr(&self) -> libc::uintptr_t {
41 skip_assert_initialized!();
42 unsafe { ffi::gst_phys_memory_get_phys_addr(self.as_mut_ptr()) }
43 }
44}