aboutsummaryrefslogtreecommitdiffstats
path: root/src/frame.rs
blob: 77a5c1730768d3e76dfeede9409779199b46b6bd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
use std::collections::HashMap;
use std::rc::Rc;
use formats::*;

#[allow(dead_code)]
#[derive(Clone,Copy)]
pub struct NAAudioInfo {
    sample_rate: u32,
    channels:    u8,
    format:      NASoniton,
    block_len:   usize,
}

impl NAAudioInfo {
    pub fn new(sr: u32, ch: u8, fmt: NASoniton, bl: usize) -> Self {
        NAAudioInfo { sample_rate: sr, channels: ch, format: fmt, block_len: bl }
    }
}

#[allow(dead_code)]
#[derive(Clone,Copy)]
pub struct NAVideoInfo {
    width:      u32,
    height:     u32,
    flipped:    bool,
    format:     NAPixelFormaton,
}

impl NAVideoInfo {
    pub fn new(w: u32, h: u32, flip: bool, fmt: NAPixelFormaton) -> Self {
        NAVideoInfo { width: w, height: h, flipped: flip, format: fmt }
    }
}

#[derive(Clone,Copy)]
pub enum NACodecTypeInfo {
    None,
    Audio(NAAudioInfo),
    Video(NAVideoInfo),
}

#[allow(dead_code)]
pub struct NABuffer<'a> {
    id:   u64,
    data: &'a mut [u8],
}

#[allow(dead_code)]
#[derive(Clone)]
pub struct NACodecInfo {
    properties: NACodecTypeInfo,
    extradata:  Option<Rc<Vec<u8>>>,
}

impl NACodecInfo {
    pub fn new(p: NACodecTypeInfo, edata: Option<Vec<u8>>) -> Self {
        let extradata = match edata {
            None => None,
            Some(vec) => Some(Rc::new(vec)),
        };
        NACodecInfo { properties: p, extradata: extradata }
    }
    pub fn get_properties(&self) -> NACodecTypeInfo { self.properties }
    pub fn get_extradata(&self) -> Option<Rc<Vec<u8>>> {
        if let Some(ref vec) = self.extradata { return Some(vec.clone()); }
        None
    }
}

pub trait NABufferAllocator {
    fn alloc_buf(info: &NACodecInfo) -> NABuffer<'static>;
}

#[derive(Debug)]
pub enum NAValue<'a> {
    None,
    Int(i32),
    Long(i64),
    String(String),
    Data(&'a [u8]),
}

#[allow(dead_code)]
pub struct NAFrame<'a> {
    pts:            Option<u64>,
    dts:            Option<u64>,
    duration:       Option<u64>,
    buffer:         &'a mut NABuffer<'a>,
    info:           &'a NACodecInfo,
    options:        HashMap<String, NAValue<'a>>,
}

#[allow(dead_code)]
pub struct NACodecContext<'a> {
    info:           &'a NACodecInfo,
}