From 67b8c292748376475699e41fc1d556d1746f99f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 4 Jul 2023 17:20:31 +0300 Subject: [PATCH] video: Add conversions between `VideoInfo` and `VideoInfoDmaDrm` Part-of: --- gstreamer-video/src/video_info_dma_drm.rs | 44 +++++++++++++++++++++-- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/gstreamer-video/src/video_info_dma_drm.rs b/gstreamer-video/src/video_info_dma_drm.rs index 6a8ddf214..b2f657021 100644 --- a/gstreamer-video/src/video_info_dma_drm.rs +++ b/gstreamer-video/src/video_info_dma_drm.rs @@ -121,9 +121,7 @@ impl VideoInfoDmaDrm { #[doc(alias = "gst_video_info_dma_drm_to_caps")] pub fn to_caps(&self) -> Result { unsafe { - let result = from_glib_full(ffi::gst_video_info_dma_drm_to_caps( - &self.0 as *const _ as *mut _, - )); + let result = from_glib_full(ffi::gst_video_info_dma_drm_to_caps(mut_override(&self.0))); match result { Some(c) => Ok(c), None => Err(glib::bool_error!( @@ -133,6 +131,46 @@ impl VideoInfoDmaDrm { } } + #[doc(alias = "gst_video_info_dma_drm_from_video_info")] + pub fn from_video_info( + video_info: &crate::VideoInfo, + modifier: u64, + ) -> Result { + skip_assert_initialized!(); + + unsafe { + let mut info = mem::MaybeUninit::uninit(); + if from_glib(ffi::gst_video_info_dma_drm_from_video_info( + info.as_mut_ptr(), + video_info.to_glib_none().0, + modifier, + )) { + Ok(Self(info.assume_init())) + } else { + Err(glib::bool_error!( + "Failed to create VideoInfoDmaDrm from VideoInfo" + )) + } + } + } + + #[doc(alias = "gst_video_info_dma_drm_to_video_info")] + pub fn to_video_info(&self) -> Result { + unsafe { + let mut video_info = mem::MaybeUninit::uninit(); + if from_glib(ffi::gst_video_info_dma_drm_to_video_info( + mut_override(&self.0), + video_info.as_mut_ptr(), + )) { + Ok(crate::VideoInfo(video_info.assume_init())) + } else { + Err(glib::bool_error!( + "Failed to create VideoInfo from VideoInfoDmaDrm" + )) + } + } + } + #[inline] pub fn fourcc(&self) -> u32 { self.0.drm_fourcc