Skip to main content

mp4_atom/moov/trak/mdia/minf/stbl/stsd/
st3d.rs

1use crate::*;
2
3use super::spatial::ignore_trailing;
4
5/// Stereoscopic 3D Video Box, [Spherical Video V2](https://github.com/google/spatial-media/blob/master/docs/spherical-video-v2-rfc.md#stereoscopic-3d-video-box-st3d).
6///
7/// `stereo_mode` is kept as the wire byte so reserved values round-trip.
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
9#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
10pub struct St3d {
11    pub stereo_mode: u8,
12}
13
14impl St3d {
15    pub const MONO: u8 = 0;
16    /// Left eye on top.
17    pub const TOP_BOTTOM: u8 = 1;
18    /// Left eye on the left.
19    pub const LEFT_RIGHT: u8 = 2;
20    /// Both eyes, in a layout signalled elsewhere: for example by an `mshp`
21    /// with one mesh per eye.
22    pub const STEREO_CUSTOM: u8 = 3;
23    /// Right eye on the left.
24    pub const RIGHT_LEFT: u8 = 4;
25}
26
27impl AtomExt for St3d {
28    type Ext = FullBoxV0;
29
30    const KIND_EXT: FourCC = FourCC::new(b"st3d");
31
32    fn decode_body_ext<B: Buf>(buf: &mut B, _ext: FullBoxV0) -> Result<Self> {
33        let stereo_mode = u8::decode(buf)?;
34        ignore_trailing(Self::KIND_EXT, buf);
35        Ok(St3d { stereo_mode })
36    }
37
38    fn encode_body_ext<B: BufMut>(&self, buf: &mut B) -> Result<FullBoxV0> {
39        self.stereo_mode.encode(buf)?;
40        Ok(FullBoxV0)
41    }
42}