From: Carl Hetherington Date: Sun, 4 Feb 2018 23:38:08 +0000 (+0000) Subject: Listen for server replies on different ports on main and batch, and get servers to... X-Git-Tag: v2.11.48~4 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=918124fb0b2fdf05bf98aee2c74c85387f1d8638 Listen for server replies on different ports on main and batch, and get servers to send replies to both (#1190). --- diff --git a/ChangeLog b/ChangeLog index 5d4a67ae7..6cdb67831 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2018-02-04 Carl Hetherington + + * Allow main DCP-o-matic and batch converter to run on the same + machine and both get access to encoding servers (#1190). + 2018-02-03 Carl Hetherington * Updated de_DE translation from Carsten Kurz. diff --git a/src/lib/encode_server.cc b/src/lib/encode_server.cc index 7bef82b26..332c7ab46 100644 --- a/src/lib/encode_server.cc +++ b/src/lib/encode_server.cc @@ -277,9 +277,19 @@ EncodeServer::broadcast_received () if (_verbose) { cout << "Offering services to master " << _broadcast.send_endpoint.address().to_string () << "\n"; } - shared_ptr socket (new Socket); + + try { + shared_ptr socket (new Socket); + socket->connect (boost::asio::ip::tcp::endpoint (_broadcast.send_endpoint.address(), MAIN_SERVER_PRESENCE_PORT)); + socket->write (xml.length() + 1); + socket->write ((uint8_t *) xml.c_str(), xml.length() + 1); + } catch (...) { + + } + try { - socket->connect (boost::asio::ip::tcp::endpoint (_broadcast.send_endpoint.address(), SERVER_PRESENCE_PORT)); + shared_ptr socket (new Socket); + socket->connect (boost::asio::ip::tcp::endpoint (_broadcast.send_endpoint.address(), BATCH_SERVER_PRESENCE_PORT)); socket->write (xml.length() + 1); socket->write ((uint8_t *) xml.c_str(), xml.length() + 1); } catch (...) { diff --git a/src/lib/encode_server_finder.cc b/src/lib/encode_server_finder.cc index 2796df8f5..267fbb62a 100644 --- a/src/lib/encode_server_finder.cc +++ b/src/lib/encode_server_finder.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2015 Carl Hetherington + Copyright (C) 2013-2018 Carl Hetherington This file is part of DCP-o-matic. @@ -157,7 +157,9 @@ try { using namespace boost::asio::ip; try { - _listen_acceptor.reset (new tcp::acceptor (_listen_io_service, tcp::endpoint (tcp::v4(), SERVER_PRESENCE_PORT))); + _listen_acceptor.reset ( + new tcp::acceptor (_listen_io_service, tcp::endpoint (tcp::v4(), is_batch_converter ? BATCH_SERVER_PRESENCE_PORT : MAIN_SERVER_PRESENCE_PORT)) + ); } catch (...) { boost::throw_exception (NetworkError (_("Could not listen for remote encode servers. Perhaps another instance of DCP-o-matic is running."))); } diff --git a/src/lib/encode_server_finder.h b/src/lib/encode_server_finder.h index da610bd54..46d66b191 100644 --- a/src/lib/encode_server_finder.h +++ b/src/lib/encode_server_finder.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2015 Carl Hetherington + Copyright (C) 2013-2018 Carl Hetherington This file is part of DCP-o-matic. diff --git a/src/lib/types.h b/src/lib/types.h index 0702c8734..8f99b8881 100644 --- a/src/lib/types.h +++ b/src/lib/types.h @@ -74,10 +74,12 @@ namespace xmlpp { #define ENCODE_FRAME_PORT (Config::instance()->server_port_base()) /** Port on which EncodeServer listens for DCPOMATIC_HELLO from masters */ #define HELLO_PORT (Config::instance()->server_port_base()+1) -/** Port on which EncodeServerFinder listens for replies to DCPOMATIC_HELLO from servers */ -#define SERVER_PRESENCE_PORT (Config::instance()->server_port_base()+2) +/** Port on which EncodeServerFinder in the main DCP-o-matic listens for replies to DCPOMATIC_HELLO from servers */ +#define MAIN_SERVER_PRESENCE_PORT (Config::instance()->server_port_base()+2) +/** Port on which EncodeServerFinder in the batch converter listens for replies to DCPOMATIC_HELLO from servers */ +#define BATCH_SERVER_PRESENCE_PORT (Config::instance()->server_port_base()+3) /** Port on which batch converter listens for job requests */ -#define BATCH_JOB_PORT (Config::instance()->server_port_base()+3) +#define BATCH_JOB_PORT (Config::instance()->server_port_base()+4) typedef std::vector > ContentList; typedef std::vector > FFmpegContentList; diff --git a/src/lib/util.cc b/src/lib/util.cc index 8ed878561..68cded2a3 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -104,6 +104,7 @@ using dcp::locale_convert; * in during App::onInit(). */ string program_name; +bool is_batch_converter = false; static boost::thread::id ui_thread; static boost::filesystem::path backtrace_file; diff --git a/src/lib/util.h b/src/lib/util.h index 53a0a2d66..5ca198ebb 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -59,6 +59,7 @@ namespace dcp { #define MAX_KDM_SIZE (256 * 1024) extern std::string program_name; +extern bool is_batch_converter; struct AVSubtitle; class AudioBuffers; diff --git a/src/tools/dcpomatic_batch.cc b/src/tools/dcpomatic_batch.cc index 827229e8f..3cfe6c0a0 100644 --- a/src/tools/dcpomatic_batch.cc +++ b/src/tools/dcpomatic_batch.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2015 Carl Hetherington + Copyright (C) 2013-2018 Carl Hetherington This file is part of DCP-o-matic. @@ -280,6 +280,7 @@ class App : public wxApp bool OnInit () { SetAppName (_("DCP-o-matic Batch Converter")); + is_batch_converter = true; Config::FailedToLoad.connect (boost::bind (&App::config_failed_to_load, this)); Config::Warning.connect (boost::bind (&App::config_warning, this, _1));