From 2ba52a2927df71bd9d0a303a1373a85c524c0662 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 22 Nov 2024 14:15:37 +0200 Subject: [PATCH] video: Add bindings for new VideoFormat <-> DRM fourcc/modifier mapping functions Part-of: --- gstreamer-video/src/video_info_dma_drm.rs | 35 +++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/gstreamer-video/src/video_info_dma_drm.rs b/gstreamer-video/src/video_info_dma_drm.rs index 173a7b3c6..256708644 100644 --- a/gstreamer-video/src/video_info_dma_drm.rs +++ b/gstreamer-video/src/video_info_dma_drm.rs @@ -56,6 +56,41 @@ pub fn dma_drm_fourcc_from_str(v: &str) -> Result<(u32, u64), glib::BoolError> { } } +#[cfg(feature = "v1_26")] +#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] +#[doc(alias = "gst_video_dma_drm_format_from_gst_format")] +pub fn dma_drm_format_from_gst_format(v: VideoFormat) -> Result<(u32, u64), glib::BoolError> { + skip_assert_initialized!(); + unsafe { + let mut modifier = mem::MaybeUninit::uninit(); + let res = + ffi::gst_video_dma_drm_format_from_gst_format(v.into_glib(), modifier.as_mut_ptr()); + if res == 0 { + Err(glib::bool_error!("Unsupported video format")) + } else { + Ok((res, modifier.assume_init())) + } + } +} + +#[cfg(feature = "v1_26")] +#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] +#[doc(alias = "gst_video_dma_drm_format_to_gst_format")] +pub fn dma_drm_format_to_gst_format( + fourcc: u32, + modifier: u64, +) -> Result { + skip_assert_initialized!(); + unsafe { + let res = ffi::gst_video_dma_drm_format_to_gst_format(fourcc, modifier); + if res == ffi::GST_VIDEO_FORMAT_UNKNOWN { + Err(glib::bool_error!("Unsupported fourcc format / modifier")) + } else { + Ok(from_glib(res)) + } + } +} + #[doc(alias = "GstVideoInfoDmaDrm")] #[derive(Clone)] #[repr(transparent)]