aboutsummaryrefslogtreecommitdiffstats
path: root/src/boxes/mfhd.rs
blob: f5235c2d2ecdcf08711f70c59e13f488b06b3548 (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
31
32
use byteorder::{BigEndian, ByteOrder};
use four_cc::FourCC;

use bytes::{BufMut, BytesMut};

use crate::Mp4BoxError;
use crate::{FullBoxHeader, Mp4Box};

pub struct MovieFragmentHeaderBox {
    pub sequence_number: u32,
}

impl Mp4Box for MovieFragmentHeaderBox {
    const NAME: FourCC = FourCC(*b"mfhd");

    fn get_full_box_header(&self) -> Option<FullBoxHeader> {
        Some(FullBoxHeader::new(0, 0))
    }

    fn content_size(&self) -> u64 {
        4
    }

    fn write_box_contents(&self, writer: &mut BytesMut) -> Result<(), Mp4BoxError> {
        let mut contents = [0u8; 4];
        BigEndian::write_u32(&mut contents, self.sequence_number);

        writer.put_slice(&contents);

        Ok(())
    }
}