gstreamer_vulkan/auto/
vulkan_swapper.rs1use crate::{VulkanDevice, VulkanQueue, VulkanWindow, ffi};
7use glib::{
8 prelude::*,
9 signal::{SignalHandlerId, connect_raw},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 #[doc(alias = "GstVulkanSwapper")]
16 pub struct VulkanSwapper(Object<ffi::GstVulkanSwapper, ffi::GstVulkanSwapperClass>) @extends gst::Object;
17
18 match fn {
19 type_ => || ffi::gst_vulkan_swapper_get_type(),
20 }
21}
22
23impl VulkanSwapper {
24 pub const NONE: Option<&'static VulkanSwapper> = None;
25
26 #[doc(alias = "gst_vulkan_swapper_new")]
27 pub fn new(device: &impl IsA<VulkanDevice>, window: &impl IsA<VulkanWindow>) -> VulkanSwapper {
28 skip_assert_initialized!();
29 unsafe {
30 from_glib_none(ffi::gst_vulkan_swapper_new(
31 device.as_ref().to_glib_none().0,
32 window.as_ref().to_glib_none().0,
33 ))
34 }
35 }
36}
37
38unsafe impl Send for VulkanSwapper {}
39unsafe impl Sync for VulkanSwapper {}
40
41pub trait VulkanSwapperExt: IsA<VulkanSwapper> + 'static {
42 #[doc(alias = "gst_vulkan_swapper_choose_queue")]
43 fn choose_queue(
44 &self,
45 available_queue: Option<&impl IsA<VulkanQueue>>,
46 ) -> Result<(), glib::Error> {
47 unsafe {
48 let mut error = std::ptr::null_mut();
49 let is_ok = ffi::gst_vulkan_swapper_choose_queue(
50 self.as_ref().to_glib_none().0,
51 available_queue.map(|p| p.as_ref()).to_glib_none().0,
52 &mut error,
53 );
54 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
55 if error.is_null() {
56 Ok(())
57 } else {
58 Err(from_glib_full(error))
59 }
60 }
61 }
62
63 #[doc(alias = "gst_vulkan_swapper_get_supported_caps")]
64 #[doc(alias = "get_supported_caps")]
65 fn supported_caps(&self) -> Result<gst::Caps, glib::Error> {
66 unsafe {
67 let mut error = std::ptr::null_mut();
68 let ret = ffi::gst_vulkan_swapper_get_supported_caps(
69 self.as_ref().to_glib_none().0,
70 &mut error,
71 );
72 if error.is_null() {
73 Ok(from_glib_full(ret))
74 } else {
75 Err(from_glib_full(error))
76 }
77 }
78 }
79
80 #[doc(alias = "gst_vulkan_swapper_render_buffer")]
87 fn render_buffer(&self, buffer: &gst::Buffer) -> Result<(), glib::Error> {
88 unsafe {
89 let mut error = std::ptr::null_mut();
90 let is_ok = ffi::gst_vulkan_swapper_render_buffer(
91 self.as_ref().to_glib_none().0,
92 buffer.to_glib_none().0,
93 &mut error,
94 );
95 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
96 if error.is_null() {
97 Ok(())
98 } else {
99 Err(from_glib_full(error))
100 }
101 }
102 }
103
104 #[doc(alias = "gst_vulkan_swapper_set_caps")]
105 fn set_caps(&self, caps: &gst::Caps) -> Result<(), glib::Error> {
106 unsafe {
107 let mut error = std::ptr::null_mut();
108 let is_ok = ffi::gst_vulkan_swapper_set_caps(
109 self.as_ref().to_glib_none().0,
110 caps.to_glib_none().0,
111 &mut error,
112 );
113 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
114 if error.is_null() {
115 Ok(())
116 } else {
117 Err(from_glib_full(error))
118 }
119 }
120 }
121
122 #[doc(alias = "force-aspect-ratio")]
123 fn is_force_aspect_ratio(&self) -> bool {
124 ObjectExt::property(self.as_ref(), "force-aspect-ratio")
125 }
126
127 #[doc(alias = "force-aspect-ratio")]
128 fn set_force_aspect_ratio(&self, force_aspect_ratio: bool) {
129 ObjectExt::set_property(self.as_ref(), "force-aspect-ratio", force_aspect_ratio)
130 }
131
132 #[doc(alias = "force-aspect-ratio")]
133 fn connect_force_aspect_ratio_notify<F: Fn(&Self) + Send + Sync + 'static>(
134 &self,
135 f: F,
136 ) -> SignalHandlerId {
137 unsafe extern "C" fn notify_force_aspect_ratio_trampoline<
138 P: IsA<VulkanSwapper>,
139 F: Fn(&P) + Send + Sync + 'static,
140 >(
141 this: *mut ffi::GstVulkanSwapper,
142 _param_spec: glib::ffi::gpointer,
143 f: glib::ffi::gpointer,
144 ) {
145 unsafe {
146 let f: &F = &*(f as *const F);
147 f(VulkanSwapper::from_glib_borrow(this).unsafe_cast_ref())
148 }
149 }
150 unsafe {
151 let f: Box_<F> = Box_::new(f);
152 connect_raw(
153 self.as_ptr() as *mut _,
154 c"notify::force-aspect-ratio".as_ptr(),
155 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
156 notify_force_aspect_ratio_trampoline::<Self, F> as *const (),
157 )),
158 Box_::into_raw(f),
159 )
160 }
161 }
162}
163
164impl<O: IsA<VulkanSwapper>> VulkanSwapperExt for O {}