2 Copyright (C) 2012-2015 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.
20 #include "lib/config.h"
21 #include "lib/dcp_video.h"
22 #include "lib/exceptions.h"
24 #include "lib/config.h"
25 #include "lib/image.h"
26 #include "lib/file_log.h"
27 #include "lib/null_log.h"
28 #include "lib/version.h"
29 #include "lib/encode_server.h"
30 #include <boost/array.hpp>
31 #include <boost/asio.hpp>
32 #include <boost/algorithm/string.hpp>
33 #include <boost/thread.hpp>
34 #include <boost/thread/mutex.hpp>
35 #include <boost/thread/condition.hpp>
47 using boost::shared_ptr;
52 cerr << "Syntax: " << n << " [OPTION]\n"
53 << " -v, --version show DCP-o-matic version\n"
54 << " -h, --help show this help\n"
55 << " -t, --threads number of parallel encoding threads to use\n"
56 << " --verbose be verbose to stdout\n"
57 << " --log write a log file of activity\n";
61 main (int argc, char* argv[])
63 dcpomatic_setup_path_encoding ();
66 int num_threads = Config::instance()->num_local_encoding_threads ();
68 bool write_log = false;
72 static struct option long_options[] = {
73 { "version", no_argument, 0, 'v'},
74 { "help", no_argument, 0, 'h'},
75 { "threads", required_argument, 0, 't'},
76 { "verbose", no_argument, 0, 'A'},
77 { "log", no_argument, 0, 'B'},
81 int c = getopt_long (argc, argv, "vht:AB", long_options, &option_index);
89 cout << "dcpomatic version " << dcpomatic_version << " " << dcpomatic_git_commit << "\n";
95 num_threads = atoi (optarg);
108 log.reset (new FileLog ("dcpomatic_server_cli.log"));
110 log.reset (new NullLog);
113 EncodeServer server (log, verbose, num_threads);
117 } catch (boost::system::system_error& e) {
118 if (e.code() == boost::system::errc::address_in_use) {
119 cerr << argv[0] << ": address already in use. Is another DCP-o-matic server instance already running?\n";
122 cerr << argv[0] << ": " << e.what() << "\n";