aboutsummaryrefslogtreecommitdiffstats
path: root/src/boxes/moof.rs
blob: 7e028f53ea43ee33b5392ccf64cd2ce53b0fe943 (plain) (blame)
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
use four_cc::FourCC;

use bytes::BytesMut;

use crate::{Mp4Box, Mp4BoxError};

use super::{MovieFragmentHeaderBox, TrackFragmentBox};

pub struct MovieFragmentBox {
    pub mfhd: MovieFragmentHeaderBox,
    pub traf: TrackFragmentBox,
}

impl Mp4Box for MovieFragmentBox {
    const NAME: FourCC = FourCC(*b"moof");

    fn content_size(&self) -> u64 {
        self.mfhd.size() + self.traf.size()
    }

    fn write_box_contents(&self, writer: &mut BytesMut) -> Result<(), Mp4BoxError> {
        self.mfhd.write(writer)?;
        self.traf.write(writer)?;

        Ok(())
    }
}