1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
// DO NOT EDIT

#[cfg(feature = "v1_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
use crate::GLAllocationParams;
use crate::{ffi, GLContext};
use glib::{prelude::*, translate::*};

glib::wrapper! {
    /// a [`GLBufferPool`][crate::GLBufferPool] is an object that allocates buffers with [`GLBaseMemory`][crate::GLBaseMemory]
    ///
    /// A [`GLBufferPool`][crate::GLBufferPool] is created with [`new()`][Self::new()]
    ///
    /// [`GLBufferPool`][crate::GLBufferPool] implements the VideoMeta buffer pool option
    /// `GST_BUFFER_POOL_OPTION_VIDEO_META`, the VideoAligment buffer pool option
    /// `GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT` as well as the OpenGL specific
    /// [`BUFFER_POOL_OPTION_GL_SYNC_META`][crate::BUFFER_POOL_OPTION_GL_SYNC_META] buffer pool option.
    ///
    /// # Implements
    ///
    /// [`GLBufferPoolExt`][trait@crate::prelude::GLBufferPoolExt], [`trait@gst::prelude::BufferPoolExt`], [`trait@gst::prelude::ObjectExt`], [`trait@glib::ObjectExt`]
    #[doc(alias = "GstGLBufferPool")]
    pub struct GLBufferPool(Object<ffi::GstGLBufferPool, ffi::GstGLBufferPoolClass>) @extends gst::BufferPool, gst::Object;

    match fn {
        type_ => || ffi::gst_gl_buffer_pool_get_type(),
    }
}

impl GLBufferPool {
    pub const NONE: Option<&'static GLBufferPool> = None;

    /// ## `context`
    /// the [`GLContext`][crate::GLContext] to use
    ///
    /// # Returns
    ///
    /// a [`gst::BufferPool`][crate::gst::BufferPool] that allocates buffers with [`GLMemory`][crate::GLMemory]
    #[doc(alias = "gst_gl_buffer_pool_new")]
    pub fn new(context: &impl IsA<GLContext>) -> GLBufferPool {
        skip_assert_initialized!();
        unsafe {
            gst::BufferPool::from_glib_none(ffi::gst_gl_buffer_pool_new(
                context.as_ref().to_glib_none().0,
            ))
            .unsafe_cast()
        }
    }
}

unsafe impl Send for GLBufferPool {}
unsafe impl Sync for GLBufferPool {}

mod sealed {
    pub trait Sealed {}
    impl<T: super::IsA<super::GLBufferPool>> Sealed for T {}
}

/// Trait containing all [`struct@GLBufferPool`] methods.
///
/// # Implementors
///
/// [`GLBufferPool`][struct@crate::GLBufferPool]
pub trait GLBufferPoolExt: IsA<GLBufferPool> + sealed::Sealed + 'static {
    /// The returned [`GLAllocationParams`][crate::GLAllocationParams] will by [`None`] before the first successful
    /// call to [`BufferPoolExtManual::set_config()`][crate::gst::prelude::BufferPoolExtManual::set_config()]. Subsequent successful calls to
    /// [`BufferPoolExtManual::set_config()`][crate::gst::prelude::BufferPoolExtManual::set_config()] will cause this function to return a new
    /// [`GLAllocationParams`][crate::GLAllocationParams] which may or may not contain the same information.
    ///
    /// # Returns
    ///
    /// a copy of the [`GLAllocationParams`][crate::GLAllocationParams] being used by the `self`
    #[cfg(feature = "v1_20")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
    #[doc(alias = "gst_gl_buffer_pool_get_gl_allocation_params")]
    #[doc(alias = "get_gl_allocation_params")]
    fn gl_allocation_params(&self) -> Option<GLAllocationParams> {
        unsafe {
            from_glib_full(ffi::gst_gl_buffer_pool_get_gl_allocation_params(
                self.as_ref().to_glib_none().0,
            ))
        }
    }
}

impl<O: IsA<GLBufferPool>> GLBufferPoolExt for O {}