From: Carl Hetherington Date: Sun, 25 Jun 2023 23:45:17 +0000 (+0200) Subject: Add verifier check for the actual asset file's ID not being the same as the one in... X-Git-Tag: v1.8.74~7 X-Git-Url: https://main.carlh.net/gitweb/?a=commitdiff_plain;h=c72e832423ceb81f30e8ca19bfeb87fca26298c1;p=libdcp.git Add verifier check for the actual asset file's ID not being the same as the one in the asset map. --- diff --git a/src/dcp.cc b/src/dcp.cc index 7fa84798..0d0dc690 100644 --- a/src/dcp.cc +++ b/src/dcp.cc @@ -253,7 +253,11 @@ DCP::read (vector* notes, bool ignore_incorrect_picture_m ) { bool found_threed_marked_as_twod = false; - other_assets.push_back (asset_factory(path, ignore_incorrect_picture_mxf_type, &found_threed_marked_as_twod)); + auto asset = asset_factory(path, ignore_incorrect_picture_mxf_type, &found_threed_marked_as_twod); + if (asset->id() != id) { + notes->push_back(VerificationNote(VerificationNote::Type::ERROR, VerificationNote::Code::MISMATCHED_ASSET_MAP_ID).set_id(id).set_other_id(asset->id())); + } + other_assets.push_back(asset); if (found_threed_marked_as_twod && notes) { notes->push_back ({VerificationNote::Type::WARNING, VerificationNote::Code::THREED_ASSET_MARKED_AS_TWOD, path}); } diff --git a/src/verify.cc b/src/verify.cc index b3fe83a2..394326fe 100644 --- a/src/verify.cc +++ b/src/verify.cc @@ -1449,6 +1449,7 @@ verify_reel( } } } + } if (reel->main_sound() && reel->main_sound()->asset_ref().resolved()) { @@ -2082,6 +2083,8 @@ dcp::note_to_string (VerificationNote note) return String::compose("A subtitle or closed caption refers to a font with ID %1 that does not have a corresponding node", note.id().get()); case VerificationNote::Code::MISSING_LOAD_FONT: return String::compose("The SMPTE subtitle asset %1 has nodes but no node", note.id().get()); + case VerificationNote::Code::MISMATCHED_ASSET_MAP_ID: + return String::compose("The asset with ID %1 in the asset map actually has an id of %2", note.id().get(), note.other_id().get()); } return ""; diff --git a/src/verify.h b/src/verify.h index 0474dca2..04c5d869 100644 --- a/src/verify.h +++ b/src/verify.h @@ -456,7 +456,12 @@ public: /** A SMPTE subtitle asset has at least one element but no * id contains the ID of the subtitle asset. */ - MISSING_LOAD_FONT + MISSING_LOAD_FONT, + /** An ID in an asset map does not match the ID obtained from reading the actual file. + * id contains the ID from the asset map. + * other_id contains the ID from the file. + */ + MISMATCHED_ASSET_MAP_ID, }; VerificationNote (Type type, Code code) @@ -512,6 +517,7 @@ private: COMPONENT, SIZE, ID, + OTHER_ID, }; template @@ -573,6 +579,15 @@ public: return data(Data::ID); } + VerificationNote& set_other_id(std::string other_id) { + _data[Data::OTHER_ID] = other_id; + return *this; + } + + boost::optional other_id() const { + return data(Data::OTHER_ID); + } + private: Type _type; Code _code; diff --git a/test/verify_test.cc b/test/verify_test.cc index 310c1f81..bc76de75 100644 --- a/test/verify_test.cc +++ b/test/verify_test.cc @@ -3723,3 +3723,27 @@ BOOST_AUTO_TEST_CASE(verify_missing_load_font) }); } + +BOOST_AUTO_TEST_CASE(verify_spots_wrong_asset) +{ + boost::filesystem::path const dir = "build/test/verify_spots_wrong_asset"; + boost::filesystem::remove_all(dir); + + auto dcp1 = make_simple(dir / "1"); + dcp1->write_xml(); + + auto const asset_1 = dcp::MonoPictureAsset(dir / "1" / "video.mxf").id(); + + auto dcp2 = make_simple(dir / "2"); + dcp2->write_xml(); + auto const asset_2 = dcp::MonoPictureAsset(dir / "2" / "video.mxf").id(); + + boost::filesystem::remove(dir / "1" / "video.mxf"); + boost::filesystem::copy_file(dir / "2" / "video.mxf", dir / "1" / "video.mxf"); + + check_verify_result( + {dir / "1"}, + { + dcp::VerificationNote(dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::MISMATCHED_ASSET_MAP_ID).set_id(asset_1).set_other_id(asset_2) + }); +}