2 Copyright (C) 2012 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/server.h"
28 #include <boost/array.hpp>
29 #include <boost/asio.hpp>
30 #include <boost/algorithm/string.hpp>
31 #include <boost/thread.hpp>
32 #include <boost/thread/mutex.hpp>
33 #include <boost/thread/condition.hpp>
34 #include "lib/config.h"
35 #include "lib/dcp_video_frame.h"
36 #include "lib/exceptions.h"
38 #include "lib/config.h"
39 #include "lib/scaler.h"
40 #include "lib/image.h"
42 #include "lib/version.h"
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 int num_threads = Config::instance()->num_local_encoding_threads ();
65 bool write_log = false;
69 static struct option long_options[] = {
70 { "version", no_argument, 0, 'v'},
71 { "help", no_argument, 0, 'h'},
72 { "threads", required_argument, 0, 't'},
73 { "verbose", no_argument, 0, 'A'},
74 { "log", no_argument, 0, 'B'},
78 int c = getopt_long (argc, argv, "vht:AB", long_options, &option_index);
86 cout << "dcpomatic version " << dcpomatic_version << " " << dcpomatic_git_commit << "\n";
92 num_threads = atoi (optarg);
103 Scaler::setup_scalers ();
106 log.reset (new FileLog ("dcpomatic_server_cli.log"));
108 log.reset (new NullLog);
111 Server server (log, verbose);
114 server.run (num_threads);
115 } catch (boost::system::system_error e) {
116 if (e.code() == boost::system::errc::address_in_use) {
117 cerr << argv[0] << ": address already in use. Is another DCP-o-matic server instance already running?\n";
120 cerr << argv[0] << ": " << e.what() << "\n";