mp4_atom/moov/trak/mdia/minf/stbl/stsd/hevc/
hvc1.rs

1use crate::*;
2
3#[derive(Debug, Clone, PartialEq, Eq, Default)]
4#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
5pub struct Hvc1 {
6    pub visual: Visual,
7    pub hvcc: Hvcc,
8    // TODO support SPS/PPS/VPS atoms
9}
10
11impl Atom for Hvc1 {
12    const KIND: FourCC = FourCC::new(b"hvc1");
13
14    fn decode_body<B: Buf>(buf: &mut B) -> Result<Self> {
15        let visual = Visual::decode(buf)?;
16
17        let mut hvcc = None;
18        while let Some(atom) = Any::decode_maybe(buf)? {
19            match atom {
20                Any::Hvcc(atom) => hvcc = atom.into(),
21                _ => tracing::warn!("unknown atom: {:?}", atom),
22            }
23        }
24
25        Ok(Self {
26            visual,
27            hvcc: hvcc.ok_or(Error::MissingBox(Hvcc::KIND))?,
28        })
29    }
30
31    fn encode_body<B: BufMut>(&self, buf: &mut B) -> Result<()> {
32        self.visual.encode(buf)?;
33        self.hvcc.encode(buf)?;
34
35        Ok(())
36    }
37}