Skip to content

Commit 6b8902b

Browse files
committed
Adds unexpected field for all SampleEntry boxes
1 parent e8aa7ba commit 6b8902b

File tree

23 files changed

+222
-41
lines changed

23 files changed

+222
-41
lines changed

src/moov/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ mod test {
227227
colr: None,
228228
pasp: None,
229229
taic: None,
230+
#[cfg(feature = "fault-tolerant")]
231+
unexpected: vec![],
230232
}
231233
.into()],
232234
},

src/moov/trak/mdia/minf/stbl/stsd/ac3.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ use crate::*;
22

33
// See ETSI TS 102 366 V1.4.1 (2017-09) for details of AC-3 and EAC-3
44

5-
#[derive(Debug, Clone, PartialEq, Eq)]
5+
#[derive(Debug, Clone, PartialEq)]
66
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
77
pub struct Ac3 {
88
pub audio: Audio,
99
pub dac3: Ac3SpecificBox,
10+
#[cfg(feature = "fault-tolerant")]
11+
pub unexpected: Vec<Any>,
1012
}
1113

1214
impl Atom for Ac3 {
@@ -16,17 +18,25 @@ impl Atom for Ac3 {
1618
let audio = Audio::decode(buf)?;
1719

1820
let mut dac3 = None;
21+
#[cfg(feature = "fault-tolerant")]
22+
let mut unexpected = Vec::new();
1923

2024
while let Some(atom) = Any::decode_maybe(buf)? {
2125
match atom {
2226
Any::Ac3SpecificBox(atom) => dac3 = atom.into(),
23-
_ => tracing::warn!("unknown atom: {:?}", atom),
27+
_ => {
28+
tracing::warn!("unknown atom: {:?}", atom);
29+
#[cfg(feature = "fault-tolerant")]
30+
unexpected.push(atom);
31+
}
2432
}
2533
}
2634

2735
Ok(Self {
2836
audio,
2937
dac3: dac3.ok_or(Error::MissingBox(Ac3SpecificBox::KIND))?,
38+
#[cfg(feature = "fault-tolerant")]
39+
unexpected,
3040
})
3141
}
3242

@@ -120,7 +130,9 @@ mod tests {
120130
acmod: 2,
121131
lfeon: false,
122132
bit_rate_code: 10
123-
}
133+
},
134+
#[cfg(feature = "fault-tolerant")]
135+
unexpected: vec![],
124136
}
125137
);
126138
}
@@ -142,6 +154,8 @@ mod tests {
142154
lfeon: false,
143155
bit_rate_code: 10,
144156
},
157+
#[cfg(feature = "fault-tolerant")]
158+
unexpected: vec![],
145159
};
146160

147161
let mut buf = Vec::new();

src/moov/trak/mdia/minf/stbl/stsd/av01.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::{Any, Atom, Buf, BufMut, DecodeMaybe, Error, FourCC, Result};
33

44
use super::{Btrt, Colr, Pasp, Taic, Visual};
55

6-
#[derive(Debug, Clone, PartialEq, Eq, Default)]
6+
#[derive(Debug, Clone, PartialEq, Default)]
77
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
88
pub struct Av01 {
99
pub visual: Visual,
@@ -12,6 +12,8 @@ pub struct Av01 {
1212
pub colr: Option<Colr>,
1313
pub pasp: Option<Pasp>,
1414
pub taic: Option<Taic>,
15+
#[cfg(feature = "fault-tolerant")]
16+
pub unexpected: Vec<Any>,
1517
}
1618

1719
impl Atom for Av01 {
@@ -25,14 +27,21 @@ impl Atom for Av01 {
2527
let mut colr = None;
2628
let mut pasp = None;
2729
let mut taic = None;
30+
#[cfg(feature = "fault-tolerant")]
31+
let mut unexpected = Vec::new();
32+
2833
while let Some(atom) = Any::decode_maybe(buf)? {
2934
match atom {
3035
Any::Av1c(atom) => av1c = atom.into(),
3136
Any::Btrt(atom) => btrt = atom.into(),
3237
Any::Colr(atom) => colr = atom.into(),
3338
Any::Pasp(atom) => pasp = atom.into(),
3439
Any::Taic(atom) => taic = atom.into(),
35-
_ => tracing::warn!("unknown atom: {:?}", atom),
40+
_ => {
41+
tracing::warn!("unknown atom: {:?}", atom);
42+
#[cfg(feature = "fault-tolerant")]
43+
unexpected.push(atom);
44+
}
3645
}
3746
}
3847

@@ -43,6 +52,8 @@ impl Atom for Av01 {
4352
colr,
4453
pasp,
4554
taic,
55+
#[cfg(feature = "fault-tolerant")]
56+
unexpected,
4657
})
4758
}
4859

src/moov/trak/mdia/minf/stbl/stsd/eac3.rs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ use crate::*;
22

33
// See ETSI TS 102 366 V1.4.1 (2017-09) for details of AC-3 and EAC-3
44

5-
#[derive(Debug, Clone, PartialEq, Eq)]
5+
#[derive(Debug, Clone, PartialEq)]
66
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
77
pub struct Eac3 {
88
pub audio: Audio,
99
pub dec3: Ec3SpecificBox,
10+
#[cfg(feature = "fault-tolerant")]
11+
pub unexpected: Vec<Any>,
1012
}
1113

1214
impl Atom for Eac3 {
@@ -16,17 +18,25 @@ impl Atom for Eac3 {
1618
let audio = Audio::decode(buf)?;
1719

1820
let mut dec3 = None;
21+
#[cfg(feature = "fault-tolerant")]
22+
let mut unexpected = Vec::new();
1923

2024
while let Some(atom) = Any::decode_maybe(buf)? {
2125
match atom {
2226
Any::Ec3SpecificBox(atom) => dec3 = atom.into(),
23-
_ => tracing::warn!("unknown atom: {:?}", atom),
27+
_ => {
28+
tracing::warn!("unknown atom: {:?}", atom);
29+
#[cfg(feature = "fault-tolerant")]
30+
unexpected.push(atom);
31+
}
2432
}
2533
}
2634

2735
Ok(Self {
2836
audio,
2937
dec3: dec3.ok_or(Error::MissingBox(Ec3SpecificBox::KIND))?,
38+
#[cfg(feature = "fault-tolerant")]
39+
unexpected,
3040
})
3141
}
3242

@@ -180,7 +190,9 @@ mod tests {
180190
num_dep_sub: 0,
181191
chan_loc: None
182192
}]
183-
}
193+
},
194+
#[cfg(feature = "fault-tolerant")]
195+
unexpected: vec![],
184196
}
185197
);
186198
}
@@ -207,6 +219,8 @@ mod tests {
207219
chan_loc: None,
208220
}],
209221
},
222+
#[cfg(feature = "fault-tolerant")]
223+
unexpected: vec![],
210224
};
211225

212226
let mut buf = Vec::new();
@@ -238,6 +252,8 @@ mod tests {
238252
chan_loc: Some(0x1FF),
239253
}],
240254
},
255+
#[cfg(feature = "fault-tolerant")]
256+
unexpected: vec![],
241257
};
242258

243259
// Encode
@@ -287,6 +303,8 @@ mod tests {
287303
},
288304
],
289305
},
306+
#[cfg(feature = "fault-tolerant")]
307+
unexpected: vec![],
290308
};
291309

292310
// Encode
@@ -342,7 +360,9 @@ mod tests {
342360
num_dep_sub: 0,
343361
chan_loc: None
344362
}]
345-
}
363+
},
364+
#[cfg(feature = "fault-tolerant")]
365+
unexpected: vec![],
346366
}
347367
);
348368
}

src/moov/trak/mdia/minf/stbl/stsd/flac.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
use crate::*;
22

3-
#[derive(Debug, Clone, PartialEq, Eq)]
3+
#[derive(Debug, Clone, PartialEq)]
44
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
55
pub struct Flac {
66
pub audio: Audio,
77
pub dfla: Dfla,
8+
#[cfg(feature = "fault-tolerant")]
9+
pub unexpected: Vec<Any>,
810
}
911

1012
impl Atom for Flac {
@@ -14,16 +16,25 @@ impl Atom for Flac {
1416
let audio = Audio::decode(buf)?;
1517

1618
let mut dfla = None;
19+
#[cfg(feature = "fault-tolerant")]
20+
let mut unexpected = Vec::new();
21+
1722
while let Some(atom) = Any::decode_maybe(buf)? {
1823
match atom {
1924
Any::Dfla(atom) => dfla = atom.into(),
20-
_ => tracing::warn!("unknown atom: {:?}", atom),
25+
_ => {
26+
tracing::warn!("unknown atom: {:?}", atom);
27+
#[cfg(feature = "fault-tolerant")]
28+
unexpected.push(atom);
29+
}
2130
}
2231
}
2332

2433
Ok(Self {
2534
audio,
2635
dfla: dfla.ok_or(Error::MissingBox(Dfla::KIND))?,
36+
#[cfg(feature = "fault-tolerant")]
37+
unexpected,
2738
})
2839
}
2940

src/moov/trak/mdia/minf/stbl/stsd/h264/avc1.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::*;
22

3-
#[derive(Debug, Clone, PartialEq, Eq, Default)]
3+
#[derive(Debug, Clone, PartialEq, Default)]
44
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
55
pub struct Avc1 {
66
pub visual: Visual,
@@ -9,6 +9,9 @@ pub struct Avc1 {
99
pub colr: Option<Colr>,
1010
pub pasp: Option<Pasp>,
1111
pub taic: Option<Taic>,
12+
13+
#[cfg(feature = "fault-tolerant")]
14+
pub unexpected: Vec<Any>,
1215
}
1316

1417
impl Atom for Avc1 {
@@ -22,14 +25,22 @@ impl Atom for Avc1 {
2225
let mut colr = None;
2326
let mut pasp = None;
2427
let mut taic = None;
28+
29+
#[cfg(feature = "fault-tolerant")]
30+
let mut unexpected = Vec::new();
31+
2532
while let Some(atom) = Any::decode_maybe(buf)? {
2633
match atom {
2734
Any::Avcc(atom) => avcc = atom.into(),
2835
Any::Btrt(atom) => btrt = atom.into(),
2936
Any::Colr(atom) => colr = atom.into(),
3037
Any::Pasp(atom) => pasp = atom.into(),
3138
Any::Taic(atom) => taic = atom.into(),
32-
_ => tracing::warn!("unknown atom: {:?}", atom),
39+
_ => {
40+
tracing::warn!("unknown atom: {:?}", atom);
41+
#[cfg(feature = "fault-tolerant")]
42+
unexpected.push(atom)
43+
}
3344
}
3445
}
3546

@@ -40,6 +51,8 @@ impl Atom for Avc1 {
4051
colr,
4152
pasp,
4253
taic,
54+
#[cfg(feature = "fault-tolerant")]
55+
unexpected,
4356
})
4457
}
4558

@@ -96,6 +109,8 @@ mod tests {
96109
colr: None,
97110
pasp: None,
98111
taic: None,
112+
#[cfg(feature = "fault-tolerant")]
113+
unexpected: Vec::new(),
99114
};
100115
let mut buf = Vec::new();
101116
expected.encode(&mut buf).unwrap();
@@ -147,6 +162,8 @@ mod tests {
147162
clock_drift_rate: i32::MAX,
148163
clock_type: ClockType::CanSync,
149164
}),
165+
#[cfg(feature = "fault-tolerant")]
166+
unexpected: Vec::new(),
150167
};
151168
let mut buf = Vec::new();
152169
expected.encode(&mut buf).unwrap();

src/moov/trak/mdia/minf/stbl/stsd/hevc/hev1.rs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::*;
22

3-
#[derive(Debug, Clone, PartialEq, Eq, Default)]
3+
#[derive(Debug, Clone, PartialEq, Default)]
44
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
55
pub struct Hev1 {
66
pub visual: Visual,
@@ -9,6 +9,9 @@ pub struct Hev1 {
99
pub colr: Option<Colr>,
1010
pub pasp: Option<Pasp>,
1111
pub taic: Option<Taic>,
12+
13+
#[cfg(feature = "fault-tolerant")]
14+
pub unexpected: Vec<Any>,
1215
}
1316

1417
impl Atom for Hev1 {
@@ -22,14 +25,22 @@ impl Atom for Hev1 {
2225
let mut colr = None;
2326
let mut pasp = None;
2427
let mut taic = None;
28+
29+
#[cfg(feature = "fault-tolerant")]
30+
let mut unexpected = Vec::new();
31+
2532
while let Some(atom) = Any::decode_maybe(buf)? {
2633
match atom {
2734
Any::Hvcc(atom) => hvcc = atom.into(),
2835
Any::Btrt(atom) => btrt = atom.into(),
2936
Any::Colr(atom) => colr = atom.into(),
3037
Any::Pasp(atom) => pasp = atom.into(),
3138
Any::Taic(atom) => taic = atom.into(),
32-
_ => tracing::warn!("unknown atom: {:?}", atom),
39+
_ => {
40+
tracing::warn!("unknown atom: {:?}", atom);
41+
#[cfg(feature = "fault-tolerant")]
42+
unexpected.push(atom)
43+
}
3344
}
3445
}
3546

@@ -40,6 +51,8 @@ impl Atom for Hev1 {
4051
colr,
4152
pasp,
4253
taic,
54+
#[cfg(feature = "fault-tolerant")]
55+
unexpected,
4356
})
4457
}
4558

@@ -58,6 +71,10 @@ impl Atom for Hev1 {
5871
if self.taic.is_some() {
5972
self.taic.encode(buf)?
6073
}
74+
#[cfg(feature = "fault-tolerant")]
75+
for atom in &self.unexpected {
76+
atom.encode(buf)?;
77+
}
6178

6279
Ok(())
6380
}
@@ -84,10 +101,7 @@ mod tests {
84101
configuration_version: 1,
85102
..Default::default()
86103
},
87-
btrt: None,
88-
colr: None,
89-
pasp: None,
90-
taic: None,
104+
..Default::default()
91105
};
92106
let mut buf = Vec::new();
93107
expected.encode(&mut buf).unwrap();

0 commit comments

Comments
 (0)