@@ -752,6 +752,10 @@ pub struct MetadataBox {
752
752
pub sort_album_artist : Option < TryString > ,
753
753
/// The name of the composer to sort by 'soco'
754
754
pub sort_composer : Option < TryString > ,
755
+ /// XML metadata
756
+ pub xml : Option < TryString > ,
757
+ /// Binary XML metadata
758
+ pub bxml : Option < TryVec < u8 > > ,
755
759
}
756
760
757
761
/// Internal data structures.
@@ -763,6 +767,7 @@ pub struct MediaContext {
763
767
pub mvex : Option < MovieExtendsBox > ,
764
768
pub psshs : TryVec < ProtectionSystemSpecificHeaderBox > ,
765
769
pub userdata : Option < Result < UserdataBox > > ,
770
+ pub metadata : Option < Result < MetadataBox > > ,
766
771
}
767
772
768
773
/// An ISOBMFF item as described by an iloc box. For the sake of avoiding copies,
@@ -2307,6 +2312,11 @@ pub fn read_mp4<T: Read>(f: &mut T) -> Result<MediaContext> {
2307
2312
BoxType :: MovieBox => {
2308
2313
context = Some ( read_moov ( & mut b, context) ?) ;
2309
2314
}
2315
+ BoxType :: MetadataBox => {
2316
+ if let Some ( ctx) = & mut context {
2317
+ ctx. metadata = Some ( read_meta ( & mut b) ) ;
2318
+ }
2319
+ }
2310
2320
_ => skip_box_content ( & mut b) ?,
2311
2321
} ;
2312
2322
check_parser_state ! ( b. content) ;
@@ -2352,6 +2362,7 @@ fn read_moov<T: Read>(f: &mut BMFFBox<T>, context: Option<MediaContext>) -> Resu
2352
2362
mut mvex,
2353
2363
mut psshs,
2354
2364
mut userdata,
2365
+ mut metadata,
2355
2366
} = context. unwrap_or_default ( ) ;
2356
2367
2357
2368
let mut iter = f. box_iter ( ) ;
@@ -2394,6 +2405,7 @@ fn read_moov<T: Read>(f: &mut BMFFBox<T>, context: Option<MediaContext>) -> Resu
2394
2405
mvex,
2395
2406
psshs,
2396
2407
userdata,
2408
+ metadata,
2397
2409
} )
2398
2410
}
2399
2411
@@ -4058,13 +4070,31 @@ fn read_meta<T: Read>(src: &mut BMFFBox<T>) -> Result<MetadataBox> {
4058
4070
while let Some ( mut b) = iter. next_box ( ) ? {
4059
4071
match b. head . name {
4060
4072
BoxType :: MetadataItemListEntry => read_ilst ( & mut b, & mut meta) ?,
4073
+ BoxType :: MetadataXMLBox => read_xml_ ( & mut b, & mut meta) ?,
4074
+ BoxType :: MetadataBXMLBox => read_bxml ( & mut b, & mut meta) ?,
4061
4075
_ => skip_box_content ( & mut b) ?,
4062
4076
} ;
4063
4077
check_parser_state ! ( b. content) ;
4064
4078
}
4065
4079
Ok ( meta)
4066
4080
}
4067
4081
4082
+ /// Parse a XML box inside a meta box
4083
+ fn read_xml_ < T : Read > ( src : & mut BMFFBox < T > , meta : & mut MetadataBox ) -> Result < ( ) > {
4084
+ let ( _, _) = read_fullbox_extra ( src) ?;
4085
+ let size = src. content . limit ( ) ;
4086
+ meta. xml = Some ( read_buf ( & mut src. content , size) ?) ;
4087
+ Ok ( ( ) )
4088
+ }
4089
+
4090
+ /// Parse a Binary XML box inside a meta box
4091
+ fn read_bxml < T : Read > ( src : & mut BMFFBox < T > , meta : & mut MetadataBox ) -> Result < ( ) > {
4092
+ let ( _, _) = read_fullbox_extra ( src) ?;
4093
+ let size = src. content . limit ( ) ;
4094
+ meta. bxml = Some ( read_buf ( & mut src. content , size) ?) ;
4095
+ Ok ( ( ) )
4096
+ }
4097
+
4068
4098
/// Parse a metadata box inside a udta box
4069
4099
fn read_ilst < T : Read > ( src : & mut BMFFBox < T > , meta : & mut MetadataBox ) -> Result < ( ) > {
4070
4100
let mut iter = src. box_iter ( ) ;
0 commit comments