Skip to main content

gstreamer_allocators/auto/
udmabuf_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::{DmaBufAllocator, FdAllocator, ffi};
7use glib::translate::*;
8
9glib::wrapper! {
10    /// This is a subclass of [`DmaBufAllocator`][crate::DmaBufAllocator] that implements the
11    /// [`AllocatorExtManual::alloc()`][crate::gst::prelude::AllocatorExtManual::alloc()] method using ``memfd_create()`` and `UDMABUF_CREATE`.
12    /// Platforms not supporting that (most non-Linux) will always return [`None`].
13    ///
14    /// # Implements
15    ///
16    /// [`DmaBufAllocatorExt`][trait@crate::prelude::DmaBufAllocatorExt], [`FdAllocatorExt`][trait@crate::prelude::FdAllocatorExt], [`trait@gst::prelude::AllocatorExt`]
17    #[doc(alias = "GstUdmabufAllocator")]
18    pub struct UdmabufAllocator(Object<ffi::GstUdmabufAllocator, ffi::GstUdmabufAllocatorClass>) @extends DmaBufAllocator, FdAllocator, gst::Allocator;
19
20    match fn {
21        type_ => || ffi::gst_udmabuf_allocator_get_type(),
22    }
23}
24
25impl UdmabufAllocator {
26    /// Get the [`UdmabufAllocator`][crate::UdmabufAllocator] singleton if available.
27    ///
28    /// # Returns
29    ///
30    /// a [`gst::Allocator`][crate::gst::Allocator] or [`None`] if
31    /// `gst_udmabuf_allocator_init_once()` did not register the allocator.
32    #[doc(alias = "gst_udmabuf_allocator_get")]
33    pub fn get() -> Option<gst::Allocator> {
34        assert_initialized_main_thread!();
35        unsafe { from_glib_full(ffi::gst_udmabuf_allocator_get()) }
36    }
37}
38
39unsafe impl Send for UdmabufAllocator {}
40unsafe impl Sync for UdmabufAllocator {}