1#![warn(missing_docs)]
11extern crate byteorder;
12extern crate mpeg2ts;
13#[macro_use]
14extern crate trackable;
15
16macro_rules! track_io {
17 ($expr:expr) => {
18 $expr.map_err(|e: std::io::Error| {
19 use trackable::error::ErrorKindExt;
20 track!(crate::Error::from(crate::ErrorKind::Other.cause(e)))
21 })
22 };
23}
24macro_rules! write_u8 {
25 ($w:expr, $n:expr) => {{
26 use byteorder::WriteBytesExt;
27 track_io!($w.write_u8($n))?;
28 }};
29}
30macro_rules! write_u16 {
31 ($w:expr, $n:expr) => {{
32 use byteorder::{BigEndian, WriteBytesExt};
33 track_io!($w.write_u16::<BigEndian>($n))?;
34 }};
35}
36macro_rules! write_i16 {
37 ($w:expr, $n:expr) => {{
38 use byteorder::{BigEndian, WriteBytesExt};
39 track_io!($w.write_i16::<BigEndian>($n))?;
40 }};
41}
42macro_rules! write_u24 {
43 ($w:expr, $n:expr) => {{
44 use byteorder::{BigEndian, WriteBytesExt};
45 track_io!($w.write_uint::<BigEndian>($n as u64, 3))?;
46 }};
47}
48macro_rules! write_u32 {
49 ($w:expr, $n:expr) => {{
50 use byteorder::{BigEndian, WriteBytesExt};
51 track_io!($w.write_u32::<BigEndian>($n))?;
52 }};
53}
54macro_rules! write_i32 {
55 ($w:expr, $n:expr) => {{
56 use byteorder::{BigEndian, WriteBytesExt};
57 track_io!($w.write_i32::<BigEndian>($n))?;
58 }};
59}
60macro_rules! write_u64 {
61 ($w:expr, $n:expr) => {{
62 use byteorder::{BigEndian, WriteBytesExt};
63 track_io!($w.write_u64::<BigEndian>($n))?;
64 }};
65}
66macro_rules! write_all {
67 ($w:expr, $n:expr) => {
68 track_io!($w.write_all($n))?;
69 };
70}
71macro_rules! write_zeroes {
72 ($w:expr, $n:expr) => {
73 track_io!($w.write_all(&[0; $n][..]))?;
74 };
75}
76macro_rules! write_box {
77 ($w:expr, $b:expr) => {
78 track!($b.write_box(&mut $w))?;
79 };
80}
81macro_rules! write_boxes {
82 ($w:expr, $bs:expr) => {
83 for b in $bs {
84 track!(b.write_box(&mut $w))?;
85 }
86 };
87}
88macro_rules! box_size {
89 ($b:expr) => {
90 track!($b.box_size())?
91 };
92}
93macro_rules! optional_box_size {
94 ($b:expr) => {
95 if let Some(ref b) = $b.as_ref() {
96 track!(b.box_size())?
97 } else {
98 0
99 }
100 };
101}
102macro_rules! boxes_size {
103 ($b:expr) => {{
104 let mut size = 0;
105 for b in $b.iter() {
106 size += box_size!(b);
107 }
108 size
109 }};
110}
111
112pub use error::{Error, ErrorKind};
113
114pub mod aac;
115pub mod avc;
116pub mod fmp4;
117pub mod io;
118pub mod mpeg2_ts;
119
120mod error;
121
122pub type Result<T, E = Error> = std::result::Result<T, E>;