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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#![warn(missing_docs)]
extern crate byteorder;
extern crate mpeg2ts;
#[macro_use]
extern crate trackable;
macro_rules! track_io {
($expr:expr) => {
$expr.map_err(|e: ::std::io::Error| {
use trackable::error::ErrorKindExt;
track!(::Error::from(::ErrorKind::Other.cause(e)))
})
};
}
macro_rules! write_u8 {
($w:expr, $n:expr) => {{
use byteorder::WriteBytesExt;
track_io!($w.write_u8($n))?;
}};
}
macro_rules! write_u16 {
($w:expr, $n:expr) => {{
use byteorder::{BigEndian, WriteBytesExt};
track_io!($w.write_u16::<BigEndian>($n))?;
}};
}
macro_rules! write_i16 {
($w:expr, $n:expr) => {{
use byteorder::{BigEndian, WriteBytesExt};
track_io!($w.write_i16::<BigEndian>($n))?;
}};
}
macro_rules! write_u24 {
($w:expr, $n:expr) => {{
use byteorder::{BigEndian, WriteBytesExt};
track_io!($w.write_uint::<BigEndian>($n as u64, 3))?;
}};
}
macro_rules! write_u32 {
($w:expr, $n:expr) => {{
use byteorder::{BigEndian, WriteBytesExt};
track_io!($w.write_u32::<BigEndian>($n))?;
}};
}
macro_rules! write_i32 {
($w:expr, $n:expr) => {{
use byteorder::{BigEndian, WriteBytesExt};
track_io!($w.write_i32::<BigEndian>($n))?;
}};
}
macro_rules! write_u64 {
($w:expr, $n:expr) => {{
use byteorder::{BigEndian, WriteBytesExt};
track_io!($w.write_u64::<BigEndian>($n))?;
}};
}
macro_rules! write_all {
($w:expr, $n:expr) => {
track_io!($w.write_all($n))?;
};
}
macro_rules! write_zeroes {
($w:expr, $n:expr) => {
track_io!($w.write_all(&[0; $n][..]))?;
};
}
macro_rules! write_box {
($w:expr, $b:expr) => {
track!($b.write_box(&mut $w))?;
};
}
macro_rules! write_boxes {
($w:expr, $bs:expr) => {
for b in $bs {
track!(b.write_box(&mut $w))?;
}
};
}
macro_rules! box_size {
($b:expr) => {
track!($b.box_size())?
};
}
macro_rules! optional_box_size {
($b:expr) => {
if let Some(ref b) = $b.as_ref() {
track!(b.box_size())?
} else {
0
}
};
}
macro_rules! boxes_size {
($b:expr) => {{
let mut size = 0;
for b in $b.iter() {
size += box_size!(b);
}
size
}};
}
pub use error::{Error, ErrorKind};
pub mod aac;
pub mod avc;
pub mod fmp4;
pub mod io;
pub mod mpeg2_ts;
mod error;
pub type Result<T> = std::result::Result<T, Error>;