/*
- Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2017 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
<< " -t, --threads specify number of local encoding threads (overriding configuration)\n"
<< " -j, --json <port> run a JSON server on the specified port\n"
<< " -k, --keep-going keep running even when the job is complete\n"
- << " -s, --servers just display a list of encoding servers that DCP-o-matic is configured to use; don't encode\n"
+ << " -l, --list-servers just display a list of encoding servers that DCP-o-matic is configured to use; don't encode\n"
<< " -d, --dcp-path echo DCP's path to stdout on successful completion (implies -n)\n"
<< " --dump just dump a summary of the film's settings; don't encode\n"
<< "\n"
print_dump (shared_ptr<Film> film)
{
cout << film->dcp_name (true) << "\n"
- << film->container()->nickname() << " at " << ((film->resolution() == RESOLUTION_2K) ? "2K" : "4K") << "\n"
+ << film->container()->container_nickname() << " at " << ((film->resolution() == RESOLUTION_2K) ? "2K" : "4K") << "\n"
<< (film->j2k_bandwidth() / 1000000) << "Mbit/s" << "\n"
<< "Output " << film->video_frame_rate() << "fps " << (film->three_d() ? "3D" : "2D") << " " << (film->audio_frame_rate() / 1000) << "kHz\n"
<< (film->interop() ? "Inter-Op" : "SMPTE") << " " << (film->encrypted() ? "encrypted" : "unencrypted") << "\n";
}
static void
-show_servers ()
+list_servers ()
{
while (true) {
int N = 0;
list<EncodeServerDescription> servers = EncodeServerFinder::instance()->servers ();
- if (Config::instance()->use_any_servers ()) {
- if (servers.empty ()) {
- cout << "No encoding servers found.\n";
- ++N;
- } else {
- cout << std::left << setw(24) << "Host" << " Threads\n";
- ++N;
- BOOST_FOREACH (EncodeServerDescription const & i, servers) {
- cout << std::left << setw(24) << i.host_name() << " " << i.threads() << "\n";
- ++N;
- }
- }
+ /* This is a bit fiddly because we want to list configured servers that are down as well
+ as all those (configured and found by broadcast) that are up.
+ */
+
+ if (servers.empty() && Config::instance()->servers().empty()) {
+ cout << "No encoding servers found or configured.\n";
+ ++N;
} else {
- vector<string> configured_servers = Config::instance()->servers();
- if (configured_servers.empty()) {
- cout << "No configured servers, and DCP-o-matic is not set to search for any server.\n";
- ++N;
- } else {
- cout << std::left << setw(24) << "Host" << " Status Threads\n";
- ++N;
- BOOST_FOREACH (string const & i, Config::instance()->servers()) {
- cout << std::left << setw(24) << i << " ";
- optional<int> threads;
- BOOST_FOREACH (EncodeServerDescription const & j, servers) {
- if (i == j.host_name()) {
- threads = j.threads();
- }
- }
- if (static_cast<bool>(threads)) {
- cout << "UP " << threads.get() << "\n";
+ cout << std::left << setw(24) << "Host" << " Status Threads\n";
+ ++N;
+
+ /* Report the state of configured servers */
+ BOOST_FOREACH (string i, Config::instance()->servers()) {
+ cout << std::left << setw(24) << i << " ";
+
+ /* See if this server is on the active list; if so, remove it and note
+ the number of threads it is offering.
+ */
+ optional<int> threads;
+ list<EncodeServerDescription>::iterator j = servers.begin ();
+ while (j != servers.end ()) {
+ if (i == j->host_name()) {
+ threads = j->threads();
+ list<EncodeServerDescription>::iterator tmp = j;
+ ++tmp;
+ servers.erase (j);
+ j = tmp;
} else {
- cout << "DOWN\n";
+ ++j;
}
- ++N;
}
+ if (static_cast<bool>(threads)) {
+ cout << "UP " << threads.get() << "\n";
+ } else {
+ cout << "DOWN\n";
+ }
+ ++N;
}
- }
+ /* Now report any left that have been found by broadcast */
+ BOOST_FOREACH (EncodeServerDescription const & i, servers) {
+ cout << std::left << setw(24) << i.host_name() << " UP " << i.threads() << "\n";
+ ++N;
+ }
+ }
dcpomatic_sleep (1);
optional<int> json_port;
bool keep_going = false;
bool dump = false;
- bool servers = false;
+ bool list_servers_ = false;
bool dcp_path = false;
int option_index = 0;
{ "threads", required_argument, 0, 't'},
{ "json", required_argument, 0, 'j'},
{ "keep-going", no_argument, 0, 'k' },
- { "servers", no_argument, 0, 's' },
+ { "list-servers", no_argument, 0, 'l' },
{ "dcp-path", no_argument, 0, 'd' },
/* Just using A, B, C ... from here on */
{ "dump", no_argument, 0, 'A' },
{ 0, 0, 0, 0 }
};
- int c = getopt_long (argc, argv, "vhfnrt:j:kAsd", long_options, &option_index);
+ int c = getopt_long (argc, argv, "vhfnrt:j:kAld", long_options, &option_index);
if (c == -1) {
break;
case 'A':
dump = true;
break;
- case 's':
- servers = true;
+ case 'l':
+ list_servers_ = true;
break;
case 'd':
dcp_path = true;
}
}
- if (servers) {
- show_servers ();
+ if (list_servers_) {
+ list_servers ();
exit (EXIT_SUCCESS);
}
}
if (threads) {
- Config::instance()->set_num_local_encoding_threads (threads.get ());
+ Config::instance()->set_master_encoding_threads (threads.get ());
}
shared_ptr<Film> film;