Skip to content

Commit 3a94319

Browse files
committed
feat: impl supports_stream for c2pa_io
1 parent b2e32dd commit 3a94319

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

sdk/src/asset_handlers/c2pa_io.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ use std::{fs::File, path::Path};
1515

1616
use crate::{
1717
asset_io::{
18-
AssetIO, CAIRead, CAIReadWrite, CAIReader, CAIWriter, ComposedManifestRef,
18+
AssetIO, CAIRead, CAIReadWrapper, CAIReadWrite, CAIReader, CAIWriter, ComposedManifestRef,
1919
HashBlockObjectType, HashObjectPositions,
2020
},
2121
error::{Error, Result},
22+
jumbf::boxes::{self, BoxReader, Cai},
2223
};
2324

2425
static SUPPORTED_TYPES: [&str; 3] = [
@@ -128,9 +129,11 @@ impl AssetIO for C2paIO {
128129
&SUPPORTED_TYPES
129130
}
130131

131-
fn supports_stream(&self, _stream: &mut dyn CAIRead) -> Result<bool> {
132-
// TODO: complex
133-
Ok(true)
132+
fn supports_stream(&self, stream: &mut dyn CAIRead) -> Result<bool> {
133+
let super_box = BoxReader::read_super_box(&mut CAIReadWrapper { reader: stream })?;
134+
let cai_block = Cai::from(super_box);
135+
136+
Ok(cai_block.desc_box().uuid() == boxes::CAI_BLOCK_UUID)
134137
}
135138

136139
fn composed_data_ref(&self) -> Option<&dyn ComposedManifestRef> {

0 commit comments

Comments
 (0)