summaryrefslogtreecommitdiff
path: root/src/verify.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2019-01-12 23:12:46 +0000
committerCarl Hetherington <cth@carlh.net>2019-01-12 23:12:46 +0000
commit7e4e6be3628308b7b16c015e2f87b27e729258dc (patch)
tree0d190200906496895c36a065a85add863e26e141 /src/verify.cc
parent9d183b0d37c02279cefad1deb5b73a2b5c9bb6e2 (diff)
Move verify API away from strings towards error codes.
Diffstat (limited to 'src/verify.cc')
-rw-r--r--src/verify.cc27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/verify.cc b/src/verify.cc
index 2288200b..4a656874 100644
--- a/src/verify.cc
+++ b/src/verify.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2018-2019 Carl Hetherington <cth@carlh.net>
This file is part of libdcp.
@@ -38,6 +38,7 @@
#include "reel_picture_asset.h"
#include "reel_sound_asset.h"
#include "exceptions.h"
+#include "compose.hpp"
#include <boost/foreach.hpp>
#include <list>
#include <vector>
@@ -108,9 +109,9 @@ dcp::verify (vector<boost::filesystem::path> directories, function<void (string,
try {
dcp->read (true, &errors);
} catch (DCPReadError& e) {
- notes.push_back (VerificationNote (VerificationNote::VERIFY_ERROR, e.what ()));
+ notes.push_back (VerificationNote(VerificationNote::VERIFY_ERROR, VerificationNote::GENERAL_READ, string(e.what())));
} catch (XMLError& e) {
- notes.push_back (VerificationNote (VerificationNote::VERIFY_ERROR, e.what ()));
+ notes.push_back (VerificationNote(VerificationNote::VERIFY_ERROR, VerificationNote::GENERAL_READ, string(e.what())));
}
BOOST_FOREACH (shared_ptr<CPL> cpl, dcp->cpls()) {
@@ -120,7 +121,7 @@ dcp::verify (vector<boost::filesystem::path> directories, function<void (string,
BOOST_FOREACH (shared_ptr<PKL> i, dcp->pkls()) {
optional<string> h = i->hash(cpl->id());
if (h && make_digest(Data(*cpl->file())) != *h) {
- notes.push_back (VerificationNote(VerificationNote::VERIFY_ERROR, "CPL hash is incorrect."));
+ notes.push_back (VerificationNote(VerificationNote::VERIFY_ERROR, VerificationNote::CPL_HASH_INCORRECT));
}
}
@@ -136,17 +137,21 @@ dcp::verify (vector<boost::filesystem::path> directories, function<void (string,
frame_rate.numerator != 48 &&
frame_rate.numerator != 50 &&
frame_rate.numerator != 60)) {
- notes.push_back (VerificationNote (VerificationNote::VERIFY_ERROR, "Invalid frame rate for picture"));
+ notes.push_back (VerificationNote(VerificationNote::VERIFY_ERROR, VerificationNote::INVALID_PICTURE_FRAME_RATE));
}
/* Check asset */
stage ("Checking picture asset hash", reel->main_picture()->asset()->file());
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."));
+ notes.push_back (
+ VerificationNote(
+ VerificationNote::VERIFY_ERROR, VerificationNote::PICTURE_HASH_INCORRECT, *reel->main_picture()->asset()->file()
+ )
+ );
break;
case RESULT_CPL_PKL_DIFFER:
- notes.push_back (VerificationNote (VerificationNote::VERIFY_ERROR, "PKL and CPL hashes differ for picture asset."));
+ notes.push_back (VerificationNote(VerificationNote::VERIFY_ERROR, VerificationNote::PKL_CPL_PICTURE_HASHES_DISAGREE));
break;
default:
break;
@@ -157,10 +162,14 @@ dcp::verify (vector<boost::filesystem::path> directories, function<void (string,
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."));
+ notes.push_back (
+ VerificationNote(
+ VerificationNote::VERIFY_ERROR, VerificationNote::SOUND_HASH_INCORRECT, *reel->main_sound()->asset()->file()
+ )
+ );
break;
case RESULT_CPL_PKL_DIFFER:
- notes.push_back (VerificationNote (VerificationNote::VERIFY_ERROR, "PKL and CPL hashes differ for sound asset."));
+ notes.push_back (VerificationNote (VerificationNote::VERIFY_ERROR, VerificationNote::PKL_CPL_SOUND_HASHES_DISAGREE));
break;
default:
break;