mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-22 17:41:05 +00:00
gl: Add bindings for GLSyncMeta
This commit is contained in:
parent
4ce27c130b
commit
d8554071b6
2 changed files with 76 additions and 0 deletions
74
gstreamer-gl/src/gl_sync_meta.rs
Normal file
74
gstreamer-gl/src/gl_sync_meta.rs
Normal file
|
@ -0,0 +1,74 @@
|
|||
use std::fmt;
|
||||
|
||||
use ffi;
|
||||
use glib;
|
||||
use glib::translate::*;
|
||||
use gst;
|
||||
use gst::prelude::*;
|
||||
|
||||
use GLContext;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct GLSyncMeta(ffi::GstGLSyncMeta);
|
||||
|
||||
impl GLSyncMeta {
|
||||
pub fn add<'a, C: IsA<GLContext>>(
|
||||
buffer: &'a mut gst::BufferRef,
|
||||
context: &C,
|
||||
) -> gst::MetaRefMut<'a, Self, gst::meta::Standalone> {
|
||||
unsafe {
|
||||
let meta = ffi::gst_buffer_add_gl_sync_meta(
|
||||
context.as_ref().to_glib_none().0,
|
||||
buffer.as_mut_ptr(),
|
||||
);
|
||||
Self::from_mut_ptr(buffer, meta)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_context(&self) -> GLContext {
|
||||
unsafe { from_glib_none(self.0.context) }
|
||||
}
|
||||
|
||||
pub fn set_sync_point<C: IsA<GLContext>>(&self, context: &C) {
|
||||
unsafe {
|
||||
ffi::gst_gl_sync_meta_set_sync_point(
|
||||
&self.0 as *const _ as *mut _,
|
||||
context.as_ref().to_glib_none().0,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn wait<C: IsA<GLContext>>(&self, context: &C) {
|
||||
unsafe {
|
||||
ffi::gst_gl_sync_meta_wait(
|
||||
&self.0 as *const _ as *mut _,
|
||||
context.as_ref().to_glib_none().0,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn wait_cpu<C: IsA<GLContext>>(&self, context: &C) {
|
||||
unsafe {
|
||||
ffi::gst_gl_sync_meta_wait_cpu(
|
||||
&self.0 as *const _ as *mut _,
|
||||
context.as_ref().to_glib_none().0,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl MetaAPI for GLSyncMeta {
|
||||
type GstType = ffi::GstGLSyncMeta;
|
||||
|
||||
fn get_meta_api() -> glib::Type {
|
||||
unsafe { from_glib(ffi::gst_gl_sync_meta_api_get_type()) }
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for GLSyncMeta {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("GLSyncMeta")
|
||||
.field("context", &self.get_context())
|
||||
.finish()
|
||||
}
|
||||
}
|
|
@ -57,6 +57,8 @@ pub use gl_display::GL_DISPLAY_CONTEXT_TYPE;
|
|||
mod gl_display_egl;
|
||||
mod gl_video_frame;
|
||||
pub use gl_video_frame::VideoFrameGLExt;
|
||||
mod gl_sync_meta;
|
||||
pub use gl_sync_meta::*;
|
||||
|
||||
// Re-export all the traits in a prelude module, so that applications
|
||||
// can always "use gst::prelude::*" without getting conflicts
|
||||
|
|
Loading…
Reference in a new issue