Add ChannelLayout API (#38)
* Create channel_layout directory * Rename ChannelLayout -> ChannelLayoutMask * Add enum Channel (<-> AVChannel) * Add struct ChannelCustom (<-> AVChannelCustom) * Add enum ChannelOrder (<-> AVChannelOrder) * Add struct ChannelLayout - Smart copy-on-write pointer to AVChannelLayout - idiomatic Rust API wrapping around FFmpeg APIs - no Ambisonic support (yet) - consts will need to be manually updated * Add ChannelLayoutIter (iterator over all standard layouts) * Add codec/Audio::ch_layouts * Add ch_layout API to Audio-related structs
This commit is contained in:
@ -12,7 +12,10 @@ use crate::frame;
|
||||
use crate::util::format;
|
||||
#[cfg(not(feature = "ffmpeg_5_0"))]
|
||||
use crate::{packet, Error};
|
||||
use crate::{AudioService, ChannelLayout};
|
||||
use crate::{AudioService, ChannelLayoutMask};
|
||||
|
||||
#[cfg(feature = "ffmpeg_5_1")]
|
||||
use crate::ChannelLayout;
|
||||
|
||||
pub struct Audio(pub Opened);
|
||||
|
||||
@ -69,22 +72,34 @@ impl Audio {
|
||||
unsafe { (*self.as_ptr()).block_align as usize }
|
||||
}
|
||||
|
||||
pub fn channel_layout(&self) -> ChannelLayout {
|
||||
unsafe { ChannelLayout::from_bits_truncate((*self.as_ptr()).channel_layout) }
|
||||
pub fn channel_layout(&self) -> ChannelLayoutMask {
|
||||
unsafe { ChannelLayoutMask::from_bits_truncate((*self.as_ptr()).channel_layout) }
|
||||
}
|
||||
|
||||
pub fn set_channel_layout(&mut self, value: ChannelLayout) {
|
||||
pub fn set_channel_layout(&mut self, value: ChannelLayoutMask) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).channel_layout = value.bits();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn request_channel_layout(&mut self, value: ChannelLayout) {
|
||||
pub fn request_channel_layout(&mut self, value: ChannelLayoutMask) {
|
||||
unsafe {
|
||||
(*self.as_mut_ptr()).request_channel_layout = value.bits();
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "ffmpeg_5_1")]
|
||||
pub fn ch_layout(&self) -> ChannelLayout {
|
||||
unsafe { ChannelLayout::from(&self.as_ptr().as_ref().unwrap().ch_layout) }
|
||||
}
|
||||
|
||||
#[cfg(feature = "ffmpeg_5_1")]
|
||||
pub fn set_ch_layout(&mut self, value: ChannelLayout) {
|
||||
unsafe {
|
||||
self.as_mut_ptr().as_mut().unwrap().ch_layout = value.into_owned();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn audio_service(&mut self) -> AudioService {
|
||||
unsafe { AudioService::from((*self.as_mut_ptr()).audio_service_type) }
|
||||
}
|
||||
|
Reference in New Issue
Block a user