Add verifier check for the actual asset file's ID not being the same as the one in...
authorCarl Hetherington <cth@carlh.net>
Sun, 25 Jun 2023 23:45:17 +0000 (01:45 +0200)
committerCarl Hetherington <cth@carlh.net>
Mon, 26 Jun 2023 22:09:54 +0000 (00:09 +0200)
src/dcp.cc
src/verify.cc
src/verify.h
test/verify_test.cc

index 7fa847987a2505e459b48b1e9de6f6c7c80344bf..0d0dc69087a37e4399812bc71180843c06bb274d 100644 (file)
@@ -253,7 +253,11 @@ DCP::read (vector<dcp::VerificationNote>* 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});
                        }
index b3fe83a28570d8b71dd7628877fad5feb2c26acf..394326fe24b08063a3c743ca0a404fa2eb8dcdc1 100644 (file)
@@ -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 <LoadFont> node", note.id().get());
        case VerificationNote::Code::MISSING_LOAD_FONT:
                return String::compose("The SMPTE subtitle asset %1 has <Text> nodes but no <LoadFont> 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 "";
index 0474dca2dfc000acf3e2903f863c9d67e7883a09..04c5d869d3a5c1bdbe2d406ffaab055f45408999 100644 (file)
@@ -456,7 +456,12 @@ public:
                /** A SMPTE subtitle asset has at least one <Text> element but no <LoadFont>
                 *  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 <class T>
@@ -573,6 +579,15 @@ public:
                return data<std::string>(Data::ID);
        }
 
+       VerificationNote& set_other_id(std::string other_id) {
+               _data[Data::OTHER_ID] = other_id;
+               return *this;
+       }
+
+       boost::optional<std::string> other_id() const {
+               return data<std::string>(Data::OTHER_ID);
+       }
+
 private:
        Type _type;
        Code _code;
index 310c1f81c5de9037d5a4b2221b854dc70d225b91..bc76de753b388b786c8eba8dfd6a9c0a845cc7e9 100644 (file)
@@ -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)
+               });
+}