isobmff/boxes/
volemetric_visual_media.rs

1use scuffle_bytes_util::zero_copy::{Deserialize, Serialize};
2
3use super::SampleEntry;
4use crate::{FullBoxHeader, IsoBox, IsoSized};
5
6/// Volumetric visual media header box
7///
8/// ISO/IEC 14496-12 - 12.10.2
9#[derive(IsoBox, Debug, PartialEq, Eq)]
10#[iso_box(box_type = b"vvhd", crate_path = crate)]
11pub struct VolumetricVisualMediaHeaderBox {
12    /// The full box header.
13    pub full_header: FullBoxHeader,
14    // empty
15}
16
17/// Volumetric visual sample entry
18///
19/// ISO/IEC 14496-12 - 12.10.3
20///
21/// Sub boxes:
22/// - [`btrt`](super::BitRateBox)
23/// - Any other boxes
24#[derive(Debug, PartialEq, Eq)]
25pub struct VolumetricVisualSampleEntry {
26    /// The sample entry that this box inherits from.
27    pub sample_entry: SampleEntry,
28    /// A name, for informative purposes. It is formatted in a fixed 32-byte field, with the
29    /// first byte set to the number of bytes to be displayed, followed by that number of bytes of displayable
30    /// data encoded using UTF-8, and then padding to complete 32 bytes total (including the size byte).
31    /// The field may be set to 0.
32    pub compressorname: [u8; 32],
33}
34
35impl<'a> Deserialize<'a> for VolumetricVisualSampleEntry {
36    fn deserialize<R>(mut reader: R) -> std::io::Result<Self>
37    where
38        R: scuffle_bytes_util::zero_copy::ZeroCopyReader<'a>,
39    {
40        let sample_entry = SampleEntry::deserialize(&mut reader)?;
41        let compressorname = <[u8; 32]>::deserialize(&mut reader)?;
42
43        Ok(Self {
44            sample_entry,
45            compressorname,
46        })
47    }
48}
49
50impl Serialize for VolumetricVisualSampleEntry {
51    fn serialize<W>(&self, mut writer: W) -> std::io::Result<()>
52    where
53        W: std::io::Write,
54    {
55        self.sample_entry.serialize(&mut writer)?;
56        self.compressorname.serialize(&mut writer)?;
57        Ok(())
58    }
59}
60
61impl IsoSized for VolumetricVisualSampleEntry {
62    fn size(&self) -> usize {
63        self.sample_entry.size() + self.compressorname.size()
64    }
65}