From 03246708c1ee9c5331eac7d058627655939e30d1 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 20 Mar 2018 23:40:58 +0000 Subject: More DCP verification bits. --- src/dcp.h | 4 ++++ src/verify.cc | 48 +++++++++++++++++++++++++++++++++++++++++++++--- src/verify.h | 8 +++++++- 3 files changed, 56 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/dcp.h b/src/dcp.h index 811f62f6..752bd814 100644 --- a/src/dcp.h +++ b/src/dcp.h @@ -124,6 +124,10 @@ public: return _standard; } + boost::filesystem::path directory () const { + return _directory; + } + static std::vector directories_from_files (std::vector files); private: diff --git a/src/verify.cc b/src/verify.cc index 8f850e83..75cab01d 100644 --- a/src/verify.cc +++ b/src/verify.cc @@ -33,19 +33,37 @@ #include "verify.h" #include "dcp.h" +#include "cpl.h" +#include "reel.h" +#include "reel_picture_asset.h" +#include "reel_sound_asset.h" #include "exceptions.h" #include #include #include +#include using std::list; using std::vector; +using std::string; +using std::cout; using boost::shared_ptr; +using boost::optional; +using boost::function; using namespace dcp; +static bool +verify_asset (shared_ptr asset, function progress) +{ + string actual_hash = asset->asset_ref()->hash(progress); + optional cpl_hash = asset->hash(); + DCP_ASSERT (cpl_hash); + return actual_hash != *cpl_hash; +} + list -dcp::verify (vector directories) +dcp::verify (vector directories, function)> stage, function progress) { list notes; @@ -54,15 +72,39 @@ dcp::verify (vector directories) dcps.push_back (shared_ptr (new DCP (i))); } - BOOST_FOREACH (shared_ptr i, dcps) { + BOOST_FOREACH (shared_ptr dcp, dcps) { + stage ("Checking DCP", dcp->directory()); DCP::ReadErrors errors; try { - i->read (true, &errors); + dcp->read (true, &errors); } catch (DCPReadError& e) { notes.push_back (VerificationNote (VerificationNote::VERIFY_ERROR, e.what ())); } catch (XMLError& e) { notes.push_back (VerificationNote (VerificationNote::VERIFY_ERROR, e.what ())); } + + BOOST_FOREACH (shared_ptr cpl, dcp->cpls()) { + stage ("Checking CPL", cpl->file()); + BOOST_FOREACH (shared_ptr reel, cpl->reels()) { + stage ("Checking reel", optional()); + if (reel->main_picture()) { + stage ("Checking picture asset hash", reel->main_picture()->asset()->file()); + if (verify_asset (reel->main_picture(), progress)) { + notes.push_back (VerificationNote (VerificationNote::VERIFY_ERROR, "Picture asset hash is incorrect")); + } else { + cout << "pic ok.\n"; + } + } + if (reel->main_sound()) { + stage ("Checking sound asset hash", reel->main_sound()->asset()->file()); + if (verify_asset (reel->main_sound(), progress)) { + notes.push_back (VerificationNote (VerificationNote::VERIFY_ERROR, "Sound asset hash is incorrect")); + } else { + cout << "sounds ok.\n"; + } + } + } + } } return notes; diff --git a/src/verify.h b/src/verify.h index 3538722e..f5b21763 100644 --- a/src/verify.h +++ b/src/verify.h @@ -35,6 +35,8 @@ #define LIBDCP_VERIFY_H #include +#include +#include #include #include #include @@ -71,7 +73,11 @@ private: std::string _note; }; -std::list verify (std::vector directories); +std::list verify ( + std::vector directories, + boost::function)> stage, + boost::function progress + ); } -- cgit v1.2.3