Bitwise MXF comparison.
[libdcp.git] / tools / dcpdiff.cc
1 #include <getopt.h>
2 #include "dcp.h"
3
4 using namespace std;
5 using namespace libdcp;
6
7 static void
8 help (string n)
9 {
10         cerr << "Syntax: " << n << " [OPTION] <DCP> <DCP>\n"
11              << "  -v, --version      show DVD-o-matic version\n"
12              << "  -h, --help         show this help\n"
13              << "\n"
14              << "The <DCP>s are the DCP directories to compare.\n";
15 }
16
17 int
18 main (int argc, char* argv[])
19 {
20         int option_index = 0;
21         while (1) {
22                 static struct option long_options[] = {
23                         { "version", no_argument, 0, 'v'},
24                         { "help", no_argument, 0, 'h'},
25                         { 0, 0, 0, 0 }
26                 };
27
28                 int c = getopt_long (argc, argv, "vh", long_options, &option_index);
29
30                 if (c == -1) {
31                         break;
32                 }
33
34                 switch (c) {
35                 case 'v':
36                         cout << "dcpdiff version " << LIBDCP_VERSION << "\n";
37                         exit (EXIT_SUCCESS);
38                 case 'h':
39                         help (argv[0]);
40                         exit (EXIT_SUCCESS);
41                 }
42         }
43
44         if (argc <= optind || argc > (optind + 2)) {
45                 help (argv[0]);
46                 exit (EXIT_FAILURE);
47         }
48
49         DCP a (argv[optind]);
50         DCP b (argv[optind + 1]);
51
52         list<string> notes = a.equals (b, EqualityFlags (LIBDCP_METADATA | MXF_BITWISE));
53         if (notes.empty ()) {
54                 cout << "DCPs identical\n";
55                 exit (EXIT_SUCCESS);
56         }
57
58         for (list<string>::iterator i = notes.begin(); i != notes.end(); ++i) {
59                 cout << "  " << *i << "\n";
60         }
61
62         exit (EXIT_FAILURE);
63 }