gstreamer_vulkan/auto/
vulkan_swapper.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
4// DO NOT EDIT
5
6use crate::{ffi, VulkanDevice, VulkanQueue, VulkanWindow};
7use glib::{
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    ///
16    ///
17    /// ## Properties
18    ///
19    ///
20    /// #### `force-aspect-ratio`
21    ///  Readable | Writeable
22    ///
23    ///
24    /// #### `pixel-aspect-ratio`
25    ///  Readable | Writeable
26    /// <details><summary><h4>Object</h4></summary>
27    ///
28    ///
29    /// #### `name`
30    ///  Readable | Writeable | Construct
31    ///
32    ///
33    /// #### `parent`
34    ///  The parent of the object. Please note, that when changing the 'parent'
35    /// property, we don't emit [`notify`][struct@crate::glib::Object#notify] and [`deep-notify`][struct@crate::gst::Object#deep-notify]
36    /// signals due to locking issues. In some cases one can use
37    /// `GstBin::element-added` or `GstBin::element-removed` signals on the parent to
38    /// achieve a similar effect.
39    ///
40    /// Readable | Writeable
41    /// </details>
42    ///
43    /// # Implements
44    ///
45    /// [`VulkanSwapperExt`][trait@crate::prelude::VulkanSwapperExt], [`trait@gst::prelude::ObjectExt`], [`trait@glib::ObjectExt`]
46    #[doc(alias = "GstVulkanSwapper")]
47    pub struct VulkanSwapper(Object<ffi::GstVulkanSwapper, ffi::GstVulkanSwapperClass>) @extends gst::Object;
48
49    match fn {
50        type_ => || ffi::gst_vulkan_swapper_get_type(),
51    }
52}
53
54impl VulkanSwapper {
55    pub const NONE: Option<&'static VulkanSwapper> = None;
56
57    #[doc(alias = "gst_vulkan_swapper_new")]
58    pub fn new(device: &impl IsA<VulkanDevice>, window: &impl IsA<VulkanWindow>) -> VulkanSwapper {
59        skip_assert_initialized!();
60        unsafe {
61            from_glib_none(ffi::gst_vulkan_swapper_new(
62                device.as_ref().to_glib_none().0,
63                window.as_ref().to_glib_none().0,
64            ))
65        }
66    }
67}
68
69unsafe impl Send for VulkanSwapper {}
70unsafe impl Sync for VulkanSwapper {}
71
72/// Trait containing all [`struct@VulkanSwapper`] methods.
73///
74/// # Implementors
75///
76/// [`VulkanSwapper`][struct@crate::VulkanSwapper]
77pub trait VulkanSwapperExt: IsA<VulkanSwapper> + 'static {
78    /// ## `available_queue`
79    /// a [`VulkanQueue`][crate::VulkanQueue] chosen elsewhere
80    #[doc(alias = "gst_vulkan_swapper_choose_queue")]
81    fn choose_queue(
82        &self,
83        available_queue: Option<&impl IsA<VulkanQueue>>,
84    ) -> Result<(), glib::Error> {
85        unsafe {
86            let mut error = std::ptr::null_mut();
87            let is_ok = ffi::gst_vulkan_swapper_choose_queue(
88                self.as_ref().to_glib_none().0,
89                available_queue.map(|p| p.as_ref()).to_glib_none().0,
90                &mut error,
91            );
92            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
93            if error.is_null() {
94                Ok(())
95            } else {
96                Err(from_glib_full(error))
97            }
98        }
99    }
100
101    #[doc(alias = "gst_vulkan_swapper_get_supported_caps")]
102    #[doc(alias = "get_supported_caps")]
103    fn supported_caps(&self) -> Result<gst::Caps, glib::Error> {
104        unsafe {
105            let mut error = std::ptr::null_mut();
106            let ret = ffi::gst_vulkan_swapper_get_supported_caps(
107                self.as_ref().to_glib_none().0,
108                &mut error,
109            );
110            if error.is_null() {
111                Ok(from_glib_full(ret))
112            } else {
113                Err(from_glib_full(error))
114            }
115        }
116    }
117
118    //#[doc(alias = "gst_vulkan_swapper_get_surface_rectangles")]
119    //#[doc(alias = "get_surface_rectangles")]
120    //fn surface_rectangles(&self, input_image: /*Ignored*/Option<gst_video::VideoRectangle>, surface_location: /*Ignored*/Option<gst_video::VideoRectangle>, display_rect: /*Ignored*/Option<gst_video::VideoRectangle>) {
121    //    unsafe { TODO: call ffi:gst_vulkan_swapper_get_surface_rectangles() }
122    //}
123
124    #[doc(alias = "gst_vulkan_swapper_render_buffer")]
125    fn render_buffer(&self, buffer: &gst::Buffer) -> Result<(), glib::Error> {
126        unsafe {
127            let mut error = std::ptr::null_mut();
128            let is_ok = ffi::gst_vulkan_swapper_render_buffer(
129                self.as_ref().to_glib_none().0,
130                buffer.to_glib_none().0,
131                &mut error,
132            );
133            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
134            if error.is_null() {
135                Ok(())
136            } else {
137                Err(from_glib_full(error))
138            }
139        }
140    }
141
142    #[doc(alias = "gst_vulkan_swapper_set_caps")]
143    fn set_caps(&self, caps: &gst::Caps) -> Result<(), glib::Error> {
144        unsafe {
145            let mut error = std::ptr::null_mut();
146            let is_ok = ffi::gst_vulkan_swapper_set_caps(
147                self.as_ref().to_glib_none().0,
148                caps.to_glib_none().0,
149                &mut error,
150            );
151            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
152            if error.is_null() {
153                Ok(())
154            } else {
155                Err(from_glib_full(error))
156            }
157        }
158    }
159
160    #[doc(alias = "force-aspect-ratio")]
161    fn is_force_aspect_ratio(&self) -> bool {
162        ObjectExt::property(self.as_ref(), "force-aspect-ratio")
163    }
164
165    #[doc(alias = "force-aspect-ratio")]
166    fn set_force_aspect_ratio(&self, force_aspect_ratio: bool) {
167        ObjectExt::set_property(self.as_ref(), "force-aspect-ratio", force_aspect_ratio)
168    }
169
170    #[doc(alias = "force-aspect-ratio")]
171    fn connect_force_aspect_ratio_notify<F: Fn(&Self) + Send + Sync + 'static>(
172        &self,
173        f: F,
174    ) -> SignalHandlerId {
175        unsafe extern "C" fn notify_force_aspect_ratio_trampoline<
176            P: IsA<VulkanSwapper>,
177            F: Fn(&P) + Send + Sync + 'static,
178        >(
179            this: *mut ffi::GstVulkanSwapper,
180            _param_spec: glib::ffi::gpointer,
181            f: glib::ffi::gpointer,
182        ) {
183            let f: &F = &*(f as *const F);
184            f(VulkanSwapper::from_glib_borrow(this).unsafe_cast_ref())
185        }
186        unsafe {
187            let f: Box_<F> = Box_::new(f);
188            connect_raw(
189                self.as_ptr() as *mut _,
190                c"notify::force-aspect-ratio".as_ptr() as *const _,
191                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
192                    notify_force_aspect_ratio_trampoline::<Self, F> as *const (),
193                )),
194                Box_::into_raw(f),
195            )
196        }
197    }
198}
199
200impl<O: IsA<VulkanSwapper>> VulkanSwapperExt for O {}