1use crate::{base_box};
2use crate::mp4box::avcc::AvcCBox;
3use crate::types::sample::VisualSampleEntry;
4
5base_box! {
6 box (b"avc1", Avc1, Avc1Box) data {
7 visual_sample_entry: VisualSampleEntry
8 } children {
9 avcc: AvcCBox
10 }
11}
12
13impl Default for Avc1 {
14 fn default() -> Self {
15 Self {
16 visual_sample_entry: Default::default(),
17 avcc: Some(Default::default())
18 }
19 }
20}
21
22#[cfg(test)]
23mod test {
24 use crate::bytes_read::Mp4Readable;
25 use crate::error::MP4Error;
26 use crate::header::BoxHeader;
27 use crate::mp4box::avc1::{Avc1Box};
28 use crate::mp4box::box_trait::{BoxRead, BoxWrite, IBox};
29
30 #[test]
31 pub fn test_rebuild() -> Result<(), MP4Error> {
32 type Box = Avc1Box;
33 futures::executor::block_on(async {
34 let base = Box::default();
35 let mut buf = vec![];
36 let mut cursor = std::io::Cursor::new(&mut buf);
37 let pos = base.write(&mut cursor)?;
38 assert_eq!(pos, base.byte_size());
39 assert_eq!(pos as u64, cursor.position());
40 let mut cursor = futures::io::Cursor::new(&mut buf);
41 let header = BoxHeader::read(&mut cursor).await?;
42 assert_eq!(header.id, Box::ID);
43 let new = Box::read(header, &mut cursor).await?;
44 assert_eq!(base, new);
45 Ok(())
46 })
47 }
48
49}