Use new memory type infrastructure in gstreamer-gl

This commit is contained in:
Christian Meissl 2022-02-26 16:36:05 +01:00 committed by Sebastian Dröge
parent 389d406e73
commit 3234a18677
4 changed files with 63 additions and 21 deletions

View file

@ -1,32 +1,32 @@
use glib::prelude::*;
use glib::translate::*;
use gst::Memory;
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!(
gst::memory_object_wrapper!(
GLBaseMemory,
GLBaseMemoryRef,
GstGLBaseMemory,
ffi::gst_gl_base_memory_get_type
|mem: &MemoryRef| { unsafe { from_glib(ffi::gst_is_gl_base_memory(mem.as_mut_ptr())) } },
Memory,
MemoryRef
);
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::fmt::Debug for GLBaseMemory {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
GLBaseMemoryRef::fmt(self, f)
}
}
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 std::fmt::Debug for GLBaseMemoryRef {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
gst::MemoryRef::fmt(self, f)
}
}

View file

@ -1,25 +1,34 @@
use glib::translate::*;
use crate::GLBaseMemory;
use crate::GLBaseMemoryRef;
use crate::GLFormat;
use crate::GLTextureTarget;
use ffi::{GstGLBaseMemory, GstGLMemory};
use ffi::GstGLMemory;
use gst::{result_from_gboolean, LoggableError, CAT_RUST};
use gst::{Memory, MemoryRef};
gst::mini_object_wrapper!(GLMemory, GLMemoryRef, GstGLMemory);
gst::memory_object_wrapper!(
GLMemory,
GLMemoryRef,
GstGLMemory,
|mem: &MemoryRef| { unsafe { from_glib(ffi::gst_is_gl_memory(mem.as_mut_ptr())) } },
GLBaseMemory,
GLBaseMemoryRef,
Memory,
MemoryRef
);
impl std::ops::Deref for GLMemoryRef {
type Target = GLBaseMemoryRef;
fn deref(&self) -> &Self::Target {
unsafe { &*(&self.0.mem as *const GstGLBaseMemory).cast::<Self::Target>() }
impl std::fmt::Debug for GLMemory {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
GLMemoryRef::fmt(self, f)
}
}
impl std::ops::DerefMut for GLMemoryRef {
fn deref_mut(&mut self) -> &mut Self::Target {
unsafe { &mut *(&mut self.0.mem as *mut GstGLBaseMemory).cast::<Self::Target>() }
impl std::fmt::Debug for GLMemoryRef {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
GLBaseMemoryRef::fmt(self, f)
}
}

View file

@ -0,0 +1,31 @@
use ffi::GstGLMemoryPBO;
use glib::translate::*;
use crate::{GLBaseMemory, GLBaseMemoryRef, GLMemory, GLMemoryRef};
use gst::{Memory, MemoryRef};
gst::memory_object_wrapper!(
GLMemoryPBO,
GLMemoryPBORef,
GstGLMemoryPBO,
|mem: &MemoryRef| { unsafe { from_glib(ffi::gst_is_gl_memory_pbo(mem.as_mut_ptr())) } },
GLMemory,
GLMemoryRef,
GLBaseMemory,
GLBaseMemoryRef,
Memory,
MemoryRef
);
impl std::fmt::Debug for GLMemoryPBO {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
GLMemoryPBORef::fmt(self, f)
}
}
impl std::fmt::Debug for GLMemoryPBORef {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
GLMemoryRef::fmt(self, f)
}
}

View file

@ -45,6 +45,8 @@ mod gl_base_memory;
pub use self::gl_base_memory::*;
mod gl_memory;
pub use crate::gl_memory::*;
mod gl_memory_pbo;
pub use crate::gl_memory_pbo::*;
// Re-export all the traits in a prelude module, so that applications
// can always "use gst_gl::prelude::*" without getting conflicts