isobmff/boxes/
compressed_boxes.rs

1use scuffle_bytes_util::BytesCow;
2
3use super::{ExtendedTypeBox, MovieBox, MovieFragmentBox, SegmentIndexBox, SubsegmentIndexBox};
4use crate::{IsoBox, UnknownBox};
5
6/// Original file-type box
7///
8/// ISO/IEC 14496-12 - 8.19.5
9#[derive(IsoBox, Debug, PartialEq, Eq)]
10#[iso_box(box_type = b"otyp", crate_path = crate)]
11pub struct OriginalFileTypeBox<'a> {
12    /// The contained [`ExtendedTypeBox`]. (optional)
13    #[iso_box(nested_box(collect))]
14    pub etyp: Option<ExtendedTypeBox<'a>>,
15    /// A list of unknown boxes that were not recognized during deserialization.
16    #[iso_box(nested_box(collect_unknown))]
17    pub unknown_boxes: Vec<UnknownBox<'a>>,
18}
19
20/// Trait for compressed boxes.
21pub trait CompressedBox {
22    /// The uncompressed box type that this compressed box represents.
23    type UncompressedBox: IsoBox;
24}
25
26/// Compressed movie box
27///
28/// ISO/IEC 14496-12 - 8.19.6
29#[derive(IsoBox, Debug, PartialEq, Eq)]
30#[iso_box(box_type = b"!mov", crate_path = crate)]
31pub struct CompressedMovieBox<'a> {
32    /// The compressed payload of a box defined by the replacement_type type. This data
33    /// contains the compressed box payload excluding the BoxHeader field of the uncompressed box.
34    pub data: BytesCow<'a>,
35}
36
37impl<'a> CompressedBox for CompressedMovieBox<'a> {
38    type UncompressedBox = MovieBox<'a>;
39}
40
41/// Compressed movie fragment box
42///
43/// ISO/IEC 14496-12 - 8.19.7
44#[derive(IsoBox, Debug, PartialEq, Eq)]
45#[iso_box(box_type = b"!mof", crate_path = crate)]
46pub struct CompressedMovieFragmentBox<'a> {
47    /// The compressed payload of a box defined by the replacement_type type. This data
48    /// contains the compressed box payload excluding the BoxHeader field of the uncompressed box.
49    pub data: BytesCow<'a>,
50}
51
52impl<'a> CompressedBox for CompressedMovieFragmentBox<'a> {
53    type UncompressedBox = MovieFragmentBox<'a>;
54}
55
56/// Compressed segment index box
57///
58/// ISO/IEC 14496-12 - 8.19.8
59#[derive(IsoBox, Debug, PartialEq, Eq)]
60#[iso_box(box_type = b"!six", crate_path = crate)]
61pub struct CompressedSegmentIndexBox<'a> {
62    /// The compressed payload of a box defined by the replacement_type type. This data
63    /// contains the compressed box payload excluding the BoxHeader field of the uncompressed box.
64    pub data: BytesCow<'a>,
65}
66
67impl CompressedBox for CompressedSegmentIndexBox<'_> {
68    type UncompressedBox = SegmentIndexBox;
69}
70
71/// Compressed subsegment index box
72///
73/// ISO/IEC 14496-12 - 8.19.9
74#[derive(IsoBox, Debug, PartialEq, Eq)]
75#[iso_box(box_type = b"!ssx", crate_path = crate)]
76pub struct CompressedSubsegmentIndexBox<'a> {
77    /// The compressed payload of a box defined by the replacement_type type. This data
78    /// contains the compressed box payload excluding the BoxHeader field of the uncompressed box.
79    pub data: BytesCow<'a>,
80}
81
82impl CompressedBox for CompressedSubsegmentIndexBox<'_> {
83    type UncompressedBox = SubsegmentIndexBox;
84}