Listen for server replies on different ports on main and batch, and get servers to...
authorCarl Hetherington <cth@carlh.net>
Sun, 4 Feb 2018 23:38:08 +0000 (23:38 +0000)
committerCarl Hetherington <cth@carlh.net>
Sun, 4 Feb 2018 23:38:08 +0000 (23:38 +0000)
ChangeLog
src/lib/encode_server.cc
src/lib/encode_server_finder.cc
src/lib/encode_server_finder.h
src/lib/types.h
src/lib/util.cc
src/lib/util.h
src/tools/dcpomatic_batch.cc

index 5d4a67ae7fcdd8a85ab5877420158851c7b53511..6cdb67831966c7e8d60ff8e9ac1a080ef8b2c5b5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2018-02-04  Carl Hetherington  <cth@carlh.net>
+
+       * 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  <cth@carlh.net>
 
        * Updated de_DE translation from Carsten Kurz.
index 7bef82b2658c6b0b0e973b70b2e778593a7ed834..332c7ab46d34c858a5ee60e78415b6fe7abd293d 100644 (file)
@@ -277,9 +277,19 @@ EncodeServer::broadcast_received ()
                if (_verbose) {
                        cout << "Offering services to master " << _broadcast.send_endpoint.address().to_string () << "\n";
                }
-               shared_ptr<Socket> socket (new Socket);
+
+               try {
+                       shared_ptr<Socket> 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> 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 (...) {
index 2796df8f55e85417b37478e1d8dcf860245d3c68..267fbb62ac78235180b42f9df680507513870ada 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2018 Carl Hetherington <cth@carlh.net>
 
     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.")));
        }
index da610bd548397e4aa159d191af5a94310f8c870f..46d66b191e24d04cb103ffa5aeac9f3a669ae5aa 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2018 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
index 0702c873405c07a823bb13ccbe03150052bf6fe4..8f99b8881ffe0efec990721dee7ca7751c0a292f 100644 (file)
@@ -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<boost::shared_ptr<Content> > ContentList;
 typedef std::vector<boost::shared_ptr<FFmpegContent> > FFmpegContentList;
index 8ed87856127a2ba57689aa07fd24c82c953c39ca..68cded2a348bee17bee9afcffe4cc749291d5105 100644 (file)
@@ -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;
 
index 53a0a2d6674317cfbb1f4a61d0ec9a4e193fe864..5ca198ebbcc8f61b46a4ebb6bb2cc5678cf6cb1b 100644 (file)
@@ -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;
index 827229e8f38066f4892efeb6abd2fe45fba6e683..3cfe6c0a09e25dfdfec1d44afdbf08f5a9f5d90f 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2018 Carl Hetherington <cth@carlh.net>
 
     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));