New dcpkdm tool.
[libdcp.git] / tools / dcpinfo.cc
index 0c41b0c3a00fddbf7eb472b2818b05006792ca7b..2779b76a5e24a090c3e27207e7e1568d55f01c47 100644 (file)
@@ -1,44 +1,62 @@
 /*
     Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
 
-    This program is free software; you can redistribute it and/or modify
+    This file is part of libdcp.
+
+    libdcp is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation; either version 2 of the License, or
     (at your option) any later version.
 
-    This program is distributed in the hope that it will be useful,
+    libdcp is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
+    along with libdcp.  If not, see <http://www.gnu.org/licenses/>.
+
+    In addition, as a special exception, the copyright holders give
+    permission to link the code of portions of this program with the
+    OpenSSL library under certain conditions as described in each
+    individual source file, and distribute linked combinations
+    including the two.
+
+    You must obey the GNU General Public License in all respects
+    for all of the code used other than OpenSSL.  If you modify
+    file(s) with this exception, you may extend this exception to your
+    version of the file(s), but you are not obligated to do so.  If you
+    do not wish to do so, delete this exception statement from your
+    version.  If you delete this exception statement from all source
+    files in the program, then also delete it here.
 */
 
-#include <iostream>
-#include <cstdlib>
-#include <boost/filesystem.hpp>
-#include <getopt.h>
 #include "dcp.h"
 #include "exceptions.h"
 #include "reel.h"
-#include "sound_mxf.h"
-#include "picture_mxf.h"
-#include "subtitle_content.h"
+#include "sound_asset.h"
+#include "picture_asset.h"
+#include "subtitle_asset.h"
 #include "reel_picture_asset.h"
 #include "reel_sound_asset.h"
 #include "reel_subtitle_asset.h"
 #include "subtitle_string.h"
+#include "interop_subtitle_asset.h"
+#include "smpte_subtitle_asset.h"
 #include "cpl.h"
 #include "common.h"
+#include <getopt.h>
+#include <boost/filesystem.hpp>
+#include <boost/foreach.hpp>
+#include <iostream>
+#include <cstdlib>
 
 using std::string;
 using std::cerr;
 using std::cout;
 using std::list;
 using boost::shared_ptr;
+using boost::dynamic_pointer_cast;
 using namespace dcp;
 
 static void
@@ -53,22 +71,22 @@ help (string n)
 static void
 main_picture (shared_ptr<Reel> reel)
 {
-       if (reel->main_picture() && reel->main_picture()->mxf()) {
+       if (reel->main_picture() && reel->main_picture()->asset()) {
                cout << "      Picture:  "
-                    << reel->main_picture()->mxf()->size().width
+                    << reel->main_picture()->asset()->size().width
                     << "x"
-                    << reel->main_picture()->mxf()->size().height << "\n";
+                    << reel->main_picture()->asset()->size().height << "\n";
        }
 }
 
 static void
 main_sound (shared_ptr<Reel> reel)
 {
-       if (reel->main_sound() && reel->main_sound()->mxf()) {
+       if (reel->main_sound() && reel->main_sound()->asset()) {
                cout << "      Sound:    "
-                    << reel->main_sound()->mxf()->channels()
+                    << reel->main_sound()->asset()->channels()
                     << " channels at "
-                    << reel->main_sound()->mxf()->sampling_rate() << "Hz\n";
+                    << reel->main_sound()->asset()->sampling_rate() << "Hz\n";
        }
 }
 
@@ -78,25 +96,20 @@ main_subtitle (shared_ptr<Reel> reel, bool list_subtitles)
        if (!reel->main_subtitle()) {
                return;
        }
-       
-       list<shared_ptr<SubtitleString> > subs = reel->main_subtitle()->subtitle_content()->subtitles ();
-       cout << "      Subtitle: " << subs.size() << " subtitles in " << reel->main_subtitle()->subtitle_content()->language() << "\n";
+
+       list<SubtitleString> subs = reel->main_subtitle()->asset()->subtitles ();
+       cout << "      Subtitle: " << subs.size() << " subtitles";
+       shared_ptr<InteropSubtitleAsset> iop = dynamic_pointer_cast<InteropSubtitleAsset> (reel->main_subtitle()->asset());
+       if (iop) {
+               cout << " in " << iop->language() << "\n";
+       }
+       shared_ptr<SMPTESubtitleAsset> smpte = dynamic_pointer_cast<SMPTESubtitleAsset> (reel->main_subtitle()->asset());
+       if (smpte && smpte->language ()) {
+               cout << " in " << smpte->language().get() << "\n";
+       }
        if (list_subtitles) {
-               for (list<shared_ptr<SubtitleString> >::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";
+               BOOST_FOREACH (SubtitleString const& k, subs) {
+                       cout << k << "\n";
                }
        }
 }
@@ -107,9 +120,9 @@ main (int argc, char* argv[])
        bool subtitles = false;
        bool keep_going = false;
        bool ignore_missing_assets = false;
-       
+
        int option_index = 0;
-       while (1) {
+       while (true) {
                static struct option long_options[] = {
                        { "version", no_argument, 0, 'v' },
                        { "help", no_argument, 0, 'h' },
@@ -127,7 +140,7 @@ main (int argc, char* argv[])
 
                switch (c) {
                case 'v':
-                       cout << "dcpdiff version " << LIBDCP_VERSION << "\n";
+                       cout << "libdcp version " << LIBDCP_VERSION << "\n";
                        exit (EXIT_SUCCESS);
                case 'h':
                        help (argv[0]);
@@ -166,7 +179,7 @@ main (int argc, char* argv[])
                cerr << "Could not read DCP " << argv[optind] << "; " << e.what() << "\n";
                exit (EXIT_FAILURE);
        }
-       
+
        cout << "DCP: " << boost::filesystem::path(argv[optind]).filename().string() << "\n";
 
        dcp::filter_errors (errors, ignore_missing_assets);
@@ -178,7 +191,7 @@ main (int argc, char* argv[])
 
        for (list<shared_ptr<CPL> >::iterator i = cpls.begin(); i != cpls.end(); ++i) {
                cout << "  CPL: " << (*i)->annotation_text() << "\n";
-               
+
                list<shared_ptr<Reel> > reels = (*i)->reels ();
 
                int R = 1;