// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
// DO NOT EDIT

#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)]
#![allow(
    clippy::approx_constant,
    clippy::type_complexity,
    clippy::unreadable_literal,
    clippy::upper_case_acronyms
)]
#![cfg_attr(docsrs, feature(doc_cfg))]

use glib_sys as glib;
use gobject_sys as gobject;
use gstreamer_sys as gst;

#[allow(unused_imports)]
use libc::{FILE, intptr_t, off_t, size_t, ssize_t, time_t, uintptr_t};
#[cfg(unix)]
#[allow(unused_imports)]
use libc::{dev_t, gid_t, pid_t, socklen_t, uid_t};
#[allow(unused_imports)]
use std::ffi::{
    c_char, c_double, c_float, c_int, c_long, c_short, c_uchar, c_uint, c_ulong, c_ushort, c_void,
};

#[allow(unused_imports)]
use glib::{GType, gboolean, gconstpointer, gpointer};

// Constants
pub const GST_ALLOCATOR_DMABUF: &[u8] = b"dmabuf\0";
pub const GST_ALLOCATOR_FD: &[u8] = b"fd\0";
pub const GST_ALLOCATOR_SHM: &[u8] = b"shm\0";
pub const GST_ALLOCATOR_UDMABUF: &[u8] = b"udmabuf\0";
pub const GST_CAPS_FEATURE_MEMORY_DMABUF: &[u8] = b"memory:DMABuf\0";

// Flags
pub type GstFdMemoryFlags = c_uint;
pub const GST_FD_MEMORY_FLAG_NONE: GstFdMemoryFlags = 0;
pub const GST_FD_MEMORY_FLAG_KEEP_MAPPED: GstFdMemoryFlags = 1;
pub const GST_FD_MEMORY_FLAG_MAP_PRIVATE: GstFdMemoryFlags = 2;
pub const GST_FD_MEMORY_FLAG_DONT_CLOSE: GstFdMemoryFlags = 4;

// Records
#[derive(Copy, Clone)]
#[repr(C)]
pub struct GstDRMDumbAllocatorClass {
    pub parent_class: gst::GstAllocatorClass,
}

impl ::std::fmt::Debug for GstDRMDumbAllocatorClass {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstDRMDumbAllocatorClass @ {self:p}"))
            .field("parent_class", &self.parent_class)
            .finish()
    }
}

#[derive(Copy, Clone)]
#[repr(C)]
pub struct GstDmaBufAllocatorClass {
    pub parent_class: GstFdAllocatorClass,
    pub _gst_reserved: [gpointer; 4],
}

impl ::std::fmt::Debug for GstDmaBufAllocatorClass {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstDmaBufAllocatorClass @ {self:p}"))
            .field("parent_class", &self.parent_class)
            .finish()
    }
}

#[derive(Copy, Clone)]
#[repr(C)]
pub struct GstFdAllocatorClass {
    pub parent_class: gst::GstAllocatorClass,
}

impl ::std::fmt::Debug for GstFdAllocatorClass {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstFdAllocatorClass @ {self:p}"))
            .field("parent_class", &self.parent_class)
            .finish()
    }
}

#[derive(Copy, Clone)]
#[repr(C)]
pub struct GstPhysMemoryAllocatorInterface {
    pub parent_iface: gobject::GTypeInterface,
    pub get_phys_addr:
        Option<unsafe extern "C" fn(*mut GstPhysMemoryAllocator, *mut gst::GstMemory) -> uintptr_t>,
}

impl ::std::fmt::Debug for GstPhysMemoryAllocatorInterface {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstPhysMemoryAllocatorInterface @ {self:p}"))
            .field("get_phys_addr", &self.get_phys_addr)
            .finish()
    }
}

#[derive(Copy, Clone)]
#[repr(C)]
pub struct GstShmAllocatorClass {
    pub parent_class: GstFdAllocatorClass,
}

impl ::std::fmt::Debug for GstShmAllocatorClass {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstShmAllocatorClass @ {self:p}"))
            .field("parent_class", &self.parent_class)
            .finish()
    }
}

#[derive(Copy, Clone)]
#[repr(C)]
pub struct GstUdmabufAllocatorClass {
    pub parent_class: GstDmaBufAllocatorClass,
}

impl ::std::fmt::Debug for GstUdmabufAllocatorClass {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstUdmabufAllocatorClass @ {self:p}"))
            .field("parent_class", &self.parent_class)
            .finish()
    }
}

// Classes
#[repr(C)]
#[allow(dead_code)]
pub struct GstDRMDumbAllocator {
    _data: [u8; 0],
    _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>,
}

impl ::std::fmt::Debug for GstDRMDumbAllocator {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstDRMDumbAllocator @ {self:p}"))
            .finish()
    }
}

#[derive(Copy, Clone)]
#[repr(C)]
pub struct GstDmaBufAllocator {
    pub parent: GstFdAllocator,
    pub _gst_reserved: [gpointer; 4],
}

impl ::std::fmt::Debug for GstDmaBufAllocator {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstDmaBufAllocator @ {self:p}"))
            .field("parent", &self.parent)
            .finish()
    }
}

#[derive(Copy, Clone)]
#[repr(C)]
pub struct GstFdAllocator {
    pub parent: gst::GstAllocator,
}

impl ::std::fmt::Debug for GstFdAllocator {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstFdAllocator @ {self:p}"))
            .field("parent", &self.parent)
            .finish()
    }
}

#[derive(Copy, Clone)]
#[repr(C)]
pub struct GstShmAllocator {
    pub parent_instance: GstFdAllocator,
}

impl ::std::fmt::Debug for GstShmAllocator {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstShmAllocator @ {self:p}"))
            .field("parent_instance", &self.parent_instance)
            .finish()
    }
}

#[repr(C)]
#[allow(dead_code)]
pub struct GstUdmabufAllocator {
    _data: [u8; 0],
    _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>,
}

impl ::std::fmt::Debug for GstUdmabufAllocator {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstUdmabufAllocator @ {self:p}"))
            .finish()
    }
}

// Interfaces
#[repr(C)]
#[allow(dead_code)]
pub struct GstPhysMemoryAllocator {
    _data: [u8; 0],
    _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>,
}

impl ::std::fmt::Debug for GstPhysMemoryAllocator {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        write!(f, "GstPhysMemoryAllocator @ {self:p}")
    }
}

unsafe extern "C" {

    //=========================================================================
    // GstDRMDumbAllocator
    //=========================================================================
    #[cfg(feature = "v1_24")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
    pub fn gst_drm_dumb_allocator_get_type() -> GType;
    #[cfg(feature = "v1_24")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
    pub fn gst_drm_dumb_allocator_new_with_device_path(
        drm_device_path: *const c_char,
    ) -> *mut gst::GstAllocator;
    #[cfg(feature = "v1_24")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
    pub fn gst_drm_dumb_allocator_new_with_fd(drm_fd: c_int) -> *mut gst::GstAllocator;
    #[cfg(feature = "v1_24")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
    pub fn gst_drm_dumb_allocator_alloc(
        allocator: *mut GstDRMDumbAllocator,
        drm_fourcc: u32,
        width: u32,
        height: u32,
        out_pitch: *mut u32,
    ) -> *mut gst::GstMemory;
    #[cfg(feature = "v1_24")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
    pub fn gst_drm_dumb_allocator_has_prime_export(allocator: *mut GstDRMDumbAllocator)
    -> gboolean;

    //=========================================================================
    // GstDmaBufAllocator
    //=========================================================================
    pub fn gst_dmabuf_allocator_get_type() -> GType;
    pub fn gst_dmabuf_allocator_new() -> *mut gst::GstAllocator;
    pub fn gst_dmabuf_allocator_alloc(
        allocator: *mut gst::GstAllocator,
        fd: c_int,
        size: size_t,
    ) -> *mut gst::GstMemory;
    #[cfg(feature = "v1_16")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
    pub fn gst_dmabuf_allocator_alloc_with_flags(
        allocator: *mut gst::GstAllocator,
        fd: c_int,
        size: size_t,
        flags: GstFdMemoryFlags,
    ) -> *mut gst::GstMemory;

    //=========================================================================
    // GstFdAllocator
    //=========================================================================
    pub fn gst_fd_allocator_get_type() -> GType;
    pub fn gst_fd_allocator_new() -> *mut gst::GstAllocator;
    pub fn gst_fd_allocator_alloc(
        allocator: *mut gst::GstAllocator,
        fd: c_int,
        size: size_t,
        flags: GstFdMemoryFlags,
    ) -> *mut gst::GstMemory;
    #[cfg(feature = "v1_28")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
    pub fn gst_fd_allocator_alloc_full(
        allocator: *mut gst::GstAllocator,
        fd: c_int,
        maxsize: size_t,
        offset: size_t,
        size: size_t,
        flags: GstFdMemoryFlags,
    ) -> *mut gst::GstMemory;

    //=========================================================================
    // GstShmAllocator
    //=========================================================================
    #[cfg(feature = "v1_24")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
    pub fn gst_shm_allocator_get_type() -> GType;
    #[cfg(feature = "v1_24")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
    pub fn gst_shm_allocator_get() -> *mut gst::GstAllocator;
    #[cfg(feature = "v1_24")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
    pub fn gst_shm_allocator_init_once();

    //=========================================================================
    // GstUdmabufAllocator
    //=========================================================================
    #[cfg(feature = "v1_28")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
    pub fn gst_udmabuf_allocator_get_type() -> GType;
    #[cfg(feature = "v1_28")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
    pub fn gst_udmabuf_allocator_get() -> *mut gst::GstAllocator;
    #[cfg(feature = "v1_28")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
    pub fn gst_udmabuf_allocator_init_once();

    //=========================================================================
    // GstPhysMemoryAllocator
    //=========================================================================
    pub fn gst_phys_memory_allocator_get_type() -> GType;

    //=========================================================================
    // Other functions
    //=========================================================================
    pub fn gst_dmabuf_memory_get_fd(mem: *mut gst::GstMemory) -> c_int;
    #[cfg(feature = "v1_24")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
    pub fn gst_drm_dumb_memory_export_dmabuf(mem: *mut gst::GstMemory) -> *mut gst::GstMemory;
    #[cfg(feature = "v1_24")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
    pub fn gst_drm_dumb_memory_get_handle(mem: *mut gst::GstMemory) -> u32;
    pub fn gst_fd_memory_get_fd(mem: *mut gst::GstMemory) -> c_int;
    pub fn gst_is_dmabuf_memory(mem: *mut gst::GstMemory) -> gboolean;
    #[cfg(feature = "v1_24")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))]
    pub fn gst_is_drm_dumb_memory(mem: *mut gst::GstMemory) -> gboolean;
    pub fn gst_is_fd_memory(mem: *mut gst::GstMemory) -> gboolean;
    pub fn gst_is_phys_memory(mem: *mut gst::GstMemory) -> gboolean;
    pub fn gst_phys_memory_get_phys_addr(mem: *mut gst::GstMemory) -> uintptr_t;

}
