]>
Commit | Line | Data |
---|---|---|
1 | use std::collections::HashMap; | |
2 | use std::rc::Rc; | |
3 | use formats::*; | |
4 | ||
5 | #[allow(dead_code)] | |
6 | #[derive(Clone,Copy)] | |
7 | pub struct NAAudioInfo { | |
8 | sample_rate: u32, | |
9 | channels: u8, | |
10 | format: NASoniton, | |
11 | block_len: usize, | |
12 | } | |
13 | ||
14 | impl NAAudioInfo { | |
15 | pub fn new(sr: u32, ch: u8, fmt: NASoniton, bl: usize) -> Self { | |
16 | NAAudioInfo { sample_rate: sr, channels: ch, format: fmt, block_len: bl } | |
17 | } | |
18 | } | |
19 | ||
20 | #[allow(dead_code)] | |
21 | #[derive(Clone,Copy)] | |
22 | pub struct NAVideoInfo { | |
23 | width: u32, | |
24 | height: u32, | |
25 | flipped: bool, | |
26 | format: NAPixelFormaton, | |
27 | } | |
28 | ||
29 | impl NAVideoInfo { | |
30 | pub fn new(w: u32, h: u32, flip: bool, fmt: NAPixelFormaton) -> Self { | |
31 | NAVideoInfo { width: w, height: h, flipped: flip, format: fmt } | |
32 | } | |
33 | } | |
34 | ||
35 | #[derive(Clone,Copy)] | |
36 | pub enum NACodecTypeInfo { | |
37 | None, | |
38 | Audio(NAAudioInfo), | |
39 | Video(NAVideoInfo), | |
40 | } | |
41 | ||
42 | #[allow(dead_code)] | |
43 | pub struct NABuffer<'a> { | |
44 | id: u64, | |
45 | data: &'a mut [u8], | |
46 | } | |
47 | ||
48 | #[allow(dead_code)] | |
49 | #[derive(Clone)] | |
50 | pub struct NACodecInfo { | |
51 | properties: NACodecTypeInfo, | |
52 | extradata: Option<Rc<Vec<u8>>>, | |
53 | } | |
54 | ||
55 | impl NACodecInfo { | |
56 | pub fn new(p: NACodecTypeInfo, edata: Option<Vec<u8>>) -> Self { | |
57 | let extradata = match edata { | |
58 | None => None, | |
59 | Some(vec) => Some(Rc::new(vec)), | |
60 | }; | |
61 | NACodecInfo { properties: p, extradata: extradata } | |
62 | } | |
63 | pub fn get_properties(&self) -> NACodecTypeInfo { self.properties } | |
64 | pub fn get_extradata(&self) -> Option<Rc<Vec<u8>>> { | |
65 | if let Some(ref vec) = self.extradata { return Some(vec.clone()); } | |
66 | None | |
67 | } | |
68 | } | |
69 | ||
70 | pub trait NABufferAllocator { | |
71 | fn alloc_buf(info: &NACodecInfo) -> NABuffer<'static>; | |
72 | } | |
73 | ||
74 | #[derive(Debug)] | |
75 | pub enum NAValue<'a> { | |
76 | None, | |
77 | Int(i32), | |
78 | Long(i64), | |
79 | String(String), | |
80 | Data(&'a [u8]), | |
81 | } | |
82 | ||
83 | #[allow(dead_code)] | |
84 | pub struct NAFrame<'a> { | |
85 | pts: Option<u64>, | |
86 | dts: Option<u64>, | |
87 | duration: Option<u64>, | |
88 | buffer: &'a mut NABuffer<'a>, | |
89 | info: &'a NACodecInfo, | |
90 | options: HashMap<String, NAValue<'a>>, | |
91 | } | |
92 | ||
93 | #[allow(dead_code)] | |
94 | pub struct NACodecContext<'a> { | |
95 | info: &'a NACodecInfo, | |
96 | } |