diff --git a/gstreamer/Gir.toml b/gstreamer/Gir.toml index d8ee6582b..f87849678 100644 --- a/gstreamer/Gir.toml +++ b/gstreamer/Gir.toml @@ -112,6 +112,10 @@ status = "generate" pattern = "util_fraction_.*" ignore = true + [[object.function]] + name = "util_simplify_fraction" + ignore = true + [[object.function]] pattern = "util_greatest_.*" ignore = true diff --git a/gstreamer/src/value.rs b/gstreamer/src/value.rs index f8c4f4adc..a226e5a2c 100644 --- a/gstreamer/src/value.rs +++ b/gstreamer/src/value.rs @@ -34,6 +34,19 @@ impl Fraction { pub fn denom(&self) -> i32 { *self.0.denom() } + + #[cfg(feature = "v1_24")] + #[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] + #[doc(alias = "gst_util_simplify_fraction")] + pub fn simplify(&mut self, n_terms: u32, threshold: u32) { + skip_assert_initialized!(); + unsafe { + let mut num = self.numer(); + let mut den = self.denom(); + ffi::gst_util_simplify_fraction(&mut num, &mut den, n_terms, threshold); + *self = Self::new(num, den); + } + } } impl fmt::Display for Fraction {