summaryrefslogtreecommitdiff
path: root/src/verify.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-08-17 00:45:59 +0100
committerCarl Hetherington <cth@carlh.net>2018-08-17 00:46:19 +0100
commit01e08cb5fef34a33524e404ae8e2ad7d029d0a22 (patch)
treeb2512bdbb9376cf95b233ab58d0ecd25a86a55f1 /src/verify.cc
parent2f6087e528c1a48fed0ac7166b1ff8704684c87a (diff)
Use PKL when verifying DCPs.
Diffstat (limited to 'src/verify.cc')
-rw-r--r--src/verify.cc54
1 files changed, 46 insertions, 8 deletions
diff --git a/src/verify.cc b/src/verify.cc
index 87958ed9..1e8c3091 100644
--- a/src/verify.cc
+++ b/src/verify.cc
@@ -53,13 +53,35 @@ using boost::function;
using namespace dcp;
-static bool
-verify_asset (shared_ptr<ReelAsset> asset, function<void (float)> progress)
+enum Result {
+ RESULT_GOOD,
+ RESULT_CPL_PKL_DIFFER,
+ RESULT_BAD
+};
+
+static Result
+verify_asset (shared_ptr<DCP> dcp, shared_ptr<ReelAsset> reel_asset, function<void (float)> progress)
{
- string actual_hash = asset->asset_ref()->hash(progress);
- optional<string> cpl_hash = asset->hash();
- DCP_ASSERT (cpl_hash);
- return actual_hash != *cpl_hash;
+ string const actual_hash = reel_asset->asset_ref()->hash(progress);
+
+ shared_ptr<PKL> pkl = dcp->pkl();
+ /* We've read this DCP in so it must have a PKL */
+ DCP_ASSERT (pkl);
+
+ shared_ptr<Asset> asset = reel_asset->asset_ref().asset();
+ cout << "looking for hash of " << reel_asset->asset_ref()->id() << "\n";
+ string const pkl_hash = pkl->hash (reel_asset->asset_ref()->id());
+
+ optional<string> cpl_hash = reel_asset->hash();
+ if (cpl_hash && *cpl_hash != pkl_hash) {
+ return RESULT_CPL_PKL_DIFFER;
+ }
+
+ if (actual_hash != pkl_hash) {
+ return RESULT_BAD;
+ }
+
+ return RESULT_GOOD;
}
list<VerificationNote>
@@ -89,14 +111,30 @@ dcp::verify (vector<boost::filesystem::path> directories, function<void (string,
stage ("Checking reel", optional<boost::filesystem::path>());
if (reel->main_picture()) {
stage ("Checking picture asset hash", reel->main_picture()->asset()->file());
- if (verify_asset (reel->main_picture(), progress)) {
+ Result const r = verify_asset (dcp, reel->main_picture(), progress);
+ switch (r) {
+ case RESULT_BAD:
notes.push_back (VerificationNote (VerificationNote::VERIFY_ERROR, "Picture asset hash is incorrect."));
+ break;
+ case RESULT_CPL_PKL_DIFFER:
+ notes.push_back (VerificationNote (VerificationNote::VERIFY_ERROR, "PKL and CPL hashes differ for picture asset."));
+ break;
+ default:
+ break;
}
}
if (reel->main_sound()) {
stage ("Checking sound asset hash", reel->main_sound()->asset()->file());
- if (verify_asset (reel->main_sound(), progress)) {
+ Result const r = verify_asset (dcp, reel->main_sound(), progress);
+ switch (r) {
+ case RESULT_BAD:
notes.push_back (VerificationNote (VerificationNote::VERIFY_ERROR, "Sound asset hash is incorrect."));
+ break;
+ case RESULT_CPL_PKL_DIFFER:
+ notes.push_back (VerificationNote (VerificationNote::VERIFY_ERROR, "PKL and CPL hashes differ for sound asset."));
+ break;
+ default:
+ break;
}
}
}