X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;f=nihav-core%2Fsrc%2Fframe.rs;h=697013c442a99d653004bcc4a593f1feb8ab1753;hb=d32c444b36000abaaf5c65866a2dbdfec1c1ac26;hp=c6e392011cbd067abc3c77655228ab6ca39e6bb5;hpb=8ee4352b1fad134b2fc3f137f9cfc94804446bfd;p=nihav.git diff --git a/nihav-core/src/frame.rs b/nihav-core/src/frame.rs index c6e3920..697013c 100644 --- a/nihav-core/src/frame.rs +++ b/nihav-core/src/frame.rs @@ -8,10 +8,10 @@ pub use crate::refs::*; #[allow(dead_code)] #[derive(Clone,Copy,PartialEq)] pub struct NAAudioInfo { - sample_rate: u32, - channels: u8, - format: NASoniton, - block_len: usize, + pub sample_rate: u32, + pub channels: u8, + pub format: NASoniton, + pub block_len: usize, } impl NAAudioInfo { @@ -235,6 +235,46 @@ impl NABufferType { _ => None, } } + pub fn get_audio_info(&self) -> Option { + match *self { + NABufferType::AudioU8(ref ab) => Some(ab.get_info()), + NABufferType::AudioI16(ref ab) => Some(ab.get_info()), + NABufferType::AudioI32(ref ab) => Some(ab.get_info()), + NABufferType::AudioF32(ref ab) => Some(ab.get_info()), + NABufferType::AudioPacked(ref ab) => Some(ab.get_info()), + _ => None, + } + } + pub fn get_chmap(&self) -> Option<&NAChannelMap> { + match *self { + NABufferType::AudioU8(ref ab) => Some(ab.get_chmap()), + NABufferType::AudioI16(ref ab) => Some(ab.get_chmap()), + NABufferType::AudioI32(ref ab) => Some(ab.get_chmap()), + NABufferType::AudioF32(ref ab) => Some(ab.get_chmap()), + NABufferType::AudioPacked(ref ab) => Some(ab.get_chmap()), + _ => None, + } + } + pub fn get_audio_length(&self) -> usize { + match *self { + NABufferType::AudioU8(ref ab) => ab.get_length(), + NABufferType::AudioI16(ref ab) => ab.get_length(), + NABufferType::AudioI32(ref ab) => ab.get_length(), + NABufferType::AudioF32(ref ab) => ab.get_length(), + NABufferType::AudioPacked(ref ab) => ab.get_length(), + _ => 0, + } + } + pub fn get_audio_stride(&self) -> usize { + match *self { + NABufferType::AudioU8(ref ab) => ab.get_stride(), + NABufferType::AudioI16(ref ab) => ab.get_stride(), + NABufferType::AudioI32(ref ab) => ab.get_stride(), + NABufferType::AudioF32(ref ab) => ab.get_stride(), + NABufferType::AudioPacked(ref ab) => ab.get_stride(), + _ => 0, + } + } pub fn get_abuf_u8(&self) -> Option> { match *self { NABufferType::AudioU8(ref ab) => Some(ab.clone()),