/*
- Copyright (C) 2019 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
This file is part of libdcp.
*/
#include "verify.h"
+#include "compose.hpp"
+#include "common.h"
#include <boost/bind.hpp>
#include <boost/optional.hpp>
#include <boost/filesystem.hpp>
-#include <boost/foreach.hpp>
#include <getopt.h>
#include <iostream>
#include <cstdlib>
help (string n)
{
cerr << "Syntax: " << n << " [OPTION] <DCP>\n"
- << " -V, --version show libdcp version\n"
- << " -h, --help show this help\n";
+ << " -V, --version show libdcp version\n"
+ << " -h, --help show this help\n"
+ << " --ignore-missing-assets don't give errors about missing assets\n"
+ << " --ignore-bv21-smpte don't give the SMPTE Bv2.1 error about a DCP not being SMPTE\n"
+ << " -q, --quiet don't report progress\n";
}
void
-stage (string s, optional<boost::filesystem::path> path)
+stage (bool quiet, string s, optional<boost::filesystem::path> path)
{
+ if (quiet) {
+ return;
+ }
+
if (path) {
cout << s << ": " << path->string() << "\n";
} else {
int
main (int argc, char* argv[])
{
+ dcp::init ();
+
+ bool ignore_missing_assets = false;
+ bool ignore_bv21_smpte = false;
+ bool quiet = false;
+
int option_index = 0;
while (true) {
static struct option long_options[] = {
- { "version", no_argument, 0, 'V'},
- { "help", no_argument, 0, 'h'},
+ { "version", no_argument, 0, 'V' },
+ { "help", no_argument, 0, 'h' },
+ { "ignore-missing-assets", no_argument, 0, 'A' },
+ { "ignore-bv21-smpte", no_argument, 0, 'B' },
+ { "quiet", no_argument, 0, 'q' },
{ 0, 0, 0, 0 }
};
- int c = getopt_long (argc, argv, "Vh", long_options, &option_index);
+ int c = getopt_long (argc, argv, "VhABq", long_options, &option_index);
if (c == -1) {
break;
case 'h':
help (argv[0]);
exit (EXIT_SUCCESS);
+ case 'A':
+ ignore_missing_assets = true;
+ break;
+ case 'B':
+ ignore_bv21_smpte = true;
+ break;
+ case 'q':
+ quiet = true;
+ break;
}
}
vector<boost::filesystem::path> directories;
directories.push_back (argv[optind]);
- list<dcp::VerificationNote> notes = dcp::verify (directories, bind(&stage, _1, _2), bind(&progress));
+ auto notes = dcp::verify (directories, bind(&stage, quiet, _1, _2), bind(&progress));
+ dcp::filter_notes (notes, ignore_missing_assets);
bool failed = false;
- BOOST_FOREACH (dcp::VerificationNote i, notes) {
+ for (auto i: notes) {
+ if (ignore_bv21_smpte && i.code() == dcp::VerificationNote::Code::INVALID_STANDARD) {
+ continue;
+ }
switch (i.type()) {
- case dcp::VerificationNote::VERIFY_ERROR:
- cout << "Error: " << i.note() << "\n";
+ case dcp::VerificationNote::Type::ERROR:
+ cout << "Error: " << note_to_string(i) << "\n";
failed = true;
break;
- case dcp::VerificationNote::VERIFY_WARNING:
- cout << "Warning: " << i.note() << "\n";
+ case dcp::VerificationNote::Type::BV21_ERROR:
+ cout << "Bv2.1 error: " << note_to_string(i) << "\n";
break;
- case dcp::VerificationNote::VERIFY_NOTE:
- cout << "Note: " << i.note() << "\n";
+ case dcp::VerificationNote::Type::WARNING:
+ cout << "Warning: " << note_to_string(i) << "\n";
break;
}
}
- if (!failed) {
+ if (!failed && !quiet) {
cout << "DCP verified OK.\n";
}