11use 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 ) ) ]
55pub 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
1417impl 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 ( ) ;
0 commit comments