aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKostya Shishkov <kostya.shishkov@gmail.com>2019-11-16 18:39:41 +0100
committerKostya Shishkov <kostya.shishkov@gmail.com>2019-11-16 18:39:41 +0100
commit049474a0116e080d49c349256da7fae5f1a1b9c3 (patch)
tree2e12eeb6b9376359c005c302863fc7eb8a6ffd68
parent8ee4352b1fad134b2fc3f137f9cfc94804446bfd (diff)
downloadnihav-049474a0116e080d49c349256da7fae5f1a1b9c3.tar.gz
core/frame: add some common audio functions to NABufferType
-rw-r--r--nihav-core/src/frame.rs40
1 files changed, 40 insertions, 0 deletions
diff --git a/nihav-core/src/frame.rs b/nihav-core/src/frame.rs
index c6e3920..e1529bf 100644
--- a/nihav-core/src/frame.rs
+++ b/nihav-core/src/frame.rs
@@ -235,6 +235,46 @@ impl NABufferType {
_ => None,
}
}
+ pub fn get_audio_info(&self) -> Option<NAAudioInfo> {
+ 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<NAAudioBuffer<u8>> {
match *self {
NABufferType::AudioU8(ref ab) => Some(ab.clone()),