gstreamer_vulkan/auto/
vulkan_swapper.rs1use 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 #[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
72pub trait VulkanSwapperExt: IsA<VulkanSwapper> + 'static {
78 #[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_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 {}