1
0
Fork 0
mirror of https://github.com/alfg/mp4-rust.git synced 2024-05-08 19:43:03 +00:00

Fix some minor issues writing traf box (#109)

Co-authored-by: Alfred Gutierrez <alfg@users.noreply.github.com>
This commit is contained in:
jensenn 2023-08-02 22:02:05 -06:00 committed by GitHub
parent 85b8209d5e
commit df92ac893c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View file

@ -22,6 +22,8 @@ impl TfhdBox {
pub const FLAG_DEFAULT_SAMPLE_DURATION: u32 = 0x08;
pub const FLAG_DEFAULT_SAMPLE_SIZE: u32 = 0x10;
pub const FLAG_DEFAULT_SAMPLE_FLAGS: u32 = 0x20;
pub const FLAG_DURATION_IS_EMPTY: u32 = 0x10000;
pub const FLAG_DEFAULT_BASE_IS_MOOF: u32 = 0x20000;
pub fn get_type(&self) -> BoxType {
BoxType::TfhdBox

View file

@ -19,6 +19,9 @@ impl TrafBox {
pub fn get_size(&self) -> u64 {
let mut size = HEADER_SIZE;
size += self.tfhd.box_size();
if let Some(ref tfdt) = self.tfdt {
size += tfdt.box_size();
}
if let Some(ref trun) = self.trun {
size += trun.box_size();
}
@ -104,6 +107,12 @@ impl<W: Write> WriteBox<&mut W> for TrafBox {
BoxHeader::new(self.box_type(), size).write(writer)?;
self.tfhd.write_box(writer)?;
if let Some(ref tfdt) = self.tfdt {
tfdt.write_box(writer)?;
}
if let Some(ref trun) = self.trun {
trun.write_box(writer)?;
}
Ok(size)
}