mp4_atom/moov/trak/mdia/minf/stbl/stsd/vp9/
vp08.rs

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