diff --git a/src/mp4box/avc1.rs b/src/mp4box/avc1.rs index 2c1bba3..f051c6c 100644 --- a/src/mp4box/avc1.rs +++ b/src/mp4box/avc1.rs @@ -55,11 +55,11 @@ impl Avc1Box { impl Mp4Box for Avc1Box { fn box_type(&self) -> BoxType { - BoxType::Avc1Box + return self.get_type(); } fn box_size(&self) -> u64 { - HEADER_SIZE + 8 + 70 + self.avcc.box_size() + return self.get_size(); } } diff --git a/src/mp4box/co64.rs b/src/mp4box/co64.rs index cbb64f2..829acf8 100644 --- a/src/mp4box/co64.rs +++ b/src/mp4box/co64.rs @@ -22,11 +22,11 @@ impl Co64Box { impl Mp4Box for Co64Box { fn box_type(&self) -> BoxType { - BoxType::Co64Box + return self.get_type(); } fn box_size(&self) -> u64 { - HEADER_SIZE + HEADER_EXT_SIZE + 4 + (8 * self.entries.len() as u64) + return self.get_size(); } } diff --git a/src/mp4box/ctts.rs b/src/mp4box/ctts.rs index d794dd1..db0ccd3 100644 --- a/src/mp4box/ctts.rs +++ b/src/mp4box/ctts.rs @@ -28,11 +28,11 @@ pub struct CttsEntry { impl Mp4Box for CttsBox { fn box_type(&self) -> BoxType { - BoxType::CttsBox + return self.get_type(); } fn box_size(&self) -> u64 { - HEADER_SIZE + HEADER_EXT_SIZE + 4 + (8 * self.entries.len() as u64) + return self.get_size(); } } diff --git a/src/mp4box/edts.rs b/src/mp4box/edts.rs index 381c35b..2cd0d09 100644 --- a/src/mp4box/edts.rs +++ b/src/mp4box/edts.rs @@ -28,15 +28,11 @@ impl EdtsBox { impl Mp4Box for EdtsBox { fn box_type(&self) -> BoxType { - BoxType::EdtsBox + return self.get_type(); } fn box_size(&self) -> u64 { - let mut size = HEADER_SIZE; - if let Some(ref elst) = self.elst { - size += elst.box_size(); - } - size + return self.get_size(); } } diff --git a/src/mp4box/elst.rs b/src/mp4box/elst.rs index 6cec343..ebbbaf0 100644 --- a/src/mp4box/elst.rs +++ b/src/mp4box/elst.rs @@ -37,18 +37,11 @@ impl ElstBox { impl Mp4Box for ElstBox { fn box_type(&self) -> BoxType { - BoxType::ElstBox + return self.get_type(); } fn box_size(&self) -> u64 { - let mut size = HEADER_SIZE + HEADER_EXT_SIZE + 4; - if self.version == 1 { - size += self.entries.len() as u64 * 20; - } else { - assert_eq!(self.version, 0); - size += self.entries.len() as u64 * 12; - } - size + return self.get_size(); } } diff --git a/src/mp4box/ftyp.rs b/src/mp4box/ftyp.rs index 62d3dc2..dfdf524 100644 --- a/src/mp4box/ftyp.rs +++ b/src/mp4box/ftyp.rs @@ -22,11 +22,11 @@ impl FtypBox { impl Mp4Box for FtypBox { fn box_type(&self) -> BoxType { - BoxType::FtypBox + return self.get_type(); } fn box_size(&self) -> u64 { - HEADER_SIZE + 8 + (4 * self.compatible_brands.len() as u64) + return self.get_size(); } } diff --git a/src/mp4box/hdlr.rs b/src/mp4box/hdlr.rs index c7931aa..62d7a32 100644 --- a/src/mp4box/hdlr.rs +++ b/src/mp4box/hdlr.rs @@ -23,11 +23,11 @@ impl HdlrBox { impl Mp4Box for HdlrBox { fn box_type(&self) -> BoxType { - BoxType::HdlrBox + return self.get_type(); } fn box_size(&self) -> u64 { - HEADER_SIZE + HEADER_EXT_SIZE + 20 + self.name.len() as u64 + 1 + return self.get_size(); } } diff --git a/src/mp4box/mdhd.rs b/src/mp4box/mdhd.rs index e8563b0..7696088 100644 --- a/src/mp4box/mdhd.rs +++ b/src/mp4box/mdhd.rs @@ -50,20 +50,11 @@ impl Default for MdhdBox { impl Mp4Box for MdhdBox { fn box_type(&self) -> BoxType { - BoxType::MdhdBox + return self.get_type(); } fn box_size(&self) -> u64 { - let mut size = HEADER_SIZE + HEADER_EXT_SIZE; - - if self.version == 1 { - size += 28; - } else { - assert_eq!(self.version, 0); - size += 16; - } - size += 4; - size + return self.get_size(); } } diff --git a/src/mp4box/mdia.rs b/src/mp4box/mdia.rs index c1d4cb8..e8ea27a 100644 --- a/src/mp4box/mdia.rs +++ b/src/mp4box/mdia.rs @@ -22,11 +22,11 @@ impl MdiaBox { impl Mp4Box for MdiaBox { fn box_type(&self) -> BoxType { - BoxType::MdiaBox + return self.get_type(); } fn box_size(&self) -> u64 { - HEADER_SIZE + self.mdhd.box_size() + self.hdlr.box_size() + self.minf.box_size() + return self.get_size(); } } diff --git a/src/mp4box/minf.rs b/src/mp4box/minf.rs index b2f8547..1dad192 100644 --- a/src/mp4box/minf.rs +++ b/src/mp4box/minf.rs @@ -30,19 +30,11 @@ impl MinfBox { impl Mp4Box for MinfBox { fn box_type(&self) -> BoxType { - BoxType::MinfBox + return self.get_type(); } fn box_size(&self) -> u64 { - let mut size = HEADER_SIZE; - if let Some(ref vmhd) = self.vmhd { - size += vmhd.box_size(); - } - if let Some(ref smhd) = self.smhd { - size += smhd.box_size(); - } - size += self.stbl.box_size(); - size + return self.get_size(); } } diff --git a/src/mp4box/moov.rs b/src/mp4box/moov.rs index 41c2823..3a9cae5 100644 --- a/src/mp4box/moov.rs +++ b/src/mp4box/moov.rs @@ -25,15 +25,11 @@ impl MoovBox { impl Mp4Box for MoovBox { fn box_type(&self) -> BoxType { - BoxType::MoovBox + return self.get_type(); } fn box_size(&self) -> u64 { - let mut size = HEADER_SIZE + self.mvhd.box_size(); - for trak in self.traks.iter() { - size += trak.box_size(); - } - size + return self.get_size(); } } diff --git a/src/mp4box/mp4a.rs b/src/mp4box/mp4a.rs index b90ed37..8a44cff 100644 --- a/src/mp4box/mp4a.rs +++ b/src/mp4box/mp4a.rs @@ -50,15 +50,11 @@ impl Mp4aBox { impl Mp4Box for Mp4aBox { fn box_type(&self) -> BoxType { - BoxType::Mp4aBox + return self.get_type(); } fn box_size(&self) -> u64 { - let mut size = HEADER_SIZE + 8 + 20; - if let Some(ref esds) = self.esds { - size += esds.box_size(); - } - size + return self.get_size(); } } diff --git a/src/mp4box/mvhd.rs b/src/mp4box/mvhd.rs index ea5387d..377bab8 100644 --- a/src/mp4box/mvhd.rs +++ b/src/mp4box/mvhd.rs @@ -48,19 +48,11 @@ impl Default for MvhdBox { impl Mp4Box for MvhdBox { fn box_type(&self) -> BoxType { - BoxType::MvhdBox + return self.get_type(); } fn box_size(&self) -> u64 { - let mut size = HEADER_SIZE + HEADER_EXT_SIZE; - if self.version == 1 { - size += 28; - } else { - assert_eq!(self.version, 0); - size += 16; - } - size += 80; - size + return self.get_size(); } } diff --git a/src/mp4box/smhd.rs b/src/mp4box/smhd.rs index 1fc8f1b..454bea9 100644 --- a/src/mp4box/smhd.rs +++ b/src/mp4box/smhd.rs @@ -32,11 +32,11 @@ impl Default for SmhdBox { impl Mp4Box for SmhdBox { fn box_type(&self) -> BoxType { - BoxType::SmhdBox + return self.get_type(); } fn box_size(&self) -> u64 { - HEADER_SIZE + HEADER_EXT_SIZE + 4 + return self.get_size(); } } diff --git a/src/mp4box/stbl.rs b/src/mp4box/stbl.rs index 14c6310..0d37416 100644 --- a/src/mp4box/stbl.rs +++ b/src/mp4box/stbl.rs @@ -47,28 +47,11 @@ impl StblBox { impl Mp4Box for StblBox { fn box_type(&self) -> BoxType { - BoxType::StblBox + return self.get_type(); } fn box_size(&self) -> u64 { - let mut size = HEADER_SIZE; - size += self.stsd.box_size(); - size += self.stts.box_size(); - if let Some(ref ctts) = self.ctts { - size += ctts.box_size(); - } - if let Some(ref stss) = self.stss { - size += stss.box_size(); - } - size += self.stsc.box_size(); - size += self.stsz.box_size(); - if let Some(ref stco) = self.stco { - size += stco.box_size(); - } - if let Some(ref co64) = self.co64 { - size += co64.box_size(); - } - size + return self.get_size(); } } diff --git a/src/mp4box/stco.rs b/src/mp4box/stco.rs index ea86dfc..c63295a 100644 --- a/src/mp4box/stco.rs +++ b/src/mp4box/stco.rs @@ -22,11 +22,11 @@ impl StcoBox { impl Mp4Box for StcoBox { fn box_type(&self) -> BoxType { - BoxType::StcoBox + return self.get_type(); } fn box_size(&self) -> u64 { - HEADER_SIZE + HEADER_EXT_SIZE + 4 + (4 * self.entries.len() as u64) + return self.get_size(); } } diff --git a/src/mp4box/stsc.rs b/src/mp4box/stsc.rs index 228a10e..78b7686 100644 --- a/src/mp4box/stsc.rs +++ b/src/mp4box/stsc.rs @@ -30,11 +30,11 @@ pub struct StscEntry { impl Mp4Box for StscBox { fn box_type(&self) -> BoxType { - BoxType::StscBox + return self.get_type(); } fn box_size(&self) -> u64 { - HEADER_SIZE + HEADER_EXT_SIZE + 4 + (12 * self.entries.len() as u64) + return self.get_size(); } } diff --git a/src/mp4box/stsd.rs b/src/mp4box/stsd.rs index 64e1d08..d09da49 100644 --- a/src/mp4box/stsd.rs +++ b/src/mp4box/stsd.rs @@ -30,17 +30,11 @@ impl StsdBox { impl Mp4Box for StsdBox { fn box_type(&self) -> BoxType { - BoxType::StsdBox + return self.get_type(); } fn box_size(&self) -> u64 { - let mut size = HEADER_SIZE + HEADER_EXT_SIZE + 4; - if let Some(ref avc1) = self.avc1 { - size += avc1.box_size(); - } else if let Some(ref mp4a) = self.mp4a { - size += mp4a.box_size(); - } - size + return self.get_size(); } } diff --git a/src/mp4box/stss.rs b/src/mp4box/stss.rs index faffe65..6d60bd9 100644 --- a/src/mp4box/stss.rs +++ b/src/mp4box/stss.rs @@ -22,11 +22,11 @@ impl StssBox { impl Mp4Box for StssBox { fn box_type(&self) -> BoxType { - BoxType::StssBox + return self.get_type(); } fn box_size(&self) -> u64 { - HEADER_SIZE + HEADER_EXT_SIZE + 4 + (4 * self.entries.len() as u64) + return self.get_size(); } } diff --git a/src/mp4box/stsz.rs b/src/mp4box/stsz.rs index ad7dc83..78fc0e6 100644 --- a/src/mp4box/stsz.rs +++ b/src/mp4box/stsz.rs @@ -24,11 +24,11 @@ impl StszBox { impl Mp4Box for StszBox { fn box_type(&self) -> BoxType { - BoxType::StszBox + return self.get_type(); } fn box_size(&self) -> u64 { - HEADER_SIZE + HEADER_EXT_SIZE + 8 + (4 * self.sample_sizes.len() as u64) + return self.get_size(); } } diff --git a/src/mp4box/stts.rs b/src/mp4box/stts.rs index 192e6a6..bb46d5b 100644 --- a/src/mp4box/stts.rs +++ b/src/mp4box/stts.rs @@ -28,11 +28,11 @@ pub struct SttsEntry { impl Mp4Box for SttsBox { fn box_type(&self) -> BoxType { - BoxType::SttsBox + return self.get_type(); } fn box_size(&self) -> u64 { - HEADER_SIZE + HEADER_EXT_SIZE + 4 + (8 * self.entries.len() as u64) + return self.get_size(); } } diff --git a/src/mp4box/tkhd.rs b/src/mp4box/tkhd.rs index 022eb1a..9023269 100644 --- a/src/mp4box/tkhd.rs +++ b/src/mp4box/tkhd.rs @@ -79,19 +79,11 @@ impl TkhdBox { impl Mp4Box for TkhdBox { fn box_type(&self) -> BoxType { - BoxType::TkhdBox + return self.get_type(); } fn box_size(&self) -> u64 { - let mut size = HEADER_SIZE + HEADER_EXT_SIZE; - if self.version == 1 { - size += 32; - } else { - assert_eq!(self.version, 0); - size += 20; - } - size += 60; - size + return self.get_size(); } } diff --git a/src/mp4box/trak.rs b/src/mp4box/trak.rs index 95440cd..2c9724f 100644 --- a/src/mp4box/trak.rs +++ b/src/mp4box/trak.rs @@ -28,17 +28,11 @@ impl TrakBox { impl Mp4Box for TrakBox { fn box_type(&self) -> BoxType { - BoxType::TrakBox + return self.get_type(); } fn box_size(&self) -> u64 { - let mut size = HEADER_SIZE; - size += self.tkhd.box_size(); - if let Some(ref edts) = self.edts { - size += edts.box_size(); - } - size += self.mdia.box_size(); - size + return self.get_size(); } } diff --git a/src/mp4box/vmhd.rs b/src/mp4box/vmhd.rs index 0edb8b2..685a3eb 100644 --- a/src/mp4box/vmhd.rs +++ b/src/mp4box/vmhd.rs @@ -30,11 +30,11 @@ impl VmhdBox { impl Mp4Box for VmhdBox { fn box_type(&self) -> BoxType { - BoxType::VmhdBox + return self.get_type(); } fn box_size(&self) -> u64 { - HEADER_SIZE + HEADER_EXT_SIZE + 8 + return self.get_size(); } }