From 12063ec83acee0bf6c2b8485c5d35b21de6f6966 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 20 May 2020 09:29:29 +0300 Subject: [PATCH] video: Add bindings for guess_framerate() --- gstreamer-video/src/functions.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/gstreamer-video/src/functions.rs b/gstreamer-video/src/functions.rs index a9ecff966..bd8407fdd 100644 --- a/gstreamer-video/src/functions.rs +++ b/gstreamer-video/src/functions.rs @@ -169,6 +169,28 @@ pub fn calculate_display_ratio( } } +pub fn guess_framerate(duration: gst::ClockTime) -> Option { + skip_assert_initialized!(); + + unsafe { + let mut dest_n = mem::MaybeUninit::uninit(); + let mut dest_d = mem::MaybeUninit::uninit(); + let res: bool = from_glib(gst_video_sys::gst_video_guess_framerate( + duration.to_glib(), + dest_n.as_mut_ptr(), + dest_d.as_mut_ptr(), + )); + if res { + Some(gst::Fraction::new( + dest_n.assume_init() as i32, + dest_d.assume_init() as i32, + )) + } else { + None + } + } +} + #[cfg(test)] mod tests { use super::*;