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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
// 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

use crate::GLContext;
use glib::{prelude::*, translate::*};

glib::wrapper! {
    /// [`GLUpload`][crate::GLUpload] is an object that uploads data from system memory into GL textures.
    ///
    /// A [`GLUpload`][crate::GLUpload] can be created with [`new()`][Self::new()]
    ///
    /// # Implements
    ///
    /// [`trait@gst::prelude::ObjectExt`], [`trait@glib::ObjectExt`]
    #[doc(alias = "GstGLUpload")]
    pub struct GLUpload(Object<ffi::GstGLUpload, ffi::GstGLUploadClass>) @extends gst::Object;

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

impl GLUpload {
    /// ## `context`
    /// a [`GLContext`][crate::GLContext]
    ///
    /// # Returns
    ///
    /// a new [`GLUpload`][crate::GLUpload] object
    #[doc(alias = "gst_gl_upload_new")]
    pub fn new(context: &impl IsA<GLContext>) -> GLUpload {
        skip_assert_initialized!();
        unsafe { from_glib_full(ffi::gst_gl_upload_new(context.as_ref().to_glib_none().0)) }
    }

    /// Fixate the `othercaps` based on the information of the `caps`.
    /// ## `direction`
    /// the pad [`gst::PadDirection`][crate::gst::PadDirection]
    /// ## `caps`
    /// a [`gst::Caps`][crate::gst::Caps] as the reference
    /// ## `othercaps`
    /// a [`gst::Caps`][crate::gst::Caps] to fixate
    ///
    /// # Returns
    ///
    /// the fixated caps
    #[cfg(feature = "v1_24")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
    #[doc(alias = "gst_gl_upload_fixate_caps")]
    pub fn fixate_caps(
        &self,
        direction: gst::PadDirection,
        caps: &gst::Caps,
        othercaps: gst::Caps,
    ) -> gst::Caps {
        unsafe {
            from_glib_full(ffi::gst_gl_upload_fixate_caps(
                self.to_glib_none().0,
                direction.into_glib(),
                caps.to_glib_none().0,
                othercaps.into_glib_ptr(),
            ))
        }
    }

    ///
    /// # Returns
    ///
    ///
    /// ## `in_caps`
    /// the input [`gst::Caps`][crate::gst::Caps]
    ///
    /// ## `out_caps`
    /// the output [`gst::Caps`][crate::gst::Caps]
    #[doc(alias = "gst_gl_upload_get_caps")]
    #[doc(alias = "get_caps")]
    pub fn caps(&self) -> (gst::Caps, gst::Caps) {
        unsafe {
            let mut in_caps = std::ptr::null_mut();
            let mut out_caps = std::ptr::null_mut();
            ffi::gst_gl_upload_get_caps(self.to_glib_none().0, &mut in_caps, &mut out_caps);
            (from_glib_full(in_caps), from_glib_full(out_caps))
        }
    }

    /// Initializes `self` with the information required for upload.
    /// ## `in_caps`
    /// input [`gst::Caps`][crate::gst::Caps]
    /// ## `out_caps`
    /// output [`gst::Caps`][crate::gst::Caps]
    ///
    /// # Returns
    ///
    /// whether `in_caps` and `out_caps` could be set on `self`
    #[doc(alias = "gst_gl_upload_set_caps")]
    pub fn set_caps(
        &self,
        in_caps: &gst::Caps,
        out_caps: &gst::Caps,
    ) -> Result<(), glib::error::BoolError> {
        unsafe {
            glib::result_from_gboolean!(
                ffi::gst_gl_upload_set_caps(
                    self.to_glib_none().0,
                    in_caps.to_glib_none().0,
                    out_caps.to_glib_none().0
                ),
                "Failed to set caps"
            )
        }
    }

    #[doc(alias = "gst_gl_upload_set_context")]
    pub fn set_context(&self, context: &impl IsA<GLContext>) {
        unsafe {
            ffi::gst_gl_upload_set_context(
                self.to_glib_none().0,
                context.as_ref().to_glib_none().0,
            );
        }
    }

    #[doc(alias = "gst_gl_upload_transform_caps")]
    pub fn transform_caps(
        &self,
        context: &impl IsA<GLContext>,
        direction: gst::PadDirection,
        caps: &gst::Caps,
        filter: &gst::Caps,
    ) -> gst::Caps {
        unsafe {
            from_glib_full(ffi::gst_gl_upload_transform_caps(
                self.to_glib_none().0,
                context.as_ref().to_glib_none().0,
                direction.into_glib(),
                caps.to_glib_none().0,
                filter.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "gst_gl_upload_get_input_template_caps")]
    #[doc(alias = "get_input_template_caps")]
    pub fn input_template_caps() -> gst::Caps {
        assert_initialized_main_thread!();
        unsafe { from_glib_full(ffi::gst_gl_upload_get_input_template_caps()) }
    }
}

unsafe impl Send for GLUpload {}
unsafe impl Sync for GLUpload {}