Add nascent dcpomatic_create.
authorCarl Hetherington <cth@carlh.net>
Mon, 30 Dec 2013 00:52:01 +0000 (00:52 +0000)
committerCarl Hetherington <cth@carlh.net>
Mon, 30 Dec 2013 00:52:01 +0000 (00:52 +0000)
ChangeLog
run/dcpomatic_create [new file with mode: 0755]
src/tools/dcpomatic_create.cc [new file with mode: 0644]
src/tools/wscript

index a8b8630b7c17a505dc78a3316963c7fc7b63dbf2..967b5034ff934d18dec0ef7f04318a03d5be2d54 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2013-12-30  Carl Hetherington  <cth@carlh.net>
+
+       * Add nascent dcpomatic_create command-line program to create films.
+
 2013-12-29  Carl Hetherington  <cth@carlh.net>
 
        * Version 1.53 released.
 2013-12-29  Carl Hetherington  <cth@carlh.net>
 
        * Version 1.53 released.
diff --git a/run/dcpomatic_create b/run/dcpomatic_create
new file mode 100755 (executable)
index 0000000..bf3c3c4
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+export LD_LIBRARY_PATH=build/src/lib:build/src/wx:build/src/asdcplib/src:$LD_LIBRARY_PATH
+if [ "$1" == "--debug" ]; then
+    shift
+    gdb --args build/src/tools/dcpomatic_create $*
+elif [ "$1" == "--valgrind" ]; then
+    shift
+    valgrind --tool="memcheck" build/src/tools/dcpomatic_create $*
+elif [ "$1" == "--callgrind" ]; then
+    shift
+    valgrind --tool="callgrind" build/src/tools/dcpomatic_create $*
+elif [ "$1" == "--perf" ]; then
+    shift
+    perf record build/src/tools/dcpomatic_create $*
+else
+    build/src/tools/dcpomatic_create $*
+fi
diff --git a/src/tools/dcpomatic_create.cc b/src/tools/dcpomatic_create.cc
new file mode 100644 (file)
index 0000000..8be468b
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+    Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
+
+    This program 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,
+    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.
+
+*/
+
+#include <string>
+#include <iostream>
+#include <cstdlib>
+#include <getopt.h>
+#include <boost/filesystem.hpp>
+#include "lib/version.h"
+#include "lib/film.h"
+#include "lib/util.h"
+#include "lib/content_factory.h"
+#include "lib/job_manager.h"
+#include "lib/ui_signaller.h"
+#include "lib/job.h"
+
+using std::string;
+using std::cout;
+using std::cerr;
+using std::list;
+using boost::shared_ptr;
+
+static void
+help (string n)
+{
+       cerr << "Create a film directory (ready for making a DCP) from some content files.\n"
+            << "Syntax: " << n << " [OPTION] <CONTENT> [<CONTENT> ...]\n"
+            << "  -v, --version   show DCP-o-matic version\n"
+            << "  -h, --help      show this help\n"
+            << "  -n, --name      film name\n"
+            << "  -o, --output    output directory (required)\n";
+}
+
+int
+main (int argc, char* argv[])
+{
+       string name;
+       boost::filesystem::path output;
+       
+       int option_index = 0;
+       while (1) {
+               static struct option long_options[] = {
+                       { "version", no_argument, 0, 'v'},
+                       { "help", no_argument, 0, 'h'},
+                       { "name", required_argument, 0, 'n'},
+                       { "output", required_argument, 0, 'o'},
+                       { 0, 0, 0, 0}
+               };
+
+               int c = getopt_long (argc, argv, "vhn:o:", long_options, &option_index);
+               if (c == -1) {
+                       break;
+               }
+
+               switch (c) {
+               case 'v':
+                       cout << "dcpomatic version " << dcpomatic_version << " " << dcpomatic_git_commit << "\n";
+                       exit (EXIT_SUCCESS);
+               case 'h':
+                       help (argv[0]);
+                       exit (EXIT_SUCCESS);
+               case 'n':
+                       name = optarg;
+                       break;
+               case 'o':
+                       output = optarg;
+                       break;
+               }
+       }
+
+       if (optind > argc) {
+               help (argv[0]);
+               exit (EXIT_FAILURE);
+       }
+
+       if (output.empty ()) {
+               cerr << "Missing required option -o or --output.\n"
+                    << "Use " << argv[0] << " --help for help.\n";
+               exit (EXIT_FAILURE);
+       }
+
+       dcpomatic_setup ();
+       ui_signaller = new UISignaller ();
+
+       shared_ptr<Film> film (new Film (output));
+       if (!name.empty ()) {
+               film->set_name (name);
+       }
+
+       for (int i = optind; i < argc; ++i) {
+               film->examine_and_add_content (content_factory (film, argv[i]));
+       }
+
+       JobManager* jm = JobManager::instance ();
+       while (jm->work_to_do ()) {
+               ui_signaller->ui_idle ();
+       }
+
+       if (jm->errors ()) {
+               list<shared_ptr<Job> > jobs = jm->get ();
+               for (list<shared_ptr<Job> >::iterator i = jobs.begin(); i != jobs.end(); ++i) {
+                       if ((*i)->finished_in_error ()) {
+                               cerr << (*i)->error_summary () << "\n"
+                                    << (*i)->error_details () << "\n";
+                       }
+               }
+               exit (EXIT_FAILURE);
+       }
+
+       film->write_metadata ();
+       return 0;
+}
index eafad44ec2cdb0fcb847965aba6b599bd7ff2a6a..0fd336676f217bde28aa410b7da95d7404e7d655 100644 (file)
@@ -9,7 +9,7 @@ def configure(conf):
         conf.env.append_value('LINKFLAGS', ['-mconsole'])
 
 def build(bld):
         conf.env.append_value('LINKFLAGS', ['-mconsole'])
 
 def build(bld):
-    for t in ['dcpomatic_cli', 'dcpomatic_server_cli', 'server_test', 'dcpomatic_kdm']:
+    for t in ['dcpomatic_cli', 'dcpomatic_server_cli', 'server_test', 'dcpomatic_kdm', 'dcpomatic_create']:
         obj = bld(features = 'cxx cxxprogram')
         obj.uselib = 'BOOST_THREAD OPENJPEG DCP CXML AVFORMAT AVFILTER AVCODEC AVUTIL SWSCALE POSTPROC WXWIDGETS QUICKMAIL'
         obj.includes = ['..']
         obj = bld(features = 'cxx cxxprogram')
         obj.uselib = 'BOOST_THREAD OPENJPEG DCP CXML AVFORMAT AVFILTER AVCODEC AVUTIL SWSCALE POSTPROC WXWIDGETS QUICKMAIL'
         obj.includes = ['..']