1 use std::collections::HashMap;
8 pub struct NAAudioInfo {
16 pub fn new(sr: u32, ch: u8, fmt: NASoniton, bl: usize) -> Self {
17 NAAudioInfo { sample_rate: sr, channels: ch, format: fmt, block_len: bl }
21 impl fmt::Display for NAAudioInfo {
22 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
23 write!(f, "{} Hz, {} ch", self.sample_rate, self.channels)
29 pub struct NAVideoInfo {
33 format: NAPixelFormaton,
37 pub fn new(w: u32, h: u32, flip: bool, fmt: NAPixelFormaton) -> Self {
38 NAVideoInfo { width: w, height: h, flipped: flip, format: fmt }
42 impl fmt::Display for NAVideoInfo {
43 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
44 write!(f, "{}x{}", self.width, self.height)
49 pub enum NACodecTypeInfo {
55 impl fmt::Display for NACodecTypeInfo {
56 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
57 let ret = match *self {
58 NACodecTypeInfo::None => format!(""),
59 NACodecTypeInfo::Audio(fmt) => format!("{}", fmt),
60 NACodecTypeInfo::Video(fmt) => format!("{}", fmt),
68 pub struct NABuffer<'a> {
75 pub struct NACodecInfo {
77 properties: NACodecTypeInfo,
78 extradata: Option<Rc<Vec<u8>>>,
82 pub fn new(name: &'static str, p: NACodecTypeInfo, edata: Option<Vec<u8>>) -> Self {
83 let extradata = match edata {
85 Some(vec) => Some(Rc::new(vec)),
87 NACodecInfo { name: name, properties: p, extradata: extradata }
89 pub fn get_properties(&self) -> NACodecTypeInfo { self.properties }
90 pub fn get_extradata(&self) -> Option<Rc<Vec<u8>>> {
91 if let Some(ref vec) = self.extradata { return Some(vec.clone()); }
96 pub trait NABufferAllocator {
97 fn alloc_buf(info: &NACodecInfo) -> NABuffer<'static>;
101 pub enum NAValue<'a> {
110 pub struct NAFrame<'a> {
113 duration: Option<u64>,
114 buffer: &'a mut NABuffer<'a>,
115 info: &'a NACodecInfo,
116 options: HashMap<String, NAValue<'a>>,
120 pub struct NACodecContext<'a> {
121 info: &'a NACodecInfo,