Barely-functional dcpdiff.
authorCarl Hetherington <cth@carlh.net>
Mon, 30 Jul 2012 23:32:58 +0000 (00:32 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 30 Jul 2012 23:32:58 +0000 (00:32 +0100)
src/dcp.cc
src/dcp.h
src/types.h
tools/dcpdiff.cc

index 8f7a73bcedaadc44a0cefe59e97c12c6371c9aa1..dc895e11c2eb5cd38f77de4d75eb291f013196e9 100644 (file)
@@ -304,3 +304,30 @@ DCP::DCP (string directory)
        }
 }
 
+list<string>
+DCP::equals (DCP const & other, EqualityType type) const
+{
+       list<string> notes;
+       
+       switch (type) {
+       case LIBDCP_METADATA:
+               if (_name != other._name) {
+                       notes.push_back ("names differ");
+               }
+               if (_content_kind != other._content_kind) {
+                       notes.push_back ("content kinds differ");
+               }
+               if (_fps != other._fps) {
+                       notes.push_back ("frames per second differ");
+               }
+               if (_length != other._length) {
+                       notes.push_back ("lengths differ");
+               }
+               if (_assets.size() != other._assets.size()) {
+                       notes.push_back ("asset counts differ");
+               }
+               break;
+       }
+
+       return notes;
+}
index 900a5665a52554ab659f7ec15c0d49da03153543..6ab57bcb9152322248271b263373c5c0c5ef5e44 100644 (file)
--- a/src/dcp.h
+++ b/src/dcp.h
@@ -106,6 +106,8 @@ public:
                return _length;
        }
 
+       std::list<std::string> equals (DCP const & other, EqualityType type) const;
+
        /** Emitted with a parameter between 0 and 1 to indicate progress
         *  for long jobs.
         */
index b8f7805a4111b97223bedd8ddc1bfac3d5958ad7..5cd76ff4099c08f632e66a18941bd5399db99ece 100644 (file)
@@ -62,6 +62,10 @@ public:
        int denominator;
 };
 
+enum EqualityType {
+       LIBDCP_METADATA
+};
+
 }
 
 #endif
index b503ee1a89ac07d9af1d1a8e20faad16fe6a4c5e..840a1b3e0508fdce57f972c51bdfffdd443e5f7a 100644 (file)
@@ -1,10 +1,63 @@
+#include <getopt.h>
 #include "dcp.h"
 
+using namespace std;
 using namespace libdcp;
 
+static void
+help (string n)
+{
+       cerr << "Syntax: " << n << " [OPTION] <DCP> <DCP>\n"
+            << "  -v, --version      show DVD-o-matic version\n"
+            << "  -h, --help         show this help\n"
+            << "\n"
+            << "The <DCP>s are the DCP directories to compare.\n";
+}
+
 int
 main (int argc, char* argv[])
 {
-       DCP dcp ("/home/carl/src/dvdomatic-test/reference/dolby_aurora.vob/dolby_aurora.vob");
-       return 0;
+       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 + 2)) {
+               help (argv[0]);
+               exit (EXIT_FAILURE);
+       }
+
+       DCP a (argv[optind]);
+       DCP b (argv[optind + 1]);
+
+       list<string> notes = a.equals (b, LIBDCP_METADATA);
+       if (notes.empty ()) {
+               cout << "DCPs identical by LIBDCP_METADATA\n";
+               exit (EXIT_SUCCESS);
+       }
+
+       for (list<string>::iterator i = notes.begin(); i != notes.end(); ++i) {
+               cout << "  " << *i << "\n";
+       }
+
+       exit (EXIT_FAILURE);
 }