Skip to main content

gstreamer_vulkan/auto/
vulkan_device.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::{VulkanFence, VulkanInstance, VulkanPhysicalDevice, VulkanQueue, 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 = "GstVulkanDevice")]
16    pub struct VulkanDevice(Object<ffi::GstVulkanDevice, ffi::GstVulkanDeviceClass>) @extends gst::Object;
17
18    match fn {
19        type_ => || ffi::gst_vulkan_device_get_type(),
20    }
21}
22
23impl VulkanDevice {
24    pub const NONE: Option<&'static VulkanDevice> = None;
25
26    #[doc(alias = "gst_vulkan_device_new")]
27    pub fn new(physical_device: &impl IsA<VulkanPhysicalDevice>) -> VulkanDevice {
28        skip_assert_initialized!();
29        unsafe {
30            from_glib_full(ffi::gst_vulkan_device_new(
31                physical_device.as_ref().to_glib_none().0,
32            ))
33        }
34    }
35
36    #[doc(alias = "gst_vulkan_device_new_with_index")]
37    #[doc(alias = "new_with_index")]
38    pub fn with_index(instance: &impl IsA<VulkanInstance>, device_index: u32) -> VulkanDevice {
39        skip_assert_initialized!();
40        unsafe {
41            from_glib_full(ffi::gst_vulkan_device_new_with_index(
42                instance.as_ref().to_glib_none().0,
43                device_index,
44            ))
45        }
46    }
47
48    #[doc(alias = "gst_vulkan_device_handle_context_query")]
49    pub fn handle_context_query(
50        element: &impl IsA<gst::Element>,
51        query: &gst::Query,
52        device: &impl IsA<VulkanDevice>,
53    ) -> bool {
54        skip_assert_initialized!();
55        unsafe {
56            from_glib(ffi::gst_vulkan_device_handle_context_query(
57                element.as_ref().to_glib_none().0,
58                query.to_glib_none().0,
59                device.as_ref().to_glib_none().0,
60            ))
61        }
62    }
63
64    //#[doc(alias = "gst_vulkan_device_run_context_query")]
65    //pub fn run_context_query(element: &impl IsA<gst::Element>, device: impl IsA<VulkanDevice>) -> bool {
66    //    unsafe { TODO: call ffi:gst_vulkan_device_run_context_query() }
67    //}
68}
69
70unsafe impl Send for VulkanDevice {}
71unsafe impl Sync for VulkanDevice {}
72
73pub trait VulkanDeviceExt: IsA<VulkanDevice> + 'static {
74    #[doc(alias = "gst_vulkan_device_create_fence")]
75    fn create_fence(&self) -> Result<Option<VulkanFence>, glib::Error> {
76        unsafe {
77            let mut error = std::ptr::null_mut();
78            let ret =
79                ffi::gst_vulkan_device_create_fence(self.as_ref().to_glib_none().0, &mut error);
80            if error.is_null() {
81                Ok(from_glib_full(ret))
82            } else {
83                Err(from_glib_full(error))
84            }
85        }
86    }
87
88    #[doc(alias = "gst_vulkan_device_disable_extension")]
89    fn disable_extension(&self, name: &str) -> bool {
90        unsafe {
91            from_glib(ffi::gst_vulkan_device_disable_extension(
92                self.as_ref().to_glib_none().0,
93                name.to_glib_none().0,
94            ))
95        }
96    }
97
98    #[doc(alias = "gst_vulkan_device_enable_extension")]
99    fn enable_extension(&self, name: &str) -> bool {
100        unsafe {
101            from_glib(ffi::gst_vulkan_device_enable_extension(
102                self.as_ref().to_glib_none().0,
103                name.to_glib_none().0,
104            ))
105        }
106    }
107
108    #[doc(alias = "gst_vulkan_device_enable_layer")]
109    fn enable_layer(&self, name: &str) -> bool {
110        unsafe {
111            from_glib(ffi::gst_vulkan_device_enable_layer(
112                self.as_ref().to_glib_none().0,
113                name.to_glib_none().0,
114            ))
115        }
116    }
117
118    #[doc(alias = "gst_vulkan_device_foreach_queue")]
119    fn foreach_queue<P: FnMut(&VulkanDevice, &VulkanQueue) -> bool>(&self, func: P) {
120        let mut func_data: P = func;
121        unsafe extern "C" fn func_func<P: FnMut(&VulkanDevice, &VulkanQueue) -> bool>(
122            device: *mut ffi::GstVulkanDevice,
123            queue: *mut ffi::GstVulkanQueue,
124            user_data: glib::ffi::gpointer,
125        ) -> glib::ffi::gboolean {
126            unsafe {
127                let device = from_glib_borrow(device);
128                let queue = from_glib_borrow(queue);
129                let callback = user_data as *mut P;
130                (*callback)(&device, &queue).into_glib()
131            }
132        }
133        let func = Some(func_func::<P> as _);
134        let super_callback0: &mut P = &mut func_data;
135        unsafe {
136            ffi::gst_vulkan_device_foreach_queue(
137                self.as_ref().to_glib_none().0,
138                func,
139                super_callback0 as *mut _ as *mut _,
140            );
141        }
142    }
143
144    #[doc(alias = "gst_vulkan_device_get_instance")]
145    #[doc(alias = "get_instance")]
146    fn instance(&self) -> Option<VulkanInstance> {
147        unsafe {
148            from_glib_full(ffi::gst_vulkan_device_get_instance(
149                self.as_ref().to_glib_none().0,
150            ))
151        }
152    }
153
154    //#[doc(alias = "gst_vulkan_device_get_physical_device")]
155    //#[doc(alias = "get_physical_device")]
156    //#[doc(alias = "physical-device")]
157    //fn physical_device(&self) -> /*Ignored*/vulkan::PhysicalDevice {
158    //    unsafe { TODO: call ffi:gst_vulkan_device_get_physical_device() }
159    //}
160
161    //#[doc(alias = "gst_vulkan_device_get_proc_address")]
162    //#[doc(alias = "get_proc_address")]
163    //fn proc_address(&self, name: &str) -> /*Unimplemented*/Option<Basic: Pointer> {
164    //    unsafe { TODO: call ffi:gst_vulkan_device_get_proc_address() }
165    //}
166
167    #[doc(alias = "gst_vulkan_device_get_queue")]
168    #[doc(alias = "get_queue")]
169    fn queue(&self, queue_family: u32, queue_i: u32) -> VulkanQueue {
170        unsafe {
171            from_glib_full(ffi::gst_vulkan_device_get_queue(
172                self.as_ref().to_glib_none().0,
173                queue_family,
174                queue_i,
175            ))
176        }
177    }
178
179    #[doc(alias = "gst_vulkan_device_is_extension_enabled")]
180    fn is_extension_enabled(&self, name: &str) -> bool {
181        unsafe {
182            from_glib(ffi::gst_vulkan_device_is_extension_enabled(
183                self.as_ref().to_glib_none().0,
184                name.to_glib_none().0,
185            ))
186        }
187    }
188
189    #[doc(alias = "gst_vulkan_device_is_layer_enabled")]
190    fn is_layer_enabled(&self, name: &str) -> bool {
191        unsafe {
192            from_glib(ffi::gst_vulkan_device_is_layer_enabled(
193                self.as_ref().to_glib_none().0,
194                name.to_glib_none().0,
195            ))
196        }
197    }
198
199    #[doc(alias = "gst_vulkan_device_open")]
200    fn open(&self) -> Result<(), glib::Error> {
201        unsafe {
202            let mut error = std::ptr::null_mut();
203            let is_ok = ffi::gst_vulkan_device_open(self.as_ref().to_glib_none().0, &mut error);
204            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
205            if error.is_null() {
206                Ok(())
207            } else {
208                Err(from_glib_full(error))
209            }
210        }
211    }
212
213    //#[cfg(feature = "v1_24")]
214    //#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
215    //#[doc(alias = "gst_vulkan_device_queue_family_indices")]
216    //fn queue_family_indices(&self) -> /*Unknown conversion*//*Unimplemented*/Array TypeId { ns_id: 0, id: 7 } {
217    //    unsafe { TODO: call ffi:gst_vulkan_device_queue_family_indices() }
218    //}
219
220    //#[cfg(feature = "v1_24")]
221    //#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
222    //#[doc(alias = "gst_vulkan_device_select_queue")]
223    //fn select_queue(&self, expected_flags: /*Ignored*/&vulkan::QueueFlagBits) -> Option<VulkanQueue> {
224    //    unsafe { TODO: call ffi:gst_vulkan_device_select_queue() }
225    //}
226
227    #[doc(alias = "instance")]
228    fn connect_instance_notify<F: Fn(&Self) + Send + Sync + 'static>(
229        &self,
230        f: F,
231    ) -> SignalHandlerId {
232        unsafe extern "C" fn notify_instance_trampoline<
233            P: IsA<VulkanDevice>,
234            F: Fn(&P) + Send + Sync + 'static,
235        >(
236            this: *mut ffi::GstVulkanDevice,
237            _param_spec: glib::ffi::gpointer,
238            f: glib::ffi::gpointer,
239        ) {
240            unsafe {
241                let f: &F = &*(f as *const F);
242                f(VulkanDevice::from_glib_borrow(this).unsafe_cast_ref())
243            }
244        }
245        unsafe {
246            let f: Box_<F> = Box_::new(f);
247            connect_raw(
248                self.as_ptr() as *mut _,
249                c"notify::instance".as_ptr(),
250                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
251                    notify_instance_trampoline::<Self, F> as *const (),
252                )),
253                Box_::into_raw(f),
254            )
255        }
256    }
257}
258
259impl<O: IsA<VulkanDevice>> VulkanDeviceExt for O {}