aboutsummaryrefslogtreecommitdiffstats
path: root/src/boxes/mdia.rs
blob: f18a8e998b2d8020777afe3de7dbe994c8a0696e (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
29
30
use four_cc::FourCC;

use bytes::BytesMut;

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

use super::{HandlerBox, MediaHeaderBox, MediaInformationBox};

pub struct MediaBox {
    pub mdhd: MediaHeaderBox,
    pub hdlr: HandlerBox,
    pub minf: MediaInformationBox,
}

impl Mp4Box for MediaBox {
    const NAME: FourCC = FourCC(*b"mdia");

    fn content_size(&self) -> u64 {
        self.mdhd.size() + self.hdlr.size() + self.minf.size()
    }

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

        Ok(())
    }
}