diff options
| author | Carl Hetherington <cth@carlh.net> | 2012-09-06 14:10:19 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2012-09-06 14:10:19 +0100 |
| commit | 8f6f5c5c8f09d8aa880c3f2f29530744576212a1 (patch) | |
| tree | 9f726c3ec1e9e047b9672705d57b0a798584ef7e /tools | |
| parent | 50a7273c4d3cedd582856eeb22c07117b8b8572d (diff) | |
Add a test corpus for XML.
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/dcpinfo.cc | 98 | ||||
| -rw-r--r-- | tools/wscript | 6 |
2 files changed, 104 insertions, 0 deletions
diff --git a/tools/dcpinfo.cc b/tools/dcpinfo.cc new file mode 100644 index 00000000..66813d95 --- /dev/null +++ b/tools/dcpinfo.cc @@ -0,0 +1,98 @@ +#include <iostream> +#include <cstdlib> +#include <boost/filesystem.hpp> +#include <getopt.h> +#include "dcp.h" +#include "exceptions.h" +#include "reel.h" + +using namespace std; +using namespace boost; +using namespace libdcp; + +static void +help (string n) +{ + cerr << "Syntax: " << n << " <DCP>\n"; +} + +int +main (int argc, char* argv[]) +{ + int option_index = 0; + while (1) { + static struct option long_options[] = { + { "version", no_argument, 0, 'v'}, + { "help", no_argument, 0, 'h'}, + { 0, 0, 0, 0 } + }; + + int c = getopt_long (argc, argv, "vh", long_options, &option_index); + + if (c == -1) { + break; + } + + switch (c) { + case 'v': + cout << "dcpdiff version " << LIBDCP_VERSION << "\n"; + exit (EXIT_SUCCESS); + case 'h': + help (argv[0]); + exit (EXIT_SUCCESS); + } + } + + if (argc <= optind || argc > (optind + 1)) { + help (argv[0]); + exit (EXIT_FAILURE); + } + + if (!filesystem::exists (argv[optind])) { + cerr << argv[0] << ": DCP " << argv[optind] << " not found.\n"; + exit (EXIT_FAILURE); + } + + list<string> missing_mxfs; + + DCP* dcp = 0; + try { + dcp = new DCP (argv[optind], false); + } catch (FileError& e) { + cerr << "Could not read DCP " << argv[optind] << "; " << e.what() << " " << e.filename() << "\n"; + exit (EXIT_FAILURE); + } + + cout << "DCP: " << argv[optind] << "\n" + << "\tLength: " << dcp->length() << "\n" + << "\tFrames per second: " << dcp->frames_per_second() << "\n"; + + if (!missing_mxfs.empty ()) { + cout << "\tmissing MXFs: "; + for (list<string>::const_iterator i = missing_mxfs.begin(); i != missing_mxfs.end(); ++i) { + cout << *i << " " ; + } + cout << "\n"; + } + + list<shared_ptr<const Reel> > reels = dcp->reels (); + + int R = 1; + for (list<shared_ptr<const Reel> >::const_iterator i = reels.begin(); i != reels.end(); ++i) { + cout << "Reel " << R << "\n"; + cout << "\tContains: "; + if ((*i)->main_picture()) { + cout << "picture "; + } + if ((*i)->main_sound()) { + cout << "sound "; + } + if ((*i)->main_subtitle()) { + cout << "subtitle "; + } + cout << "\n"; + ++R; + } + + return 0; +} diff --git a/tools/wscript b/tools/wscript index 665d44b7..d9ed0419 100644 --- a/tools/wscript +++ b/tools/wscript @@ -3,3 +3,9 @@ def build(bld): obj.use = ['libdcp'] obj.source = 'dcpdiff.cc' obj.target = 'dcpdiff' + + obj = bld(features = 'cxx cxxprogram') + obj.use = ['libdcp'] + obj.source = 'dcpinfo.cc' + obj.target = 'dcpinfo' + |
