1use crate::{ffi, GLContext, GLStereoDownmix};
7use glib::{
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "GstGLViewConvert")]
59    pub struct GLViewConvert(Object<ffi::GstGLViewConvert, ffi::GstGLViewConvertClass>) @extends gst::Object;
60
61    match fn {
62        type_ => || ffi::gst_gl_view_convert_get_type(),
63    }
64}
65
66impl GLViewConvert {
67    #[doc(alias = "gst_gl_view_convert_new")]
72    pub fn new() -> GLViewConvert {
73        assert_initialized_main_thread!();
74        unsafe { from_glib_full(ffi::gst_gl_view_convert_new()) }
75    }
76
77    #[doc(alias = "gst_gl_view_convert_perform")]
86    pub fn perform(&self, inbuf: &gst::Buffer) -> Option<gst::Buffer> {
87        unsafe {
88            from_glib_full(ffi::gst_gl_view_convert_perform(
89                self.to_glib_none().0,
90                inbuf.to_glib_none().0,
91            ))
92        }
93    }
94
95    #[doc(alias = "gst_gl_view_convert_reset")]
98    pub fn reset(&self) {
99        unsafe {
100            ffi::gst_gl_view_convert_reset(self.to_glib_none().0);
101        }
102    }
103
104    #[doc(alias = "gst_gl_view_convert_set_caps")]
110    pub fn set_caps(
111        &self,
112        in_caps: &gst::Caps,
113        out_caps: &gst::Caps,
114    ) -> Result<(), glib::error::BoolError> {
115        unsafe {
116            glib::result_from_gboolean!(
117                ffi::gst_gl_view_convert_set_caps(
118                    self.to_glib_none().0,
119                    in_caps.to_glib_none().0,
120                    out_caps.to_glib_none().0
121                ),
122                "Failed to set caps"
123            )
124        }
125    }
126
127    #[doc(alias = "gst_gl_view_convert_set_context")]
131    pub fn set_context(&self, context: &impl IsA<GLContext>) {
132        unsafe {
133            ffi::gst_gl_view_convert_set_context(
134                self.to_glib_none().0,
135                context.as_ref().to_glib_none().0,
136            );
137        }
138    }
139
140    #[doc(alias = "gst_gl_view_convert_transform_caps")]
152    pub fn transform_caps(
153        &self,
154        direction: gst::PadDirection,
155        caps: &gst::Caps,
156        filter: &gst::Caps,
157    ) -> gst::Caps {
158        unsafe {
159            from_glib_full(ffi::gst_gl_view_convert_transform_caps(
160                self.to_glib_none().0,
161                direction.into_glib(),
162                caps.to_glib_none().0,
163                filter.to_glib_none().0,
164            ))
165        }
166    }
167
168    #[doc(alias = "downmix-mode")]
169    pub fn downmix_mode(&self) -> GLStereoDownmix {
170        ObjectExt::property(self, "downmix-mode")
171    }
172
173    #[doc(alias = "downmix-mode")]
174    pub fn set_downmix_mode(&self, downmix_mode: GLStereoDownmix) {
175        ObjectExt::set_property(self, "downmix-mode", downmix_mode)
176    }
177
178    #[doc(alias = "input-flags-override")]
179    pub fn input_flags_override(&self) -> gst_video::VideoMultiviewFlags {
180        ObjectExt::property(self, "input-flags-override")
181    }
182
183    #[doc(alias = "input-flags-override")]
184    pub fn set_input_flags_override(&self, input_flags_override: gst_video::VideoMultiviewFlags) {
185        ObjectExt::set_property(self, "input-flags-override", input_flags_override)
186    }
187
188    #[doc(alias = "input-mode-override")]
189    pub fn input_mode_override(&self) -> gst_video::VideoMultiviewMode {
190        ObjectExt::property(self, "input-mode-override")
191    }
192
193    #[doc(alias = "input-mode-override")]
194    pub fn set_input_mode_override(&self, input_mode_override: gst_video::VideoMultiviewMode) {
195        ObjectExt::set_property(self, "input-mode-override", input_mode_override)
196    }
197
198    #[doc(alias = "output-flags-override")]
199    pub fn output_flags_override(&self) -> gst_video::VideoMultiviewFlags {
200        ObjectExt::property(self, "output-flags-override")
201    }
202
203    #[doc(alias = "output-flags-override")]
204    pub fn set_output_flags_override(&self, output_flags_override: gst_video::VideoMultiviewFlags) {
205        ObjectExt::set_property(self, "output-flags-override", output_flags_override)
206    }
207
208    #[doc(alias = "output-mode-override")]
209    pub fn output_mode_override(&self) -> gst_video::VideoMultiviewMode {
210        ObjectExt::property(self, "output-mode-override")
211    }
212
213    #[doc(alias = "output-mode-override")]
214    pub fn set_output_mode_override(&self, output_mode_override: gst_video::VideoMultiviewMode) {
215        ObjectExt::set_property(self, "output-mode-override", output_mode_override)
216    }
217
218    #[doc(alias = "downmix-mode")]
219    pub fn connect_downmix_mode_notify<F: Fn(&Self) + Send + Sync + 'static>(
220        &self,
221        f: F,
222    ) -> SignalHandlerId {
223        unsafe extern "C" fn notify_downmix_mode_trampoline<
224            F: Fn(&GLViewConvert) + Send + Sync + 'static,
225        >(
226            this: *mut ffi::GstGLViewConvert,
227            _param_spec: glib::ffi::gpointer,
228            f: glib::ffi::gpointer,
229        ) {
230            let f: &F = &*(f as *const F);
231            f(&from_glib_borrow(this))
232        }
233        unsafe {
234            let f: Box_<F> = Box_::new(f);
235            connect_raw(
236                self.as_ptr() as *mut _,
237                c"notify::downmix-mode".as_ptr() as *const _,
238                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
239                    notify_downmix_mode_trampoline::<F> as *const (),
240                )),
241                Box_::into_raw(f),
242            )
243        }
244    }
245
246    #[doc(alias = "input-flags-override")]
247    pub fn connect_input_flags_override_notify<F: Fn(&Self) + Send + Sync + 'static>(
248        &self,
249        f: F,
250    ) -> SignalHandlerId {
251        unsafe extern "C" fn notify_input_flags_override_trampoline<
252            F: Fn(&GLViewConvert) + Send + Sync + 'static,
253        >(
254            this: *mut ffi::GstGLViewConvert,
255            _param_spec: glib::ffi::gpointer,
256            f: glib::ffi::gpointer,
257        ) {
258            let f: &F = &*(f as *const F);
259            f(&from_glib_borrow(this))
260        }
261        unsafe {
262            let f: Box_<F> = Box_::new(f);
263            connect_raw(
264                self.as_ptr() as *mut _,
265                c"notify::input-flags-override".as_ptr() as *const _,
266                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
267                    notify_input_flags_override_trampoline::<F> as *const (),
268                )),
269                Box_::into_raw(f),
270            )
271        }
272    }
273
274    #[doc(alias = "input-mode-override")]
275    pub fn connect_input_mode_override_notify<F: Fn(&Self) + Send + Sync + 'static>(
276        &self,
277        f: F,
278    ) -> SignalHandlerId {
279        unsafe extern "C" fn notify_input_mode_override_trampoline<
280            F: Fn(&GLViewConvert) + Send + Sync + 'static,
281        >(
282            this: *mut ffi::GstGLViewConvert,
283            _param_spec: glib::ffi::gpointer,
284            f: glib::ffi::gpointer,
285        ) {
286            let f: &F = &*(f as *const F);
287            f(&from_glib_borrow(this))
288        }
289        unsafe {
290            let f: Box_<F> = Box_::new(f);
291            connect_raw(
292                self.as_ptr() as *mut _,
293                c"notify::input-mode-override".as_ptr() as *const _,
294                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
295                    notify_input_mode_override_trampoline::<F> as *const (),
296                )),
297                Box_::into_raw(f),
298            )
299        }
300    }
301
302    #[doc(alias = "output-flags-override")]
303    pub fn connect_output_flags_override_notify<F: Fn(&Self) + Send + Sync + 'static>(
304        &self,
305        f: F,
306    ) -> SignalHandlerId {
307        unsafe extern "C" fn notify_output_flags_override_trampoline<
308            F: Fn(&GLViewConvert) + Send + Sync + 'static,
309        >(
310            this: *mut ffi::GstGLViewConvert,
311            _param_spec: glib::ffi::gpointer,
312            f: glib::ffi::gpointer,
313        ) {
314            let f: &F = &*(f as *const F);
315            f(&from_glib_borrow(this))
316        }
317        unsafe {
318            let f: Box_<F> = Box_::new(f);
319            connect_raw(
320                self.as_ptr() as *mut _,
321                c"notify::output-flags-override".as_ptr() as *const _,
322                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
323                    notify_output_flags_override_trampoline::<F> as *const (),
324                )),
325                Box_::into_raw(f),
326            )
327        }
328    }
329
330    #[doc(alias = "output-mode-override")]
331    pub fn connect_output_mode_override_notify<F: Fn(&Self) + Send + Sync + 'static>(
332        &self,
333        f: F,
334    ) -> SignalHandlerId {
335        unsafe extern "C" fn notify_output_mode_override_trampoline<
336            F: Fn(&GLViewConvert) + Send + Sync + 'static,
337        >(
338            this: *mut ffi::GstGLViewConvert,
339            _param_spec: glib::ffi::gpointer,
340            f: glib::ffi::gpointer,
341        ) {
342            let f: &F = &*(f as *const F);
343            f(&from_glib_borrow(this))
344        }
345        unsafe {
346            let f: Box_<F> = Box_::new(f);
347            connect_raw(
348                self.as_ptr() as *mut _,
349                c"notify::output-mode-override".as_ptr() as *const _,
350                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
351                    notify_output_mode_override_trampoline::<F> as *const (),
352                )),
353                Box_::into_raw(f),
354            )
355        }
356    }
357}
358
359impl Default for GLViewConvert {
360    fn default() -> Self {
361        Self::new()
362    }
363}
364
365unsafe impl Send for GLViewConvert {}
366unsafe impl Sync for GLViewConvert {}