More DCP verification detail and testing.
authorCarl Hetherington <cth@carlh.net>
Sun, 6 Jan 2019 19:30:00 +0000 (19:30 +0000)
committerCarl Hetherington <cth@carlh.net>
Sun, 6 Jan 2019 19:30:00 +0000 (19:30 +0000)
src/verify.cc
test/verify_test.cc

index bd61124c779303b9dad05ea2b766da1448706e35..2288200b720d2e742b5d24bc274407bda22bdded 100644 (file)
@@ -127,6 +127,18 @@ dcp::verify (vector<boost::filesystem::path> directories, function<void (string,
                        BOOST_FOREACH (shared_ptr<Reel> reel, cpl->reels()) {
                                stage ("Checking reel", optional<boost::filesystem::path>());
                                if (reel->main_picture()) {
+                                       /* Check reel stuff */
+                                       Fraction const frame_rate = reel->main_picture()->frame_rate();
+                                       if (frame_rate.denominator != 1 ||
+                                           (frame_rate.numerator != 24 &&
+                                            frame_rate.numerator != 25 &&
+                                            frame_rate.numerator != 30 &&
+                                            frame_rate.numerator != 48 &&
+                                            frame_rate.numerator != 50 &&
+                                            frame_rate.numerator != 60)) {
+                                               notes.push_back (VerificationNote (VerificationNote::VERIFY_ERROR, "Invalid frame rate for picture"));
+                                       }
+                                       /* Check asset */
                                        stage ("Checking picture asset hash", reel->main_picture()->asset()->file());
                                        Result const r = verify_asset (dcp, reel->main_picture(), progress);
                                        switch (r) {
index 58bc59781bd13bf9d1c256615ae29fa38be92eef..a7e703a21447c0de11df4fe635af16aeb4e6cd07 100644 (file)
@@ -128,7 +128,7 @@ BOOST_AUTO_TEST_CASE (verify_test2)
 
        list<dcp::VerificationNote> notes = dcp::verify (directories, &stage, &progress);
 
-       BOOST_CHECK_EQUAL (notes.size(), 2);
+       BOOST_REQUIRE_EQUAL (notes.size(), 2);
        BOOST_CHECK_EQUAL (notes.front().type(), dcp::VerificationNote::VERIFY_ERROR);
        BOOST_CHECK_EQUAL (notes.front().note(), "Picture asset hash is incorrect.");
        BOOST_CHECK_EQUAL (notes.back().type(), dcp::VerificationNote::VERIFY_ERROR);
@@ -178,6 +178,26 @@ BOOST_AUTO_TEST_CASE (verify_test4)
 
        list<dcp::VerificationNote> notes = dcp::verify (directories, &stage, &progress);
 
-       BOOST_CHECK_EQUAL (notes.size(), 1);
+       BOOST_REQUIRE_EQUAL (notes.size(), 1);
        BOOST_CHECK_EQUAL (notes.front().note(), "Bad content kind 'xfeature'");
 }
+
+/* FrameRate */
+BOOST_AUTO_TEST_CASE (verify_test5)
+{
+       vector<boost::filesystem::path> directories = setup (5);
+
+       boost::filesystem::path const cpl_file = "build/test/verify_test5/cpl_81fb54df-e1bf-4647-8788-ea7ba154375b.xml";
+
+       string cpl = dcp::file_to_string (cpl_file);
+       boost::algorithm::replace_all (cpl, "<FrameRate>24 1", "<FrameRate>99 1");
+       FILE* f = fopen(cpl_file.string().c_str(), "w");
+       fwrite(cpl.c_str(), cpl.length(), 1, f);
+       fclose(f);
+
+       list<dcp::VerificationNote> notes = dcp::verify (directories, &stage, &progress);
+
+       BOOST_REQUIRE_EQUAL (notes.size(), 2);
+       BOOST_CHECK_EQUAL (notes.front().note(), "CPL hash is incorrect.");
+       BOOST_CHECK_EQUAL (notes.back().note(), "Invalid frame rate for picture");
+}