2 Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
22 #include "lib/config.h"
23 #include "lib/config.h"
24 #include "lib/dcp_video.h"
25 #include "lib/dcpomatic_log.h"
26 #include "lib/encode_server.h"
27 #include "lib/exceptions.h"
28 #include "lib/file_log.h"
29 #include "lib/image.h"
30 #include "lib/null_log.h"
32 #include "lib/version.h"
33 #include <boost/algorithm/string.hpp>
34 #include <boost/array.hpp>
35 #include <boost/asio.hpp>
36 #include <boost/thread.hpp>
37 #include <boost/thread/condition.hpp>
38 #include <boost/thread/mutex.hpp>
50 using std::shared_ptr;
57 cerr << "Syntax: " << n << " [OPTION]\n"
58 << " -v, --version show DCP-o-matic version\n"
59 << " -h, --help show this help\n"
60 << " -t, --threads number of parallel encoding threads to use\n"
61 << " --verbose be verbose to stdout\n"
62 << " --log write a log file of activity\n";
67 main (int argc, char* argv[])
69 dcpomatic_setup_path_encoding ();
72 int num_threads = Config::instance()->server_encoding_threads ();
74 bool write_log = false;
78 static struct option long_options[] = {
79 { "version", no_argument, 0, 'v'},
80 { "help", no_argument, 0, 'h'},
81 { "threads", required_argument, 0, 't'},
82 { "verbose", no_argument, 0, 'A'},
83 { "log", no_argument, 0, 'B'},
87 int c = getopt_long (argc, argv, "vht:AB", long_options, &option_index);
95 cout << "dcpomatic version " << dcpomatic_version << " " << dcpomatic_git_commit << "\n";
101 num_threads = atoi (optarg);
113 dcpomatic_log.reset (new FileLog("dcpomatic_server_cli.log"));
117 EncodeServer server (verbose, num_threads);
119 } catch (boost::system::system_error& e) {
120 if (e.code() == boost::system::errc::address_in_use) {
121 cerr << argv[0] << ": address already in use. Is another DCP-o-matic server instance already running?\n";
124 cerr << argv[0] << ": " << e.what() << "\n";
125 } catch (std::exception& e) {
126 cerr << argv[0] << ": failed to start server; " << e.what() << "\n";