diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-02-03 09:55:51 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-02-03 09:55:51 +0000 |
| commit | 391860586976a6b6309caa56cc1191e1ca9efd06 (patch) | |
| tree | b64d4dabe32de2e03a025a681fd387c276c7981f /tools/dcpdiff.cc | |
| parent | 500b0e29e64a5b02f8541d94c02dfb15789346cc (diff) | |
Try to add basic decryption support to dcpdiff.
Diffstat (limited to 'tools/dcpdiff.cc')
| -rw-r--r-- | tools/dcpdiff.cc | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/tools/dcpdiff.cc b/tools/dcpdiff.cc index c99a8523..08b72710 100644 --- a/tools/dcpdiff.cc +++ b/tools/dcpdiff.cc @@ -17,12 +17,13 @@ */ -#include <iostream> -#include <boost/filesystem.hpp> -#include <getopt.h> #include "dcp.h" #include "exceptions.h" #include "common.h" +#include "mxf.h" +#include <getopt.h> +#include <boost/filesystem.hpp> +#include <iostream> using namespace std; using namespace boost; @@ -41,6 +42,7 @@ help (string n) << " --cpl-annotation-texts allow differing CPL annotation texts\n" << " -m, --mean-pixel maximum allowed mean pixel error (default 5)\n" << " -s, --std-dev-pixel maximum allowed standard deviation of pixel error (default 5)\n" + << " --key hexadecimal key to use to decrypt MXFs\n" << " -k, --keep-going carry on in the event of errors, if possible\n" << " --ignore-missing-assets ignore missing asset files\n" << "\n" @@ -58,7 +60,7 @@ note (NoteType t, string n) } DCP * -load_dcp (boost::filesystem::path path, bool keep_going, bool ignore_missing_assets) +load_dcp (boost::filesystem::path path, bool keep_going, bool ignore_missing_assets, optional<string> key) { DCP* dcp = 0; try { @@ -69,6 +71,17 @@ load_dcp (boost::filesystem::path path, bool keep_going, bool ignore_missing_ass for (DCP::ReadErrors::const_iterator i = errors.begin(); i != errors.end(); ++i) { cerr << (*i)->what() << "\n"; } + + if (key) { + list<shared_ptr<Asset> > assets = dcp->assets (); + for (list<shared_ptr<Asset> >::const_iterator i = assets.begin(); i != assets.end(); ++i) { + shared_ptr<MXF> mxf = dynamic_pointer_cast<MXF> (*i); + if (mxf) { + mxf->set_key (Key (key.get ())); + } + } + } + } catch (FileError& e) { cerr << "Could not read DCP " << path.string() << "; " << e.what() << " " << e.filename() << "\n"; exit (EXIT_FAILURE); @@ -86,6 +99,7 @@ main (int argc, char* argv[]) options.reel_hashes_can_differ = true; bool keep_going = false; bool ignore_missing_assets = false; + optional<string> key; int option_index = 0; while (1) { @@ -100,10 +114,11 @@ main (int argc, char* argv[]) /* From here we're using random capital letters for the short option */ { "ignore-missing-assets", no_argument, 0, 'A'}, { "cpl-annotation-texts", no_argument, 0, 'C'}, + { "key", no_argument, 0, 'D'}, { 0, 0, 0, 0 } }; - int c = getopt_long (argc, argv, "Vhvnm:s:kA", long_options, &option_index); + int c = getopt_long (argc, argv, "Vhvnm:s:kACD", long_options, &option_index); if (c == -1) { break; @@ -138,6 +153,9 @@ main (int argc, char* argv[]) case 'C': options.cpl_annotation_texts_can_differ = true; break; + case 'D': + key = optarg; + break; } } @@ -156,8 +174,8 @@ main (int argc, char* argv[]) exit (EXIT_FAILURE); } - DCP* a = load_dcp (argv[optind], keep_going, ignore_missing_assets); - DCP* b = load_dcp (argv[optind + 1], keep_going, ignore_missing_assets); + DCP* a = load_dcp (argv[optind], keep_going, ignore_missing_assets, key); + DCP* b = load_dcp (argv[optind + 1], keep_going, ignore_missing_assets, key); /* I think this is just below the LSB at 16-bits (ie the 8th most significant bit at 24-bit) */ options.max_audio_sample_error = 255; |
