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 | |
| parent | 50a7273c4d3cedd582856eeb22c07117b8b8572d (diff) | |
Add a test corpus for XML.
| -rwxr-xr-x | release | 79 | ||||
| -rwxr-xr-x | run-tests.sh | 17 | ||||
| -rwxr-xr-x | run/tools/dcpinfo | 12 | ||||
| -rw-r--r-- | src/dcp.cc | 8 | ||||
| -rw-r--r-- | src/dcp.h | 4 | ||||
| -rw-r--r-- | tools/dcpinfo.cc | 98 | ||||
| -rw-r--r-- | tools/wscript | 6 |
7 files changed, 218 insertions, 6 deletions
diff --git a/release b/release new file mode 100755 index 00000000..d9466132 --- /dev/null +++ b/release @@ -0,0 +1,79 @@ +#!/usr/bin/python + +import os +import sys +import datetime +import shutil + +def command(c): + os.system(c) + print c + +def release_version(s): + s = s[1:-1] + if s.endswith('pre'): + s = s[0:-3] + p = s.split('.') + return '0.%02d' % int(p[1]) + +def new_pre_version(s): + s = s[1:-1] + p = s.split('.') + return '0.%02dpre' % (int(p[1]) + 1) + +def rewrite_wscript(version_maker): + f = open('wscript', 'rw') + o = open('wscript.tmp', 'w') + while 1: + l = f.readline() + if l == '': + break + + s = l.split() + if len(s) == 3 and s[0] == "VERSION": + v = version_maker(s[2]) + print "REWRITE %s -> %s" % (s[2], v) + print >>o,"VERSION = '%s'" % v + else: + print >>o,l, + f.close() + o.close() + + os.rename('wscript.tmp', 'wscript') + return v + +def append_to_changelog(version): + f = open('ChangeLog', 'r') + c = f.read() + f.close() + + f = open('ChangeLog', 'w') + now = datetime.datetime.now() + f.write('%d-%02d-%02d Carl Hetherington <cth@carlh.net>\n\n\t* Version %s released.\n\n' % (now.year, now.month, now.day, version)) + f.write(c) + +release_version_string = rewrite_wscript(release_version) +#append_to_changelog(release_version_string) + +command("git diff") +if (raw_input() != "y"): + command("git reset --hard") + print 'Aborted' + sys.exit(1) + +command("git commit -a -m \"Bump version\"") +command("git tag -m \"v%s\" v%s" % (release_version_string, release_version_string)) +command("./waf clean") +command("./waf") +command("./waf configure") +command("./waf dist") + +rewrite_wscript(new_pre_version) + +command("git diff") +if (raw_input() != "y"): + command("git reset --hard") + print 'Aborted' + sys.exit(1) + +command("git commit -a -m \"Bump version\"") diff --git a/run-tests.sh b/run-tests.sh index 8873a3e9..c75c8c2a 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -18,4 +18,19 @@ if [ "$?" != "0" ]; then echo "FAIL: files differ" exit 1 fi -echo "PASS"
\ No newline at end of file + +if [ -e "../libdcp-test" ]; then + for d in `find ../libdcp-test -mindepth 1 -maxdepth 1 -type d`; do + LD_LIBRARY_PATH=build/src:build/asdcplib/src build/tools/dcpinfo $d + if [ "$?" != "0" ]; then + echo "FAIL: dcpinfo failed" + exit 1 + fi + done +else + echo "Test corpus not found" + exit 1 +fi + +echo "PASS" + diff --git a/run/tools/dcpinfo b/run/tools/dcpinfo new file mode 100755 index 00000000..54e3c659 --- /dev/null +++ b/run/tools/dcpinfo @@ -0,0 +1,12 @@ +#!/bin/bash + +export LD_LIBRARY_PATH=build/src:build/asdcplib/src +if [ "$1" == "--debug" ]; then + shift + gdb --args build/tools/dcpinfo "$@" +elif [ "$1" == "--valgrind" ]; then + shift + valgrind --tool="memcheck" --leak-check=full --show-reachable=yes build/tools/dcpinfo "$@" +else + build/tools/dcpinfo "$@" +fi @@ -214,7 +214,7 @@ DCP::write_assetmap (string cpl_uuid, int cpl_length, string pkl_uuid, int pkl_l } -DCP::DCP (string directory) +DCP::DCP (string directory, bool read_mxfs) : _directory (directory) { Files files; @@ -282,7 +282,7 @@ DCP::DCP (string directory) shared_ptr<SoundAsset> sound; shared_ptr<SubtitleAsset> subtitle; - if ((*i)->asset_list->main_picture) { + if (read_mxfs && (*i)->asset_list->main_picture) { string n = pkl->asset_from_id (p->id)->original_file_name; if (n.empty ()) { @@ -298,7 +298,7 @@ DCP::DCP (string directory) ) ); - } else if ((*i)->asset_list->main_stereoscopic_picture) { + } else if (read_mxfs && (*i)->asset_list->main_stereoscopic_picture) { string n = pkl->asset_from_id (p->id)->original_file_name; if (n.empty ()) { @@ -316,7 +316,7 @@ DCP::DCP (string directory) } - if ((*i)->asset_list->main_sound) { + if (read_mxfs && (*i)->asset_list->main_sound) { string n = pkl->asset_from_id ((*i)->asset_list->main_sound->id)->original_file_name; if (n.empty ()) { @@ -69,8 +69,10 @@ public: * of the DCP. * * @param directory Existing DCP's directory. + * @param read_mxfs true to read MXF files; setting to false can be useful for testing, but + * normally it should be set to true. */ - DCP (std::string directory); + DCP (std::string directory, bool read_mxfs = true); void add_reel (boost::shared_ptr<const Reel> reel); 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' + |
