scuffle_h264/
boxes.rs

1//! ISO base media file format boxes for AVC/h264.
2//!
3//! ISO/IEC 14496-15 - 5.4
4
5use isobmff::boxes::{MPEG4ExtensionDescriptorsBox, VisualSampleEntry};
6use isobmff::{IsoBox, UnknownBox};
7
8use crate::AVCDecoderConfigurationRecord;
9
10/// AVC configuration box
11///
12/// ISO/IEC 14496-15 - 5.4.2
13#[derive(IsoBox, Debug, PartialEq, Eq)]
14#[iso_box(box_type = b"avcC")]
15pub struct AVCConfigurationBox<'a> {
16    /// The AVC decoder configuration record.
17    pub avc_config: AVCDecoderConfigurationRecord<'a>,
18}
19
20impl<'a> AVCConfigurationBox<'a> {
21    /// Creates a new AVC configuration box.
22    pub fn new(avc_config: AVCDecoderConfigurationRecord<'a>) -> Self {
23        Self { avc_config }
24    }
25}
26
27// This doesn't make sense to me, the following 4 box types (avc1 - avc4) are all the same
28
29/// AVC sample entry
30///
31/// ISO/IEC 14496-15 - 5.4.2
32#[derive(IsoBox, Debug, PartialEq, Eq)]
33#[iso_box(box_type = b"avc1")]
34pub struct AVCSampleEntry1<'a> {
35    /// The visual sample entry fields that this box inherits.
36    pub visual_sample_entry: VisualSampleEntry,
37    /// The AVC configuration box contained in this box.
38    #[iso_box(nested_box)]
39    pub config: AVCConfigurationBox<'a>,
40    /// The optional MPEG-4 extension descriptors box contained in this box.
41    #[iso_box(nested_box(collect))]
42    pub mpeg4_extension: Option<MPEG4ExtensionDescriptorsBox<'a>>,
43    /// Any other boxes contained in this box.
44    #[iso_box(nested_box(collect_unknown))]
45    pub sub_boxes: Vec<UnknownBox<'a>>,
46}
47
48/// AVC sample entry
49///
50/// ISO/IEC 14496-15 - 5.4.2
51#[derive(IsoBox, Debug, PartialEq, Eq)]
52#[iso_box(box_type = b"avc2")]
53pub struct AVCSampleEntry2<'a> {
54    /// The visual sample entry fields that this box inherits.
55    pub visual_sample_entry: VisualSampleEntry,
56    /// The AVC configuration box contained in this box.
57    #[iso_box(nested_box)]
58    pub config: AVCConfigurationBox<'a>,
59    /// The optional MPEG-4 extension descriptors box contained in this box.
60    #[iso_box(nested_box(collect))]
61    pub mpeg4_extension: Option<MPEG4ExtensionDescriptorsBox<'a>>,
62    /// Any other boxes contained in this box.
63    #[iso_box(nested_box(collect_unknown))]
64    pub sub_boxes: Vec<UnknownBox<'a>>,
65}
66
67/// AVC sample entry
68///
69/// ISO/IEC 14496-15 - 5.4.2
70#[derive(IsoBox, Debug, PartialEq, Eq)]
71#[iso_box(box_type = b"avc3")]
72pub struct AVCSampleEntry3<'a> {
73    /// The visual sample entry fields that this box inherits.
74    pub visual_sample_entry: VisualSampleEntry,
75    /// The AVC configuration box contained in this box.
76    #[iso_box(nested_box)]
77    pub config: AVCConfigurationBox<'a>,
78    /// The optional MPEG-4 extension descriptors box contained in this box.
79    #[iso_box(nested_box(collect))]
80    pub mpeg4_extension: Option<MPEG4ExtensionDescriptorsBox<'a>>,
81    /// Any other boxes contained in this box.
82    #[iso_box(nested_box(collect_unknown))]
83    pub sub_boxes: Vec<UnknownBox<'a>>,
84}
85
86/// AVC sample entry
87///
88/// ISO/IEC 14496-15 - 5.4.2
89#[derive(IsoBox, Debug, PartialEq, Eq)]
90#[iso_box(box_type = b"avc4")]
91pub struct AVCSampleEntry4<'a> {
92    /// The visual sample entry fields that this box inherits.
93    pub visual_sample_entry: VisualSampleEntry,
94    /// The AVC configuration box contained in this box.
95    #[iso_box(nested_box)]
96    pub config: AVCConfigurationBox<'a>,
97    /// The optional MPEG-4 extension descriptors box contained in this box.
98    #[iso_box(nested_box(collect))]
99    pub mpeg4_extension: Option<MPEG4ExtensionDescriptorsBox<'a>>,
100    /// Any other boxes contained in this box.
101    #[iso_box(nested_box(collect_unknown))]
102    pub sub_boxes: Vec<UnknownBox<'a>>,
103}
104
105/// AVC parameter sample entry
106///
107/// ISO/IEC 14496-15 - 5.4.3
108#[derive(IsoBox, Debug, PartialEq, Eq)]
109#[iso_box(box_type = b"avcp")]
110pub struct AVCParameterSampleEntry<'a> {
111    /// The visual sample entry fields that this box inherits.
112    pub visual_sample_entry: VisualSampleEntry,
113    /// The AVC configuration box contained in this box.
114    #[iso_box(nested_box)]
115    pub config: AVCConfigurationBox<'a>,
116    /// Any other boxes contained in this box.
117    #[iso_box(nested_box(collect_unknown))]
118    pub sub_boxes: Vec<UnknownBox<'a>>,
119}