+2013-11-14 Carl Hetherington <cth@carlh.net>
+
+ * Add server configuration back in.
+
2013-11-12 Carl Hetherington <cth@carlh.net>
* Version 1.29 released.
#include <fstream>
#include <glib.h>
#include <boost/filesystem.hpp>
+#include <boost/algorithm/string.hpp>
#include <libdcp/colour_matrix.h>
#include <libcxml/cxml.h>
#include "config.h"
using boost::shared_ptr;
using boost::lexical_cast;
using boost::optional;
+using boost::algorithm::is_any_of;
+using boost::algorithm::split;
Config* Config::_instance = 0;
Config::Config ()
: _num_local_encoding_threads (max (2U, boost::thread::hardware_concurrency()))
, _server_port_base (6192)
+ , _use_any_servers (true)
, _tms_path (".")
, _sound_processor (SoundProcessor::from_id (N_("dolby_cp750")))
, _default_still_length (10)
b = f.optional_number_child<int> ("ServerPortBase");
}
_server_port_base = b.get ();
+
+ boost::optional<bool> u = f.optional_bool_child ("UseAnyServers");
+ _use_any_servers = u.get_value_or (true);
+
+ list<shared_ptr<cxml::Node> > servers = f.node_children ("Server");
+ for (list<shared_ptr<cxml::Node> >::iterator i = servers.begin(); i != servers.end(); ++i) {
+ if ((*i)->node_children("HostName").size() == 1) {
+ _servers.push_back ((*i)->string_child ("HostName"));
+ } else {
+ _servers.push_back ((*i)->content ());
+ }
+ }
_tms_ip = f.string_child ("TMSIP");
_tms_path = f.string_child ("TMSPath");
_default_directory = v;
} else if (k == N_("server_port")) {
_server_port_base = atoi (v.c_str ());
+ } else if (k == N_("server")) {
+ vector<string> b;
+ split (b, v, is_any_of (" "));
+ if (b.size() == 2) {
+ _servers.push_back (b[0]);
+ }
} else if (k == N_("tms_ip")) {
_tms_ip = v;
} else if (k == N_("tms_path")) {
root->add_child("NumLocalEncodingThreads")->add_child_text (lexical_cast<string> (_num_local_encoding_threads));
root->add_child("DefaultDirectory")->add_child_text (_default_directory.string ());
root->add_child("ServerPortBase")->add_child_text (lexical_cast<string> (_server_port_base));
+ root->add_child("UseAnyServers")->add_child_text (_use_any_servers ? "1" : "0");
+
+ for (vector<string>::const_iterator i = _servers.begin(); i != _servers.end(); ++i) {
+ root->add_child("Server")->add_child_text (*i);
+ }
+
root->add_child("TMSIP")->add_child_text (_tms_ip);
root->add_child("TMSPath")->add_child_text (_tms_path);
root->add_child("TMSUser")->add_child_text (_tms_user);
#include <libdcp/metadata.h>
#include "dci_metadata.h"
#include "colour_conversion.h"
+#include "server.h"
+class ServerDescription;
class Scaler;
class Filter;
class SoundProcessor;
return _server_port_base;
}
+ void set_use_any_servers (bool u) {
+ _use_any_servers = u;
+ }
+
+ bool use_any_servers () const {
+ return _use_any_servers;
+ }
+
+ /** @param s New list of servers */
+ void set_servers (std::vector<std::string> s) {
+ _servers = s;
+ }
+
+ /** @return Host names / IP addresses of J2K encoding servers that should definitely be used */
+ std::vector<std::string> servers () const {
+ return _servers;
+ }
+
/** @return The IP address of a TMS that we can copy DCPs to */
std::string tms_ip () const {
return _tms_ip;
}
-
+
/** @return The path on a TMS that we should write DCPs to */
std::string tms_path () const {
return _tms_path;
* this port and the one above it will be used.
*/
int _server_port_base;
+ /** true to broadcast on the `any' address to look for servers */
+ bool _use_any_servers;
+ /** J2K encoding servers that should definitely be used */
+ std::vector<std::string> _servers;
/** Scaler to use for the "A" part of A/B comparisons */
Scaler const * _reference_scaler;
/** Filters to use for the "A" part of A/B comparisons */
using std::string;
using std::stringstream;
using std::list;
+using std::vector;
using boost::shared_ptr;
using boost::scoped_array;
socket.set_option (boost::asio::ip::udp::socket::reuse_address (true));
socket.set_option (boost::asio::socket_base::broadcast (true));
-
- boost::asio::ip::udp::endpoint end_point (boost::asio::ip::address_v4::broadcast(), Config::instance()->server_port_base() + 1);
+ string const data = DCPOMATIC_HELLO;
+
while (1) {
- string const data = DCPOMATIC_HELLO;
- socket.send_to (boost::asio::buffer (data.c_str(), data.size() + 1), end_point);
+ if (Config::instance()->use_any_servers ()) {
+ /* Broadcast to look for servers */
+ boost::asio::ip::udp::endpoint end_point (boost::asio::ip::address_v4::broadcast(), Config::instance()->server_port_base() + 1);
+ socket.send_to (boost::asio::buffer (data.c_str(), data.size() + 1), end_point);
+ }
+
+ /* Query our `definite' servers (if there are any) */
+ vector<string> servers = Config::instance()->servers ();
+ for (vector<string>::const_iterator i = servers.begin(); i != servers.end(); ++i) {
+ try {
+ boost::asio::ip::udp::resolver resolver (io_service);
+ boost::asio::ip::udp::resolver::query query (*i);
+ boost::asio::ip::udp::endpoint end_point (*resolver.resolve (query));
+ socket.send_to (boost::asio::buffer (data.c_str(), data.size() + 1), end_point);
+ } catch (...) {
+
+ }
+ }
+
dcpomatic_sleep (10);
}
}
#include "dir_picker_ctrl.h"
#include "dci_metadata_dialog.h"
#include "preset_colour_conversion_dialog.h"
+#include "server_dialog.h"
using std::vector;
using std::string;
make_misc_panel ();
_notebook->AddPage (_misc_panel, _("Miscellaneous"), true);
+ make_servers_panel ();
+ _notebook->AddPage (_servers_panel, _("Encoding servers"), false);
make_colour_conversions_panel ();
_notebook->AddPage (_colour_conversions_panel, _("Colour conversions"), false);
make_metadata_panel ();
_creator->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&ConfigDialog::creator_changed, this));
}
+static string
+server_column (string s)
+{
+ return s;
+}
+
+void
+ConfigDialog::make_servers_panel ()
+{
+ _servers_panel = new wxPanel (_notebook);
+ wxBoxSizer* s = new wxBoxSizer (wxVERTICAL);
+ _servers_panel->SetSizer (s);
+
+ _use_any_servers = new wxCheckBox (_servers_panel, wxID_ANY, _("Use all servers"));
+ s->Add (_use_any_servers, 0, wxALL, DCPOMATIC_SIZER_X_GAP);
+
+ vector<string> columns;
+ columns.push_back (wx_to_std (_("IP address / host name")));
+ _servers_list = new EditableList<std::string, ServerDialog> (
+ _servers_panel,
+ columns,
+ boost::bind (&Config::servers, Config::instance()),
+ boost::bind (&Config::set_servers, Config::instance(), _1),
+ boost::bind (&server_column, _1)
+ );
+
+ s->Add (_servers_list, 1, wxEXPAND | wxALL, DCPOMATIC_SIZER_X_GAP);
+
+ _use_any_servers->SetValue (Config::instance()->use_any_servers ());
+ _use_any_servers->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&ConfigDialog::use_any_servers_changed, this));
+}
+
+void
+ConfigDialog::use_any_servers_changed ()
+{
+ Config::instance()->set_use_any_servers (_use_any_servers->GetValue ());
+}
+
void
ConfigDialog::language_changed ()
{
class wxNotebook;
class PresetColourConversion;
class PresetColourConversionDialog;
+class ServerDialog;
/** @class ConfigDialog
* @brief A dialogue to edit DCP-o-matic configuration.
void mail_server_changed ();
void kdm_from_changed ();
void kdm_email_changed ();
+ void use_any_servers_changed ();
void setup_language_sensitivity ();
void make_misc_panel ();
+ void make_servers_panel ();
void make_tms_panel ();
void make_metadata_panel ();
void make_colour_conversions_panel ();
wxNotebook* _notebook;
wxPanel* _misc_panel;
+ wxPanel* _servers_panel;
wxPanel* _tms_panel;
EditableList<PresetColourConversion, PresetColourConversionDialog>* _colour_conversions_panel;
wxPanel* _metadata_panel;
wxSpinCtrl* _default_j2k_bandwidth;
wxPanel* _kdm_email_panel;
wxTextCtrl* _kdm_email;
+ wxCheckBox* _use_any_servers;
+ EditableList<std::string, ServerDialog>* _servers_list;
};
--- /dev/null
+/*
+ Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "lib/server.h"
+#include "server_dialog.h"
+#include "wx_util.h"
+
+using std::string;
+using boost::shared_ptr;
+
+ServerDialog::ServerDialog (wxWindow* parent)
+ : wxDialog (parent, wxID_ANY, _("Server"))
+{
+ wxFlexGridSizer* table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
+ table->AddGrowableCol (1, 1);
+
+ wxClientDC dc (parent);
+ /* XXX: bit of a mystery why we need such a long string here */
+ wxSize size = dc.GetTextExtent (wxT ("255.255.255.255.255.255.255.255"));
+ size.SetHeight (-1);
+
+ wxTextValidator validator (wxFILTER_INCLUDE_CHAR_LIST);
+ wxArrayString list;
+
+ add_label_to_sizer (table, this, _("Host name or IP address"), true);
+ _host = new wxTextCtrl (this, wxID_ANY, wxT (""), wxDefaultPosition, size);
+ table->Add (_host, 1, wxEXPAND | wxALL);
+
+ wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
+ overall_sizer->Add (table, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
+
+ wxSizer* buttons = CreateSeparatedButtonSizer (wxOK);
+ if (buttons) {
+ overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
+ }
+
+ SetSizer (overall_sizer);
+ overall_sizer->Layout ();
+ overall_sizer->SetSizeHints (this);
+}
+
+void
+ServerDialog::set (string server)
+{
+ _host->SetValue (std_to_wx (server));
+}
+
+string
+ServerDialog::get () const
+{
+ return wx_to_std (_host->GetValue ());
+}
+
--- /dev/null
+/*
+ Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <wx/wx.h>
+
+class ServerDialog : public wxDialog
+{
+public:
+ ServerDialog (wxWindow *);
+
+ void set (std::string);
+ std::string get () const;
+
+private:
+ wxTextCtrl* _host;
+};
properties_dialog.cc
repeat_dialog.cc
screen_dialog.cc
+ server_dialog.cc
servers_list_dialog.cc
subtitle_panel.cc
timecode.cc