Clean up DCP comparison a bit.
[libdcp.git] / tools / dcpinfo.cc
index 66813d9570236660174776c9bd34ce0b1b990fa3..4f149f37a9b8596c45be332c25fa4ed05b135b7b 100644 (file)
@@ -5,6 +5,9 @@
 #include "dcp.h"
 #include "exceptions.h"
 #include "reel.h"
+#include "sound_asset.h"
+#include "picture_asset.h"
+#include "subtitle_asset.h"
 
 using namespace std;
 using namespace boost;
@@ -13,21 +16,25 @@ using namespace libdcp;
 static void
 help (string n)
 {
-       cerr << "Syntax: " << n << " <DCP>\n";
+       cerr << "Syntax: " << n << " [options] <DCP>\n"
+            << "  -s, --subtitles  list all subtitles\n";
 }
 
 int
 main (int argc, char* argv[])
 {
+       bool subtitles = false;
+       
        int option_index = 0;
        while (1) {
                static struct option long_options[] = {
                        { "version", no_argument, 0, 'v'},
                        { "help", no_argument, 0, 'h'},
+                       { "subtitles", no_argument, 0, 's'},
                        { 0, 0, 0, 0 }
                };
 
-               int c = getopt_long (argc, argv, "vh", long_options, &option_index);
+               int c = getopt_long (argc, argv, "vhs", long_options, &option_index);
 
                if (c == -1) {
                        break;
@@ -40,6 +47,9 @@ main (int argc, char* argv[])
                case 'h':
                        help (argv[0]);
                        exit (EXIT_SUCCESS);
+               case 's':
+                       subtitles = true;
+                       break;
                }
        }
 
@@ -53,45 +63,60 @@ main (int argc, char* argv[])
                exit (EXIT_FAILURE);
        }
 
-       list<string> missing_mxfs;
-
        DCP* dcp = 0;
        try {
-               dcp = new DCP (argv[optind], false);
+               dcp = new DCP (argv[optind]);
+               dcp->read (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";
+       cout << "DCP: " << argv[optind] << "\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 CPL> > cpls = dcp->cpls ();
 
-       list<shared_ptr<const Reel> > reels = dcp->reels ();
+       for (list<shared_ptr<const CPL> >::iterator i = cpls.begin(); i != cpls.end(); ++i) {
+               cout << "  CPL: " << (*i)->name() << "\n"
+                    << "    Length: " << (*i)->length() << "\n"
+                    << "    Frames per second: " << (*i)->frames_per_second() << "\n";
+               
+               list<shared_ptr<const Reel> > reels = (*i)->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 ";
+               int R = 1;
+               for (list<shared_ptr<const Reel> >::const_iterator j = reels.begin(); j != reels.end(); ++j) {
+                       cout << "    Reel " << R << "\n";
+                       
+                       if ((*j)->main_picture()) {
+                               cout << "      Picture:  " << (*j)->main_picture()->width() << "x" << (*j)->main_picture()->height() << "\n";
+                       }
+                       if ((*j)->main_sound()) {
+                               cout << "      Sound:    " << (*j)->main_sound()->channels() << " channels at " << (*j)->main_sound()->sampling_rate() << "Hz\n";
+                       }
+                       if ((*j)->main_subtitle()) {
+                               list<shared_ptr<Subtitle> > subs = (*j)->main_subtitle()->subtitles ();
+                               cout << "      Subtitle: " << subs.size() << " subtitles in " << (*j)->main_subtitle()->language() << "\n";
+                               if (subtitles) {
+                                       for (list<shared_ptr<Subtitle> >::const_iterator k = subs.begin(); k != subs.end(); ++k) {
+                                               cout << "        " << (*k)->text() << "\n";
+                                               cout << "          "
+                                                    << "font:" << (*k)->font() << "; "
+                                                    << "italic:" << (*k)->italic() << "; "
+                                                    << "color:" << (*k)->color() << "; "
+                                                    << "in:" << (*k)->in() << "; "
+                                                    << "out:" << (*k)->out() << "; "
+                                                    << "v_position:" << (*k)->v_position() << "; "
+                                                    << "v_align:" << (*k)->v_align() << "; "
+                                                    << "effect:" << (*k)->effect() << "; "
+                                                    << "effect_color:" << (*k)->effect_color() << "; "
+                                                    << "fade_up_time:" << (*k)->fade_up_time() << "; "
+                                                    << "fade_down_time:" << (*k)->fade_down_time() << "; "
+                                                    << "size: " << (*k)->size() << "\n";
+                                       }
+                               }
+                       }
+                       ++R;
                }
-               cout << "\n";
-               ++R;
        }
 
        return 0;