audio/video: Update to v1.20 functions

This commit is contained in:
Marijn Suijten 2020-11-24 10:11:35 +01:00
parent 132477f51f
commit a215610167
3 changed files with 23 additions and 12 deletions

View file

@ -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" }

View file

@ -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())
}
}
}
}

View file

@ -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<Self, Self::Err> {
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";
}