2 Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include <boost/filesystem.hpp>
25 #include "lib/version.h"
28 #include "lib/content_factory.h"
29 #include "lib/job_manager.h"
30 #include "lib/ui_signaller.h"
37 using boost::shared_ptr;
42 cerr << "Create a film directory (ready for making a DCP) from some content files.\n"
43 << "Syntax: " << n << " [OPTION] <CONTENT> [<CONTENT> ...]\n"
44 << " -v, --version show DCP-o-matic version\n"
45 << " -h, --help show this help\n"
46 << " -n, --name film name\n"
47 << " -o, --output output directory (required)\n";
51 main (int argc, char* argv[])
54 boost::filesystem::path output;
58 static struct option long_options[] = {
59 { "version", no_argument, 0, 'v'},
60 { "help", no_argument, 0, 'h'},
61 { "name", required_argument, 0, 'n'},
62 { "output", required_argument, 0, 'o'},
66 int c = getopt_long (argc, argv, "vhn:o:", long_options, &option_index);
73 cout << "dcpomatic version " << dcpomatic_version << " " << dcpomatic_git_commit << "\n";
92 if (output.empty ()) {
93 cerr << "Missing required option -o or --output.\n"
94 << "Use " << argv[0] << " --help for help.\n";
99 ui_signaller = new UISignaller ();
101 shared_ptr<Film> film (new Film (output));
102 if (!name.empty ()) {
103 film->set_name (name);
106 for (int i = optind; i < argc; ++i) {
107 film->examine_and_add_content (content_factory (film, argv[i]));
110 JobManager* jm = JobManager::instance ();
111 while (jm->work_to_do ()) {
112 ui_signaller->ui_idle ();
116 list<shared_ptr<Job> > jobs = jm->get ();
117 for (list<shared_ptr<Job> >::iterator i = jobs.begin(); i != jobs.end(); ++i) {
118 if ((*i)->finished_in_error ()) {
119 cerr << (*i)->error_summary () << "\n"
120 << (*i)->error_details () << "\n";
126 film->write_metadata ();