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/>.
21 #include "lib/config.h"
22 #include "lib/dcp_video.h"
23 #include "lib/exceptions.h"
25 #include "lib/config.h"
26 #include "lib/image.h"
27 #include "lib/file_log.h"
28 #include "lib/null_log.h"
29 #include "lib/version.h"
30 #include "lib/encode_server.h"
31 #include <boost/array.hpp>
32 #include <boost/asio.hpp>
33 #include <boost/algorithm/string.hpp>
34 #include <boost/thread.hpp>
35 #include <boost/thread/mutex.hpp>
36 #include <boost/thread/condition.hpp>
48 using boost::shared_ptr;
53 cerr << "Syntax: " << n << " [OPTION]\n"
54 << " -v, --version show DCP-o-matic version\n"
55 << " -h, --help show this help\n"
56 << " -t, --threads number of parallel encoding threads to use\n"
57 << " --verbose be verbose to stdout\n"
58 << " --log write a log file of activity\n";
62 main (int argc, char* argv[])
64 dcpomatic_setup_path_encoding ();
67 int num_threads = Config::instance()->server_encoding_threads ();
69 bool write_log = false;
73 static struct option long_options[] = {
74 { "version", no_argument, 0, 'v'},
75 { "help", no_argument, 0, 'h'},
76 { "threads", required_argument, 0, 't'},
77 { "verbose", no_argument, 0, 'A'},
78 { "log", no_argument, 0, 'B'},
82 int c = getopt_long (argc, argv, "vht:AB", long_options, &option_index);
90 cout << "dcpomatic version " << dcpomatic_version << " " << dcpomatic_git_commit << "\n";
96 num_threads = atoi (optarg);
109 log.reset (new FileLog ("dcpomatic_server_cli.log"));
111 log.reset (new NullLog);
114 EncodeServer server (log, verbose, num_threads);
118 } catch (boost::system::system_error& e) {
119 if (e.code() == boost::system::errc::address_in_use) {
120 cerr << argv[0] << ": address already in use. Is another DCP-o-matic server instance already running?\n";
123 cerr << argv[0] << ": " << e.what() << "\n";
124 } catch (std::exception& e) {
125 cerr << argv[0] << ": failed to start server; " << e.what() << "\n";