Bv2.1 8.4 We must have <Hash>es
authorCarl Hetherington <cth@carlh.net>
Fri, 15 Jan 2021 21:56:38 +0000 (22:56 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 17 Jan 2021 19:13:23 +0000 (20:13 +0100)
src/verify.cc
src/verify.h
test/verify_test.cc

index 01d2e786ff0fa78fc8ea103fe42f277a1b75d257..e02c573b5ace043c62afaf1b30f937fb694c76a1 100644 (file)
@@ -1084,6 +1084,10 @@ dcp::verify (
                                        if ((i->intrinsic_duration() * i->edit_rate().denominator / i->edit_rate().numerator) < 1) {
                                                notes.push_back (VerificationNote(VerificationNote::VERIFY_ERROR, VerificationNote::INTRINSIC_DURATION_TOO_SMALL, i->id()));
                                        }
+                                       auto mxf = dynamic_pointer_cast<ReelMXF>(i);
+                                       if (mxf && !mxf->hash()) {
+                                               notes.push_back ({VerificationNote::VERIFY_BV21_ERROR, VerificationNote::MISSING_HASH, i->id()});
+                                       }
                                }
 
                                if (dcp->standard() == dcp::SMPTE) {
@@ -1304,6 +1308,8 @@ dcp::note_to_string (dcp::VerificationNote note)
                return "Closed caption assets must have an <EntryPoint> tag.";
        case dcp::VerificationNote::CLOSED_CAPTION_ENTRY_POINT_NON_ZERO:
                return "Closed caption assets must have an <EntryPoint> of 0.";
+       case dcp::VerificationNote::MISSING_HASH:
+               return String::compose("An asset is missing a <Hash> tag: %1", note.note().get());
        }
 
        return "";
index 917d5e53b46320abe1c003ebc5b4c2346a16c800..5ba029c98bc80480034842d6ce1be119b98683cc 100644 (file)
@@ -151,6 +151,8 @@ public:
                MISSING_CLOSED_CAPTION_ENTRY_POINT,
                /** Closed caption MainSubtitle <EntryPoint> must be zero Bv2.1_8.3.2 */
                CLOSED_CAPTION_ENTRY_POINT_NON_ZERO,
+               /** <Hash> must be present for assets in CPLs */
+               MISSING_HASH,
        };
 
        VerificationNote (Type type, Code code)
index 3164793305b411e131ee1e60b026629d7f84ce0b..0b7faad59621c20c62a770813b345034317d25e7 100644 (file)
@@ -1902,3 +1902,28 @@ BOOST_AUTO_TEST_CASE (verify_text_entry_point)
                        }
                );
 }
+
+
+BOOST_AUTO_TEST_CASE (verify_assets_must_have_hashes)
+{
+       RNGFixer fix;
+
+       boost::filesystem::path const dir("build/test/verify_assets_must_have_hashes");
+       auto dcp = make_simple (dir);
+       dcp->write_xml (dcp::SMPTE);
+       BOOST_REQUIRE_EQUAL (dcp->cpls().size(), 1U);
+
+       {
+               BOOST_REQUIRE (dcp->cpls()[0]->file());
+               Editor e(dcp->cpls()[0]->file().get());
+               e.replace("<Hash>cb1OLhgHG9svy7G8hoTSPpltzhw=</Hash>", "");
+       }
+
+       check_verify_result (
+               {dir},
+               {
+                       { dcp::VerificationNote::VERIFY_ERROR, dcp::VerificationNote::CPL_HASH_INCORRECT },
+                       { dcp::VerificationNote::VERIFY_BV21_ERROR, dcp::VerificationNote::MISSING_HASH }
+               });
+}
+