diff --git a/gstreamer-audio/Cargo.toml b/gstreamer-audio/Cargo.toml index 5281a7327..fef0de965 100644 --- a/gstreamer-audio/Cargo.toml +++ b/gstreamer-audio/Cargo.toml @@ -15,6 +15,7 @@ edition = "2018" [dependencies] libc = "0.2" +cfg-if = "1.0" bitflags = "1.0" ffi = { package = "gstreamer-audio-sys", path = "sys", features = ["v1_8"] } glib = { git = "https://github.com/gtk-rs/gtk-rs" } diff --git a/gstreamer-audio/src/audio_format_info.rs b/gstreamer-audio/src/audio_format_info.rs index 0354ab065..dd7d97c69 100644 --- a/gstreamer-audio/src/audio_format_info.rs +++ b/gstreamer-audio/src/audio_format_info.rs @@ -175,7 +175,13 @@ impl AudioFormatInfo { } unsafe { - ffi::gst_audio_format_fill_silence(self.0, dest.as_mut_ptr() as *mut _, dest.len()) + cfg_if::cfg_if! { + if #[cfg(any(feature = "v1_20", all(not(doctest), doc)))] { + ffi::gst_audio_format_info_fill_silence(self.0, dest.as_mut_ptr() as *mut _, dest.len()) + } else { + ffi::gst_audio_format_fill_silence(self.0, dest.as_mut_ptr() as *mut _, dest.len()) + } + } } } diff --git a/gstreamer-video/src/video_info.rs b/gstreamer-video/src/video_info.rs index 58c8d93d9..27ee8d0c5 100644 --- a/gstreamer-video/src/video_info.rs +++ b/gstreamer-video/src/video_info.rs @@ -12,10 +12,6 @@ use glib::translate::{ }; use gst::prelude::*; -#[cfg(any(feature = "v1_12", feature = "dox"))] -#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_12")))] -use std::ffi::CStr; - use std::fmt; use std::mem; use std::ptr; @@ -183,16 +179,22 @@ impl str::FromStr for crate::VideoChromaSite { type Err = glib::error::BoolError; fn from_str(s: &str) -> Result { - assert_initialized_main_thread!(); + skip_assert_initialized!(); - unsafe { - let chroma_site: Self = - from_glib(ffi::gst_video_chroma_from_string(s.to_glib_none().0)); - if chroma_site.is_empty() { - Err(glib::glib_bool_error!("Invalid chroma site")) + cfg_if::cfg_if! { + if #[cfg(any(feature = "v1_20", all(not(doctest), doc)))] { + let chroma_site = Self::from_string(s); } else { - Ok(chroma_site) + assert_initialized_main_thread!(); + let chroma_site: Self = + unsafe { from_glib(ffi::gst_video_chroma_from_string(s.to_glib_none().0)) }; } + }; + + if chroma_site.is_empty() { + Err(glib::glib_bool_error!("Invalid chroma site")) + } else { + Ok(chroma_site) } } } @@ -935,6 +937,8 @@ impl glib::translate::FromGlibPtrFull<*mut ffi::GstVideoInfo> for VideoInfo { #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_12")))] impl crate::VideoFieldOrder { pub fn to_str<'a>(self) -> &'a str { + use std::ffi::CStr; + if self == Self::Unknown { return "UNKNOWN"; }