aboutsummaryrefslogtreecommitdiffstats
path: root/src/boxes/trak.rs
blob: bb3630fda5397dec42c3a0509ee00c607430cac9 (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
28
use four_cc::FourCC;

use bytes::BytesMut;

use crate::Mp4Box;
use crate::Mp4BoxError;

use super::{MediaBox, TrackHeaderBox};

pub struct TrackBox {
    pub tkhd: TrackHeaderBox,
    pub mdia: MediaBox,
}

impl Mp4Box for TrackBox {
    const NAME: FourCC = FourCC(*b"trak");

    fn content_size(&self) -> u64 {
        self.tkhd.size() + self.mdia.size()
    }

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

        Ok(())
    }
}