forked from mirrors/gstreamer-rs
Use new memory type infrastructure in gstreamer-gl
This commit is contained in:
parent
389d406e73
commit
3234a18677
4 changed files with 63 additions and 21 deletions
|
@ -1,32 +1,32 @@
|
||||||
use glib::prelude::*;
|
use glib::prelude::*;
|
||||||
use glib::translate::*;
|
use glib::translate::*;
|
||||||
|
use gst::Memory;
|
||||||
|
|
||||||
use crate::GLAllocationParams;
|
use crate::GLAllocationParams;
|
||||||
use crate::GLBaseMemoryAllocator;
|
use crate::GLBaseMemoryAllocator;
|
||||||
|
|
||||||
use ffi::GstGLBaseMemory;
|
use ffi::GstGLBaseMemory;
|
||||||
use gst::ffi::GstMemory;
|
|
||||||
use gst::MemoryRef;
|
use gst::MemoryRef;
|
||||||
use gst::{result_from_gboolean, LoggableError, CAT_RUST};
|
use gst::{result_from_gboolean, LoggableError, CAT_RUST};
|
||||||
|
|
||||||
gst::mini_object_wrapper!(
|
gst::memory_object_wrapper!(
|
||||||
GLBaseMemory,
|
GLBaseMemory,
|
||||||
GLBaseMemoryRef,
|
GLBaseMemoryRef,
|
||||||
GstGLBaseMemory,
|
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 {
|
impl std::fmt::Debug for GLBaseMemory {
|
||||||
type Target = MemoryRef;
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
GLBaseMemoryRef::fmt(self, f)
|
||||||
fn deref(&self) -> &Self::Target {
|
|
||||||
unsafe { &*(&self.0.mem as *const GstMemory).cast::<Self::Target>() }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::ops::DerefMut for GLBaseMemoryRef {
|
impl std::fmt::Debug for GLBaseMemoryRef {
|
||||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
unsafe { &mut *(&mut self.0.mem as *mut GstMemory).cast::<Self::Target>() }
|
gst::MemoryRef::fmt(self, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,25 +1,34 @@
|
||||||
use glib::translate::*;
|
use glib::translate::*;
|
||||||
|
|
||||||
|
use crate::GLBaseMemory;
|
||||||
use crate::GLBaseMemoryRef;
|
use crate::GLBaseMemoryRef;
|
||||||
use crate::GLFormat;
|
use crate::GLFormat;
|
||||||
use crate::GLTextureTarget;
|
use crate::GLTextureTarget;
|
||||||
|
|
||||||
use ffi::{GstGLBaseMemory, GstGLMemory};
|
use ffi::GstGLMemory;
|
||||||
use gst::{result_from_gboolean, LoggableError, CAT_RUST};
|
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 {
|
impl std::fmt::Debug for GLMemory {
|
||||||
type Target = GLBaseMemoryRef;
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
GLMemoryRef::fmt(self, f)
|
||||||
fn deref(&self) -> &Self::Target {
|
|
||||||
unsafe { &*(&self.0.mem as *const GstGLBaseMemory).cast::<Self::Target>() }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::ops::DerefMut for GLMemoryRef {
|
impl std::fmt::Debug for GLMemoryRef {
|
||||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
unsafe { &mut *(&mut self.0.mem as *mut GstGLBaseMemory).cast::<Self::Target>() }
|
GLBaseMemoryRef::fmt(self, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
31
gstreamer-gl/src/gl_memory_pbo.rs
Normal file
31
gstreamer-gl/src/gl_memory_pbo.rs
Normal 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)
|
||||||
|
}
|
||||||
|
}
|
|
@ -45,6 +45,8 @@ mod gl_base_memory;
|
||||||
pub use self::gl_base_memory::*;
|
pub use self::gl_base_memory::*;
|
||||||
mod gl_memory;
|
mod gl_memory;
|
||||||
pub use crate::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
|
// Re-export all the traits in a prelude module, so that applications
|
||||||
// can always "use gst_gl::prelude::*" without getting conflicts
|
// can always "use gst_gl::prelude::*" without getting conflicts
|
||||||
|
|
Loading…
Reference in a new issue