Add a note when verifying if the DCP refers to assets
authorCarl Hetherington <cth@carlh.net>
Tue, 12 May 2020 10:35:07 +0000 (12:35 +0200)
committerCarl Hetherington <cth@carlh.net>
Tue, 12 May 2020 11:12:48 +0000 (13:12 +0200)
that are not mentioned in its ASSETMAP (i.e. a VF).

src/dcp.cc
src/verify.cc
src/verify.h
test/verify_test.cc

index 09db952377e66ee7233dffe889e2e3b1c1fe91bf..2929b5d85bf81d45c2cdec4e92c10d6a60446e83 100644 (file)
@@ -256,8 +256,17 @@ DCP::read (list<dcp::VerificationNote>* notes, bool ignore_incorrect_picture_mxf
                }
        }
 
-       BOOST_FOREACH (shared_ptr<CPL> i, cpls ()) {
-               i->resolve_refs (other_assets);
+       resolve_refs (other_assets);
+
+       /* While we've got the ASSETMAP lets look and see if this DCP refers to things that are not in its ASSETMAP */
+       if (notes) {
+               BOOST_FOREACH (shared_ptr<CPL> i, cpls()) {
+                       BOOST_FOREACH (shared_ptr<const ReelMXF> j, i->reel_mxfs()) {
+                               if (!j->asset_ref().resolved() && paths.find(j->asset_ref().id()) == paths.end()) {
+                                       notes->push_back (VerificationNote(VerificationNote::VERIFY_WARNING, VerificationNote::EXTERNAL_ASSET));
+                               }
+                       }
+               }
        }
 }
 
index 11eb75d2188ec1b89522c12e26ea05d18d21305f..0820c7b0f6a4255b8a02adb1da980197abf8f8d5 100644 (file)
@@ -659,6 +659,8 @@ dcp::note_to_string (dcp::VerificationNote note)
                return String::compose("The instantaneous bit rate of the picture asset %1 is larger than the limit of 250Mbit/s in at least one place", note.file()->filename());
        case dcp::VerificationNote::PICTURE_FRAME_NEARLY_TOO_LARGE:
                return String::compose("The instantaneous bit rate of the picture asset %1 is close to the limit of 250Mbit/s in at least one place", note.file()->filename());
+       case dcp::VerificationNote::EXTERNAL_ASSET:
+               return "An asset that this DCP refers to is not included in the DCP.  It may be a VF.";
        }
 
        return "";
index 405c6b099574c754adea3b0359c8fd5c5c514610..87d52d44913375bd2e198b84b3fe43521d1a6a65 100644 (file)
@@ -87,6 +87,8 @@ public:
                PICTURE_FRAME_TOO_LARGE,
                /** The JPEG2000 data in at least one picture frame is larger than the equivalent of 230Mbit/s */
                PICTURE_FRAME_NEARLY_TOO_LARGE,
+               /** An asset that the CPL requires is not in this DCP; the DCP may be a VF */
+               EXTERNAL_ASSET,
        };
 
        VerificationNote (Type type, Code code)
index d744eff604c368559c0d95ffc3bbdc43c9dfd64b..4d577a5a04c968b54dc8ff9d7d6aabe214aae4c2 100644 (file)
@@ -735,3 +735,40 @@ BOOST_AUTO_TEST_CASE (verify_test21)
        BOOST_CHECK_EQUAL (notes.back().code(), dcp::VerificationNote::XML_VALIDATION_ERROR);
 }
 
+
+/* VF */
+BOOST_AUTO_TEST_CASE (verify_test22)
+{
+       boost::filesystem::path const ov_dir("build/test/verify_test22_ov");
+       boost::filesystem::remove_all (ov_dir);
+       boost::filesystem::create_directories (ov_dir);
+
+       shared_ptr<dcp::OpenJPEGImage> image = black_image ();
+       dcp::Data frame = dcp::compress_j2k (image, 100000000, 24, false, false);
+       BOOST_REQUIRE (frame.size() < 230000000 / (24 * 8));
+       dcp_from_frame (frame, ov_dir);
+
+       dcp::DCP ov (ov_dir);
+       ov.read ();
+
+       boost::filesystem::path const vf_dir("build/test/verify_test22_vf");
+       boost::filesystem::remove_all (vf_dir);
+       boost::filesystem::create_directories (vf_dir);
+
+       shared_ptr<dcp::Reel> reel(new dcp::Reel());
+       reel->add (ov.cpls().front()->reels().front()->main_picture());
+       shared_ptr<dcp::CPL> cpl(new dcp::CPL("hello", dcp::FEATURE));
+       cpl->add (reel);
+       dcp::DCP vf (vf_dir);
+       vf.add (cpl);
+       vf.write_xml (dcp::SMPTE);
+
+       vector<boost::filesystem::path> dirs;
+       dirs.push_back (vf_dir);
+       list<dcp::VerificationNote> notes = dcp::verify (dirs, &stage, &progress, "xsd");
+       dump_notes (notes);
+       BOOST_REQUIRE_EQUAL (notes.size(), 1);
+       BOOST_CHECK_EQUAL (notes.front().code(), dcp::VerificationNote::EXTERNAL_ASSET);
+}
+
+