@@ -104,14 +104,24 @@ pub(crate) fn is_bmff_format(asset_type: &str) -> bool {
104104/// [Error::IncorrectFormat].
105105pub fn check_stream_supported ( asset_type : & str , stream : & mut dyn CAIRead ) -> Result < ( ) > {
106106 match get_assetio_handler ( asset_type) {
107- Some ( asset_handler) => {
108- if !asset_handler. supports_stream ( stream) ? {
109- Err ( Error :: IncorrectFormat ( asset_type. to_owned ( ) ) )
110- } else {
111- Ok ( ( ) )
112- }
113- }
114- None => Err ( Error :: IncorrectFormat ( asset_type. to_owned ( ) ) ) ,
107+ Some ( asset_handler) => match asset_handler. supports_stream ( stream) {
108+ // Failed to check if asset supports the stream.
109+ Err ( err) => Err ( Error :: IncorrectFormat {
110+ format : asset_type. to_owned ( ) ,
111+ source : Some ( Box :: new ( err) ) ,
112+ } ) ,
113+ // Did not fail, although the asset doesn't support the stream.
114+ Ok ( false ) => Err ( Error :: IncorrectFormat {
115+ format : asset_type. to_owned ( ) ,
116+ source : None ,
117+ } ) ,
118+ // Stream supported.
119+ Ok ( true ) => Ok ( ( ) ) ,
120+ } ,
121+ None => Err ( Error :: IncorrectFormat {
122+ format : asset_type. to_owned ( ) ,
123+ source : None ,
124+ } ) ,
115125 }
116126}
117127
@@ -530,8 +540,12 @@ pub mod tests {
530540 . unwrap ( ) ;
531541 removed. set_position ( 0 ) ;
532542 let result = load_jumbf_from_stream ( asset_type, & mut removed) ;
533- if ( asset_type != "wav" )
534- && ( asset_type != "avi" && asset_type != "mp3" && asset_type != "webp" )
543+ // For c2pa this is expected to return `Error::IncorrectFormat`.
544+ if asset_type != "wav"
545+ && asset_type != "avi"
546+ && asset_type != "mp3"
547+ && asset_type != "webp"
548+ && asset_type != "c2pa"
535549 {
536550 assert ! ( matches!( & result. err( ) . unwrap( ) , Error :: JumbfNotFound ) ) ;
537551 }
0 commit comments