gstreamer_gl/
gl_sync_meta.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use std::fmt;
4
5use glib::translate::*;
6use gst::prelude::*;
7
8use crate::{ffi, GLContext};
9
10#[repr(transparent)]
11#[doc(alias = "GstGLSyncMeta")]
12pub struct GLSyncMeta(ffi::GstGLSyncMeta);
13
14unsafe impl Send for GLSyncMeta {}
15unsafe impl Sync for GLSyncMeta {}
16
17impl GLSyncMeta {
18    #[doc(alias = "gst_buffer_add_gl_sync_meta")]
19    pub fn add<'a, C: IsA<GLContext>>(
20        buffer: &'a mut gst::BufferRef,
21        context: &C,
22    ) -> gst::MetaRefMut<'a, Self, gst::meta::Standalone> {
23        skip_assert_initialized!();
24        unsafe {
25            let meta = ffi::gst_buffer_add_gl_sync_meta(
26                context.as_ref().to_glib_none().0,
27                buffer.as_mut_ptr(),
28            );
29            Self::from_mut_ptr(buffer, meta)
30        }
31    }
32
33    #[doc(alias = "get_context")]
34    #[inline]
35    pub fn context(&self) -> &GLContext {
36        unsafe { &*(&self.0.context as *const *mut ffi::GstGLContext as *const GLContext) }
37    }
38
39    #[doc(alias = "gst_gl_sync_meta_set_sync_point")]
40    pub fn set_sync_point(&self, context: &impl IsA<GLContext>) {
41        unsafe {
42            ffi::gst_gl_sync_meta_set_sync_point(
43                mut_override(&self.0),
44                context.as_ref().to_glib_none().0,
45            );
46        }
47    }
48
49    #[doc(alias = "gst_gl_sync_meta_wait")]
50    pub fn wait(&self, context: &impl IsA<GLContext>) {
51        unsafe {
52            ffi::gst_gl_sync_meta_wait(mut_override(&self.0), context.as_ref().to_glib_none().0);
53        }
54    }
55
56    #[doc(alias = "gst_gl_sync_meta_wait_cpu")]
57    pub fn wait_cpu(&self, context: &impl IsA<GLContext>) {
58        unsafe {
59            ffi::gst_gl_sync_meta_wait_cpu(
60                mut_override(&self.0),
61                context.as_ref().to_glib_none().0,
62            );
63        }
64    }
65}
66
67unsafe impl MetaAPI for GLSyncMeta {
68    type GstType = ffi::GstGLSyncMeta;
69
70    #[doc(alias = "gst_gl_sync_meta_api_get_type")]
71    #[inline]
72    fn meta_api() -> glib::Type {
73        unsafe { from_glib(ffi::gst_gl_sync_meta_api_get_type()) }
74    }
75}
76
77impl fmt::Debug for GLSyncMeta {
78    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
79        f.debug_struct("GLSyncMeta")
80            .field("context", &self.context())
81            .finish()
82    }
83}