summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2023-01-01 21:14:30 +0100
committerCarl Hetherington <cth@carlh.net>2023-01-07 22:45:50 +0100
commit38bf41a1b3fc0228ea44f69b2f145a7fa2a9aabb (patch)
treeb676fb52374562694393937efbc47aa75206d1d9
parent356ca40b85676e9e0f07f24d0752b30f2d0e8565 (diff)
Check for multiple asset IDs in an ASSETMAP during verify.
-rw-r--r--src/verify.cc15
-rw-r--r--src/verify.h7
-rw-r--r--test/verify_test.cc33
3 files changed, 53 insertions, 2 deletions
diff --git a/src/verify.cc b/src/verify.cc
index b554612b..3c5d180a 100644
--- a/src/verify.cc
+++ b/src/verify.cc
@@ -1646,7 +1646,18 @@ verify_assetmap(
vector<VerificationNote>& notes
)
{
- validate_xml(dcp->asset_map_path().get(), xsd_dtd_directory, notes);
+ auto asset_map = dcp->asset_map();
+ DCP_ASSERT(asset_map);
+
+ validate_xml(asset_map->path().get(), xsd_dtd_directory, notes);
+
+ set<string> uuid_set;
+ for (auto const& asset: asset_map->assets()) {
+ if (!uuid_set.insert(asset.id()).second) {
+ notes.push_back({VerificationNote::Type::ERROR, VerificationNote::Code::DUPLICATE_ASSET_ID_IN_ASSETMAP, asset_map->id(), asset_map->path().get()});
+ break;
+ }
+ }
}
@@ -1925,6 +1936,8 @@ dcp::note_to_string (VerificationNote note)
return String::compose("<MainPictureActiveaArea> has an invalid value: %1", note.note().get());
case VerificationNote::Code::DUPLICATE_ASSET_ID_IN_PKL:
return String::compose("The PKL %1 has more than one asset with the same ID", note.note().get());
+ case VerificationNote::Code::DUPLICATE_ASSET_ID_IN_ASSETMAP:
+ return String::compose("The ASSETMAP %1 has more than one asset with the same ID", note.note().get());
}
return "";
diff --git a/src/verify.h b/src/verify.h
index d565abfa..e9b5c9d0 100644
--- a/src/verify.h
+++ b/src/verify.h
@@ -405,7 +405,12 @@ public:
* note contains the PKL ID
* file contains the PKL filename
*/
- DUPLICATE_ASSET_ID_IN_PKL
+ DUPLICATE_ASSET_ID_IN_PKL,
+ /** An ASSETMAP has more than one asset with the same ID
+ * note contains the ASSETMAP ID
+ * file contains the ASSETMAP filename
+ */
+ DUPLICATE_ASSET_ID_IN_ASSETMAP
};
VerificationNote (Type type, Code code)
diff --git a/test/verify_test.cc b/test/verify_test.cc
index 7791f8b5..652bf12d 100644
--- a/test/verify_test.cc
+++ b/test/verify_test.cc
@@ -988,6 +988,12 @@ find_pkl(path dir)
}
+path
+find_asset_map(path dir)
+{
+ return find_prefix(dir, "ASSETMAP");
+}
+
/* DCP with invalid CompositionMetadataAsset */
BOOST_AUTO_TEST_CASE (verify_invalid_cpl_metadata_bad_tag)
@@ -3366,3 +3372,30 @@ BOOST_AUTO_TEST_CASE(verify_duplicate_pkl_asset_ids)
});
}
+
+BOOST_AUTO_TEST_CASE(verify_duplicate_assetmap_asset_ids)
+{
+ RNGFixer rg;
+
+ path dir = "build/test/verify_duplicate_assetmap_asset_ids";
+ prepare_directory(dir);
+ auto dcp = make_simple(dir, 1, 24);
+ dcp->write_xml();
+
+ {
+ Editor e(find_asset_map(dir));
+ e.replace("urn:uuid:5407b210-4441-4e97-8b16-8bdc7c12da54", "urn:uuid:97f0f352-5b77-48ee-a558-9df37717f4fa");
+ }
+
+ dcp::PKL pkl(find_pkl(dir));
+ dcp::AssetMap asset_map(find_asset_map(dir));
+
+ check_verify_result(
+ { dir },
+ {
+ { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::MISMATCHED_PKL_ANNOTATION_TEXT_WITH_CPL, pkl.id(), canonical(find_pkl(dir)), },
+ { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::DUPLICATE_ASSET_ID_IN_ASSETMAP, asset_map.id(), canonical(find_asset_map(dir)) },
+ { dcp::VerificationNote::Type::WARNING, dcp::VerificationNote::Code::EXTERNAL_ASSET, string("5407b210-4441-4e97-8b16-8bdc7c12da54") },
+ });
+}
+