gstreamer_allocators/auto/drm_dumb_allocator.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;
7use glib::{prelude::*, translate::*};
8
9glib::wrapper! {
10 /// Private intance object for [`DRMDumbAllocator`][crate::DRMDumbAllocator].
11 ///
12 /// ## Properties
13 ///
14 ///
15 /// #### `drm-device-path`
16 /// Readable | Writeable | Construct Only
17 ///
18 ///
19 /// #### `drm-fd`
20 /// Readable | Writeable | Construct Only
21 /// <details><summary><h4>Object</h4></summary>
22 ///
23 ///
24 /// #### `name`
25 /// Readable | Writeable | Construct
26 ///
27 ///
28 /// #### `parent`
29 /// The parent of the object. Please note, that when changing the 'parent'
30 /// property, we don't emit `GObject::notify` and `GstObject::deep-notify`
31 /// signals due to locking issues. In some cases one can use
32 /// `GstBin::element-added` or `GstBin::element-removed` signals on the parent to
33 /// achieve a similar effect.
34 ///
35 /// Readable | Writeable
36 /// </details>
37 ///
38 /// # Implements
39 ///
40 /// [`trait@gst::prelude::AllocatorExt`]
41 #[doc(alias = "GstDRMDumbAllocator")]
42 pub struct DRMDumbAllocator(Object<ffi::GstDRMDumbAllocator, ffi::GstDRMDumbAllocatorClass>) @extends gst::Allocator;
43
44 match fn {
45 type_ => || ffi::gst_drm_dumb_allocator_get_type(),
46 }
47}
48
49impl DRMDumbAllocator {
50 /// Creates a new [`DRMDumbAllocator`][crate::DRMDumbAllocator] for the specific device path. This
51 /// function can fail if the path does not exist, is not a DRM device or if
52 /// the DRM device doesnot support DUMB allocation.
53 /// ## `drm_device_path`
54 /// path to the DRM device to open
55 ///
56 /// # Returns
57 ///
58 /// a new DRM Dumb allocator. Use `gst_object_unref()`
59 /// to release the allocator after usage.
60 #[doc(alias = "gst_drm_dumb_allocator_new_with_device_path")]
61 #[doc(alias = "new_with_device_path")]
62 pub fn with_device_path(
63 drm_device_path: impl AsRef<std::path::Path>,
64 ) -> Result<DRMDumbAllocator, glib::BoolError> {
65 assert_initialized_main_thread!();
66 unsafe {
67 Option::<gst::Allocator>::from_glib_full(
68 ffi::gst_drm_dumb_allocator_new_with_device_path(
69 drm_device_path.as_ref().to_glib_none().0,
70 ),
71 )
72 .map(|o| o.unsafe_cast())
73 .ok_or_else(|| glib::bool_error!("Failed to create allocator"))
74 }
75 }
76
77 /// This function allow verifying if the driver support dma-buf exportation.
78 ///
79 /// # Returns
80 ///
81 /// [`true`] if the allocator support exporting dma-buf.
82 #[doc(alias = "gst_drm_dumb_allocator_has_prime_export")]
83 pub fn has_prime_export(&self) -> bool {
84 unsafe {
85 from_glib(ffi::gst_drm_dumb_allocator_has_prime_export(
86 self.to_glib_none().0,
87 ))
88 }
89 }
90
91 #[cfg(feature = "v1_24")]
92 #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
93 #[doc(alias = "drm-device-path")]
94 pub fn drm_device_path(&self) -> Option<std::path::PathBuf> {
95 ObjectExt::property(self, "drm-device-path")
96 }
97
98 #[cfg(feature = "v1_24")]
99 #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
100 #[doc(alias = "drm-fd")]
101 pub fn drm_fd(&self) -> i32 {
102 ObjectExt::property(self, "drm-fd")
103 }
104}
105
106unsafe impl Send for DRMDumbAllocator {}
107unsafe impl Sync for DRMDumbAllocator {}