isobmff/boxes/
hint_media.rs

1use std::io;
2
3use scuffle_bytes_util::zero_copy::{Deserialize, Serialize, ZeroCopyReader};
4
5use super::SampleEntry;
6use crate::{FullBoxHeader, IsoBox, IsoSized};
7
8/// Hint media header box
9///
10/// ISO/IEC 14496-12 - 12.4.3
11#[derive(IsoBox, Debug, PartialEq, Eq)]
12#[iso_box(box_type = b"hmhd", crate_path = crate)]
13pub struct HintMediaHeaderBox {
14    /// The full box header.
15    pub full_header: FullBoxHeader,
16    /// The size in bytes of the largest PDU in this (hint) stream.
17    pub max_pdu_size: u16,
18    /// The average size of a PDU over the entire presentation.
19    pub avg_pdu_size: u16,
20    /// The maximum rate in bits/second over any window of one second.
21    pub maxbitrate: u32,
22    /// The average rate in bits/second over the entire presentation.
23    pub avgbitrate: u32,
24    /// Reserved 32 bits, must be set to zero.
25    pub reserved: u32,
26}
27
28/// Hint sample entry
29///
30/// ISO/IEC 14496-12 - 12.4.4
31///
32/// Sub boxes:
33/// - [`btrt`](super::BitRateBox)
34/// - Any other boxes
35#[derive(Debug, PartialEq, Eq)]
36pub struct HintSampleEntry {
37    /// The sample entry that this box inherits from.
38    pub sample_entry: SampleEntry,
39}
40
41impl<'a> Deserialize<'a> for HintSampleEntry {
42    fn deserialize<R: ZeroCopyReader<'a>>(reader: R) -> io::Result<Self> {
43        let sample_entry = SampleEntry::deserialize(reader)?;
44        Ok(HintSampleEntry { sample_entry })
45    }
46}
47
48impl Serialize for HintSampleEntry {
49    fn serialize<W: io::Write>(&self, writer: W) -> io::Result<()> {
50        self.sample_entry.serialize(writer)
51    }
52}
53
54impl IsoSized for HintSampleEntry {
55    fn size(&self) -> usize {
56        self.sample_entry.size()
57    }
58}