Add a test corpus for XML.
authorCarl Hetherington <cth@carlh.net>
Thu, 6 Sep 2012 13:10:19 +0000 (14:10 +0100)
committerCarl Hetherington <cth@carlh.net>
Thu, 6 Sep 2012 13:10:19 +0000 (14:10 +0100)
release [new file with mode: 0755]
run-tests.sh
run/tools/dcpinfo [new file with mode: 0755]
src/dcp.cc
src/dcp.h
tools/dcpinfo.cc [new file with mode: 0644]
tools/wscript

diff --git a/release b/release
new file mode 100755 (executable)
index 0000000..d946613
--- /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\"")
index 8873a3e96bc1189fee5d39008902c74883dfaa06..c75c8c2ad97a0515468025d1881d4fd6d9e1bd43 100755 (executable)
@@ -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 (executable)
index 0000000..54e3c65
--- /dev/null
@@ -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
index d3c5367b8e2c27cafd691b86af00c65b30e99fa6..95849e48f774ff8bbe75ef67a9b09c6d56cde9f1 100644 (file)
@@ -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 ()) {
index 2f7a31aa0cb1d657e001aad73cf668b7540ba097..9e9b1130fcde67e5974fe6bedd5de198b56bf56a 100644 (file)
--- a/src/dcp.h
+++ b/src/dcp.h
@@ -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 (file)
index 0000000..66813d9
--- /dev/null
@@ -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;
+}
index 665d44b7592019b4bfdae2c98079caae70686ab1..d9ed0419a5749e23a91119f9c0552e1bbb2b9c6d 100644 (file)
@@ -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'
+