Skip to content

Commit

Permalink
Merge branch 'main' into gpeacock/makefile_fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
gpeacock authored Aug 9, 2022
2 parents b3940e1 + 61905cf commit 0921279
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
14 changes: 9 additions & 5 deletions sdk/src/asset_handlers/bmff_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,13 @@ impl AssetIO for BmffIO {
&mut bmff_map,
)?;

// get ftyp location
// start after ftyp
let ftyp_token = bmff_map.get("/ftyp").ok_or(Error::UnsupportedType)?; // todo check ftyps to make sure we supprt any special format requirements
let ftyp_info = &bmff_tree[ftyp_token[0]].data;
let ftyp_offset = ftyp_info.offset;
let ftyp_size = ftyp_info.size;

// get position to insert c2pa
let (c2pa_start, c2pa_length) = if let Some(uuid_tokens) = bmff_map.get("/uuid") {
let uuid_info = &bmff_tree[uuid_tokens[0]].data;
Expand All @@ -919,13 +926,10 @@ impl AssetIO for BmffIO {
if is_c2pa {
(uuid_info.offset, Some(uuid_info.size))
} else {
(0, None)
((ftyp_offset + ftyp_size), None)
}
} else {
// start after ftyp
let ftyp_token = bmff_map.get("/ftyp").ok_or(Error::UnsupportedType)?; // todo check ftyps to make sure we supprt any special format requirements
let ftyp_info = &bmff_tree[ftyp_token[0]].data;
((ftyp_info.offset + ftyp_info.size), None)
((ftyp_offset + ftyp_size), None)
};

let mut new_c2pa_box: Vec<u8> = Vec::with_capacity(store_bytes.len() * 2);
Expand Down
27 changes: 19 additions & 8 deletions sdk/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2820,18 +2820,29 @@ pub mod tests {
}

#[test]
#[cfg(feature = "bmff")]
fn test_bmff() {
#[cfg(feature = "file_io")]
fn test_bmff_jumbf_generation() {
// test adding to actual image
let ap = fixture_path("video1.mp4");
let mut report = DetailedStatusTracker::new();
let store = Store::load_from_asset(&ap, true, &mut report).expect("load_from_asset");
let temp_dir = tempdir().expect("temp dir");
let op = temp_dir_path(&temp_dir, "video1.mp4");

let errors = report_split_errors(report.get_log_mut());
// Create claims store.
let mut store = Store::new();

println!("Error report for {}: {:?}", ap.as_display(), errors);
assert!(errors.is_empty());
// Create a new claim.
let claim1 = create_test_claim().unwrap();

println!("store = {}", store);
let signer = temp_signer();

// Move the claim to claims list.
store.commit_claim(claim1).unwrap();
store.save_to_asset(&ap, &signer, &op).unwrap();

let mut report = DetailedStatusTracker::new();

// can we read back in
let _new_store = Store::load_from_asset(&op, true, &mut report).unwrap();
}

#[test]
Expand Down
Binary file modified sdk/tests/fixtures/video1.mp4
Binary file not shown.

0 comments on commit 0921279

Please sign in to comment.