forked from mirrors/gstreamer-rs
gstreamer-audio: Update manual code to 2018 edition
This commit is contained in:
parent
1e489ee1e2
commit
4a928136ed
17 changed files with 713 additions and 833 deletions
|
@ -11,18 +11,15 @@ homepage = "https://gstreamer.freedesktop.org"
|
|||
documentation = "https://gstreamer.pages.freedesktop.org/gstreamer-rs/gstreamer_audio/"
|
||||
keywords = ["gstreamer", "multimedia", "audio", "video", "gnome"]
|
||||
build = "build.rs"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
libc = "0.2"
|
||||
bitflags = "1.0"
|
||||
glib-sys = { git = "https://github.com/gtk-rs/gtk-rs" }
|
||||
gobject-sys = { git = "https://github.com/gtk-rs/gtk-rs" }
|
||||
gstreamer-sys = { path = "../gstreamer/sys", features = ["v1_8"] }
|
||||
gstreamer-base-sys = { path = "../gstreamer-base/sys", features = ["v1_8"] }
|
||||
gstreamer-audio-sys = { path = "../gstreamer-audio/sys", features = ["v1_8"] }
|
||||
ffi = { package = "gstreamer-audio-sys", path = "../gstreamer-audio/sys", features = ["v1_8"] }
|
||||
glib = { git = "https://github.com/gtk-rs/gtk-rs" }
|
||||
gstreamer = { path = "../gstreamer" }
|
||||
gstreamer-base = { path = "../gstreamer-base" }
|
||||
gst = { package = "gstreamer", path = "../gstreamer" }
|
||||
gst-base = { package = "gstreamer-base", path = "../gstreamer-base" }
|
||||
array-init = "1.0"
|
||||
once_cell = "1.0"
|
||||
|
||||
|
@ -34,14 +31,14 @@ itertools = "0.9"
|
|||
|
||||
[features]
|
||||
default = []
|
||||
v1_10 = ["gstreamer/v1_10", "gstreamer-base/v1_10", "gstreamer-audio-sys/v1_10"]
|
||||
v1_12 = ["gstreamer/v1_12", "gstreamer-base/v1_12", "gstreamer-audio-sys/v1_12", "v1_10"]
|
||||
v1_14 = ["gstreamer/v1_14", "gstreamer-base/v1_14", "gstreamer-audio-sys/v1_14", "v1_12"]
|
||||
v1_16 = ["gstreamer/v1_16", "gstreamer-base/v1_16", "gstreamer-audio-sys/v1_16", "v1_14"]
|
||||
v1_18 = ["gstreamer/v1_18", "gstreamer-base/v1_18", "gstreamer-audio-sys/v1_18", "v1_16"]
|
||||
v1_10 = ["gst/v1_10", "gst-base/v1_10", "ffi/v1_10"]
|
||||
v1_12 = ["gst/v1_12", "gst-base/v1_12", "ffi/v1_12", "v1_10"]
|
||||
v1_14 = ["gst/v1_14", "gst-base/v1_14", "ffi/v1_14", "v1_12"]
|
||||
v1_16 = ["gst/v1_16", "gst-base/v1_16", "ffi/v1_16", "v1_14"]
|
||||
v1_18 = ["gst/v1_18", "gst-base/v1_18", "ffi/v1_18", "v1_16"]
|
||||
embed-lgpl-docs = ["gstreamer-rs-lgpl-docs"]
|
||||
purge-lgpl-docs = ["gstreamer-rs-lgpl-docs"]
|
||||
dox = ["v1_18", "gstreamer-audio-sys/dox", "glib/dox", "gstreamer/dox", "gstreamer-base/dox"]
|
||||
dox = ["v1_18", "ffi/dox", "glib/dox", "gst/dox", "gst-base/dox"]
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
features = ["dox", "embed-lgpl-docs"]
|
||||
|
|
|
@ -6,12 +6,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use gst_audio_sys;
|
||||
use gst_sys;
|
||||
|
||||
use glib;
|
||||
use glib::translate::{from_glib, Borrowed, FromGlibPtrNone, ToGlibPtr};
|
||||
use gst;
|
||||
|
||||
use std::fmt;
|
||||
use std::marker::PhantomData;
|
||||
|
@ -25,9 +20,9 @@ pub enum Writable {}
|
|||
|
||||
pub struct AudioBuffer<T> {
|
||||
// Has to be boxed because it contains self-references
|
||||
audio_buffer: Box<gst_audio_sys::GstAudioBuffer>,
|
||||
audio_buffer: Box<ffi::GstAudioBuffer>,
|
||||
buffer: Option<gst::Buffer>,
|
||||
info: ::AudioInfo,
|
||||
info: crate::AudioInfo,
|
||||
phantom: PhantomData<T>,
|
||||
}
|
||||
|
||||
|
@ -46,7 +41,7 @@ impl<T> fmt::Debug for AudioBuffer<T> {
|
|||
}
|
||||
|
||||
impl<T> AudioBuffer<T> {
|
||||
pub fn info(&self) -> &::AudioInfo {
|
||||
pub fn info(&self) -> &crate::AudioInfo {
|
||||
&self.info
|
||||
}
|
||||
|
||||
|
@ -54,11 +49,11 @@ impl<T> AudioBuffer<T> {
|
|||
self.buffer.take().unwrap()
|
||||
}
|
||||
|
||||
pub fn format(&self) -> ::AudioFormat {
|
||||
pub fn format(&self) -> crate::AudioFormat {
|
||||
self.info().format()
|
||||
}
|
||||
|
||||
pub fn format_info(&self) -> ::AudioFormatInfo {
|
||||
pub fn format_info(&self) -> crate::AudioFormatInfo {
|
||||
self.info().format_info()
|
||||
}
|
||||
|
||||
|
@ -70,7 +65,7 @@ impl<T> AudioBuffer<T> {
|
|||
self.info().rate()
|
||||
}
|
||||
|
||||
pub fn layout(&self) -> ::AudioLayout {
|
||||
pub fn layout(&self) -> crate::AudioLayout {
|
||||
self.info().layout()
|
||||
}
|
||||
|
||||
|
@ -113,7 +108,9 @@ impl<T> AudioBuffer<T> {
|
|||
|
||||
pub fn plane_data(&self, plane: u32) -> Result<&[u8], glib::BoolError> {
|
||||
if plane >= self.n_planes() {
|
||||
return Err(glib_bool_error!("Plane index higher than number of planes"));
|
||||
return Err(glib::glib_bool_error!(
|
||||
"Plane index higher than number of planes"
|
||||
));
|
||||
}
|
||||
|
||||
unsafe {
|
||||
|
@ -134,7 +131,7 @@ impl<T> AudioBuffer<T> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn as_ptr(&self) -> *const gst_audio_sys::GstAudioBuffer {
|
||||
pub fn as_ptr(&self) -> *const ffi::GstAudioBuffer {
|
||||
&*self.audio_buffer
|
||||
}
|
||||
}
|
||||
|
@ -142,7 +139,7 @@ impl<T> AudioBuffer<T> {
|
|||
impl<T> Drop for AudioBuffer<T> {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
gst_audio_sys::gst_audio_buffer_unmap(&mut *self.audio_buffer);
|
||||
ffi::gst_audio_buffer_unmap(&mut *self.audio_buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -150,7 +147,7 @@ impl<T> Drop for AudioBuffer<T> {
|
|||
impl AudioBuffer<Readable> {
|
||||
pub fn from_buffer_readable(
|
||||
buffer: gst::Buffer,
|
||||
info: &::AudioInfo,
|
||||
info: &crate::AudioInfo,
|
||||
) -> Result<AudioBuffer<Readable>, gst::Buffer> {
|
||||
skip_assert_initialized!();
|
||||
|
||||
|
@ -158,18 +155,18 @@ impl AudioBuffer<Readable> {
|
|||
|
||||
unsafe {
|
||||
let mut audio_buffer = Box::new(mem::MaybeUninit::zeroed().assume_init());
|
||||
let res: bool = from_glib(gst_audio_sys::gst_audio_buffer_map(
|
||||
let res: bool = from_glib(ffi::gst_audio_buffer_map(
|
||||
&mut *audio_buffer,
|
||||
info.to_glib_none().0 as *mut _,
|
||||
buffer.to_glib_none().0,
|
||||
gst_sys::GST_MAP_READ,
|
||||
gst::ffi::GST_MAP_READ,
|
||||
));
|
||||
|
||||
if !res {
|
||||
Err(buffer)
|
||||
} else {
|
||||
let info = ::AudioInfo::from_glib_none(
|
||||
&audio_buffer.info as *const _ as *mut gst_audio_sys::GstAudioInfo,
|
||||
let info = crate::AudioInfo::from_glib_none(
|
||||
&audio_buffer.info as *const _ as *mut ffi::GstAudioInfo,
|
||||
);
|
||||
Ok(AudioBuffer {
|
||||
audio_buffer,
|
||||
|
@ -185,7 +182,7 @@ impl AudioBuffer<Readable> {
|
|||
impl AudioBuffer<Writable> {
|
||||
pub fn from_buffer_writable(
|
||||
buffer: gst::Buffer,
|
||||
info: &::AudioInfo,
|
||||
info: &crate::AudioInfo,
|
||||
) -> Result<AudioBuffer<Writable>, gst::Buffer> {
|
||||
skip_assert_initialized!();
|
||||
|
||||
|
@ -193,18 +190,18 @@ impl AudioBuffer<Writable> {
|
|||
|
||||
unsafe {
|
||||
let mut audio_buffer = Box::new(mem::MaybeUninit::zeroed().assume_init());
|
||||
let res: bool = from_glib(gst_audio_sys::gst_audio_buffer_map(
|
||||
let res: bool = from_glib(ffi::gst_audio_buffer_map(
|
||||
&mut *audio_buffer,
|
||||
info.to_glib_none().0 as *mut _,
|
||||
buffer.to_glib_none().0,
|
||||
gst_sys::GST_MAP_READ | gst_sys::GST_MAP_WRITE,
|
||||
gst::ffi::GST_MAP_READ | gst::ffi::GST_MAP_WRITE,
|
||||
));
|
||||
|
||||
if !res {
|
||||
Err(buffer)
|
||||
} else {
|
||||
let info = ::AudioInfo::from_glib_none(
|
||||
&audio_buffer.info as *const _ as *mut gst_audio_sys::GstAudioInfo,
|
||||
let info = crate::AudioInfo::from_glib_none(
|
||||
&audio_buffer.info as *const _ as *mut ffi::GstAudioInfo,
|
||||
);
|
||||
Ok(AudioBuffer {
|
||||
audio_buffer,
|
||||
|
@ -222,7 +219,9 @@ impl AudioBuffer<Writable> {
|
|||
|
||||
pub fn plane_data_mut(&mut self, plane: u32) -> Result<&mut [u8], glib::BoolError> {
|
||||
if plane >= self.n_planes() {
|
||||
return Err(glib_bool_error!("Plane index higher than number of planes"));
|
||||
return Err(glib::glib_bool_error!(
|
||||
"Plane index higher than number of planes"
|
||||
));
|
||||
}
|
||||
|
||||
unsafe {
|
||||
|
@ -243,19 +242,19 @@ impl AudioBuffer<Writable> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn as_mut_ptr(&mut self) -> *mut gst_audio_sys::GstAudioBuffer {
|
||||
pub fn as_mut_ptr(&mut self) -> *mut ffi::GstAudioBuffer {
|
||||
&mut *self.audio_buffer
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum AudioBufferPtr {
|
||||
Owned(Box<gst_audio_sys::GstAudioBuffer>),
|
||||
Borrowed(ptr::NonNull<gst_audio_sys::GstAudioBuffer>),
|
||||
Owned(Box<ffi::GstAudioBuffer>),
|
||||
Borrowed(ptr::NonNull<ffi::GstAudioBuffer>),
|
||||
}
|
||||
|
||||
impl ops::Deref for AudioBufferPtr {
|
||||
type Target = gst_audio_sys::GstAudioBuffer;
|
||||
type Target = ffi::GstAudioBuffer;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
match self {
|
||||
|
@ -279,20 +278,20 @@ pub struct AudioBufferRef<T> {
|
|||
// Has to be boxed because it contains self-references
|
||||
audio_buffer: AudioBufferPtr,
|
||||
buffer: Option<T>,
|
||||
info: ::AudioInfo,
|
||||
info: crate::AudioInfo,
|
||||
unmap: bool,
|
||||
}
|
||||
|
||||
impl<T> AudioBufferRef<T> {
|
||||
pub fn info(&self) -> &::AudioInfo {
|
||||
pub fn info(&self) -> &crate::AudioInfo {
|
||||
&self.info
|
||||
}
|
||||
|
||||
pub fn format(&self) -> ::AudioFormat {
|
||||
pub fn format(&self) -> crate::AudioFormat {
|
||||
self.info().format()
|
||||
}
|
||||
|
||||
pub fn format_info(&self) -> ::AudioFormatInfo {
|
||||
pub fn format_info(&self) -> crate::AudioFormatInfo {
|
||||
self.info().format_info()
|
||||
}
|
||||
|
||||
|
@ -304,7 +303,7 @@ impl<T> AudioBufferRef<T> {
|
|||
self.info().rate()
|
||||
}
|
||||
|
||||
pub fn layout(&self) -> ::AudioLayout {
|
||||
pub fn layout(&self) -> crate::AudioLayout {
|
||||
self.info().layout()
|
||||
}
|
||||
|
||||
|
@ -343,7 +342,9 @@ impl<T> AudioBufferRef<T> {
|
|||
|
||||
pub fn plane_data(&self, plane: u32) -> Result<&[u8], glib::BoolError> {
|
||||
if plane >= self.n_planes() {
|
||||
return Err(glib_bool_error!("Plane index higher than number of planes"));
|
||||
return Err(glib::glib_bool_error!(
|
||||
"Plane index higher than number of planes"
|
||||
));
|
||||
}
|
||||
|
||||
unsafe {
|
||||
|
@ -354,19 +355,17 @@ impl<T> AudioBufferRef<T> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn as_ptr(&self) -> *const gst_audio_sys::GstAudioBuffer {
|
||||
pub fn as_ptr(&self) -> *const ffi::GstAudioBuffer {
|
||||
&*self.audio_buffer
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> AudioBufferRef<&'a gst::BufferRef> {
|
||||
pub unsafe fn from_glib_borrow(
|
||||
audio_buffer: *const gst_audio_sys::GstAudioBuffer,
|
||||
) -> Borrowed<Self> {
|
||||
pub unsafe fn from_glib_borrow(audio_buffer: *const ffi::GstAudioBuffer) -> Borrowed<Self> {
|
||||
assert!(!audio_buffer.is_null());
|
||||
|
||||
let info = ::AudioInfo::from_glib_none(
|
||||
&(*audio_buffer).info as *const _ as *mut gst_audio_sys::GstAudioInfo,
|
||||
let info = crate::AudioInfo::from_glib_none(
|
||||
&(*audio_buffer).info as *const _ as *mut ffi::GstAudioInfo,
|
||||
);
|
||||
let buffer = gst::BufferRef::from_ptr((*audio_buffer).buffer);
|
||||
Borrowed::new(AudioBufferRef {
|
||||
|
@ -381,7 +380,7 @@ impl<'a> AudioBufferRef<&'a gst::BufferRef> {
|
|||
|
||||
pub fn from_buffer_ref_readable<'b>(
|
||||
buffer: &'a gst::BufferRef,
|
||||
info: &'b ::AudioInfo,
|
||||
info: &'b crate::AudioInfo,
|
||||
) -> Result<AudioBufferRef<&'a gst::BufferRef>, glib::BoolError> {
|
||||
skip_assert_initialized!();
|
||||
|
||||
|
@ -389,18 +388,18 @@ impl<'a> AudioBufferRef<&'a gst::BufferRef> {
|
|||
|
||||
unsafe {
|
||||
let mut audio_buffer = Box::new(mem::MaybeUninit::zeroed().assume_init());
|
||||
let res: bool = from_glib(gst_audio_sys::gst_audio_buffer_map(
|
||||
let res: bool = from_glib(ffi::gst_audio_buffer_map(
|
||||
&mut *audio_buffer,
|
||||
info.to_glib_none().0 as *mut _,
|
||||
buffer.as_mut_ptr(),
|
||||
gst_sys::GST_MAP_READ,
|
||||
gst::ffi::GST_MAP_READ,
|
||||
));
|
||||
|
||||
if !res {
|
||||
Err(glib_bool_error!("Failed to map AudioBuffer"))
|
||||
Err(glib::glib_bool_error!("Failed to map AudioBuffer"))
|
||||
} else {
|
||||
let info = ::AudioInfo::from_glib_none(
|
||||
&audio_buffer.info as *const _ as *mut gst_audio_sys::GstAudioInfo,
|
||||
let info = crate::AudioInfo::from_glib_none(
|
||||
&audio_buffer.info as *const _ as *mut ffi::GstAudioInfo,
|
||||
);
|
||||
Ok(AudioBufferRef {
|
||||
audio_buffer: AudioBufferPtr::Owned(audio_buffer),
|
||||
|
@ -418,13 +417,11 @@ impl<'a> AudioBufferRef<&'a gst::BufferRef> {
|
|||
}
|
||||
|
||||
impl<'a> AudioBufferRef<&'a mut gst::BufferRef> {
|
||||
pub unsafe fn from_glib_borrow_mut(
|
||||
audio_buffer: *mut gst_audio_sys::GstAudioBuffer,
|
||||
) -> Borrowed<Self> {
|
||||
pub unsafe fn from_glib_borrow_mut(audio_buffer: *mut ffi::GstAudioBuffer) -> Borrowed<Self> {
|
||||
assert!(!audio_buffer.is_null());
|
||||
|
||||
let info = ::AudioInfo::from_glib_none(
|
||||
&(*audio_buffer).info as *const _ as *mut gst_audio_sys::GstAudioInfo,
|
||||
let info = crate::AudioInfo::from_glib_none(
|
||||
&(*audio_buffer).info as *const _ as *mut ffi::GstAudioInfo,
|
||||
);
|
||||
let buffer = gst::BufferRef::from_mut_ptr((*audio_buffer).buffer);
|
||||
Borrowed::new(AudioBufferRef {
|
||||
|
@ -437,7 +434,7 @@ impl<'a> AudioBufferRef<&'a mut gst::BufferRef> {
|
|||
|
||||
pub fn from_buffer_ref_writable<'b>(
|
||||
buffer: &'a mut gst::BufferRef,
|
||||
info: &'b ::AudioInfo,
|
||||
info: &'b crate::AudioInfo,
|
||||
) -> Result<AudioBufferRef<&'a mut gst::BufferRef>, glib::BoolError> {
|
||||
skip_assert_initialized!();
|
||||
|
||||
|
@ -445,18 +442,18 @@ impl<'a> AudioBufferRef<&'a mut gst::BufferRef> {
|
|||
|
||||
unsafe {
|
||||
let mut audio_buffer = Box::new(mem::MaybeUninit::zeroed().assume_init());
|
||||
let res: bool = from_glib(gst_audio_sys::gst_audio_buffer_map(
|
||||
let res: bool = from_glib(ffi::gst_audio_buffer_map(
|
||||
&mut *audio_buffer,
|
||||
info.to_glib_none().0 as *mut _,
|
||||
buffer.as_mut_ptr(),
|
||||
gst_sys::GST_MAP_READ | gst_sys::GST_MAP_WRITE,
|
||||
gst::ffi::GST_MAP_READ | gst::ffi::GST_MAP_WRITE,
|
||||
));
|
||||
|
||||
if !res {
|
||||
Err(glib_bool_error!("Failed to map AudioBuffer"))
|
||||
Err(glib::glib_bool_error!("Failed to map AudioBuffer"))
|
||||
} else {
|
||||
let info = ::AudioInfo::from_glib_none(
|
||||
&audio_buffer.info as *const _ as *mut gst_audio_sys::GstAudioInfo,
|
||||
let info = crate::AudioInfo::from_glib_none(
|
||||
&audio_buffer.info as *const _ as *mut ffi::GstAudioInfo,
|
||||
);
|
||||
Ok(AudioBufferRef {
|
||||
audio_buffer: AudioBufferPtr::Owned(audio_buffer),
|
||||
|
@ -474,7 +471,9 @@ impl<'a> AudioBufferRef<&'a mut gst::BufferRef> {
|
|||
|
||||
pub fn plane_data_mut(&mut self, plane: u32) -> Result<&mut [u8], glib::BoolError> {
|
||||
if plane >= self.n_planes() {
|
||||
return Err(glib_bool_error!("Plane index higher than number of planes"));
|
||||
return Err(glib::glib_bool_error!(
|
||||
"Plane index higher than number of planes"
|
||||
));
|
||||
}
|
||||
|
||||
unsafe {
|
||||
|
@ -485,7 +484,7 @@ impl<'a> AudioBufferRef<&'a mut gst::BufferRef> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn as_mut_ptr(&mut self) -> *mut gst_audio_sys::GstAudioBuffer {
|
||||
pub fn as_mut_ptr(&mut self) -> *mut ffi::GstAudioBuffer {
|
||||
&mut *self.audio_buffer
|
||||
}
|
||||
}
|
||||
|
@ -508,7 +507,7 @@ impl<T> Drop for AudioBufferRef<T> {
|
|||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
if self.unmap {
|
||||
gst_audio_sys::gst_audio_buffer_unmap(&mut *self.audio_buffer);
|
||||
ffi::gst_audio_buffer_unmap(&mut *self.audio_buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -517,13 +516,12 @@ impl<T> Drop for AudioBufferRef<T> {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use gst;
|
||||
|
||||
#[test]
|
||||
fn test_map_read() {
|
||||
gst::init().unwrap();
|
||||
|
||||
let info = ::AudioInfo::builder(::AUDIO_FORMAT_S16, 48000, 2)
|
||||
let info = crate::AudioInfo::builder(crate::AUDIO_FORMAT_S16, 48000, 2)
|
||||
.build()
|
||||
.unwrap();
|
||||
let buffer = gst::Buffer::with_size(info.rate() as usize * info.bpf() as usize).unwrap();
|
||||
|
@ -553,15 +551,15 @@ mod tests {
|
|||
fn test_map_read_planar() {
|
||||
gst::init().unwrap();
|
||||
|
||||
let info = ::AudioInfo::builder(::AUDIO_FORMAT_S16, 48000, 2)
|
||||
.layout(::AudioLayout::NonInterleaved)
|
||||
let info = crate::AudioInfo::builder(crate::AUDIO_FORMAT_S16, 48000, 2)
|
||||
.layout(crate::AudioLayout::NonInterleaved)
|
||||
.build()
|
||||
.unwrap();
|
||||
let mut buffer =
|
||||
gst::Buffer::with_size(info.rate() as usize * info.bpf() as usize).unwrap();
|
||||
{
|
||||
let buffer = buffer.get_mut().unwrap();
|
||||
::AudioMeta::add(buffer, &info, 48000, &[]).unwrap();
|
||||
crate::AudioMeta::add(buffer, &info, 48000, &[]).unwrap();
|
||||
}
|
||||
let buffer = AudioBuffer::from_buffer_readable(buffer, &info).unwrap();
|
||||
|
||||
|
@ -592,7 +590,7 @@ mod tests {
|
|||
fn test_map_write() {
|
||||
gst::init().unwrap();
|
||||
|
||||
let info = ::AudioInfo::builder(::AUDIO_FORMAT_S16, 48000, 2)
|
||||
let info = crate::AudioInfo::builder(crate::AUDIO_FORMAT_S16, 48000, 2)
|
||||
.build()
|
||||
.unwrap();
|
||||
let buffer = gst::Buffer::with_size(info.rate() as usize * info.bpf() as usize).unwrap();
|
||||
|
@ -622,15 +620,15 @@ mod tests {
|
|||
fn test_map_write_planar() {
|
||||
gst::init().unwrap();
|
||||
|
||||
let info = ::AudioInfo::builder(::AUDIO_FORMAT_S16, 48000, 2)
|
||||
.layout(::AudioLayout::NonInterleaved)
|
||||
let info = crate::AudioInfo::builder(crate::AUDIO_FORMAT_S16, 48000, 2)
|
||||
.layout(crate::AudioLayout::NonInterleaved)
|
||||
.build()
|
||||
.unwrap();
|
||||
let mut buffer =
|
||||
gst::Buffer::with_size(info.rate() as usize * info.bpf() as usize).unwrap();
|
||||
{
|
||||
let buffer = buffer.get_mut().unwrap();
|
||||
::AudioMeta::add(buffer, &info, 48000, &[]).unwrap();
|
||||
crate::AudioMeta::add(buffer, &info, 48000, &[]).unwrap();
|
||||
}
|
||||
let mut buffer = AudioBuffer::from_buffer_writable(buffer, &info).unwrap();
|
||||
|
||||
|
@ -661,7 +659,7 @@ mod tests {
|
|||
fn test_map_ref_read() {
|
||||
gst::init().unwrap();
|
||||
|
||||
let info = ::AudioInfo::builder(::AUDIO_FORMAT_S16, 48000, 2)
|
||||
let info = crate::AudioInfo::builder(crate::AUDIO_FORMAT_S16, 48000, 2)
|
||||
.build()
|
||||
.unwrap();
|
||||
let buffer = gst::Buffer::with_size(info.rate() as usize * info.bpf() as usize).unwrap();
|
||||
|
@ -682,15 +680,15 @@ mod tests {
|
|||
fn test_map_ref_read_planar() {
|
||||
gst::init().unwrap();
|
||||
|
||||
let info = ::AudioInfo::builder(::AUDIO_FORMAT_S16, 48000, 2)
|
||||
.layout(::AudioLayout::NonInterleaved)
|
||||
let info = crate::AudioInfo::builder(crate::AUDIO_FORMAT_S16, 48000, 2)
|
||||
.layout(crate::AudioLayout::NonInterleaved)
|
||||
.build()
|
||||
.unwrap();
|
||||
let mut buffer =
|
||||
gst::Buffer::with_size(info.rate() as usize * info.bpf() as usize).unwrap();
|
||||
{
|
||||
let buffer = buffer.get_mut().unwrap();
|
||||
::AudioMeta::add(buffer, &info, 48000, &[]).unwrap();
|
||||
crate::AudioMeta::add(buffer, &info, 48000, &[]).unwrap();
|
||||
}
|
||||
let buffer = AudioBufferRef::from_buffer_ref_readable(&buffer, &info).unwrap();
|
||||
|
||||
|
@ -711,7 +709,7 @@ mod tests {
|
|||
fn test_map_ref_write() {
|
||||
gst::init().unwrap();
|
||||
|
||||
let info = ::AudioInfo::builder(::AUDIO_FORMAT_S16, 48000, 2)
|
||||
let info = crate::AudioInfo::builder(crate::AUDIO_FORMAT_S16, 48000, 2)
|
||||
.build()
|
||||
.unwrap();
|
||||
let mut buffer =
|
||||
|
@ -737,15 +735,15 @@ mod tests {
|
|||
fn test_map_ref_write_planar() {
|
||||
gst::init().unwrap();
|
||||
|
||||
let info = ::AudioInfo::builder(::AUDIO_FORMAT_S16, 48000, 2)
|
||||
.layout(::AudioLayout::NonInterleaved)
|
||||
let info = crate::AudioInfo::builder(crate::AUDIO_FORMAT_S16, 48000, 2)
|
||||
.layout(crate::AudioLayout::NonInterleaved)
|
||||
.build()
|
||||
.unwrap();
|
||||
let mut buffer =
|
||||
gst::Buffer::with_size(info.rate() as usize * info.bpf() as usize).unwrap();
|
||||
{
|
||||
let buffer = buffer.get_mut().unwrap();
|
||||
::AudioMeta::add(buffer, &info, 48000, &[]).unwrap();
|
||||
crate::AudioMeta::add(buffer, &info, 48000, &[]).unwrap();
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
@ -6,16 +6,11 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use gst_audio_sys;
|
||||
use AudioChannelPosition;
|
||||
use crate::AudioChannelPosition;
|
||||
|
||||
use std::mem;
|
||||
|
||||
use glib;
|
||||
use glib::translate::{from_glib, ToGlib};
|
||||
use gst;
|
||||
|
||||
use array_init;
|
||||
|
||||
impl AudioChannelPosition {
|
||||
pub fn to_mask(self) -> u64 {
|
||||
|
@ -35,13 +30,12 @@ impl AudioChannelPosition {
|
|||
|
||||
let len = positions.len();
|
||||
if len > 64 {
|
||||
return Err(glib_bool_error!("Invalid number of channels"));
|
||||
return Err(glib::glib_bool_error!("Invalid number of channels"));
|
||||
}
|
||||
|
||||
let positions_raw: [gst_audio_sys::GstAudioChannelPosition; 64] =
|
||||
array_init::array_init(|i| {
|
||||
let positions_raw: [ffi::GstAudioChannelPosition; 64] = array_init::array_init(|i| {
|
||||
if i >= len as usize {
|
||||
gst_audio_sys::GST_AUDIO_CHANNEL_POSITION_INVALID
|
||||
ffi::GST_AUDIO_CHANNEL_POSITION_INVALID
|
||||
} else {
|
||||
positions[i].to_glib()
|
||||
}
|
||||
|
@ -49,7 +43,7 @@ impl AudioChannelPosition {
|
|||
|
||||
unsafe {
|
||||
let mut mask = mem::MaybeUninit::uninit();
|
||||
let valid: bool = from_glib(gst_audio_sys::gst_audio_channel_positions_to_mask(
|
||||
let valid: bool = from_glib(ffi::gst_audio_channel_positions_to_mask(
|
||||
positions_raw.as_ptr() as *mut _,
|
||||
len as i32,
|
||||
force_order.to_glib(),
|
||||
|
@ -58,7 +52,7 @@ impl AudioChannelPosition {
|
|||
if valid {
|
||||
Ok(mask.assume_init())
|
||||
} else {
|
||||
Err(glib_bool_error!(
|
||||
Err(glib::glib_bool_error!(
|
||||
"Couldn't convert channel positions to mask"
|
||||
))
|
||||
}
|
||||
|
@ -72,14 +66,14 @@ impl AudioChannelPosition {
|
|||
assert_initialized_main_thread!();
|
||||
|
||||
if positions.len() > 64 {
|
||||
return Err(glib_bool_error!("Invalid number of channels"));
|
||||
return Err(glib::glib_bool_error!("Invalid number of channels"));
|
||||
}
|
||||
|
||||
let len = positions.len();
|
||||
let mut positions_raw: [gst_audio_sys::GstAudioChannelPosition; 64] =
|
||||
[gst_audio_sys::GST_AUDIO_CHANNEL_POSITION_INVALID; 64];
|
||||
let mut positions_raw: [ffi::GstAudioChannelPosition; 64] =
|
||||
[ffi::GST_AUDIO_CHANNEL_POSITION_INVALID; 64];
|
||||
let valid: bool = unsafe {
|
||||
from_glib(gst_audio_sys::gst_audio_channel_positions_from_mask(
|
||||
from_glib(ffi::gst_audio_channel_positions_from_mask(
|
||||
len as i32,
|
||||
mask,
|
||||
positions_raw.as_mut_ptr(),
|
||||
|
@ -92,7 +86,7 @@ impl AudioChannelPosition {
|
|||
}
|
||||
Ok(())
|
||||
} else {
|
||||
Err(glib_bool_error!(
|
||||
Err(glib::glib_bool_error!(
|
||||
"Couldn't convert channel positions to mask",
|
||||
))
|
||||
}
|
||||
|
@ -104,21 +98,20 @@ impl AudioChannelPosition {
|
|||
assert_initialized_main_thread!();
|
||||
|
||||
if positions.len() > 64 {
|
||||
return Err(glib_bool_error!("Invalid number of channels"));
|
||||
return Err(glib::glib_bool_error!("Invalid number of channels"));
|
||||
}
|
||||
|
||||
let len = positions.len();
|
||||
let mut positions_raw: [gst_audio_sys::GstAudioChannelPosition; 64] =
|
||||
array_init::array_init(|i| {
|
||||
let mut positions_raw: [ffi::GstAudioChannelPosition; 64] = array_init::array_init(|i| {
|
||||
if i >= len as usize {
|
||||
gst_audio_sys::GST_AUDIO_CHANNEL_POSITION_INVALID
|
||||
ffi::GST_AUDIO_CHANNEL_POSITION_INVALID
|
||||
} else {
|
||||
positions[i].to_glib()
|
||||
}
|
||||
});
|
||||
|
||||
let valid: bool = unsafe {
|
||||
from_glib(gst_audio_sys::gst_audio_channel_positions_to_valid_order(
|
||||
from_glib(ffi::gst_audio_channel_positions_to_valid_order(
|
||||
positions_raw.as_mut_ptr(),
|
||||
len as i32,
|
||||
))
|
||||
|
@ -130,7 +123,7 @@ impl AudioChannelPosition {
|
|||
}
|
||||
Ok(())
|
||||
} else {
|
||||
Err(glib_bool_error!(
|
||||
Err(glib::glib_bool_error!(
|
||||
"Couldn't convert channel positions to mask",
|
||||
))
|
||||
}
|
||||
|
@ -139,11 +132,11 @@ impl AudioChannelPosition {
|
|||
pub fn get_fallback_mask(channels: u32) -> u64 {
|
||||
assert_initialized_main_thread!();
|
||||
|
||||
unsafe { gst_audio_sys::gst_audio_channel_get_fallback_mask(channels as i32) }
|
||||
unsafe { ffi::gst_audio_channel_get_fallback_mask(channels as i32) }
|
||||
}
|
||||
|
||||
pub fn check_valid_channel_positions(
|
||||
positions: &[::AudioChannelPosition],
|
||||
positions: &[crate::AudioChannelPosition],
|
||||
force_order: bool,
|
||||
) -> bool {
|
||||
assert_initialized_main_thread!();
|
||||
|
@ -153,17 +146,16 @@ impl AudioChannelPosition {
|
|||
}
|
||||
|
||||
let len = positions.len();
|
||||
let positions_raw: [gst_audio_sys::GstAudioChannelPosition; 64] =
|
||||
array_init::array_init(|i| {
|
||||
let positions_raw: [ffi::GstAudioChannelPosition; 64] = array_init::array_init(|i| {
|
||||
if i >= len as usize {
|
||||
gst_audio_sys::GST_AUDIO_CHANNEL_POSITION_INVALID
|
||||
ffi::GST_AUDIO_CHANNEL_POSITION_INVALID
|
||||
} else {
|
||||
positions[i].to_glib()
|
||||
}
|
||||
});
|
||||
|
||||
unsafe {
|
||||
from_glib(gst_audio_sys::gst_audio_check_valid_channel_positions(
|
||||
from_glib(ffi::gst_audio_check_valid_channel_positions(
|
||||
positions_raw.as_ptr() as *mut _,
|
||||
len as i32,
|
||||
force_order.to_glib(),
|
||||
|
@ -174,7 +166,7 @@ impl AudioChannelPosition {
|
|||
|
||||
pub fn buffer_reorder_channels(
|
||||
buffer: &mut gst::BufferRef,
|
||||
format: ::AudioFormat,
|
||||
format: crate::AudioFormat,
|
||||
channels: u32,
|
||||
from: &[AudioChannelPosition],
|
||||
to: &[AudioChannelPosition],
|
||||
|
@ -182,30 +174,30 @@ pub fn buffer_reorder_channels(
|
|||
assert_initialized_main_thread!();
|
||||
|
||||
if from.len() != to.len() || from.len() > 64 {
|
||||
return Err(glib_bool_error!("Invalid number of channels"));
|
||||
return Err(glib::glib_bool_error!("Invalid number of channels"));
|
||||
}
|
||||
|
||||
let from_len = from.len();
|
||||
let to_len = to.len();
|
||||
|
||||
let from_raw: [gst_audio_sys::GstAudioChannelPosition; 64] = array_init::array_init(|i| {
|
||||
let from_raw: [ffi::GstAudioChannelPosition; 64] = array_init::array_init(|i| {
|
||||
if i >= from_len as usize {
|
||||
gst_audio_sys::GST_AUDIO_CHANNEL_POSITION_INVALID
|
||||
ffi::GST_AUDIO_CHANNEL_POSITION_INVALID
|
||||
} else {
|
||||
from[i].to_glib()
|
||||
}
|
||||
});
|
||||
|
||||
let to_raw: [gst_audio_sys::GstAudioChannelPosition; 64] = array_init::array_init(|i| {
|
||||
let to_raw: [ffi::GstAudioChannelPosition; 64] = array_init::array_init(|i| {
|
||||
if i >= to_len as usize {
|
||||
gst_audio_sys::GST_AUDIO_CHANNEL_POSITION_INVALID
|
||||
ffi::GST_AUDIO_CHANNEL_POSITION_INVALID
|
||||
} else {
|
||||
to[i].to_glib()
|
||||
}
|
||||
});
|
||||
|
||||
let valid: bool = unsafe {
|
||||
from_glib(gst_audio_sys::gst_audio_buffer_reorder_channels(
|
||||
from_glib(ffi::gst_audio_buffer_reorder_channels(
|
||||
buffer.as_mut_ptr(),
|
||||
format.to_glib(),
|
||||
channels as i32,
|
||||
|
@ -217,13 +209,13 @@ pub fn buffer_reorder_channels(
|
|||
if valid {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(glib_bool_error!("Failed to reorder channels"))
|
||||
Err(glib::glib_bool_error!("Failed to reorder channels"))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn reorder_channels(
|
||||
data: &mut [u8],
|
||||
format: ::AudioFormat,
|
||||
format: crate::AudioFormat,
|
||||
channels: u32,
|
||||
from: &[AudioChannelPosition],
|
||||
to: &[AudioChannelPosition],
|
||||
|
@ -231,30 +223,30 @@ pub fn reorder_channels(
|
|||
assert_initialized_main_thread!();
|
||||
|
||||
if from.len() != to.len() || from.len() > 64 {
|
||||
return Err(glib_bool_error!("Invalid number of channels"));
|
||||
return Err(glib::glib_bool_error!("Invalid number of channels"));
|
||||
}
|
||||
|
||||
let from_len = from.len();
|
||||
let to_len = to.len();
|
||||
|
||||
let from_raw: [gst_audio_sys::GstAudioChannelPosition; 64] = array_init::array_init(|i| {
|
||||
let from_raw: [ffi::GstAudioChannelPosition; 64] = array_init::array_init(|i| {
|
||||
if i >= from_len as usize {
|
||||
gst_audio_sys::GST_AUDIO_CHANNEL_POSITION_INVALID
|
||||
ffi::GST_AUDIO_CHANNEL_POSITION_INVALID
|
||||
} else {
|
||||
from[i].to_glib()
|
||||
}
|
||||
});
|
||||
|
||||
let to_raw: [gst_audio_sys::GstAudioChannelPosition; 64] = array_init::array_init(|i| {
|
||||
let to_raw: [ffi::GstAudioChannelPosition; 64] = array_init::array_init(|i| {
|
||||
if i >= to_len as usize {
|
||||
gst_audio_sys::GST_AUDIO_CHANNEL_POSITION_INVALID
|
||||
ffi::GST_AUDIO_CHANNEL_POSITION_INVALID
|
||||
} else {
|
||||
to[i].to_glib()
|
||||
}
|
||||
});
|
||||
|
||||
let valid: bool = unsafe {
|
||||
from_glib(gst_audio_sys::gst_audio_reorder_channels(
|
||||
from_glib(ffi::gst_audio_reorder_channels(
|
||||
data.as_mut_ptr() as *mut _,
|
||||
data.len(),
|
||||
format.to_glib(),
|
||||
|
@ -267,7 +259,7 @@ pub fn reorder_channels(
|
|||
if valid {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(glib_bool_error!("Failed to reorder channels"))
|
||||
Err(glib::glib_bool_error!("Failed to reorder channels"))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -279,23 +271,23 @@ pub fn get_channel_reorder_map(
|
|||
assert_initialized_main_thread!();
|
||||
|
||||
if from.len() != to.len() || from.len() != reorder_map.len() || from.len() > 64 {
|
||||
return Err(glib_bool_error!("Invalid number of channels"));
|
||||
return Err(glib::glib_bool_error!("Invalid number of channels"));
|
||||
}
|
||||
|
||||
let from_len = from.len();
|
||||
let to_len = to.len();
|
||||
|
||||
let from_raw: [gst_audio_sys::GstAudioChannelPosition; 64] = array_init::array_init(|i| {
|
||||
let from_raw: [ffi::GstAudioChannelPosition; 64] = array_init::array_init(|i| {
|
||||
if i >= from_len as usize {
|
||||
gst_audio_sys::GST_AUDIO_CHANNEL_POSITION_INVALID
|
||||
ffi::GST_AUDIO_CHANNEL_POSITION_INVALID
|
||||
} else {
|
||||
from[i].to_glib()
|
||||
}
|
||||
});
|
||||
|
||||
let to_raw: [gst_audio_sys::GstAudioChannelPosition; 64] = array_init::array_init(|i| {
|
||||
let to_raw: [ffi::GstAudioChannelPosition; 64] = array_init::array_init(|i| {
|
||||
if i >= to_len as usize {
|
||||
gst_audio_sys::GST_AUDIO_CHANNEL_POSITION_INVALID
|
||||
ffi::GST_AUDIO_CHANNEL_POSITION_INVALID
|
||||
} else {
|
||||
to[i].to_glib()
|
||||
}
|
||||
|
@ -303,7 +295,7 @@ pub fn get_channel_reorder_map(
|
|||
|
||||
let mut reorder_map_raw = [0i32, 64];
|
||||
let valid: bool = unsafe {
|
||||
from_glib(gst_audio_sys::gst_audio_get_channel_reorder_map(
|
||||
from_glib(ffi::gst_audio_get_channel_reorder_map(
|
||||
from_len as i32,
|
||||
from_raw.as_ptr() as *mut _,
|
||||
to_raw.as_ptr() as *mut _,
|
||||
|
@ -317,6 +309,6 @@ pub fn get_channel_reorder_map(
|
|||
}
|
||||
Ok(())
|
||||
} else {
|
||||
Err(glib_bool_error!("Failed to reorder channels"))
|
||||
Err(glib::glib_bool_error!("Failed to reorder channels"))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,27 +6,25 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use crate::AudioDecoder;
|
||||
use crate::AudioInfo;
|
||||
use glib::object::IsA;
|
||||
use glib::translate::*;
|
||||
use gst;
|
||||
use gst_audio_sys;
|
||||
use std::mem;
|
||||
use std::ptr;
|
||||
use AudioDecoder;
|
||||
use AudioInfo;
|
||||
|
||||
extern "C" {
|
||||
fn _gst_audio_decoder_error(
|
||||
dec: *mut gst_audio_sys::GstAudioDecoder,
|
||||
dec: *mut ffi::GstAudioDecoder,
|
||||
weight: i32,
|
||||
domain: glib_sys::GQuark,
|
||||
domain: glib::ffi::GQuark,
|
||||
code: i32,
|
||||
txt: *mut libc::c_char,
|
||||
debug: *mut libc::c_char,
|
||||
file: *const libc::c_char,
|
||||
function: *const libc::c_char,
|
||||
line: i32,
|
||||
) -> gst_sys::GstFlowReturn;
|
||||
) -> gst::ffi::GstFlowReturn;
|
||||
}
|
||||
|
||||
pub trait AudioDecoderExtManual: 'static {
|
||||
|
@ -73,7 +71,7 @@ impl<O: IsA<AudioDecoder>> AudioDecoderExtManual for O {
|
|||
frames: i32,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let ret: gst::FlowReturn = unsafe {
|
||||
from_glib(gst_audio_sys::gst_audio_decoder_finish_frame(
|
||||
from_glib(ffi::gst_audio_decoder_finish_frame(
|
||||
self.as_ref().to_glib_none().0,
|
||||
buffer.map(|b| b.into_ptr()).unwrap_or(ptr::null_mut()),
|
||||
frames,
|
||||
|
@ -89,7 +87,7 @@ impl<O: IsA<AudioDecoder>> AudioDecoderExtManual for O {
|
|||
buffer: Option<gst::Buffer>,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let ret: gst::FlowReturn = unsafe {
|
||||
from_glib(gst_audio_sys::gst_audio_decoder_finish_subframe(
|
||||
from_glib(ffi::gst_audio_decoder_finish_subframe(
|
||||
self.as_ref().to_glib_none().0,
|
||||
buffer.map(|b| b.into_ptr()).unwrap_or(ptr::null_mut()),
|
||||
))
|
||||
|
@ -99,7 +97,7 @@ impl<O: IsA<AudioDecoder>> AudioDecoderExtManual for O {
|
|||
|
||||
fn negotiate(&self) -> Result<(), gst::FlowError> {
|
||||
unsafe {
|
||||
let ret = from_glib(gst_audio_sys::gst_audio_decoder_negotiate(
|
||||
let ret = from_glib(ffi::gst_audio_decoder_negotiate(
|
||||
self.as_ref().to_glib_none().0,
|
||||
));
|
||||
if ret {
|
||||
|
@ -114,7 +112,7 @@ impl<O: IsA<AudioDecoder>> AudioDecoderExtManual for O {
|
|||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
|
||||
fn set_output_caps(&self, caps: &gst::Caps) -> Result<(), gst::FlowError> {
|
||||
unsafe {
|
||||
let ret = from_glib(gst_audio_sys::gst_audio_decoder_set_output_caps(
|
||||
let ret = from_glib(ffi::gst_audio_decoder_set_output_caps(
|
||||
self.as_ref().to_glib_none().0,
|
||||
caps.to_glib_none().0,
|
||||
));
|
||||
|
@ -128,7 +126,7 @@ impl<O: IsA<AudioDecoder>> AudioDecoderExtManual for O {
|
|||
|
||||
fn set_output_format(&self, info: &AudioInfo) -> Result<(), gst::FlowError> {
|
||||
unsafe {
|
||||
let ret = from_glib(gst_audio_sys::gst_audio_decoder_set_output_format(
|
||||
let ret = from_glib(ffi::gst_audio_decoder_set_output_format(
|
||||
self.as_ref().to_glib_none().0,
|
||||
info.to_glib_none().0,
|
||||
));
|
||||
|
@ -144,7 +142,7 @@ impl<O: IsA<AudioDecoder>> AudioDecoderExtManual for O {
|
|||
unsafe {
|
||||
let mut allocator = ptr::null_mut();
|
||||
let mut params = mem::zeroed();
|
||||
gst_audio_sys::gst_audio_decoder_get_allocator(
|
||||
ffi::gst_audio_decoder_get_allocator(
|
||||
self.as_ref().to_glib_none().0,
|
||||
&mut allocator,
|
||||
&mut params,
|
||||
|
|
|
@ -6,13 +6,11 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use crate::AudioEncoder;
|
||||
use glib::object::IsA;
|
||||
use glib::translate::*;
|
||||
use gst;
|
||||
use gst_audio_sys;
|
||||
use std::mem;
|
||||
use std::ptr;
|
||||
use AudioEncoder;
|
||||
|
||||
pub trait AudioEncoderExtManual: 'static {
|
||||
fn finish_frame(
|
||||
|
@ -37,7 +35,7 @@ impl<O: IsA<AudioEncoder>> AudioEncoderExtManual for O {
|
|||
frames: i32,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let ret: gst::FlowReturn = unsafe {
|
||||
from_glib(gst_audio_sys::gst_audio_encoder_finish_frame(
|
||||
from_glib(ffi::gst_audio_encoder_finish_frame(
|
||||
self.as_ref().to_glib_none().0,
|
||||
buffer.map(|b| b.into_ptr()).unwrap_or(ptr::null_mut()),
|
||||
frames,
|
||||
|
@ -48,7 +46,7 @@ impl<O: IsA<AudioEncoder>> AudioEncoderExtManual for O {
|
|||
|
||||
fn negotiate(&self) -> Result<(), gst::FlowError> {
|
||||
unsafe {
|
||||
let ret = from_glib(gst_audio_sys::gst_audio_encoder_negotiate(
|
||||
let ret = from_glib(ffi::gst_audio_encoder_negotiate(
|
||||
self.as_ref().to_glib_none().0,
|
||||
));
|
||||
if ret {
|
||||
|
@ -61,7 +59,7 @@ impl<O: IsA<AudioEncoder>> AudioEncoderExtManual for O {
|
|||
|
||||
fn set_output_format(&self, caps: &gst::Caps) -> Result<(), gst::FlowError> {
|
||||
unsafe {
|
||||
let ret = from_glib(gst_audio_sys::gst_audio_encoder_set_output_format(
|
||||
let ret = from_glib(ffi::gst_audio_encoder_set_output_format(
|
||||
self.as_ref().to_glib_none().0,
|
||||
caps.to_glib_none().0,
|
||||
));
|
||||
|
@ -77,7 +75,7 @@ impl<O: IsA<AudioEncoder>> AudioEncoderExtManual for O {
|
|||
unsafe {
|
||||
let mut allocator = ptr::null_mut();
|
||||
let mut params = mem::zeroed();
|
||||
gst_audio_sys::gst_audio_encoder_get_allocator(
|
||||
ffi::gst_audio_encoder_get_allocator(
|
||||
self.as_ref().to_glib_none().0,
|
||||
&mut allocator,
|
||||
&mut params,
|
||||
|
@ -90,7 +88,7 @@ impl<O: IsA<AudioEncoder>> AudioEncoderExtManual for O {
|
|||
unsafe {
|
||||
let mut min = mem::MaybeUninit::uninit();
|
||||
let mut max = mem::MaybeUninit::uninit();
|
||||
gst_audio_sys::gst_audio_encoder_get_latency(
|
||||
ffi::gst_audio_encoder_get_latency(
|
||||
self.as_ref().to_glib_none().0,
|
||||
min.as_mut_ptr(),
|
||||
max.as_mut_ptr(),
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use gst_audio_sys;
|
||||
|
||||
use std::ffi::CStr;
|
||||
use std::fmt;
|
||||
use std::str;
|
||||
|
@ -16,10 +14,10 @@ use glib::translate::{from_glib, FromGlib, ToGlib, ToGlibPtr};
|
|||
use once_cell::sync::Lazy;
|
||||
|
||||
#[cfg(feature = "v1_18")]
|
||||
pub static AUDIO_FORMATS_ALL: Lazy<Box<[::AudioFormat]>> = Lazy::new(|| unsafe {
|
||||
pub static AUDIO_FORMATS_ALL: Lazy<Box<[crate::AudioFormat]>> = Lazy::new(|| unsafe {
|
||||
let mut len: u32 = 0;
|
||||
let mut res = Vec::with_capacity(len as usize);
|
||||
let formats = gst_audio_sys::gst_audio_formats_raw(&mut len);
|
||||
let formats = ffi::gst_audio_formats_raw(&mut len);
|
||||
for i in 0..len {
|
||||
let format = formats.offset(i as isize);
|
||||
res.push(from_glib(*format));
|
||||
|
@ -28,40 +26,40 @@ pub static AUDIO_FORMATS_ALL: Lazy<Box<[::AudioFormat]>> = Lazy::new(|| unsafe {
|
|||
});
|
||||
|
||||
#[cfg(not(feature = "v1_18"))]
|
||||
pub static AUDIO_FORMATS_ALL: Lazy<Box<[::AudioFormat]>> = Lazy::new(|| {
|
||||
pub static AUDIO_FORMATS_ALL: Lazy<Box<[crate::AudioFormat]>> = Lazy::new(|| {
|
||||
#[cfg(target_endian = "little")]
|
||||
{
|
||||
Box::new([
|
||||
::AudioFormat::F64le,
|
||||
::AudioFormat::F64be,
|
||||
::AudioFormat::F32le,
|
||||
::AudioFormat::F32be,
|
||||
::AudioFormat::S32le,
|
||||
::AudioFormat::S32be,
|
||||
::AudioFormat::U32le,
|
||||
::AudioFormat::U32be,
|
||||
::AudioFormat::S2432le,
|
||||
::AudioFormat::S2432be,
|
||||
::AudioFormat::U2432le,
|
||||
::AudioFormat::U2432be,
|
||||
::AudioFormat::S24le,
|
||||
::AudioFormat::S24be,
|
||||
::AudioFormat::U24le,
|
||||
::AudioFormat::U24be,
|
||||
::AudioFormat::S20le,
|
||||
::AudioFormat::S20be,
|
||||
::AudioFormat::U20le,
|
||||
::AudioFormat::U20be,
|
||||
::AudioFormat::S18le,
|
||||
::AudioFormat::S18be,
|
||||
::AudioFormat::U18le,
|
||||
::AudioFormat::U18be,
|
||||
::AudioFormat::S16le,
|
||||
::AudioFormat::S16be,
|
||||
::AudioFormat::U16le,
|
||||
::AudioFormat::U16be,
|
||||
::AudioFormat::S8,
|
||||
::AudioFormat::U8,
|
||||
crate::AudioFormat::F64le,
|
||||
crate::AudioFormat::F64be,
|
||||
crate::AudioFormat::F32le,
|
||||
crate::AudioFormat::F32be,
|
||||
crate::AudioFormat::S32le,
|
||||
crate::AudioFormat::S32be,
|
||||
crate::AudioFormat::U32le,
|
||||
crate::AudioFormat::U32be,
|
||||
crate::AudioFormat::S2432le,
|
||||
crate::AudioFormat::S2432be,
|
||||
crate::AudioFormat::U2432le,
|
||||
crate::AudioFormat::U2432be,
|
||||
crate::AudioFormat::S24le,
|
||||
crate::AudioFormat::S24be,
|
||||
crate::AudioFormat::U24le,
|
||||
crate::AudioFormat::U24be,
|
||||
crate::AudioFormat::S20le,
|
||||
crate::AudioFormat::S20be,
|
||||
crate::AudioFormat::U20le,
|
||||
crate::AudioFormat::U20be,
|
||||
crate::AudioFormat::S18le,
|
||||
crate::AudioFormat::S18be,
|
||||
crate::AudioFormat::U18le,
|
||||
crate::AudioFormat::U18be,
|
||||
crate::AudioFormat::S16le,
|
||||
crate::AudioFormat::S16be,
|
||||
crate::AudioFormat::U16le,
|
||||
crate::AudioFormat::U16be,
|
||||
crate::AudioFormat::S8,
|
||||
crate::AudioFormat::U8,
|
||||
])
|
||||
}
|
||||
#[cfg(target_endian = "big")]
|
||||
|
@ -101,17 +99,17 @@ pub static AUDIO_FORMATS_ALL: Lazy<Box<[::AudioFormat]>> = Lazy::new(|| {
|
|||
}
|
||||
});
|
||||
|
||||
impl ::AudioFormat {
|
||||
impl crate::AudioFormat {
|
||||
pub fn build_integer(
|
||||
sign: bool,
|
||||
endianness: ::AudioEndianness,
|
||||
endianness: crate::AudioEndianness,
|
||||
width: i32,
|
||||
depth: i32,
|
||||
) -> ::AudioFormat {
|
||||
) -> crate::AudioFormat {
|
||||
assert_initialized_main_thread!();
|
||||
|
||||
unsafe {
|
||||
from_glib(gst_audio_sys::gst_audio_format_build_integer(
|
||||
from_glib(ffi::gst_audio_format_build_integer(
|
||||
sign.to_glib(),
|
||||
endianness.to_glib(),
|
||||
width,
|
||||
|
@ -121,12 +119,12 @@ impl ::AudioFormat {
|
|||
}
|
||||
|
||||
pub fn to_str<'a>(self) -> &'a str {
|
||||
if self == ::AudioFormat::Unknown {
|
||||
if self == crate::AudioFormat::Unknown {
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
unsafe {
|
||||
CStr::from_ptr(gst_audio_sys::gst_audio_format_to_string(self.to_glib()))
|
||||
CStr::from_ptr(ffi::gst_audio_format_to_string(self.to_glib()))
|
||||
.to_str()
|
||||
.unwrap()
|
||||
}
|
||||
|
@ -137,18 +135,20 @@ impl ::AudioFormat {
|
|||
}
|
||||
}
|
||||
|
||||
impl str::FromStr for ::AudioFormat {
|
||||
impl str::FromStr for crate::AudioFormat {
|
||||
type Err = glib::BoolError;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, glib::BoolError> {
|
||||
assert_initialized_main_thread!();
|
||||
|
||||
unsafe {
|
||||
let fmt = ::AudioFormat::from_glib(gst_audio_sys::gst_audio_format_from_string(
|
||||
let fmt = crate::AudioFormat::from_glib(ffi::gst_audio_format_from_string(
|
||||
s.to_glib_none().0,
|
||||
));
|
||||
if fmt == ::AudioFormat::Unknown {
|
||||
Err(glib_bool_error!("Failed to parse audio format from string"))
|
||||
if fmt == crate::AudioFormat::Unknown {
|
||||
Err(glib::glib_bool_error!(
|
||||
"Failed to parse audio format from string"
|
||||
))
|
||||
} else {
|
||||
Ok(fmt)
|
||||
}
|
||||
|
@ -156,28 +156,29 @@ impl str::FromStr for ::AudioFormat {
|
|||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for ::AudioFormat {
|
||||
impl fmt::Display for crate::AudioFormat {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
||||
f.write_str((*self).to_str())
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialOrd for ::AudioFormat {
|
||||
fn partial_cmp(&self, other: &::AudioFormat) -> Option<std::cmp::Ordering> {
|
||||
::AudioFormatInfo::from_format(*self).partial_cmp(&::AudioFormatInfo::from_format(*other))
|
||||
impl PartialOrd for crate::AudioFormat {
|
||||
fn partial_cmp(&self, other: &crate::AudioFormat) -> Option<std::cmp::Ordering> {
|
||||
crate::AudioFormatInfo::from_format(*self)
|
||||
.partial_cmp(&crate::AudioFormatInfo::from_format(*other))
|
||||
}
|
||||
}
|
||||
|
||||
impl Ord for ::AudioFormat {
|
||||
fn cmp(&self, other: &::AudioFormat) -> std::cmp::Ordering {
|
||||
::AudioFormatInfo::from_format(*self).cmp(&::AudioFormatInfo::from_format(*other))
|
||||
impl Ord for crate::AudioFormat {
|
||||
fn cmp(&self, other: &crate::AudioFormat) -> std::cmp::Ordering {
|
||||
crate::AudioFormatInfo::from_format(*self).cmp(&crate::AudioFormatInfo::from_format(*other))
|
||||
}
|
||||
}
|
||||
|
||||
pub const AUDIO_FORMAT_UNKNOWN: ::AudioFormat = ::AudioFormat::Unknown;
|
||||
pub const AUDIO_FORMAT_ENCODED: ::AudioFormat = ::AudioFormat::Encoded;
|
||||
pub const AUDIO_FORMAT_S8: ::AudioFormat = ::AudioFormat::S8;
|
||||
pub const AUDIO_FORMAT_U8: ::AudioFormat = ::AudioFormat::U8;
|
||||
pub const AUDIO_FORMAT_UNKNOWN: crate::AudioFormat = crate::AudioFormat::Unknown;
|
||||
pub const AUDIO_FORMAT_ENCODED: crate::AudioFormat = crate::AudioFormat::Encoded;
|
||||
pub const AUDIO_FORMAT_S8: crate::AudioFormat = crate::AudioFormat::S8;
|
||||
pub const AUDIO_FORMAT_U8: crate::AudioFormat = crate::AudioFormat::U8;
|
||||
|
||||
#[cfg(target_endian = "big")]
|
||||
pub const AUDIO_FORMAT_S16: ::AudioFormat = ::AudioFormat::S16be;
|
||||
|
@ -209,33 +210,33 @@ pub const AUDIO_FORMAT_F32: ::AudioFormat = ::AudioFormat::F32be;
|
|||
pub const AUDIO_FORMAT_F64: ::AudioFormat = ::AudioFormat::F64be;
|
||||
|
||||
#[cfg(target_endian = "little")]
|
||||
pub const AUDIO_FORMAT_S16: ::AudioFormat = ::AudioFormat::S16le;
|
||||
pub const AUDIO_FORMAT_S16: crate::AudioFormat = crate::AudioFormat::S16le;
|
||||
#[cfg(target_endian = "little")]
|
||||
pub const AUDIO_FORMAT_U16: ::AudioFormat = ::AudioFormat::U16le;
|
||||
pub const AUDIO_FORMAT_U16: crate::AudioFormat = crate::AudioFormat::U16le;
|
||||
#[cfg(target_endian = "little")]
|
||||
pub const AUDIO_FORMAT_S2432: ::AudioFormat = ::AudioFormat::S2432le;
|
||||
pub const AUDIO_FORMAT_S2432: crate::AudioFormat = crate::AudioFormat::S2432le;
|
||||
#[cfg(target_endian = "little")]
|
||||
pub const AUDIO_FORMAT_U2432: ::AudioFormat = ::AudioFormat::U2432le;
|
||||
pub const AUDIO_FORMAT_U2432: crate::AudioFormat = crate::AudioFormat::U2432le;
|
||||
#[cfg(target_endian = "little")]
|
||||
pub const AUDIO_FORMAT_S32: ::AudioFormat = ::AudioFormat::S32le;
|
||||
pub const AUDIO_FORMAT_S32: crate::AudioFormat = crate::AudioFormat::S32le;
|
||||
#[cfg(target_endian = "little")]
|
||||
pub const AUDIO_FORMAT_U32: ::AudioFormat = ::AudioFormat::U32le;
|
||||
pub const AUDIO_FORMAT_U32: crate::AudioFormat = crate::AudioFormat::U32le;
|
||||
#[cfg(target_endian = "little")]
|
||||
pub const AUDIO_FORMAT_S24: ::AudioFormat = ::AudioFormat::S24le;
|
||||
pub const AUDIO_FORMAT_S24: crate::AudioFormat = crate::AudioFormat::S24le;
|
||||
#[cfg(target_endian = "little")]
|
||||
pub const AUDIO_FORMAT_U24: ::AudioFormat = ::AudioFormat::U24le;
|
||||
pub const AUDIO_FORMAT_U24: crate::AudioFormat = crate::AudioFormat::U24le;
|
||||
#[cfg(target_endian = "little")]
|
||||
pub const AUDIO_FORMAT_S20: ::AudioFormat = ::AudioFormat::S20le;
|
||||
pub const AUDIO_FORMAT_S20: crate::AudioFormat = crate::AudioFormat::S20le;
|
||||
#[cfg(target_endian = "little")]
|
||||
pub const AUDIO_FORMAT_U20: ::AudioFormat = ::AudioFormat::U20le;
|
||||
pub const AUDIO_FORMAT_U20: crate::AudioFormat = crate::AudioFormat::U20le;
|
||||
#[cfg(target_endian = "little")]
|
||||
pub const AUDIO_FORMAT_S18: ::AudioFormat = ::AudioFormat::S18le;
|
||||
pub const AUDIO_FORMAT_S18: crate::AudioFormat = crate::AudioFormat::S18le;
|
||||
#[cfg(target_endian = "little")]
|
||||
pub const AUDIO_FORMAT_U18: ::AudioFormat = ::AudioFormat::U18le;
|
||||
pub const AUDIO_FORMAT_U18: crate::AudioFormat = crate::AudioFormat::U18le;
|
||||
#[cfg(target_endian = "little")]
|
||||
pub const AUDIO_FORMAT_F32: ::AudioFormat = ::AudioFormat::F32le;
|
||||
pub const AUDIO_FORMAT_F32: crate::AudioFormat = crate::AudioFormat::F32le;
|
||||
#[cfg(target_endian = "little")]
|
||||
pub const AUDIO_FORMAT_F64: ::AudioFormat = ::AudioFormat::F64le;
|
||||
pub const AUDIO_FORMAT_F64: crate::AudioFormat = crate::AudioFormat::F64le;
|
||||
|
||||
pub struct AudioFormatIterator {
|
||||
idx: usize,
|
||||
|
@ -252,7 +253,7 @@ impl Default for AudioFormatIterator {
|
|||
}
|
||||
|
||||
impl Iterator for AudioFormatIterator {
|
||||
type Item = ::AudioFormat;
|
||||
type Item = crate::AudioFormat;
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
if self.idx >= self.len {
|
||||
|
@ -291,21 +292,21 @@ impl DoubleEndedIterator for AudioFormatIterator {
|
|||
pub trait AudioFormatIteratorExt {
|
||||
fn into_audio_caps(
|
||||
self,
|
||||
layout: ::AudioLayout,
|
||||
layout: crate::AudioLayout,
|
||||
) -> Option<gst::caps::Builder<gst::caps::NoFeature>>;
|
||||
}
|
||||
|
||||
impl<T> AudioFormatIteratorExt for T
|
||||
where
|
||||
T: Iterator<Item = ::AudioFormat>,
|
||||
T: Iterator<Item = crate::AudioFormat>,
|
||||
{
|
||||
fn into_audio_caps(
|
||||
self,
|
||||
layout: ::AudioLayout,
|
||||
layout: crate::AudioLayout,
|
||||
) -> Option<gst::caps::Builder<gst::caps::NoFeature>> {
|
||||
let formats: Vec<::AudioFormat> = self.collect();
|
||||
let formats: Vec<crate::AudioFormat> = self.collect();
|
||||
if !formats.is_empty() {
|
||||
Some(::functions::audio_make_raw_caps(&formats, layout))
|
||||
Some(crate::functions::audio_make_raw_caps(&formats, layout))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
@ -315,21 +316,21 @@ where
|
|||
pub trait AudioFormatIteratorExtRef {
|
||||
fn into_audio_caps(
|
||||
self,
|
||||
layout: ::AudioLayout,
|
||||
layout: crate::AudioLayout,
|
||||
) -> Option<gst::caps::Builder<gst::caps::NoFeature>>;
|
||||
}
|
||||
|
||||
impl<'a, T> AudioFormatIteratorExtRef for T
|
||||
where
|
||||
T: Iterator<Item = &'a ::AudioFormat>,
|
||||
T: Iterator<Item = &'a crate::AudioFormat>,
|
||||
{
|
||||
fn into_audio_caps(
|
||||
self,
|
||||
layout: ::AudioLayout,
|
||||
layout: crate::AudioLayout,
|
||||
) -> Option<gst::caps::Builder<gst::caps::NoFeature>> {
|
||||
let formats: Vec<::AudioFormat> = self.copied().collect();
|
||||
let formats: Vec<crate::AudioFormat> = self.copied().collect();
|
||||
if !formats.is_empty() {
|
||||
Some(::functions::audio_make_raw_caps(&formats, layout))
|
||||
Some(crate::functions::audio_make_raw_caps(&formats, layout))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
@ -338,14 +339,13 @@ where
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use gst;
|
||||
use itertools::Itertools;
|
||||
|
||||
#[test]
|
||||
fn test_display() {
|
||||
gst::init().unwrap();
|
||||
|
||||
format!("{}", ::AudioFormat::S16be);
|
||||
format!("{}", crate::AudioFormat::S16be);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -353,13 +353,13 @@ mod tests {
|
|||
use super::*;
|
||||
gst::init().unwrap();
|
||||
|
||||
assert!(::AudioFormat::iter_raw().count() > 0);
|
||||
assert!(crate::AudioFormat::iter_raw().count() > 0);
|
||||
assert_eq!(
|
||||
::AudioFormat::iter_raw().count(),
|
||||
::AudioFormat::iter_raw().len()
|
||||
crate::AudioFormat::iter_raw().count(),
|
||||
crate::AudioFormat::iter_raw().len()
|
||||
);
|
||||
|
||||
let mut i = ::AudioFormat::iter_raw();
|
||||
let mut i = crate::AudioFormat::iter_raw();
|
||||
let mut count = 0;
|
||||
loop {
|
||||
if i.next().is_none() {
|
||||
|
@ -371,29 +371,29 @@ mod tests {
|
|||
}
|
||||
count += 1;
|
||||
}
|
||||
assert_eq!(count, ::AudioFormat::iter_raw().len());
|
||||
assert_eq!(count, crate::AudioFormat::iter_raw().len());
|
||||
|
||||
assert!(::AudioFormat::iter_raw().any(|f| f == ::AudioFormat::F64be));
|
||||
assert!(::AudioFormat::iter_raw()
|
||||
.find(|f| *f == ::AudioFormat::Encoded)
|
||||
assert!(crate::AudioFormat::iter_raw().any(|f| f == crate::AudioFormat::F64be));
|
||||
assert!(crate::AudioFormat::iter_raw()
|
||||
.find(|f| *f == crate::AudioFormat::Encoded)
|
||||
.is_none());
|
||||
|
||||
let caps = ::AudioFormat::iter_raw().into_audio_caps(::AudioLayout::Interleaved);
|
||||
let caps = crate::AudioFormat::iter_raw().into_audio_caps(crate::AudioLayout::Interleaved);
|
||||
assert!(caps.is_some());
|
||||
|
||||
let caps = ::AudioFormat::iter_raw()
|
||||
.filter(|f| ::AudioFormatInfo::from_format(*f).is_little_endian())
|
||||
.into_audio_caps(::AudioLayout::Interleaved);
|
||||
let caps = crate::AudioFormat::iter_raw()
|
||||
.filter(|f| crate::AudioFormatInfo::from_format(*f).is_little_endian())
|
||||
.into_audio_caps(crate::AudioLayout::Interleaved);
|
||||
assert!(caps.is_some());
|
||||
|
||||
let caps = ::AudioFormat::iter_raw()
|
||||
let caps = crate::AudioFormat::iter_raw()
|
||||
.skip(1000)
|
||||
.into_audio_caps(::AudioLayout::Interleaved);
|
||||
.into_audio_caps(crate::AudioLayout::Interleaved);
|
||||
assert!(caps.is_none());
|
||||
|
||||
let caps = [::AudioFormat::S16le, ::AudioFormat::S16be]
|
||||
let caps = [crate::AudioFormat::S16le, crate::AudioFormat::S16be]
|
||||
.iter()
|
||||
.into_audio_caps(::AudioLayout::Interleaved)
|
||||
.into_audio_caps(crate::AudioLayout::Interleaved)
|
||||
.unwrap()
|
||||
.build();
|
||||
assert_eq!(caps.to_string(), "audio/x-raw, format=(string){ S16LE, S16BE }, rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 2147483647 ], layout=(string)interleaved");
|
||||
|
@ -404,16 +404,17 @@ mod tests {
|
|||
gst::init().unwrap();
|
||||
|
||||
assert!(
|
||||
::AudioFormatInfo::from_format(::AudioFormat::F64be)
|
||||
> ::AudioFormatInfo::from_format(::AudioFormat::U8)
|
||||
crate::AudioFormatInfo::from_format(crate::AudioFormat::F64be)
|
||||
> crate::AudioFormatInfo::from_format(crate::AudioFormat::U8)
|
||||
);
|
||||
assert!(::AudioFormat::S20be > ::AudioFormat::S18be);
|
||||
assert!(crate::AudioFormat::S20be > crate::AudioFormat::S18be);
|
||||
|
||||
let sorted: Vec<::AudioFormat> = ::AudioFormat::iter_raw().sorted().rev().collect();
|
||||
let sorted: Vec<crate::AudioFormat> =
|
||||
crate::AudioFormat::iter_raw().sorted().rev().collect();
|
||||
// FIXME: use is_sorted_by() once API is in stable
|
||||
assert_eq!(
|
||||
sorted,
|
||||
::AudioFormat::iter_raw().collect::<Vec<::AudioFormat>>()
|
||||
crate::AudioFormat::iter_raw().collect::<Vec<crate::AudioFormat>>()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,16 +6,11 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use glib_sys;
|
||||
use gobject_sys;
|
||||
use gst_audio_sys;
|
||||
|
||||
use std::cmp::Ordering;
|
||||
use std::ffi::CStr;
|
||||
use std::fmt;
|
||||
use std::str;
|
||||
|
||||
use glib;
|
||||
use glib::translate::{from_glib, FromGlib, FromGlibPtrNone, ToGlib, ToGlibPtr, ToGlibPtrMut};
|
||||
|
||||
#[derive(PartialEq, Eq, Copy, Clone, Debug, Hash)]
|
||||
|
@ -49,21 +44,21 @@ impl ToGlib for AudioEndianness {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct AudioFormatInfo(&'static gst_audio_sys::GstAudioFormatInfo);
|
||||
pub struct AudioFormatInfo(&'static ffi::GstAudioFormatInfo);
|
||||
|
||||
impl AudioFormatInfo {
|
||||
pub fn from_format(format: ::AudioFormat) -> AudioFormatInfo {
|
||||
pub fn from_format(format: crate::AudioFormat) -> AudioFormatInfo {
|
||||
assert_initialized_main_thread!();
|
||||
|
||||
unsafe {
|
||||
let info = gst_audio_sys::gst_audio_format_get_info(format.to_glib());
|
||||
let info = ffi::gst_audio_format_get_info(format.to_glib());
|
||||
assert!(!info.is_null());
|
||||
|
||||
AudioFormatInfo(&*info)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn format(&self) -> ::AudioFormat {
|
||||
pub fn format(&self) -> crate::AudioFormat {
|
||||
from_glib(self.0.format)
|
||||
}
|
||||
|
||||
|
@ -75,7 +70,7 @@ impl AudioFormatInfo {
|
|||
unsafe { CStr::from_ptr(self.0.description).to_str().unwrap() }
|
||||
}
|
||||
|
||||
pub fn flags(&self) -> ::AudioFormatFlags {
|
||||
pub fn flags(&self) -> crate::AudioFormatFlags {
|
||||
from_glib(self.0.flags)
|
||||
}
|
||||
|
||||
|
@ -91,7 +86,7 @@ impl AudioFormatInfo {
|
|||
self.0.depth as u32
|
||||
}
|
||||
|
||||
pub fn unpack_format(&self) -> ::AudioFormat {
|
||||
pub fn unpack_format(&self) -> crate::AudioFormat {
|
||||
from_glib(self.0.unpack_format)
|
||||
}
|
||||
|
||||
|
@ -99,7 +94,7 @@ impl AudioFormatInfo {
|
|||
&self.0.silence
|
||||
}
|
||||
|
||||
pub fn unpack(&self, flags: ::AudioPackFlags, dest: &mut [u8], src: &[u8]) {
|
||||
pub fn unpack(&self, flags: crate::AudioPackFlags, dest: &mut [u8], src: &[u8]) {
|
||||
let unpack_format = Self::from_format(self.unpack_format());
|
||||
let unpack_width = unpack_format.width() as usize;
|
||||
|
||||
|
@ -133,7 +128,7 @@ impl AudioFormatInfo {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn pack(&self, flags: ::AudioPackFlags, dest: &mut [u8], src: &[u8]) {
|
||||
pub fn pack(&self, flags: crate::AudioPackFlags, dest: &mut [u8], src: &[u8]) {
|
||||
let unpack_format = Self::from_format(self.unpack_format());
|
||||
let unpack_width = unpack_format.width() as usize;
|
||||
|
||||
|
@ -179,24 +174,20 @@ impl AudioFormatInfo {
|
|||
}
|
||||
|
||||
unsafe {
|
||||
gst_audio_sys::gst_audio_format_fill_silence(
|
||||
self.0,
|
||||
dest.as_mut_ptr() as *mut _,
|
||||
dest.len(),
|
||||
)
|
||||
ffi::gst_audio_format_fill_silence(self.0, dest.as_mut_ptr() as *mut _, dest.len())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_float(&self) -> bool {
|
||||
self.flags().contains(::AudioFormatFlags::FLOAT)
|
||||
self.flags().contains(crate::AudioFormatFlags::FLOAT)
|
||||
}
|
||||
|
||||
pub fn is_integer(&self) -> bool {
|
||||
self.flags().contains(::AudioFormatFlags::INTEGER)
|
||||
self.flags().contains(crate::AudioFormatFlags::INTEGER)
|
||||
}
|
||||
|
||||
pub fn is_signed(&self) -> bool {
|
||||
self.flags().contains(::AudioFormatFlags::SIGNED)
|
||||
self.flags().contains(crate::AudioFormatFlags::SIGNED)
|
||||
}
|
||||
|
||||
pub fn is_little_endian(&self) -> bool {
|
||||
|
@ -233,8 +224,8 @@ impl Ord for AudioFormatInfo {
|
|||
.then_with(|| self.width().cmp(&other.width()))
|
||||
.then_with(|| {
|
||||
match (
|
||||
self.flags().contains(::AudioFormatFlags::FLOAT),
|
||||
other.flags().contains(::AudioFormatFlags::FLOAT),
|
||||
self.flags().contains(crate::AudioFormatFlags::FLOAT),
|
||||
other.flags().contains(crate::AudioFormatFlags::FLOAT),
|
||||
) {
|
||||
(true, false) => Ordering::Greater,
|
||||
(false, true) => Ordering::Less,
|
||||
|
@ -243,8 +234,8 @@ impl Ord for AudioFormatInfo {
|
|||
})
|
||||
.then_with(|| {
|
||||
match (
|
||||
self.flags().contains(::AudioFormatFlags::SIGNED),
|
||||
other.flags().contains(::AudioFormatFlags::SIGNED),
|
||||
self.flags().contains(crate::AudioFormatFlags::SIGNED),
|
||||
other.flags().contains(crate::AudioFormatFlags::SIGNED),
|
||||
) {
|
||||
(true, false) => Ordering::Greater,
|
||||
(false, true) => Ordering::Less,
|
||||
|
@ -252,7 +243,7 @@ impl Ord for AudioFormatInfo {
|
|||
}
|
||||
})
|
||||
.then_with(|| match (self.endianness(), other.endianness()) {
|
||||
(::AudioEndianness::LittleEndian, ::AudioEndianness::BigEndian) => {
|
||||
(crate::AudioEndianness::LittleEndian, crate::AudioEndianness::BigEndian) => {
|
||||
#[cfg(target_endian = "little")]
|
||||
{
|
||||
Ordering::Greater
|
||||
|
@ -262,7 +253,7 @@ impl Ord for AudioFormatInfo {
|
|||
Ordering::Less
|
||||
}
|
||||
}
|
||||
(::AudioEndianness::BigEndian, ::AudioEndianness::LittleEndian) => {
|
||||
(crate::AudioEndianness::BigEndian, crate::AudioEndianness::LittleEndian) => {
|
||||
#[cfg(target_endian = "little")]
|
||||
{
|
||||
Ordering::Less
|
||||
|
@ -298,7 +289,7 @@ impl fmt::Display for AudioFormatInfo {
|
|||
}
|
||||
}
|
||||
|
||||
impl str::FromStr for ::AudioFormatInfo {
|
||||
impl str::FromStr for crate::AudioFormatInfo {
|
||||
type Err = glib::BoolError;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, glib::BoolError> {
|
||||
|
@ -308,8 +299,8 @@ impl str::FromStr for ::AudioFormatInfo {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<::AudioFormat> for AudioFormatInfo {
|
||||
fn from(f: ::AudioFormat) -> Self {
|
||||
impl From<crate::AudioFormat> for AudioFormatInfo {
|
||||
fn from(f: crate::AudioFormat) -> Self {
|
||||
skip_assert_initialized!();
|
||||
Self::from_format(f)
|
||||
}
|
||||
|
@ -317,29 +308,26 @@ impl From<::AudioFormat> for AudioFormatInfo {
|
|||
|
||||
impl glib::types::StaticType for AudioFormatInfo {
|
||||
fn static_type() -> glib::types::Type {
|
||||
unsafe { glib::translate::from_glib(gst_audio_sys::gst_audio_format_info_get_type()) }
|
||||
unsafe { glib::translate::from_glib(ffi::gst_audio_format_info_get_type()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
impl<'a> glib::value::FromValueOptional<'a> for AudioFormatInfo {
|
||||
unsafe fn from_value_optional(value: &glib::Value) -> Option<Self> {
|
||||
Option::<AudioFormatInfo>::from_glib_none(gobject_sys::g_value_get_boxed(
|
||||
Option::<AudioFormatInfo>::from_glib_none(glib::gobject_ffi::g_value_get_boxed(
|
||||
value.to_glib_none().0,
|
||||
)
|
||||
as *mut gst_audio_sys::GstAudioFormatInfo)
|
||||
) as *mut ffi::GstAudioFormatInfo)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
impl glib::value::SetValue for AudioFormatInfo {
|
||||
unsafe fn set_value(value: &mut glib::Value, this: &Self) {
|
||||
gobject_sys::g_value_set_boxed(
|
||||
glib::gobject_ffi::g_value_set_boxed(
|
||||
value.to_glib_none_mut().0,
|
||||
glib::translate::ToGlibPtr::<*const gst_audio_sys::GstAudioFormatInfo>::to_glib_none(
|
||||
this,
|
||||
)
|
||||
.0 as glib_sys::gpointer,
|
||||
glib::translate::ToGlibPtr::<*const ffi::GstAudioFormatInfo>::to_glib_none(this).0
|
||||
as glib::ffi::gpointer,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -347,42 +335,36 @@ impl glib::value::SetValue for AudioFormatInfo {
|
|||
#[doc(hidden)]
|
||||
impl glib::value::SetValueOptional for AudioFormatInfo {
|
||||
unsafe fn set_value_optional(value: &mut glib::Value, this: Option<&Self>) {
|
||||
gobject_sys::g_value_set_boxed(
|
||||
glib::gobject_ffi::g_value_set_boxed(
|
||||
value.to_glib_none_mut().0,
|
||||
glib::translate::ToGlibPtr::<*const gst_audio_sys::GstAudioFormatInfo>::to_glib_none(
|
||||
&this,
|
||||
)
|
||||
.0 as glib_sys::gpointer,
|
||||
glib::translate::ToGlibPtr::<*const ffi::GstAudioFormatInfo>::to_glib_none(&this).0
|
||||
as glib::ffi::gpointer,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
impl glib::translate::GlibPtrDefault for AudioFormatInfo {
|
||||
type GlibType = *mut gst_audio_sys::GstAudioFormatInfo;
|
||||
type GlibType = *mut ffi::GstAudioFormatInfo;
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
impl<'a> glib::translate::ToGlibPtr<'a, *const gst_audio_sys::GstAudioFormatInfo>
|
||||
for AudioFormatInfo
|
||||
{
|
||||
impl<'a> glib::translate::ToGlibPtr<'a, *const ffi::GstAudioFormatInfo> for AudioFormatInfo {
|
||||
type Storage = &'a AudioFormatInfo;
|
||||
|
||||
fn to_glib_none(
|
||||
&'a self,
|
||||
) -> glib::translate::Stash<'a, *const gst_audio_sys::GstAudioFormatInfo, Self> {
|
||||
fn to_glib_none(&'a self) -> glib::translate::Stash<'a, *const ffi::GstAudioFormatInfo, Self> {
|
||||
glib::translate::Stash(self.0, self)
|
||||
}
|
||||
|
||||
fn to_glib_full(&self) -> *const gst_audio_sys::GstAudioFormatInfo {
|
||||
fn to_glib_full(&self) -> *const ffi::GstAudioFormatInfo {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
impl glib::translate::FromGlibPtrNone<*mut gst_audio_sys::GstAudioFormatInfo> for AudioFormatInfo {
|
||||
impl glib::translate::FromGlibPtrNone<*mut ffi::GstAudioFormatInfo> for AudioFormatInfo {
|
||||
#[inline]
|
||||
unsafe fn from_glib_none(ptr: *mut gst_audio_sys::GstAudioFormatInfo) -> Self {
|
||||
unsafe fn from_glib_none(ptr: *mut ffi::GstAudioFormatInfo) -> Self {
|
||||
AudioFormatInfo(&*ptr)
|
||||
}
|
||||
}
|
||||
|
@ -390,13 +372,12 @@ impl glib::translate::FromGlibPtrNone<*mut gst_audio_sys::GstAudioFormatInfo> fo
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use gst;
|
||||
|
||||
#[test]
|
||||
fn test_get() {
|
||||
gst::init().unwrap();
|
||||
|
||||
let info = AudioFormatInfo::from_format(::AudioFormat::S16le);
|
||||
let info = AudioFormatInfo::from_format(crate::AudioFormat::S16le);
|
||||
assert_eq!(info.name(), "S16LE");
|
||||
|
||||
let other_info = "S16LE".parse().unwrap();
|
||||
|
@ -407,7 +388,7 @@ mod tests {
|
|||
fn pack_unpack() {
|
||||
gst::init().unwrap();
|
||||
|
||||
let info = AudioFormatInfo::from_format(::AudioFormat::S16le);
|
||||
let info = AudioFormatInfo::from_format(crate::AudioFormat::S16le);
|
||||
let unpack_info = AudioFormatInfo::from_format(info.unpack_format());
|
||||
|
||||
assert!(unpack_info.width() > 0);
|
||||
|
@ -416,8 +397,8 @@ mod tests {
|
|||
let mut unpacked = [0; 16];
|
||||
let mut output = [0; 8];
|
||||
|
||||
info.unpack(::AudioPackFlags::empty(), &mut unpacked, &input);
|
||||
info.pack(::AudioPackFlags::empty(), &mut output, &unpacked);
|
||||
info.unpack(crate::AudioPackFlags::empty(), &mut unpacked, &input);
|
||||
info.pack(crate::AudioPackFlags::empty(), &mut output, &unpacked);
|
||||
|
||||
assert_eq!(input, output);
|
||||
}
|
||||
|
|
|
@ -6,24 +6,16 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use glib_sys;
|
||||
use gobject_sys;
|
||||
use gst_audio_sys;
|
||||
|
||||
use glib;
|
||||
use glib::translate::{
|
||||
from_glib, from_glib_full, from_glib_none, FromGlibPtrNone, ToGlib, ToGlibPtr, ToGlibPtrMut,
|
||||
};
|
||||
use gst;
|
||||
use gst::prelude::*;
|
||||
|
||||
use std::fmt;
|
||||
use std::mem;
|
||||
use std::ptr;
|
||||
|
||||
use array_init;
|
||||
|
||||
pub struct AudioInfo(gst_audio_sys::GstAudioInfo, [::AudioChannelPosition; 64]);
|
||||
pub struct AudioInfo(ffi::GstAudioInfo, [crate::AudioChannelPosition; 64]);
|
||||
|
||||
impl fmt::Debug for AudioInfo {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
||||
|
@ -40,12 +32,12 @@ impl fmt::Debug for AudioInfo {
|
|||
|
||||
#[derive(Debug)]
|
||||
pub struct AudioInfoBuilder<'a> {
|
||||
format: ::AudioFormat,
|
||||
format: crate::AudioFormat,
|
||||
rate: u32,
|
||||
channels: u32,
|
||||
positions: Option<&'a [::AudioChannelPosition]>,
|
||||
flags: Option<::AudioFlags>,
|
||||
layout: Option<::AudioLayout>,
|
||||
positions: Option<&'a [crate::AudioChannelPosition]>,
|
||||
flags: Option<crate::AudioFlags>,
|
||||
layout: Option<crate::AudioLayout>,
|
||||
}
|
||||
|
||||
impl<'a> AudioInfoBuilder<'a> {
|
||||
|
@ -55,26 +47,24 @@ impl<'a> AudioInfoBuilder<'a> {
|
|||
|
||||
let positions = if let Some(p) = self.positions {
|
||||
if p.len() != self.channels as usize || p.len() > 64 {
|
||||
return Err(glib_bool_error!("Invalid positions length"));
|
||||
return Err(glib::glib_bool_error!("Invalid positions length"));
|
||||
}
|
||||
|
||||
let positions: [gst_audio_sys::GstAudioChannelPosition; 64] =
|
||||
array_init::array_init(|i| {
|
||||
let positions: [ffi::GstAudioChannelPosition; 64] = array_init::array_init(|i| {
|
||||
if i >= self.channels as usize {
|
||||
gst_audio_sys::GST_AUDIO_CHANNEL_POSITION_INVALID
|
||||
ffi::GST_AUDIO_CHANNEL_POSITION_INVALID
|
||||
} else {
|
||||
p[i].to_glib()
|
||||
}
|
||||
});
|
||||
|
||||
let valid: bool =
|
||||
from_glib(gst_audio_sys::gst_audio_check_valid_channel_positions(
|
||||
let valid: bool = from_glib(ffi::gst_audio_check_valid_channel_positions(
|
||||
positions.as_ptr() as *mut _,
|
||||
self.channels as i32,
|
||||
true.to_glib(),
|
||||
));
|
||||
if !valid {
|
||||
return Err(glib_bool_error!("channel positions are invalid"));
|
||||
return Err(glib::glib_bool_error!("channel positions are invalid"));
|
||||
}
|
||||
|
||||
Some(positions)
|
||||
|
@ -87,7 +77,7 @@ impl<'a> AudioInfoBuilder<'a> {
|
|||
.map(|p| p.as_ptr())
|
||||
.unwrap_or(ptr::null());
|
||||
|
||||
gst_audio_sys::gst_audio_info_set_format(
|
||||
ffi::gst_audio_info_set_format(
|
||||
info.as_mut_ptr(),
|
||||
self.format.to_glib(),
|
||||
self.rate as i32,
|
||||
|
@ -98,7 +88,7 @@ impl<'a> AudioInfoBuilder<'a> {
|
|||
let mut info = info.assume_init();
|
||||
|
||||
if info.finfo.is_null() || info.rate <= 0 || info.channels <= 0 {
|
||||
return Err(glib_bool_error!("Failed to build AudioInfo"));
|
||||
return Err(glib::glib_bool_error!("Failed to build AudioInfo"));
|
||||
}
|
||||
|
||||
if let Some(flags) = self.flags {
|
||||
|
@ -114,21 +104,21 @@ impl<'a> AudioInfoBuilder<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn positions(self, positions: &'a [::AudioChannelPosition]) -> AudioInfoBuilder<'a> {
|
||||
pub fn positions(self, positions: &'a [crate::AudioChannelPosition]) -> AudioInfoBuilder<'a> {
|
||||
Self {
|
||||
positions: Some(positions),
|
||||
..self
|
||||
}
|
||||
}
|
||||
|
||||
pub fn flags(self, flags: ::AudioFlags) -> Self {
|
||||
pub fn flags(self, flags: crate::AudioFlags) -> Self {
|
||||
Self {
|
||||
flags: Some(flags),
|
||||
..self
|
||||
}
|
||||
}
|
||||
|
||||
pub fn layout(self, layout: ::AudioLayout) -> Self {
|
||||
pub fn layout(self, layout: crate::AudioLayout) -> Self {
|
||||
Self {
|
||||
layout: Some(layout),
|
||||
..self
|
||||
|
@ -137,7 +127,11 @@ impl<'a> AudioInfoBuilder<'a> {
|
|||
}
|
||||
|
||||
impl AudioInfo {
|
||||
pub fn builder<'a>(format: ::AudioFormat, rate: u32, channels: u32) -> AudioInfoBuilder<'a> {
|
||||
pub fn builder<'a>(
|
||||
format: crate::AudioFormat,
|
||||
rate: u32,
|
||||
channels: u32,
|
||||
) -> AudioInfoBuilder<'a> {
|
||||
assert_initialized_main_thread!();
|
||||
|
||||
AudioInfoBuilder {
|
||||
|
@ -159,7 +153,7 @@ impl AudioInfo {
|
|||
|
||||
unsafe {
|
||||
let mut info = mem::MaybeUninit::uninit();
|
||||
if from_glib(gst_audio_sys::gst_audio_info_from_caps(
|
||||
if from_glib(ffi::gst_audio_info_from_caps(
|
||||
info.as_mut_ptr(),
|
||||
caps.as_ptr(),
|
||||
)) {
|
||||
|
@ -167,17 +161,21 @@ impl AudioInfo {
|
|||
let positions = array_init::array_init(|i| from_glib(info.position[i]));
|
||||
Ok(AudioInfo(info, positions))
|
||||
} else {
|
||||
Err(glib_bool_error!("Failed to create AudioInfo from caps"))
|
||||
Err(glib::glib_bool_error!(
|
||||
"Failed to create AudioInfo from caps"
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_caps(&self) -> Result<gst::Caps, glib::error::BoolError> {
|
||||
unsafe {
|
||||
let result = from_glib_full(gst_audio_sys::gst_audio_info_to_caps(&self.0));
|
||||
let result = from_glib_full(ffi::gst_audio_info_to_caps(&self.0));
|
||||
match result {
|
||||
Some(c) => Ok(c),
|
||||
None => Err(glib_bool_error!("Failed to create caps from AudioInfo")),
|
||||
None => Err(glib::glib_bool_error!(
|
||||
"Failed to create caps from AudioInfo"
|
||||
)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -191,7 +189,7 @@ impl AudioInfo {
|
|||
let src_val = src_val.into();
|
||||
unsafe {
|
||||
let mut dest_val = mem::MaybeUninit::uninit();
|
||||
if from_glib(gst_audio_sys::gst_audio_info_convert(
|
||||
if from_glib(ffi::gst_audio_info_convert(
|
||||
&self.0,
|
||||
src_val.get_format().to_glib(),
|
||||
src_val.to_raw_value(),
|
||||
|
@ -215,7 +213,7 @@ impl AudioInfo {
|
|||
let src_val = src_val.into();
|
||||
unsafe {
|
||||
let mut dest_val = mem::MaybeUninit::uninit();
|
||||
if from_glib(gst_audio_sys::gst_audio_info_convert(
|
||||
if from_glib(ffi::gst_audio_info_convert(
|
||||
&self.0,
|
||||
src_val.get_format().to_glib(),
|
||||
src_val.to_raw_value(),
|
||||
|
@ -232,23 +230,23 @@ impl AudioInfo {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn format(&self) -> ::AudioFormat {
|
||||
pub fn format(&self) -> crate::AudioFormat {
|
||||
if self.0.finfo.is_null() {
|
||||
return ::AudioFormat::Unknown;
|
||||
return crate::AudioFormat::Unknown;
|
||||
}
|
||||
|
||||
unsafe { from_glib((*self.0.finfo).format) }
|
||||
}
|
||||
|
||||
pub fn format_info(&self) -> ::AudioFormatInfo {
|
||||
::AudioFormatInfo::from_format(self.format())
|
||||
pub fn format_info(&self) -> crate::AudioFormatInfo {
|
||||
crate::AudioFormatInfo::from_format(self.format())
|
||||
}
|
||||
|
||||
pub fn layout(&self) -> ::AudioLayout {
|
||||
pub fn layout(&self) -> crate::AudioLayout {
|
||||
from_glib(self.0.layout)
|
||||
}
|
||||
|
||||
pub fn flags(&self) -> ::AudioFlags {
|
||||
pub fn flags(&self) -> crate::AudioFlags {
|
||||
from_glib(self.0.flags)
|
||||
}
|
||||
|
||||
|
@ -276,7 +274,7 @@ impl AudioInfo {
|
|||
self.format_info().width()
|
||||
}
|
||||
|
||||
pub fn endianness(&self) -> ::AudioEndianness {
|
||||
pub fn endianness(&self) -> crate::AudioEndianness {
|
||||
self.format_info().endianness()
|
||||
}
|
||||
|
||||
|
@ -300,7 +298,7 @@ impl AudioInfo {
|
|||
self.format_info().is_signed()
|
||||
}
|
||||
|
||||
pub fn positions(&self) -> Option<&[::AudioChannelPosition]> {
|
||||
pub fn positions(&self) -> Option<&[crate::AudioChannelPosition]> {
|
||||
if self.0.channels > 64 || self.is_unpositioned() {
|
||||
return None;
|
||||
}
|
||||
|
@ -309,7 +307,7 @@ impl AudioInfo {
|
|||
}
|
||||
|
||||
pub fn is_unpositioned(&self) -> bool {
|
||||
self.flags().contains(::AudioFlags::UNPOSITIONED)
|
||||
self.flags().contains(crate::AudioFlags::UNPOSITIONED)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -321,7 +319,7 @@ impl Clone for AudioInfo {
|
|||
|
||||
impl PartialEq for AudioInfo {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
unsafe { from_glib(gst_audio_sys::gst_audio_info_is_equal(&self.0, &other.0)) }
|
||||
unsafe { from_glib(ffi::gst_audio_info_is_equal(&self.0, &other.0)) }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -332,25 +330,26 @@ unsafe impl Sync for AudioInfo {}
|
|||
|
||||
impl glib::types::StaticType for AudioInfo {
|
||||
fn static_type() -> glib::types::Type {
|
||||
unsafe { glib::translate::from_glib(gst_audio_sys::gst_audio_info_get_type()) }
|
||||
unsafe { glib::translate::from_glib(ffi::gst_audio_info_get_type()) }
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
impl<'a> glib::value::FromValueOptional<'a> for AudioInfo {
|
||||
unsafe fn from_value_optional(value: &glib::Value) -> Option<Self> {
|
||||
Option::<AudioInfo>::from_glib_none(gobject_sys::g_value_get_boxed(value.to_glib_none().0)
|
||||
as *mut gst_audio_sys::GstAudioInfo)
|
||||
Option::<AudioInfo>::from_glib_none(glib::gobject_ffi::g_value_get_boxed(
|
||||
value.to_glib_none().0,
|
||||
) as *mut ffi::GstAudioInfo)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
impl glib::value::SetValue for AudioInfo {
|
||||
unsafe fn set_value(value: &mut glib::Value, this: &Self) {
|
||||
gobject_sys::g_value_set_boxed(
|
||||
glib::gobject_ffi::g_value_set_boxed(
|
||||
value.to_glib_none_mut().0,
|
||||
glib::translate::ToGlibPtr::<*const gst_audio_sys::GstAudioInfo>::to_glib_none(this).0
|
||||
as glib_sys::gpointer,
|
||||
glib::translate::ToGlibPtr::<*const ffi::GstAudioInfo>::to_glib_none(this).0
|
||||
as glib::ffi::gpointer,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -358,10 +357,10 @@ impl glib::value::SetValue for AudioInfo {
|
|||
#[doc(hidden)]
|
||||
impl glib::value::SetValueOptional for AudioInfo {
|
||||
unsafe fn set_value_optional(value: &mut glib::Value, this: Option<&Self>) {
|
||||
gobject_sys::g_value_set_boxed(
|
||||
glib::gobject_ffi::g_value_set_boxed(
|
||||
value.to_glib_none_mut().0,
|
||||
glib::translate::ToGlibPtr::<*const gst_audio_sys::GstAudioInfo>::to_glib_none(&this).0
|
||||
as glib_sys::gpointer,
|
||||
glib::translate::ToGlibPtr::<*const ffi::GstAudioInfo>::to_glib_none(&this).0
|
||||
as glib::ffi::gpointer,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -375,28 +374,26 @@ impl glib::translate::Uninitialized for AudioInfo {
|
|||
|
||||
#[doc(hidden)]
|
||||
impl glib::translate::GlibPtrDefault for AudioInfo {
|
||||
type GlibType = *mut gst_audio_sys::GstAudioInfo;
|
||||
type GlibType = *mut ffi::GstAudioInfo;
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
impl<'a> glib::translate::ToGlibPtr<'a, *const gst_audio_sys::GstAudioInfo> for AudioInfo {
|
||||
impl<'a> glib::translate::ToGlibPtr<'a, *const ffi::GstAudioInfo> for AudioInfo {
|
||||
type Storage = &'a AudioInfo;
|
||||
|
||||
fn to_glib_none(
|
||||
&'a self,
|
||||
) -> glib::translate::Stash<'a, *const gst_audio_sys::GstAudioInfo, Self> {
|
||||
fn to_glib_none(&'a self) -> glib::translate::Stash<'a, *const ffi::GstAudioInfo, Self> {
|
||||
glib::translate::Stash(&self.0, self)
|
||||
}
|
||||
|
||||
fn to_glib_full(&self) -> *const gst_audio_sys::GstAudioInfo {
|
||||
fn to_glib_full(&self) -> *const ffi::GstAudioInfo {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
impl glib::translate::FromGlibPtrNone<*mut gst_audio_sys::GstAudioInfo> for AudioInfo {
|
||||
impl glib::translate::FromGlibPtrNone<*mut ffi::GstAudioInfo> for AudioInfo {
|
||||
#[inline]
|
||||
unsafe fn from_glib_none(ptr: *mut gst_audio_sys::GstAudioInfo) -> Self {
|
||||
unsafe fn from_glib_none(ptr: *mut ffi::GstAudioInfo) -> Self {
|
||||
AudioInfo(
|
||||
ptr::read(ptr),
|
||||
array_init::array_init(|i| from_glib((*ptr).position[i])),
|
||||
|
@ -405,11 +402,11 @@ impl glib::translate::FromGlibPtrNone<*mut gst_audio_sys::GstAudioInfo> for Audi
|
|||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
impl glib::translate::FromGlibPtrFull<*mut gst_audio_sys::GstAudioInfo> for AudioInfo {
|
||||
impl glib::translate::FromGlibPtrFull<*mut ffi::GstAudioInfo> for AudioInfo {
|
||||
#[inline]
|
||||
unsafe fn from_glib_full(ptr: *mut gst_audio_sys::GstAudioInfo) -> Self {
|
||||
unsafe fn from_glib_full(ptr: *mut ffi::GstAudioInfo) -> Self {
|
||||
let info = from_glib_none(ptr);
|
||||
glib_sys::g_free(ptr as *mut _);
|
||||
glib::ffi::g_free(ptr as *mut _);
|
||||
info
|
||||
}
|
||||
}
|
||||
|
@ -417,42 +414,41 @@ impl glib::translate::FromGlibPtrFull<*mut gst_audio_sys::GstAudioInfo> for Audi
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use gst;
|
||||
|
||||
#[test]
|
||||
fn test_new() {
|
||||
gst::init().unwrap();
|
||||
|
||||
let info = AudioInfo::builder(::AudioFormat::S16le, 48000, 2)
|
||||
let info = AudioInfo::builder(crate::AudioFormat::S16le, 48000, 2)
|
||||
.build()
|
||||
.unwrap();
|
||||
assert_eq!(info.format(), ::AudioFormat::S16le);
|
||||
assert_eq!(info.format(), crate::AudioFormat::S16le);
|
||||
assert_eq!(info.rate(), 48000);
|
||||
assert_eq!(info.channels(), 2);
|
||||
assert_eq!(
|
||||
&info.positions().unwrap(),
|
||||
&[
|
||||
::AudioChannelPosition::FrontLeft,
|
||||
::AudioChannelPosition::FrontRight,
|
||||
crate::AudioChannelPosition::FrontLeft,
|
||||
crate::AudioChannelPosition::FrontRight,
|
||||
]
|
||||
);
|
||||
|
||||
let positions = [
|
||||
::AudioChannelPosition::RearLeft,
|
||||
::AudioChannelPosition::RearRight,
|
||||
crate::AudioChannelPosition::RearLeft,
|
||||
crate::AudioChannelPosition::RearRight,
|
||||
];
|
||||
let info = AudioInfo::builder(::AudioFormat::S16le, 48000, 2)
|
||||
let info = AudioInfo::builder(crate::AudioFormat::S16le, 48000, 2)
|
||||
.positions(&positions)
|
||||
.build()
|
||||
.unwrap();
|
||||
assert_eq!(info.format(), ::AudioFormat::S16le);
|
||||
assert_eq!(info.format(), crate::AudioFormat::S16le);
|
||||
assert_eq!(info.rate(), 48000);
|
||||
assert_eq!(info.channels(), 2);
|
||||
assert_eq!(
|
||||
&info.positions().unwrap(),
|
||||
&[
|
||||
::AudioChannelPosition::RearLeft,
|
||||
::AudioChannelPosition::RearRight,
|
||||
crate::AudioChannelPosition::RearLeft,
|
||||
crate::AudioChannelPosition::RearRight,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@ -472,14 +468,14 @@ mod tests {
|
|||
],
|
||||
);
|
||||
let info = AudioInfo::from_caps(&caps).unwrap();
|
||||
assert_eq!(info.format(), ::AudioFormat::S16le);
|
||||
assert_eq!(info.format(), crate::AudioFormat::S16le);
|
||||
assert_eq!(info.rate(), 48000);
|
||||
assert_eq!(info.channels(), 2);
|
||||
assert_eq!(
|
||||
&info.positions().unwrap(),
|
||||
&[
|
||||
::AudioChannelPosition::FrontLeft,
|
||||
::AudioChannelPosition::FrontRight,
|
||||
crate::AudioChannelPosition::FrontLeft,
|
||||
crate::AudioChannelPosition::FrontRight,
|
||||
]
|
||||
);
|
||||
|
||||
|
|
|
@ -15,17 +15,14 @@ use std::ptr;
|
|||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
|
||||
use std::slice;
|
||||
|
||||
use glib;
|
||||
use glib::translate::{from_glib, ToGlib};
|
||||
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
|
||||
use glib::translate::{from_glib_none, ToGlibPtr};
|
||||
use gst;
|
||||
use gst::prelude::*;
|
||||
use gst_audio_sys;
|
||||
|
||||
#[repr(transparent)]
|
||||
pub struct AudioClippingMeta(gst_audio_sys::GstAudioClippingMeta);
|
||||
pub struct AudioClippingMeta(ffi::GstAudioClippingMeta);
|
||||
|
||||
unsafe impl Send for AudioClippingMeta {}
|
||||
unsafe impl Sync for AudioClippingMeta {}
|
||||
|
@ -41,7 +38,7 @@ impl AudioClippingMeta {
|
|||
let end = end.into();
|
||||
assert_eq!(start.get_format(), end.get_format());
|
||||
unsafe {
|
||||
let meta = gst_audio_sys::gst_buffer_add_audio_clipping_meta(
|
||||
let meta = ffi::gst_buffer_add_audio_clipping_meta(
|
||||
buffer.as_mut_ptr(),
|
||||
start.get_format().to_glib(),
|
||||
start.get_value() as u64,
|
||||
|
@ -62,10 +59,10 @@ impl AudioClippingMeta {
|
|||
}
|
||||
|
||||
unsafe impl MetaAPI for AudioClippingMeta {
|
||||
type GstType = gst_audio_sys::GstAudioClippingMeta;
|
||||
type GstType = ffi::GstAudioClippingMeta;
|
||||
|
||||
fn get_meta_api() -> glib::Type {
|
||||
unsafe { from_glib(gst_audio_sys::gst_audio_clipping_meta_api_get_type()) }
|
||||
unsafe { from_glib(ffi::gst_audio_clipping_meta_api_get_type()) }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,7 +78,7 @@ impl fmt::Debug for AudioClippingMeta {
|
|||
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
|
||||
#[repr(transparent)]
|
||||
pub struct AudioMeta(gst_audio_sys::GstAudioMeta);
|
||||
pub struct AudioMeta(ffi::GstAudioMeta);
|
||||
|
||||
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
|
||||
|
@ -95,39 +92,42 @@ unsafe impl Sync for AudioMeta {}
|
|||
impl AudioMeta {
|
||||
pub fn add<'a>(
|
||||
buffer: &'a mut gst::BufferRef,
|
||||
info: &::AudioInfo,
|
||||
info: &crate::AudioInfo,
|
||||
samples: usize,
|
||||
offsets: &[usize],
|
||||
) -> Result<gst::MetaRefMut<'a, Self, gst::meta::Standalone>, glib::BoolError> {
|
||||
skip_assert_initialized!();
|
||||
|
||||
if !info.is_valid() {
|
||||
return Err(glib_bool_error!("Invalid audio info"));
|
||||
return Err(glib::glib_bool_error!("Invalid audio info"));
|
||||
}
|
||||
|
||||
if info.rate() == 0
|
||||
|| info.channels() == 0
|
||||
|| info.format() == ::AudioFormat::Unknown
|
||||
|| info.format() == ::AudioFormat::Encoded
|
||||
|| info.format() == crate::AudioFormat::Unknown
|
||||
|| info.format() == crate::AudioFormat::Encoded
|
||||
{
|
||||
return Err(glib_bool_error!("Unsupported audio format {:?}", info));
|
||||
return Err(glib::glib_bool_error!(
|
||||
"Unsupported audio format {:?}",
|
||||
info
|
||||
));
|
||||
}
|
||||
|
||||
if !offsets.is_empty() && info.layout() != ::AudioLayout::NonInterleaved {
|
||||
return Err(glib_bool_error!(
|
||||
if !offsets.is_empty() && info.layout() != crate::AudioLayout::NonInterleaved {
|
||||
return Err(glib::glib_bool_error!(
|
||||
"Channel offsets only supported for non-interleaved audio"
|
||||
));
|
||||
}
|
||||
|
||||
if !offsets.is_empty() && offsets.len() != info.channels() as usize {
|
||||
return Err(glib_bool_error!(
|
||||
return Err(glib::glib_bool_error!(
|
||||
"Number of channel offsets different than number of channels ({} != {})",
|
||||
offsets.len(),
|
||||
info.channels()
|
||||
));
|
||||
}
|
||||
|
||||
if info.layout() == ::AudioLayout::NonInterleaved {
|
||||
if info.layout() == crate::AudioLayout::NonInterleaved {
|
||||
let plane_size = samples * (info.width() / 8) as usize;
|
||||
let max_offset = if offsets.is_empty() {
|
||||
plane_size * (info.channels() - 1) as usize
|
||||
|
@ -146,7 +146,7 @@ impl AudioMeta {
|
|||
&& !(other_offset + plane_size <= offset
|
||||
|| offset + plane_size <= other_offset)
|
||||
{
|
||||
return Err(glib_bool_error!("Overlapping audio channel offsets: offset {} for channel {} and offset {} for channel {} with a plane size of {}", offset, i, other_offset, j, plane_size));
|
||||
return Err(glib::glib_bool_error!("Overlapping audio channel offsets: offset {} for channel {} and offset {} for channel {} with a plane size of {}", offset, i, other_offset, j, plane_size));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -155,12 +155,12 @@ impl AudioMeta {
|
|||
};
|
||||
|
||||
if max_offset + plane_size > buffer.get_size() {
|
||||
return Err(glib_bool_error!("Audio channel offsets out of bounds: max offset {} with plane size {} and buffer size {}", max_offset, plane_size, buffer.get_size()));
|
||||
return Err(glib::glib_bool_error!("Audio channel offsets out of bounds: max offset {} with plane size {} and buffer size {}", max_offset, plane_size, buffer.get_size()));
|
||||
}
|
||||
}
|
||||
|
||||
unsafe {
|
||||
let meta = gst_audio_sys::gst_buffer_add_audio_meta(
|
||||
let meta = ffi::gst_buffer_add_audio_meta(
|
||||
buffer.as_mut_ptr(),
|
||||
info.to_glib_none().0,
|
||||
samples,
|
||||
|
@ -172,15 +172,15 @@ impl AudioMeta {
|
|||
);
|
||||
|
||||
if meta.is_null() {
|
||||
return Err(glib_bool_error!("Failed to add audio meta"));
|
||||
return Err(glib::glib_bool_error!("Failed to add audio meta"));
|
||||
}
|
||||
|
||||
Ok(Self::from_mut_ptr(buffer, meta))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_info(&self) -> ::AudioInfo {
|
||||
unsafe { from_glib_none(&self.0.info as *const _ as *mut gst_audio_sys::GstAudioInfo) }
|
||||
pub fn get_info(&self) -> crate::AudioInfo {
|
||||
unsafe { from_glib_none(&self.0.info as *const _ as *mut ffi::GstAudioInfo) }
|
||||
}
|
||||
|
||||
pub fn get_samples(&self) -> usize {
|
||||
|
@ -199,10 +199,10 @@ impl AudioMeta {
|
|||
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
|
||||
unsafe impl MetaAPI for AudioMeta {
|
||||
type GstType = gst_audio_sys::GstAudioMeta;
|
||||
type GstType = ffi::GstAudioMeta;
|
||||
|
||||
fn get_meta_api() -> glib::Type {
|
||||
unsafe { from_glib(gst_audio_sys::gst_audio_meta_api_get_type()) }
|
||||
unsafe { from_glib(ffi::gst_audio_meta_api_get_type()) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use crate::ffi::GstAudioRingBufferSpec;
|
||||
use glib::translate::*;
|
||||
use gst::Caps;
|
||||
use gst_audio_sys::GstAudioRingBufferSpec;
|
||||
|
||||
use AudioInfo;
|
||||
use AudioRingBufferFormatType;
|
||||
use crate::AudioInfo;
|
||||
use crate::AudioRingBufferFormatType;
|
||||
|
||||
use std::fmt;
|
||||
|
||||
|
@ -72,7 +72,7 @@ impl Clone for AudioRingBufferSpec {
|
|||
fn clone(&self) -> Self {
|
||||
unsafe {
|
||||
let spec = self.0;
|
||||
gst_sys::gst_mini_object_ref(spec.caps as *mut gst_sys::GstMiniObject);
|
||||
gst::ffi::gst_mini_object_ref(spec.caps as *mut gst::ffi::GstMiniObject);
|
||||
|
||||
AudioRingBufferSpec(spec)
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ impl Clone for AudioRingBufferSpec {
|
|||
impl Drop for AudioRingBufferSpec {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
gst_sys::gst_mini_object_unref(self.0.caps as *mut gst_sys::GstMiniObject);
|
||||
gst::ffi::gst_mini_object_unref(self.0.caps as *mut gst::ffi::GstMiniObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,11 +6,9 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use gst_audio_sys;
|
||||
use AudioStreamAlign;
|
||||
use crate::AudioStreamAlign;
|
||||
|
||||
use glib::translate::*;
|
||||
use gst;
|
||||
use std::mem;
|
||||
|
||||
impl AudioStreamAlign {
|
||||
|
@ -26,7 +24,7 @@ impl AudioStreamAlign {
|
|||
let mut out_timestamp = mem::MaybeUninit::uninit();
|
||||
let mut out_duration = mem::MaybeUninit::uninit();
|
||||
let mut out_sample_position = mem::MaybeUninit::uninit();
|
||||
let ret = from_glib(gst_audio_sys::gst_audio_stream_align_process(
|
||||
let ret = from_glib(ffi::gst_audio_stream_align_process(
|
||||
self.to_glib_none_mut().0,
|
||||
discont.to_glib(),
|
||||
timestamp.to_glib(),
|
||||
|
|
|
@ -7,10 +7,8 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use glib;
|
||||
use glib::translate::{from_glib_full, ToGlibPtr};
|
||||
use glib::ToSendValue;
|
||||
use gst;
|
||||
|
||||
use std::i32;
|
||||
|
||||
|
@ -23,7 +21,7 @@ pub fn audio_buffer_clip(
|
|||
skip_assert_initialized!();
|
||||
|
||||
unsafe {
|
||||
from_glib_full(gst_audio_sys::gst_audio_buffer_clip(
|
||||
from_glib_full(ffi::gst_audio_buffer_clip(
|
||||
buffer.into_ptr(),
|
||||
segment.to_glib_none().0,
|
||||
rate as i32,
|
||||
|
@ -43,7 +41,7 @@ pub fn audio_buffer_truncate(
|
|||
skip_assert_initialized!();
|
||||
|
||||
unsafe {
|
||||
from_glib_full(gst_audio_sys::gst_audio_buffer_truncate(
|
||||
from_glib_full(ffi::gst_audio_buffer_truncate(
|
||||
buffer.into_ptr(),
|
||||
bpf as i32,
|
||||
trim,
|
||||
|
@ -53,16 +51,16 @@ pub fn audio_buffer_truncate(
|
|||
}
|
||||
|
||||
pub fn audio_make_raw_caps(
|
||||
formats: &[::AudioFormat],
|
||||
layout: ::AudioLayout,
|
||||
formats: &[crate::AudioFormat],
|
||||
layout: crate::AudioLayout,
|
||||
) -> gst::caps::Builder<gst::caps::NoFeature> {
|
||||
assert_initialized_main_thread!();
|
||||
|
||||
let formats: Vec<glib::SendValue> = formats
|
||||
.iter()
|
||||
.map(|f| match f {
|
||||
::AudioFormat::Encoded => panic!("Invalid encoded format"),
|
||||
::AudioFormat::Unknown => panic!("Invalid unknown format"),
|
||||
crate::AudioFormat::Encoded => panic!("Invalid encoded format"),
|
||||
crate::AudioFormat::Unknown => panic!("Invalid unknown format"),
|
||||
_ => f.to_string().to_send_value(),
|
||||
})
|
||||
.collect();
|
||||
|
@ -73,24 +71,23 @@ pub fn audio_make_raw_caps(
|
|||
.field("channels", &gst::IntRange::<i32>::new(1, i32::MAX));
|
||||
|
||||
match layout {
|
||||
::AudioLayout::Interleaved => builder.field("layout", &"interleaved"),
|
||||
::AudioLayout::NonInterleaved => builder.field("layout", &"non-interleaved"),
|
||||
::AudioLayout::__Unknown(_) => builder,
|
||||
crate::AudioLayout::Interleaved => builder.field("layout", &"interleaved"),
|
||||
crate::AudioLayout::NonInterleaved => builder.field("layout", &"non-interleaved"),
|
||||
crate::AudioLayout::__Unknown(_) => builder,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use gst;
|
||||
|
||||
#[test]
|
||||
fn audio_caps() {
|
||||
gst::init().unwrap();
|
||||
|
||||
let caps = audio_make_raw_caps(
|
||||
&[::AudioFormat::S16be, ::AudioFormat::S16le],
|
||||
::AudioLayout::Interleaved,
|
||||
&[crate::AudioFormat::S16be, crate::AudioFormat::S16le],
|
||||
crate::AudioLayout::Interleaved,
|
||||
)
|
||||
.build();
|
||||
assert_eq!(caps.to_string(), "audio/x-raw, format=(string){ S16BE, S16LE }, rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 2147483647 ], layout=(string)interleaved");
|
||||
|
@ -101,15 +98,15 @@ mod tests {
|
|||
|
||||
/* audio_make_raw_caps() is a re-implementation so ensure it returns the same caps as the C API */
|
||||
let c_caps = unsafe {
|
||||
let formats: Vec<gst_audio_sys::GstAudioFormat> =
|
||||
[::AudioFormat::S16be, ::AudioFormat::S16le]
|
||||
let formats: Vec<ffi::GstAudioFormat> =
|
||||
[crate::AudioFormat::S16be, crate::AudioFormat::S16le]
|
||||
.iter()
|
||||
.map(|f| f.to_glib())
|
||||
.collect();
|
||||
let caps = gst_audio_sys::gst_audio_make_raw_caps(
|
||||
let caps = ffi::gst_audio_make_raw_caps(
|
||||
formats.as_ptr(),
|
||||
formats.len() as u32,
|
||||
gst_audio_sys::GST_AUDIO_LAYOUT_INTERLEAVED,
|
||||
ffi::GST_AUDIO_LAYOUT_INTERLEAVED,
|
||||
);
|
||||
from_glib_full(caps)
|
||||
};
|
||||
|
@ -117,8 +114,8 @@ mod tests {
|
|||
}
|
||||
|
||||
let caps = audio_make_raw_caps(
|
||||
&[::AudioFormat::S16be, ::AudioFormat::S16le],
|
||||
::AudioLayout::NonInterleaved,
|
||||
&[crate::AudioFormat::S16be, crate::AudioFormat::S16le],
|
||||
crate::AudioLayout::NonInterleaved,
|
||||
)
|
||||
.field("rate", &16000)
|
||||
.field("channels", &2)
|
||||
|
@ -133,13 +130,19 @@ mod tests {
|
|||
#[should_panic(expected = "Invalid encoded format")]
|
||||
fn audio_caps_encoded() {
|
||||
gst::init().unwrap();
|
||||
audio_make_raw_caps(&[::AudioFormat::Encoded], ::AudioLayout::Interleaved);
|
||||
audio_make_raw_caps(
|
||||
&[crate::AudioFormat::Encoded],
|
||||
crate::AudioLayout::Interleaved,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic(expected = "Invalid unknown format")]
|
||||
fn audio_caps_unknown() {
|
||||
gst::init().unwrap();
|
||||
audio_make_raw_caps(&[::AudioFormat::Unknown], ::AudioLayout::Interleaved);
|
||||
audio_make_raw_caps(
|
||||
&[crate::AudioFormat::Unknown],
|
||||
crate::AudioLayout::Interleaved,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,28 +8,11 @@
|
|||
|
||||
#![cfg_attr(feature = "dox", feature(doc_cfg))]
|
||||
|
||||
extern crate array_init;
|
||||
#[macro_use]
|
||||
extern crate bitflags;
|
||||
extern crate once_cell;
|
||||
|
||||
#[macro_use]
|
||||
extern crate glib;
|
||||
extern crate glib_sys;
|
||||
extern crate gobject_sys;
|
||||
#[macro_use]
|
||||
extern crate gstreamer as gst;
|
||||
extern crate gstreamer_audio_sys as gst_audio_sys;
|
||||
extern crate gstreamer_base as gst_base;
|
||||
extern crate gstreamer_base_sys as gst_base_sys;
|
||||
extern crate gstreamer_sys as gst_sys;
|
||||
|
||||
#[cfg(test)]
|
||||
extern crate itertools;
|
||||
pub use ffi;
|
||||
|
||||
macro_rules! assert_initialized_main_thread {
|
||||
() => {
|
||||
if unsafe { ::gst_sys::gst_is_initialized() } != ::glib_sys::GTRUE {
|
||||
if unsafe { gst::ffi::gst_is_initialized() } != glib::ffi::GTRUE {
|
||||
panic!("GStreamer has not been initialized. Call `gst::init` first.");
|
||||
}
|
||||
};
|
||||
|
@ -44,25 +27,25 @@ macro_rules! skip_assert_initialized {
|
|||
#[allow(clippy::match_same_arms)]
|
||||
#[allow(unused_imports)]
|
||||
mod auto;
|
||||
pub use auto::*;
|
||||
pub use crate::auto::*;
|
||||
|
||||
mod audio_format;
|
||||
pub use audio_format::*;
|
||||
pub use crate::audio_format::*;
|
||||
mod audio_format_info;
|
||||
pub use audio_format_info::*;
|
||||
pub use crate::audio_format_info::*;
|
||||
mod audio_ring_buffer_spec;
|
||||
pub use audio_ring_buffer_spec::*;
|
||||
pub use crate::audio_ring_buffer_spec::*;
|
||||
mod audio_info;
|
||||
pub use audio_info::*;
|
||||
pub use crate::audio_info::*;
|
||||
mod audio_meta;
|
||||
pub use audio_meta::*;
|
||||
pub use crate::audio_meta::*;
|
||||
mod audio_channel_position;
|
||||
pub use audio_channel_position::*;
|
||||
pub use crate::audio_channel_position::*;
|
||||
#[cfg(any(feature = "v1_14", feature = "dox"))]
|
||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))]
|
||||
mod audio_stream_align;
|
||||
mod functions;
|
||||
pub use functions::*;
|
||||
pub use crate::functions::*;
|
||||
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
|
||||
pub mod audio_buffer;
|
||||
|
@ -71,9 +54,9 @@ pub mod audio_buffer;
|
|||
pub use audio_buffer::{AudioBuffer, AudioBufferRef};
|
||||
|
||||
mod audio_decoder;
|
||||
pub use audio_decoder::AudioDecoderExtManual;
|
||||
pub use crate::audio_decoder::AudioDecoderExtManual;
|
||||
mod audio_encoder;
|
||||
pub use audio_encoder::AudioEncoderExtManual;
|
||||
pub use crate::audio_encoder::AudioEncoderExtManual;
|
||||
|
||||
// Re-export all the traits in a prelude module, so that applications
|
||||
// can always "use gst::prelude::*" without getting conflicts
|
||||
|
@ -83,8 +66,8 @@ pub mod prelude {
|
|||
|
||||
pub use super::audio_decoder::AudioDecoderExtManual;
|
||||
pub use super::audio_encoder::AudioEncoderExtManual;
|
||||
pub use audio_format::AudioFormatIteratorExt;
|
||||
pub use auto::traits::*;
|
||||
pub use crate::audio_format::AudioFormatIteratorExt;
|
||||
pub use crate::auto::traits::*;
|
||||
}
|
||||
|
||||
pub mod subclass;
|
||||
|
|
|
@ -6,23 +6,17 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use glib_sys;
|
||||
use gst_audio_sys;
|
||||
use gst_sys;
|
||||
|
||||
use glib::subclass::prelude::*;
|
||||
use glib::translate::*;
|
||||
|
||||
use gst;
|
||||
use gst::subclass::prelude::*;
|
||||
use gst_base;
|
||||
|
||||
use std::mem;
|
||||
use std::ptr;
|
||||
|
||||
use crate::prelude::*;
|
||||
|
||||
use AudioDecoder;
|
||||
use crate::AudioDecoder;
|
||||
|
||||
pub trait AudioDecoderImpl: AudioDecoderImplExt + ElementImpl {
|
||||
fn open(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
|
@ -178,8 +172,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
fn parent_open(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioDecoderClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioDecoderClass;
|
||||
(*parent_class)
|
||||
.open
|
||||
.map(|f| {
|
||||
|
@ -190,7 +183,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
{
|
||||
Ok(())
|
||||
} else {
|
||||
Err(gst_error_msg!(
|
||||
Err(gst::gst_error_msg!(
|
||||
gst::CoreError::StateChange,
|
||||
["Parent function `open` failed"]
|
||||
))
|
||||
|
@ -203,8 +196,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
fn parent_close(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioDecoderClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioDecoderClass;
|
||||
(*parent_class)
|
||||
.close
|
||||
.map(|f| {
|
||||
|
@ -215,7 +207,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
{
|
||||
Ok(())
|
||||
} else {
|
||||
Err(gst_error_msg!(
|
||||
Err(gst::gst_error_msg!(
|
||||
gst::CoreError::StateChange,
|
||||
["Parent function `close` failed"]
|
||||
))
|
||||
|
@ -228,8 +220,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
fn parent_start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioDecoderClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioDecoderClass;
|
||||
(*parent_class)
|
||||
.start
|
||||
.map(|f| {
|
||||
|
@ -240,7 +231,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
{
|
||||
Ok(())
|
||||
} else {
|
||||
Err(gst_error_msg!(
|
||||
Err(gst::gst_error_msg!(
|
||||
gst::CoreError::StateChange,
|
||||
["Parent function `start` failed"]
|
||||
))
|
||||
|
@ -253,8 +244,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
fn parent_stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioDecoderClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioDecoderClass;
|
||||
(*parent_class)
|
||||
.stop
|
||||
.map(|f| {
|
||||
|
@ -265,7 +255,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
{
|
||||
Ok(())
|
||||
} else {
|
||||
Err(gst_error_msg!(
|
||||
Err(gst::gst_error_msg!(
|
||||
gst::CoreError::StateChange,
|
||||
["Parent function `stop` failed"]
|
||||
))
|
||||
|
@ -282,12 +272,11 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioDecoderClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioDecoderClass;
|
||||
(*parent_class)
|
||||
.set_format
|
||||
.map(|f| {
|
||||
gst_result_from_gboolean!(
|
||||
gst::gst_result_from_gboolean!(
|
||||
f(
|
||||
element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0,
|
||||
caps.to_glib_none().0
|
||||
|
@ -307,8 +296,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
) -> Result<(u32, u32), gst::FlowError> {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioDecoderClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioDecoderClass;
|
||||
(*parent_class)
|
||||
.parse
|
||||
.map(|f| {
|
||||
|
@ -343,15 +331,14 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioDecoderClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioDecoderClass;
|
||||
(*parent_class)
|
||||
.handle_frame
|
||||
.map(|f| {
|
||||
gst::FlowReturn::from_glib(f(
|
||||
element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0,
|
||||
buffer
|
||||
.map(|buffer| buffer.as_mut_ptr() as *mut *mut gst_sys::GstBuffer)
|
||||
.map(|buffer| buffer.as_mut_ptr() as *mut *mut gst::ffi::GstBuffer)
|
||||
.unwrap_or(ptr::null_mut()),
|
||||
))
|
||||
})
|
||||
|
@ -367,8 +354,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
) -> Result<Option<gst::Buffer>, gst::FlowError> {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioDecoderClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioDecoderClass;
|
||||
if let Some(f) = (*parent_class).pre_push {
|
||||
let mut buffer = buffer.into_ptr();
|
||||
match gst::FlowReturn::from_glib(f(
|
||||
|
@ -389,8 +375,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
fn parent_flush(&self, element: &Self::Type, hard: bool) {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioDecoderClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioDecoderClass;
|
||||
(*parent_class)
|
||||
.flush
|
||||
.map(|f| {
|
||||
|
@ -406,12 +391,11 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
fn parent_negotiate(&self, element: &Self::Type) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioDecoderClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioDecoderClass;
|
||||
(*parent_class)
|
||||
.negotiate
|
||||
.map(|f| {
|
||||
gst_result_from_gboolean!(
|
||||
gst::gst_result_from_gboolean!(
|
||||
f(element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0),
|
||||
gst::CAT_RUST,
|
||||
"Parent function `negotiate` failed"
|
||||
|
@ -424,8 +408,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
fn parent_get_caps(&self, element: &Self::Type, filter: Option<&gst::Caps>) -> gst::Caps {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioDecoderClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioDecoderClass;
|
||||
(*parent_class)
|
||||
.getcaps
|
||||
.map(|f| {
|
||||
|
@ -445,8 +428,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
fn parent_sink_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioDecoderClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioDecoderClass;
|
||||
let f = (*parent_class)
|
||||
.sink_event
|
||||
.expect("Missing parent function `sink_event`");
|
||||
|
@ -460,8 +442,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
fn parent_sink_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioDecoderClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioDecoderClass;
|
||||
let f = (*parent_class)
|
||||
.sink_query
|
||||
.expect("Missing parent function `sink_query`");
|
||||
|
@ -475,8 +456,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
fn parent_src_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioDecoderClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioDecoderClass;
|
||||
let f = (*parent_class)
|
||||
.src_event
|
||||
.expect("Missing parent function `src_event`");
|
||||
|
@ -490,8 +470,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
fn parent_src_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioDecoderClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioDecoderClass;
|
||||
let f = (*parent_class)
|
||||
.src_query
|
||||
.expect("Missing parent function `src_query`");
|
||||
|
@ -509,8 +488,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioDecoderClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioDecoderClass;
|
||||
(*parent_class)
|
||||
.propose_allocation
|
||||
.map(|f| {
|
||||
|
@ -520,7 +498,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
)) {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(gst_error_msg!(
|
||||
Err(gst::gst_error_msg!(
|
||||
gst::CoreError::StateChange,
|
||||
["Parent function `propose_allocation` failed"]
|
||||
))
|
||||
|
@ -537,8 +515,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioDecoderClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioDecoderClass;
|
||||
(*parent_class)
|
||||
.decide_allocation
|
||||
.map(|f| {
|
||||
|
@ -548,7 +525,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
)) {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(gst_error_msg!(
|
||||
Err(gst::gst_error_msg!(
|
||||
gst::CoreError::StateChange,
|
||||
["Parent function `decide_allocation` failed"]
|
||||
))
|
||||
|
@ -587,8 +564,8 @@ where
|
|||
}
|
||||
|
||||
unsafe extern "C" fn audio_decoder_open<T: AudioDecoderImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioDecoder,
|
||||
) -> glib_sys::gboolean
|
||||
ptr: *mut ffi::GstAudioDecoder,
|
||||
) -> glib::ffi::gboolean
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -596,7 +573,7 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
match imp.open(wrap.unsafe_cast_ref()) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
|
@ -609,8 +586,8 @@ where
|
|||
}
|
||||
|
||||
unsafe extern "C" fn audio_decoder_close<T: AudioDecoderImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioDecoder,
|
||||
) -> glib_sys::gboolean
|
||||
ptr: *mut ffi::GstAudioDecoder,
|
||||
) -> glib::ffi::gboolean
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -618,7 +595,7 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
match imp.close(wrap.unsafe_cast_ref()) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
|
@ -631,8 +608,8 @@ where
|
|||
}
|
||||
|
||||
unsafe extern "C" fn audio_decoder_start<T: AudioDecoderImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioDecoder,
|
||||
) -> glib_sys::gboolean
|
||||
ptr: *mut ffi::GstAudioDecoder,
|
||||
) -> glib::ffi::gboolean
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -640,7 +617,7 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
match imp.start(wrap.unsafe_cast_ref()) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
|
@ -653,8 +630,8 @@ where
|
|||
}
|
||||
|
||||
unsafe extern "C" fn audio_decoder_stop<T: AudioDecoderImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioDecoder,
|
||||
) -> glib_sys::gboolean
|
||||
ptr: *mut ffi::GstAudioDecoder,
|
||||
) -> glib::ffi::gboolean
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -662,7 +639,7 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
match imp.stop(wrap.unsafe_cast_ref()) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
|
@ -675,9 +652,9 @@ where
|
|||
}
|
||||
|
||||
unsafe extern "C" fn audio_decoder_set_format<T: AudioDecoderImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioDecoder,
|
||||
caps: *mut gst_sys::GstCaps,
|
||||
) -> glib_sys::gboolean
|
||||
ptr: *mut ffi::GstAudioDecoder,
|
||||
caps: *mut gst::ffi::GstCaps,
|
||||
) -> glib::ffi::gboolean
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -685,7 +662,7 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
match imp.set_format(wrap.unsafe_cast_ref(), &from_glib_borrow(caps)) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
|
@ -698,11 +675,11 @@ where
|
|||
}
|
||||
|
||||
unsafe extern "C" fn audio_decoder_parse<T: AudioDecoderImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioDecoder,
|
||||
adapter: *mut gst_base_sys::GstAdapter,
|
||||
ptr: *mut ffi::GstAudioDecoder,
|
||||
adapter: *mut gst_base::ffi::GstAdapter,
|
||||
offset: *mut i32,
|
||||
len: *mut i32,
|
||||
) -> gst_sys::GstFlowReturn
|
||||
) -> gst::ffi::GstFlowReturn
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -710,7 +687,7 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
||||
match imp.parse(wrap.unsafe_cast_ref(), &from_glib_borrow(adapter)) {
|
||||
Ok((new_offset, new_len)) => {
|
||||
assert!(new_offset <= std::i32::MAX as u32);
|
||||
|
@ -727,19 +704,19 @@ where
|
|||
}
|
||||
|
||||
unsafe extern "C" fn audio_decoder_handle_frame<T: AudioDecoderImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioDecoder,
|
||||
buffer: *mut *mut gst_sys::GstBuffer,
|
||||
) -> gst_sys::GstFlowReturn
|
||||
ptr: *mut ffi::GstAudioDecoder,
|
||||
buffer: *mut *mut gst::ffi::GstBuffer,
|
||||
) -> gst::ffi::GstFlowReturn
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
// FIXME: Misgenerated in gstreamer-audio-sys
|
||||
let buffer = buffer as *mut gst_sys::GstBuffer;
|
||||
let buffer = buffer as *mut gst::ffi::GstBuffer;
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
||||
imp.handle_frame(
|
||||
wrap.unsafe_cast_ref(),
|
||||
Option::<gst::Buffer>::from_glib_none(buffer).as_ref(),
|
||||
|
@ -750,9 +727,9 @@ where
|
|||
}
|
||||
|
||||
unsafe extern "C" fn audio_decoder_pre_push<T: AudioDecoderImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioDecoder,
|
||||
buffer: *mut *mut gst_sys::GstBuffer,
|
||||
) -> gst_sys::GstFlowReturn
|
||||
ptr: *mut ffi::GstAudioDecoder,
|
||||
buffer: *mut *mut gst::ffi::GstBuffer,
|
||||
) -> gst::ffi::GstFlowReturn
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -760,7 +737,7 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
||||
match imp.pre_push(wrap.unsafe_cast_ref(), from_glib_full(*buffer)) {
|
||||
Ok(Some(new_buffer)) => {
|
||||
*buffer = new_buffer.into_ptr();
|
||||
|
@ -778,8 +755,8 @@ where
|
|||
}
|
||||
|
||||
unsafe extern "C" fn audio_decoder_flush<T: AudioDecoderImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioDecoder,
|
||||
hard: glib_sys::gboolean,
|
||||
ptr: *mut ffi::GstAudioDecoder,
|
||||
hard: glib::ffi::gboolean,
|
||||
) where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -787,14 +764,14 @@ unsafe extern "C" fn audio_decoder_flush<T: AudioDecoderImpl>(
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), (), {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), (), {
|
||||
AudioDecoderImpl::flush(imp, wrap.unsafe_cast_ref(), from_glib(hard))
|
||||
})
|
||||
}
|
||||
|
||||
unsafe extern "C" fn audio_decoder_negotiate<T: AudioDecoderImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioDecoder,
|
||||
) -> glib_sys::gboolean
|
||||
ptr: *mut ffi::GstAudioDecoder,
|
||||
) -> glib::ffi::gboolean
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -802,7 +779,7 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
match imp.negotiate(wrap.unsafe_cast_ref()) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
|
@ -815,9 +792,9 @@ where
|
|||
}
|
||||
|
||||
unsafe extern "C" fn audio_decoder_getcaps<T: AudioDecoderImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioDecoder,
|
||||
filter: *mut gst_sys::GstCaps,
|
||||
) -> *mut gst_sys::GstCaps
|
||||
ptr: *mut ffi::GstAudioDecoder,
|
||||
filter: *mut gst::ffi::GstCaps,
|
||||
) -> *mut gst::ffi::GstCaps
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -825,7 +802,7 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), gst::Caps::new_empty(), {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), gst::Caps::new_empty(), {
|
||||
AudioDecoderImpl::get_caps(
|
||||
imp,
|
||||
wrap.unsafe_cast_ref(),
|
||||
|
@ -838,9 +815,9 @@ where
|
|||
}
|
||||
|
||||
unsafe extern "C" fn audio_decoder_sink_event<T: AudioDecoderImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioDecoder,
|
||||
event: *mut gst_sys::GstEvent,
|
||||
) -> glib_sys::gboolean
|
||||
ptr: *mut ffi::GstAudioDecoder,
|
||||
event: *mut gst::ffi::GstEvent,
|
||||
) -> glib::ffi::gboolean
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -848,16 +825,16 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
imp.sink_event(wrap.unsafe_cast_ref(), from_glib_full(event))
|
||||
})
|
||||
.to_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn audio_decoder_sink_query<T: AudioDecoderImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioDecoder,
|
||||
query: *mut gst_sys::GstQuery,
|
||||
) -> glib_sys::gboolean
|
||||
ptr: *mut ffi::GstAudioDecoder,
|
||||
query: *mut gst::ffi::GstQuery,
|
||||
) -> glib::ffi::gboolean
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -865,16 +842,16 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
imp.sink_query(wrap.unsafe_cast_ref(), gst::QueryRef::from_mut_ptr(query))
|
||||
})
|
||||
.to_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn audio_decoder_src_event<T: AudioDecoderImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioDecoder,
|
||||
event: *mut gst_sys::GstEvent,
|
||||
) -> glib_sys::gboolean
|
||||
ptr: *mut ffi::GstAudioDecoder,
|
||||
event: *mut gst::ffi::GstEvent,
|
||||
) -> glib::ffi::gboolean
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -882,16 +859,16 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
imp.src_event(wrap.unsafe_cast_ref(), from_glib_full(event))
|
||||
})
|
||||
.to_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn audio_decoder_src_query<T: AudioDecoderImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioDecoder,
|
||||
query: *mut gst_sys::GstQuery,
|
||||
) -> glib_sys::gboolean
|
||||
ptr: *mut ffi::GstAudioDecoder,
|
||||
query: *mut gst::ffi::GstQuery,
|
||||
) -> glib::ffi::gboolean
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -899,16 +876,16 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
imp.src_query(wrap.unsafe_cast_ref(), gst::QueryRef::from_mut_ptr(query))
|
||||
})
|
||||
.to_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn audio_decoder_propose_allocation<T: AudioDecoderImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioDecoder,
|
||||
query: *mut gst_sys::GstQuery,
|
||||
) -> glib_sys::gboolean
|
||||
ptr: *mut ffi::GstAudioDecoder,
|
||||
query: *mut gst::ffi::GstQuery,
|
||||
) -> glib::ffi::gboolean
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -917,7 +894,7 @@ where
|
|||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||
let query = gst::QueryRef::from_mut_ptr(query);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
match imp.propose_allocation(wrap.unsafe_cast_ref(), query) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
|
@ -930,9 +907,9 @@ where
|
|||
}
|
||||
|
||||
unsafe extern "C" fn audio_decoder_decide_allocation<T: AudioDecoderImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioDecoder,
|
||||
query: *mut gst_sys::GstQuery,
|
||||
) -> glib_sys::gboolean
|
||||
ptr: *mut ffi::GstAudioDecoder,
|
||||
query: *mut gst::ffi::GstQuery,
|
||||
) -> glib::ffi::gboolean
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -941,7 +918,7 @@ where
|
|||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||
let query = gst::QueryRef::from_mut_ptr(query);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
match imp.decide_allocation(wrap.unsafe_cast_ref(), query) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
|
|
|
@ -6,22 +6,17 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use glib_sys;
|
||||
use gst_audio_sys;
|
||||
use gst_sys;
|
||||
|
||||
use glib::subclass::prelude::*;
|
||||
use glib::translate::*;
|
||||
|
||||
use gst;
|
||||
use gst::subclass::prelude::*;
|
||||
|
||||
use std::ptr;
|
||||
|
||||
use crate::prelude::*;
|
||||
|
||||
use AudioEncoder;
|
||||
use AudioInfo;
|
||||
use crate::AudioEncoder;
|
||||
use crate::AudioInfo;
|
||||
|
||||
pub trait AudioEncoderImpl: AudioEncoderImplExt + ElementImpl {
|
||||
fn open(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
|
@ -163,8 +158,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
fn parent_open(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioEncoderClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioEncoderClass;
|
||||
(*parent_class)
|
||||
.open
|
||||
.map(|f| {
|
||||
|
@ -175,7 +169,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
{
|
||||
Ok(())
|
||||
} else {
|
||||
Err(gst_error_msg!(
|
||||
Err(gst::gst_error_msg!(
|
||||
gst::CoreError::StateChange,
|
||||
["Parent function `open` failed"]
|
||||
))
|
||||
|
@ -188,8 +182,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
fn parent_close(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioEncoderClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioEncoderClass;
|
||||
(*parent_class)
|
||||
.close
|
||||
.map(|f| {
|
||||
|
@ -200,7 +193,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
{
|
||||
Ok(())
|
||||
} else {
|
||||
Err(gst_error_msg!(
|
||||
Err(gst::gst_error_msg!(
|
||||
gst::CoreError::StateChange,
|
||||
["Parent function `close` failed"]
|
||||
))
|
||||
|
@ -213,8 +206,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
fn parent_start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioEncoderClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioEncoderClass;
|
||||
(*parent_class)
|
||||
.start
|
||||
.map(|f| {
|
||||
|
@ -225,7 +217,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
{
|
||||
Ok(())
|
||||
} else {
|
||||
Err(gst_error_msg!(
|
||||
Err(gst::gst_error_msg!(
|
||||
gst::CoreError::StateChange,
|
||||
["Parent function `start` failed"]
|
||||
))
|
||||
|
@ -238,8 +230,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
fn parent_stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioEncoderClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioEncoderClass;
|
||||
(*parent_class)
|
||||
.stop
|
||||
.map(|f| {
|
||||
|
@ -250,7 +241,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
{
|
||||
Ok(())
|
||||
} else {
|
||||
Err(gst_error_msg!(
|
||||
Err(gst::gst_error_msg!(
|
||||
gst::CoreError::StateChange,
|
||||
["Parent function `stop` failed"]
|
||||
))
|
||||
|
@ -267,12 +258,11 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioEncoderClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioEncoderClass;
|
||||
(*parent_class)
|
||||
.set_format
|
||||
.map(|f| {
|
||||
gst_result_from_gboolean!(
|
||||
gst::gst_result_from_gboolean!(
|
||||
f(
|
||||
element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0,
|
||||
info.to_glib_none().0 as *mut _
|
||||
|
@ -292,15 +282,14 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioEncoderClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioEncoderClass;
|
||||
(*parent_class)
|
||||
.handle_frame
|
||||
.map(|f| {
|
||||
gst::FlowReturn::from_glib(f(
|
||||
element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0,
|
||||
buffer
|
||||
.map(|buffer| buffer.as_mut_ptr() as *mut *mut gst_sys::GstBuffer)
|
||||
.map(|buffer| buffer.as_mut_ptr() as *mut *mut gst::ffi::GstBuffer)
|
||||
.unwrap_or(ptr::null_mut()),
|
||||
))
|
||||
})
|
||||
|
@ -316,8 +305,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
) -> Result<Option<gst::Buffer>, gst::FlowError> {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioEncoderClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioEncoderClass;
|
||||
if let Some(f) = (*parent_class).pre_push {
|
||||
let mut buffer = buffer.into_ptr();
|
||||
match gst::FlowReturn::from_glib(f(
|
||||
|
@ -338,8 +326,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
fn parent_flush(&self, element: &Self::Type) {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioEncoderClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioEncoderClass;
|
||||
(*parent_class)
|
||||
.flush
|
||||
.map(|f| f(element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0))
|
||||
|
@ -350,12 +337,11 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
fn parent_negotiate(&self, element: &Self::Type) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioEncoderClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioEncoderClass;
|
||||
(*parent_class)
|
||||
.negotiate
|
||||
.map(|f| {
|
||||
gst_result_from_gboolean!(
|
||||
gst::gst_result_from_gboolean!(
|
||||
f(element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0),
|
||||
gst::CAT_RUST,
|
||||
"Parent function `negotiate` failed"
|
||||
|
@ -368,8 +354,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
fn parent_get_caps(&self, element: &Self::Type, filter: Option<&gst::Caps>) -> gst::Caps {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioEncoderClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioEncoderClass;
|
||||
(*parent_class)
|
||||
.getcaps
|
||||
.map(|f| {
|
||||
|
@ -389,8 +374,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
fn parent_sink_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioEncoderClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioEncoderClass;
|
||||
let f = (*parent_class)
|
||||
.sink_event
|
||||
.expect("Missing parent function `sink_event`");
|
||||
|
@ -404,8 +388,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
fn parent_sink_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioEncoderClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioEncoderClass;
|
||||
let f = (*parent_class)
|
||||
.sink_query
|
||||
.expect("Missing parent function `sink_query`");
|
||||
|
@ -419,8 +402,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
fn parent_src_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioEncoderClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioEncoderClass;
|
||||
let f = (*parent_class)
|
||||
.src_event
|
||||
.expect("Missing parent function `src_event`");
|
||||
|
@ -434,8 +416,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
fn parent_src_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioEncoderClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioEncoderClass;
|
||||
let f = (*parent_class)
|
||||
.src_query
|
||||
.expect("Missing parent function `src_query`");
|
||||
|
@ -453,8 +434,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioEncoderClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioEncoderClass;
|
||||
(*parent_class)
|
||||
.propose_allocation
|
||||
.map(|f| {
|
||||
|
@ -464,7 +444,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
)) {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(gst_error_msg!(
|
||||
Err(gst::gst_error_msg!(
|
||||
gst::CoreError::StateChange,
|
||||
["Parent function `propose_allocation` failed"]
|
||||
))
|
||||
|
@ -481,8 +461,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioEncoderClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioEncoderClass;
|
||||
(*parent_class)
|
||||
.decide_allocation
|
||||
.map(|f| {
|
||||
|
@ -492,7 +471,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
)) {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(gst_error_msg!(
|
||||
Err(gst::gst_error_msg!(
|
||||
gst::CoreError::StateChange,
|
||||
["Parent function `decide_allocation` failed"]
|
||||
))
|
||||
|
@ -530,8 +509,8 @@ where
|
|||
}
|
||||
|
||||
unsafe extern "C" fn audio_encoder_open<T: AudioEncoderImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioEncoder,
|
||||
) -> glib_sys::gboolean
|
||||
ptr: *mut ffi::GstAudioEncoder,
|
||||
) -> glib::ffi::gboolean
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -539,7 +518,7 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
match imp.open(wrap.unsafe_cast_ref()) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
|
@ -552,8 +531,8 @@ where
|
|||
}
|
||||
|
||||
unsafe extern "C" fn audio_encoder_close<T: AudioEncoderImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioEncoder,
|
||||
) -> glib_sys::gboolean
|
||||
ptr: *mut ffi::GstAudioEncoder,
|
||||
) -> glib::ffi::gboolean
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -561,7 +540,7 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
match imp.close(wrap.unsafe_cast_ref()) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
|
@ -574,8 +553,8 @@ where
|
|||
}
|
||||
|
||||
unsafe extern "C" fn audio_encoder_start<T: AudioEncoderImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioEncoder,
|
||||
) -> glib_sys::gboolean
|
||||
ptr: *mut ffi::GstAudioEncoder,
|
||||
) -> glib::ffi::gboolean
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -583,7 +562,7 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
match imp.start(wrap.unsafe_cast_ref()) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
|
@ -596,8 +575,8 @@ where
|
|||
}
|
||||
|
||||
unsafe extern "C" fn audio_encoder_stop<T: AudioEncoderImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioEncoder,
|
||||
) -> glib_sys::gboolean
|
||||
ptr: *mut ffi::GstAudioEncoder,
|
||||
) -> glib::ffi::gboolean
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -605,7 +584,7 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
match imp.stop(wrap.unsafe_cast_ref()) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
|
@ -618,9 +597,9 @@ where
|
|||
}
|
||||
|
||||
unsafe extern "C" fn audio_encoder_set_format<T: AudioEncoderImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioEncoder,
|
||||
info: *mut gst_audio_sys::GstAudioInfo,
|
||||
) -> glib_sys::gboolean
|
||||
ptr: *mut ffi::GstAudioEncoder,
|
||||
info: *mut ffi::GstAudioInfo,
|
||||
) -> glib::ffi::gboolean
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -628,7 +607,7 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
match imp.set_format(wrap.unsafe_cast_ref(), &from_glib_none(info)) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
|
@ -641,19 +620,19 @@ where
|
|||
}
|
||||
|
||||
unsafe extern "C" fn audio_encoder_handle_frame<T: AudioEncoderImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioEncoder,
|
||||
buffer: *mut *mut gst_sys::GstBuffer,
|
||||
) -> gst_sys::GstFlowReturn
|
||||
ptr: *mut ffi::GstAudioEncoder,
|
||||
buffer: *mut *mut gst::ffi::GstBuffer,
|
||||
) -> gst::ffi::GstFlowReturn
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
// FIXME: Misgenerated in gstreamer-audio-sys
|
||||
let buffer = buffer as *mut gst_sys::GstBuffer;
|
||||
let buffer = buffer as *mut gst::ffi::GstBuffer;
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
||||
imp.handle_frame(
|
||||
wrap.unsafe_cast_ref(),
|
||||
Option::<gst::Buffer>::from_glib_none(buffer).as_ref(),
|
||||
|
@ -664,9 +643,9 @@ where
|
|||
}
|
||||
|
||||
unsafe extern "C" fn audio_encoder_pre_push<T: AudioEncoderImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioEncoder,
|
||||
buffer: *mut *mut gst_sys::GstBuffer,
|
||||
) -> gst_sys::GstFlowReturn
|
||||
ptr: *mut ffi::GstAudioEncoder,
|
||||
buffer: *mut *mut gst::ffi::GstBuffer,
|
||||
) -> gst::ffi::GstFlowReturn
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -674,7 +653,7 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
||||
match imp.pre_push(wrap.unsafe_cast_ref(), from_glib_full(*buffer)) {
|
||||
Ok(Some(new_buffer)) => {
|
||||
*buffer = new_buffer.into_ptr();
|
||||
|
@ -691,23 +670,7 @@ where
|
|||
.to_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn audio_encoder_flush<T: AudioEncoderImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioEncoder,
|
||||
) where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), (), {
|
||||
AudioEncoderImpl::flush(imp, wrap.unsafe_cast_ref())
|
||||
})
|
||||
}
|
||||
|
||||
unsafe extern "C" fn audio_encoder_negotiate<T: AudioEncoderImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioEncoder,
|
||||
) -> glib_sys::gboolean
|
||||
unsafe extern "C" fn audio_encoder_flush<T: AudioEncoderImpl>(ptr: *mut ffi::GstAudioEncoder)
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -715,7 +678,22 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), (), {
|
||||
AudioEncoderImpl::flush(imp, wrap.unsafe_cast_ref())
|
||||
})
|
||||
}
|
||||
|
||||
unsafe extern "C" fn audio_encoder_negotiate<T: AudioEncoderImpl>(
|
||||
ptr: *mut ffi::GstAudioEncoder,
|
||||
) -> glib::ffi::gboolean
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
match imp.negotiate(wrap.unsafe_cast_ref()) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
|
@ -728,9 +706,9 @@ where
|
|||
}
|
||||
|
||||
unsafe extern "C" fn audio_encoder_getcaps<T: AudioEncoderImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioEncoder,
|
||||
filter: *mut gst_sys::GstCaps,
|
||||
) -> *mut gst_sys::GstCaps
|
||||
ptr: *mut ffi::GstAudioEncoder,
|
||||
filter: *mut gst::ffi::GstCaps,
|
||||
) -> *mut gst::ffi::GstCaps
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -738,7 +716,7 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), gst::Caps::new_empty(), {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), gst::Caps::new_empty(), {
|
||||
AudioEncoderImpl::get_caps(
|
||||
imp,
|
||||
wrap.unsafe_cast_ref(),
|
||||
|
@ -751,9 +729,9 @@ where
|
|||
}
|
||||
|
||||
unsafe extern "C" fn audio_encoder_sink_event<T: AudioEncoderImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioEncoder,
|
||||
event: *mut gst_sys::GstEvent,
|
||||
) -> glib_sys::gboolean
|
||||
ptr: *mut ffi::GstAudioEncoder,
|
||||
event: *mut gst::ffi::GstEvent,
|
||||
) -> glib::ffi::gboolean
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -761,16 +739,16 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
imp.sink_event(wrap.unsafe_cast_ref(), from_glib_full(event))
|
||||
})
|
||||
.to_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn audio_encoder_sink_query<T: AudioEncoderImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioEncoder,
|
||||
query: *mut gst_sys::GstQuery,
|
||||
) -> glib_sys::gboolean
|
||||
ptr: *mut ffi::GstAudioEncoder,
|
||||
query: *mut gst::ffi::GstQuery,
|
||||
) -> glib::ffi::gboolean
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -778,16 +756,16 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
imp.sink_query(wrap.unsafe_cast_ref(), gst::QueryRef::from_mut_ptr(query))
|
||||
})
|
||||
.to_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn audio_encoder_src_event<T: AudioEncoderImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioEncoder,
|
||||
event: *mut gst_sys::GstEvent,
|
||||
) -> glib_sys::gboolean
|
||||
ptr: *mut ffi::GstAudioEncoder,
|
||||
event: *mut gst::ffi::GstEvent,
|
||||
) -> glib::ffi::gboolean
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -795,16 +773,16 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
imp.src_event(wrap.unsafe_cast_ref(), from_glib_full(event))
|
||||
})
|
||||
.to_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn audio_encoder_src_query<T: AudioEncoderImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioEncoder,
|
||||
query: *mut gst_sys::GstQuery,
|
||||
) -> glib_sys::gboolean
|
||||
ptr: *mut ffi::GstAudioEncoder,
|
||||
query: *mut gst::ffi::GstQuery,
|
||||
) -> glib::ffi::gboolean
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -812,16 +790,16 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
imp.src_query(wrap.unsafe_cast_ref(), gst::QueryRef::from_mut_ptr(query))
|
||||
})
|
||||
.to_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn audio_encoder_propose_allocation<T: AudioEncoderImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioEncoder,
|
||||
query: *mut gst_sys::GstQuery,
|
||||
) -> glib_sys::gboolean
|
||||
ptr: *mut ffi::GstAudioEncoder,
|
||||
query: *mut gst::ffi::GstQuery,
|
||||
) -> glib::ffi::gboolean
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -830,7 +808,7 @@ where
|
|||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||
let query = gst::QueryRef::from_mut_ptr(query);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
match imp.propose_allocation(wrap.unsafe_cast_ref(), query) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
|
@ -843,9 +821,9 @@ where
|
|||
}
|
||||
|
||||
unsafe extern "C" fn audio_encoder_decide_allocation<T: AudioEncoderImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioEncoder,
|
||||
query: *mut gst_sys::GstQuery,
|
||||
) -> glib_sys::gboolean
|
||||
ptr: *mut ffi::GstAudioEncoder,
|
||||
query: *mut gst::ffi::GstQuery,
|
||||
) -> glib::ffi::gboolean
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -854,7 +832,7 @@ where
|
|||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||
let query = gst::QueryRef::from_mut_ptr(query);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
match imp.decide_allocation(wrap.unsafe_cast_ref(), query) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
use glib_sys;
|
||||
use gst_audio_sys;
|
||||
|
||||
use glib::prelude::*;
|
||||
use glib::subclass::prelude::*;
|
||||
use glib::translate::*;
|
||||
|
@ -9,8 +6,8 @@ use gst::subclass::prelude::*;
|
|||
use gst::LoggableError;
|
||||
use gst_base::subclass::prelude::*;
|
||||
|
||||
use AudioRingBufferSpec;
|
||||
use AudioSink;
|
||||
use crate::AudioRingBufferSpec;
|
||||
use crate::AudioSink;
|
||||
|
||||
pub trait AudioSinkImpl: AudioSinkImplExt + BaseSinkImpl {
|
||||
fn close(&self, sink: &Self::Type) -> Result<(), LoggableError> {
|
||||
|
@ -64,13 +61,12 @@ impl<T: AudioSinkImpl> AudioSinkImplExt for T {
|
|||
fn parent_close(&self, sink: &Self::Type) -> Result<(), LoggableError> {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioSinkClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioSinkClass;
|
||||
let f = match (*parent_class).close {
|
||||
None => return Ok(()),
|
||||
Some(f) => f,
|
||||
};
|
||||
gst_result_from_gboolean!(
|
||||
gst::gst_result_from_gboolean!(
|
||||
f(sink.unsafe_cast_ref::<AudioSink>().to_glib_none().0),
|
||||
gst::CAT_RUST,
|
||||
"Failed to close element using the parent function"
|
||||
|
@ -81,8 +77,7 @@ impl<T: AudioSinkImpl> AudioSinkImplExt for T {
|
|||
fn parent_delay(&self, sink: &Self::Type) -> u32 {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioSinkClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioSinkClass;
|
||||
let f = match (*parent_class).delay {
|
||||
Some(f) => f,
|
||||
None => return 0,
|
||||
|
@ -94,13 +89,12 @@ impl<T: AudioSinkImpl> AudioSinkImplExt for T {
|
|||
fn parent_open(&self, sink: &Self::Type) -> Result<(), LoggableError> {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioSinkClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioSinkClass;
|
||||
let f = match (*parent_class).open {
|
||||
Some(f) => f,
|
||||
None => return Ok(()),
|
||||
};
|
||||
gst_result_from_gboolean!(
|
||||
gst::gst_result_from_gboolean!(
|
||||
f(sink.unsafe_cast_ref::<AudioSink>().to_glib_none().0),
|
||||
gst::CAT_RUST,
|
||||
"Failed to open element using the parent function"
|
||||
|
@ -115,13 +109,12 @@ impl<T: AudioSinkImpl> AudioSinkImplExt for T {
|
|||
) -> Result<(), LoggableError> {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioSinkClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioSinkClass;
|
||||
let f = match (*parent_class).prepare {
|
||||
Some(f) => f,
|
||||
None => return Ok(()),
|
||||
};
|
||||
gst_result_from_gboolean!(
|
||||
gst::gst_result_from_gboolean!(
|
||||
f(
|
||||
sink.unsafe_cast_ref::<AudioSink>().to_glib_none().0,
|
||||
&mut spec.0
|
||||
|
@ -135,8 +128,7 @@ impl<T: AudioSinkImpl> AudioSinkImplExt for T {
|
|||
fn parent_unprepare(&self, sink: &Self::Type) -> Result<(), LoggableError> {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioSinkClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioSinkClass;
|
||||
let f = match (*parent_class).unprepare {
|
||||
Some(f) => f,
|
||||
None => {
|
||||
|
@ -146,7 +138,7 @@ impl<T: AudioSinkImpl> AudioSinkImplExt for T {
|
|||
))
|
||||
}
|
||||
};
|
||||
gst_result_from_gboolean!(
|
||||
gst::gst_result_from_gboolean!(
|
||||
f(sink.unsafe_cast_ref::<AudioSink>().to_glib_none().0),
|
||||
gst::CAT_RUST,
|
||||
"Failed to unprepare element using the parent function"
|
||||
|
@ -157,8 +149,7 @@ impl<T: AudioSinkImpl> AudioSinkImplExt for T {
|
|||
fn parent_write(&self, sink: &Self::Type, buffer: &[u8]) -> Result<i32, LoggableError> {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioSinkClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioSinkClass;
|
||||
let f = match (*parent_class).write {
|
||||
Some(f) => f,
|
||||
None => return Ok(-1),
|
||||
|
@ -183,8 +174,7 @@ impl<T: AudioSinkImpl> AudioSinkImplExt for T {
|
|||
fn parent_reset(&self, sink: &Self::Type) {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioSinkClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioSinkClass;
|
||||
if let Some(f) = (*parent_class).reset {
|
||||
f(sink.unsafe_cast_ref::<AudioSink>().to_glib_none().0)
|
||||
}
|
||||
|
@ -210,8 +200,8 @@ where
|
|||
}
|
||||
|
||||
unsafe extern "C" fn audiosink_close<T: AudioSinkImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioSink,
|
||||
) -> glib_sys::gboolean
|
||||
ptr: *mut ffi::GstAudioSink,
|
||||
) -> glib::ffi::gboolean
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -219,7 +209,7 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioSink> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
match imp.close(wrap.unsafe_cast_ref()) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
|
@ -231,7 +221,7 @@ where
|
|||
.to_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn audiosink_delay<T: AudioSinkImpl>(ptr: *mut gst_audio_sys::GstAudioSink) -> u32
|
||||
unsafe extern "C" fn audiosink_delay<T: AudioSinkImpl>(ptr: *mut ffi::GstAudioSink) -> u32
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -239,14 +229,14 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioSink> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), 0, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), 0, {
|
||||
imp.delay(wrap.unsafe_cast_ref())
|
||||
})
|
||||
}
|
||||
|
||||
unsafe extern "C" fn audiosink_open<T: AudioSinkImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioSink,
|
||||
) -> glib_sys::gboolean
|
||||
ptr: *mut ffi::GstAudioSink,
|
||||
) -> glib::ffi::gboolean
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -254,7 +244,7 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioSink> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
match imp.open(wrap.unsafe_cast_ref()) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
|
@ -267,9 +257,9 @@ where
|
|||
}
|
||||
|
||||
unsafe extern "C" fn audiosink_prepare<T: AudioSinkImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioSink,
|
||||
spec: *mut gst_audio_sys::GstAudioRingBufferSpec,
|
||||
) -> glib_sys::gboolean
|
||||
ptr: *mut ffi::GstAudioSink,
|
||||
spec: *mut ffi::GstAudioRingBufferSpec,
|
||||
) -> glib::ffi::gboolean
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -279,7 +269,7 @@ where
|
|||
|
||||
let spec = &mut *(spec as *mut AudioRingBufferSpec);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
match AudioSinkImpl::prepare(imp, wrap.unsafe_cast_ref(), spec) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
|
@ -292,8 +282,8 @@ where
|
|||
}
|
||||
|
||||
unsafe extern "C" fn audiosink_unprepare<T: AudioSinkImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioSink,
|
||||
) -> glib_sys::gboolean
|
||||
ptr: *mut ffi::GstAudioSink,
|
||||
) -> glib::ffi::gboolean
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -301,7 +291,7 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioSink> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
match imp.unprepare(wrap.unsafe_cast_ref()) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
|
@ -314,8 +304,8 @@ where
|
|||
}
|
||||
|
||||
unsafe extern "C" fn audiosink_write<T: AudioSinkImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioSink,
|
||||
data: glib_sys::gpointer,
|
||||
ptr: *mut ffi::GstAudioSink,
|
||||
data: glib::ffi::gpointer,
|
||||
length: u32,
|
||||
) -> i32
|
||||
where
|
||||
|
@ -326,12 +316,12 @@ where
|
|||
let wrap: Borrowed<AudioSink> = from_glib_borrow(ptr);
|
||||
let data_slice = std::slice::from_raw_parts(data as *const u8, length as usize);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), -1, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), -1, {
|
||||
imp.write(wrap.unsafe_cast_ref(), data_slice).unwrap_or(-1)
|
||||
})
|
||||
}
|
||||
|
||||
unsafe extern "C" fn audiosink_reset<T: AudioSinkImpl>(ptr: *mut gst_audio_sys::GstAudioSink)
|
||||
unsafe extern "C" fn audiosink_reset<T: AudioSinkImpl>(ptr: *mut ffi::GstAudioSink)
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -339,7 +329,7 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioSink> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), (), {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), (), {
|
||||
imp.reset(wrap.unsafe_cast_ref());
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
use glib_sys;
|
||||
use gst_audio_sys;
|
||||
|
||||
use std::mem;
|
||||
|
||||
use glib::prelude::*;
|
||||
|
@ -11,8 +8,8 @@ use gst::subclass::prelude::*;
|
|||
use gst::LoggableError;
|
||||
use gst_base::subclass::prelude::*;
|
||||
|
||||
use AudioRingBufferSpec;
|
||||
use AudioSrc;
|
||||
use crate::AudioRingBufferSpec;
|
||||
use crate::AudioSrc;
|
||||
|
||||
pub trait AudioSrcImpl: AudioSrcImplExt + BaseSrcImpl {
|
||||
fn close(&self, src: &Self::Type) -> Result<(), LoggableError> {
|
||||
|
@ -74,13 +71,12 @@ impl<T: AudioSrcImpl> AudioSrcImplExt for T {
|
|||
fn parent_close(&self, src: &Self::Type) -> Result<(), LoggableError> {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioSrcClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioSrcClass;
|
||||
let f = match (*parent_class).close {
|
||||
None => return Ok(()),
|
||||
Some(f) => f,
|
||||
};
|
||||
gst_result_from_gboolean!(
|
||||
gst::gst_result_from_gboolean!(
|
||||
f(src.unsafe_cast_ref::<AudioSrc>().to_glib_none().0),
|
||||
gst::CAT_RUST,
|
||||
"Failed to close element using the parent function"
|
||||
|
@ -91,8 +87,7 @@ impl<T: AudioSrcImpl> AudioSrcImplExt for T {
|
|||
fn parent_delay(&self, src: &Self::Type) -> u32 {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioSrcClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioSrcClass;
|
||||
let f = match (*parent_class).delay {
|
||||
Some(f) => f,
|
||||
None => return 0,
|
||||
|
@ -104,13 +99,12 @@ impl<T: AudioSrcImpl> AudioSrcImplExt for T {
|
|||
fn parent_open(&self, src: &Self::Type) -> Result<(), LoggableError> {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioSrcClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioSrcClass;
|
||||
let f = match (*parent_class).open {
|
||||
Some(f) => f,
|
||||
None => return Ok(()),
|
||||
};
|
||||
gst_result_from_gboolean!(
|
||||
gst::gst_result_from_gboolean!(
|
||||
f(src.unsafe_cast_ref::<AudioSrc>().to_glib_none().0),
|
||||
gst::CAT_RUST,
|
||||
"Failed to open element using the parent function"
|
||||
|
@ -125,13 +119,12 @@ impl<T: AudioSrcImpl> AudioSrcImplExt for T {
|
|||
) -> Result<(), LoggableError> {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioSrcClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioSrcClass;
|
||||
let f = match (*parent_class).prepare {
|
||||
Some(f) => f,
|
||||
None => return Ok(()),
|
||||
};
|
||||
gst_result_from_gboolean!(
|
||||
gst::gst_result_from_gboolean!(
|
||||
f(
|
||||
src.unsafe_cast_ref::<AudioSrc>().to_glib_none().0,
|
||||
&mut spec.0
|
||||
|
@ -145,8 +138,7 @@ impl<T: AudioSrcImpl> AudioSrcImplExt for T {
|
|||
fn parent_unprepare(&self, src: &Self::Type) -> Result<(), LoggableError> {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioSrcClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioSrcClass;
|
||||
let f = match (*parent_class).unprepare {
|
||||
Some(f) => f,
|
||||
None => {
|
||||
|
@ -156,7 +148,7 @@ impl<T: AudioSrcImpl> AudioSrcImplExt for T {
|
|||
))
|
||||
}
|
||||
};
|
||||
gst_result_from_gboolean!(
|
||||
gst::gst_result_from_gboolean!(
|
||||
f(src.unsafe_cast_ref::<AudioSrc>().to_glib_none().0),
|
||||
gst::CAT_RUST,
|
||||
"Failed to unprepare element using the parent function"
|
||||
|
@ -171,8 +163,7 @@ impl<T: AudioSrcImpl> AudioSrcImplExt for T {
|
|||
) -> Result<(u32, gst::ClockTime), LoggableError> {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioSrcClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioSrcClass;
|
||||
let f = match (*parent_class).read {
|
||||
Some(f) => f,
|
||||
None => return Ok((0, gst::CLOCK_TIME_NONE)),
|
||||
|
@ -199,8 +190,7 @@ impl<T: AudioSrcImpl> AudioSrcImplExt for T {
|
|||
fn parent_reset(&self, src: &Self::Type) {
|
||||
unsafe {
|
||||
let data = T::type_data();
|
||||
let parent_class =
|
||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioSrcClass;
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAudioSrcClass;
|
||||
if let Some(f) = (*parent_class).reset {
|
||||
f(src.unsafe_cast_ref::<AudioSrc>().to_glib_none().0)
|
||||
}
|
||||
|
@ -226,8 +216,8 @@ where
|
|||
}
|
||||
|
||||
unsafe extern "C" fn audiosrc_close<T: AudioSrcImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioSrc,
|
||||
) -> glib_sys::gboolean
|
||||
ptr: *mut ffi::GstAudioSrc,
|
||||
) -> glib::ffi::gboolean
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -235,7 +225,7 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioSrc> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
match imp.close(wrap.unsafe_cast_ref()) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
|
@ -247,7 +237,7 @@ where
|
|||
.to_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn audiosrc_delay<T: AudioSrcImpl>(ptr: *mut gst_audio_sys::GstAudioSrc) -> u32
|
||||
unsafe extern "C" fn audiosrc_delay<T: AudioSrcImpl>(ptr: *mut ffi::GstAudioSrc) -> u32
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -255,14 +245,14 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioSrc> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), 0, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), 0, {
|
||||
imp.delay(wrap.unsafe_cast_ref())
|
||||
})
|
||||
}
|
||||
|
||||
unsafe extern "C" fn audiosrc_open<T: AudioSrcImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioSrc,
|
||||
) -> glib_sys::gboolean
|
||||
ptr: *mut ffi::GstAudioSrc,
|
||||
) -> glib::ffi::gboolean
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -270,7 +260,7 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioSrc> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
match imp.open(wrap.unsafe_cast_ref()) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
|
@ -283,9 +273,9 @@ where
|
|||
}
|
||||
|
||||
unsafe extern "C" fn audiosrc_prepare<T: AudioSrcImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioSrc,
|
||||
spec: *mut gst_audio_sys::GstAudioRingBufferSpec,
|
||||
) -> glib_sys::gboolean
|
||||
ptr: *mut ffi::GstAudioSrc,
|
||||
spec: *mut ffi::GstAudioRingBufferSpec,
|
||||
) -> glib::ffi::gboolean
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -295,7 +285,7 @@ where
|
|||
|
||||
let spec = &mut *(spec as *mut AudioRingBufferSpec);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
match AudioSrcImpl::prepare(imp, wrap.unsafe_cast_ref(), spec) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
|
@ -308,8 +298,8 @@ where
|
|||
}
|
||||
|
||||
unsafe extern "C" fn audiosrc_unprepare<T: AudioSrcImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioSrc,
|
||||
) -> glib_sys::gboolean
|
||||
ptr: *mut ffi::GstAudioSrc,
|
||||
) -> glib::ffi::gboolean
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -317,7 +307,7 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioSrc> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
match imp.unprepare(wrap.unsafe_cast_ref()) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
|
@ -330,10 +320,10 @@ where
|
|||
}
|
||||
|
||||
unsafe extern "C" fn audiosrc_read<T: AudioSrcImpl>(
|
||||
ptr: *mut gst_audio_sys::GstAudioSrc,
|
||||
data: glib_sys::gpointer,
|
||||
ptr: *mut ffi::GstAudioSrc,
|
||||
data: glib::ffi::gpointer,
|
||||
length: u32,
|
||||
timestamp: *mut gst_sys::GstClockTime,
|
||||
timestamp: *mut gst::ffi::GstClockTime,
|
||||
) -> u32
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
|
@ -343,7 +333,7 @@ where
|
|||
let wrap: Borrowed<AudioSrc> = from_glib_borrow(ptr);
|
||||
let data_slice = std::slice::from_raw_parts_mut(data as *mut u8, length as usize);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), 0, {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), 0, {
|
||||
let (res, timestamp_res) = imp
|
||||
.read(wrap.unsafe_cast_ref(), data_slice)
|
||||
.unwrap_or((0, gst::CLOCK_TIME_NONE));
|
||||
|
@ -353,7 +343,7 @@ where
|
|||
})
|
||||
}
|
||||
|
||||
unsafe extern "C" fn audiosrc_reset<T: AudioSrcImpl>(ptr: *mut gst_audio_sys::GstAudioSrc)
|
||||
unsafe extern "C" fn audiosrc_reset<T: AudioSrcImpl>(ptr: *mut ffi::GstAudioSrc)
|
||||
where
|
||||
T::Instance: PanicPoison,
|
||||
{
|
||||
|
@ -361,7 +351,7 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: Borrowed<AudioSrc> = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), (), {
|
||||
gst::gst_panic_to_error!(&wrap, &instance.panicked(), (), {
|
||||
imp.reset(wrap.unsafe_cast_ref());
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue