}
_server_port_base = b.get ();
- list<shared_ptr<cxml::Node> > servers = f.node_children ("Server");
- for (list<shared_ptr<cxml::Node> >::iterator i = servers.begin(); i != servers.end(); ++i) {
- _servers.push_back (ServerDescription (*i));
- }
-
_tms_ip = f.string_child ("TMSIP");
_tms_path = f.string_child ("TMSPath");
_tms_user = f.string_child ("TMSUser");
_default_directory = v;
} else if (k == N_("server_port")) {
_server_port_base = atoi (v.c_str ());
- } else if (k == N_("server")) {
- optional<ServerDescription> server = ServerDescription::create_from_metadata (v);
- if (server) {
- _servers.push_back (server.get ());
- }
} 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));
-
- for (vector<ServerDescription>::const_iterator i = _servers.begin(); i != _servers.end(); ++i) {
- i->as_xml (root->add_child ("Server"));
- }
-
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);
root->add_child("KDMFrom")->add_child_text (_kdm_from);
root->add_child("KDMEmail")->add_child_text (_kdm_email);
- std::cout << "dcpomatic: writing configuration to " << file(false).string() << "\n";
doc.write_to_file_formatted (file(false).string ());
- std::cout << "dcpomatic: wrote configuration to " << file(false).string() << "\n";
}
boost::filesystem::path
#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;
}
- /** @return J2K encoding servers to use */
- std::vector<ServerDescription> 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;
_server_port_base = p;
}
- /** @param s New list of servers */
- void set_servers (std::vector<ServerDescription> s) {
- _servers = s;
- }
-
void set_reference_scaler (Scaler const * s) {
_reference_scaler = s;
}
* this port and the one above it will be used.
*/
int _server_port_base;
-
- /** J2K encoding servers to use */
- std::vector<ServerDescription> _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 */
_threads.push_back (new boost::thread (boost::bind (&Encoder::encoder_thread, this, optional<ServerDescription> ())));
}
- vector<ServerDescription> servers = Config::instance()->servers ();
-
- for (vector<ServerDescription>::iterator i = servers.begin(); i != servers.end(); ++i) {
- add_worker_threads (*i);
- }
-
_writer.reset (new Writer (_film, _job));
ServerFinder::instance()->connect (boost::bind (&Encoder::server_found, this, _1));
}
using boost::lexical_cast;
using libdcp::Size;
-ServerDescription::ServerDescription (shared_ptr<const cxml::Node> node)
-{
- _host_name = node->string_child ("HostName");
- _threads = node->number_child<int> ("Threads");
-}
-
-void
-ServerDescription::as_xml (xmlpp::Node* root) const
-{
- root->add_child("HostName")->add_child_text (_host_name);
- root->add_child("Threads")->add_child_text (boost::lexical_cast<string> (_threads));
-}
-
-/** Create a server description from a string of metadata returned from as_metadata().
- * @param v Metadata.
- * @return ServerDescription, or 0.
- */
-optional<ServerDescription>
-ServerDescription::create_from_metadata (string v)
-{
- vector<string> b;
- split (b, v, is_any_of (" "));
-
- if (b.size() != 2) {
- return optional<ServerDescription> ();
- }
-
- return ServerDescription (b[0], atoi (b[1].c_str ()));
-}
-
Server::Server (shared_ptr<Log> log, bool verbose)
: _log (log)
, _verbose (verbose)
, _threads (t)
{}
- ServerDescription (boost::shared_ptr<const cxml::Node>);
-
/* Default copy constructor is fine */
/** @return server's host name or IP address in string form */
_threads = t;
}
- void as_xml (xmlpp::Node *) const;
-
- static boost::optional<ServerDescription> create_from_metadata (std::string);
-
private:
/** server's host name */
std::string _host_name;
ServerFinder* ServerFinder::_instance = 0;
ServerFinder::ServerFinder ()
- : _broadcast_thread (0)
+ : _disabled (false)
+ , _broadcast_thread (0)
, _listen_thread (0)
{
_broadcast_thread = new boost::thread (boost::bind (&ServerFinder::broadcast_thread, this));
void
ServerFinder::connect (boost::function<void (ServerDescription)> fn)
{
+ if (_disabled) {
+ return;
+ }
+
boost::mutex::scoped_lock lm (_mutex);
/* Emit the current list of servers */
static ServerFinder* instance ();
+ void disable () {
+ _disabled = true;
+ }
+
private:
ServerFinder ();
void listen_thread ();
boost::signals2::signal<void (ServerDescription)> ServerFound;
+
+ bool _disabled;
/** Thread to periodically issue broadcasts to find encoding servers */
boost::thread* _broadcast_thread;
#include "lib/config.h"
#include "lib/log.h"
#include "lib/ui_signaller.h"
+#include "lib/server_finder.h"
using std::string;
using std::cerr;
ui_signaller = new UISignaller ();
if (no_remote) {
- Config::instance()->set_servers (vector<ServerDescription> ());
+ ServerFinder::instance()->disable ();
}
cout << "DCP-o-matic " << dcpomatic_version << " git " << dcpomatic_git_commit;
#include <wx/notebook.h>
#include <libdcp/colour_matrix.h>
#include "lib/config.h"
-#include "lib/server.h"
#include "lib/ratio.h"
#include "lib/scaler.h"
#include "lib/filter.h"
#include "config_dialog.h"
#include "wx_util.h"
#include "filter_dialog.h"
-#include "server_dialog.h"
#include "dir_picker_ctrl.h"
#include "dci_metadata_dialog.h"
#include "preset_colour_conversion_dialog.h"
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 std::string
-server_column (ServerDescription s, int c)
-{
- switch (c) {
- case 0:
- return s.host_name ();
- case 1:
- return lexical_cast<string> (s.threads ());
- }
-
- return "";
-}
-
-void
-ConfigDialog::make_servers_panel ()
-{
- vector<string> columns;
- columns.push_back (wx_to_std (_("IP address")));
- columns.push_back (wx_to_std (_("Threads")));
- _servers_panel = new EditableList<ServerDescription, ServerDialog> (
- _notebook,
- columns,
- boost::bind (&Config::servers, Config::instance()),
- boost::bind (&Config::set_servers, Config::instance(), _1),
- boost::bind (&server_column, _1, _2)
- );
-}
-
void
ConfigDialog::language_changed ()
{
class DirPickerCtrl;
class wxNotebook;
-class ServerDescription;
class PresetColourConversion;
class PresetColourConversionDialog;
-class ServerDialog;
/** @class ConfigDialog
* @brief A dialogue to edit DCP-o-matic configuration.
void make_misc_panel ();
void make_tms_panel ();
void make_metadata_panel ();
- void make_servers_panel ();
void make_colour_conversions_panel ();
void make_kdm_email_panel ();
wxPanel* _misc_panel;
wxPanel* _tms_panel;
EditableList<PresetColourConversion, PresetColourConversionDialog>* _colour_conversions_panel;
- EditableList<ServerDescription, ServerDialog>* _servers_panel;
wxPanel* _metadata_panel;
wxCheckBox* _set_language;
wxChoice* _language;
+++ /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 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);
-
- add_label_to_sizer (table, this, _("Threads to use"), true);
- _threads = new wxSpinCtrl (this, wxID_ANY);
- table->Add (_threads, 1, wxEXPAND);
-
- _threads->SetRange (0, 256);
-
- 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 (ServerDescription server)
-{
- _host->SetValue (std_to_wx (server.host_name ()));
- _threads->SetValue (server.threads ());
-}
-
-ServerDescription
-ServerDialog::get () const
-{
- ServerDescription server;
- server.set_host_name (wx_to_std (_host->GetValue ()));
- server.set_threads (_threads->GetValue ());
- return server;
-}
-
+++ /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>
-#include <wx/spinctrl.h>
-
-class ServerDescription;
-
-class ServerDialog : public wxDialog
-{
-public:
- ServerDialog (wxWindow *);
-
- void set (ServerDescription);
- ServerDescription get () const;
-
-private:
- wxTextCtrl* _host;
- wxSpinCtrl* _threads;
-};
#include <wx/wx.h>
#include <wx/listctrl.h>
+#include "lib/server.h"
class ServersListDialog : public wxDialog
{
properties_dialog.cc
repeat_dialog.cc
screen_dialog.cc
- server_dialog.cc
servers_list_dialog.cc
subtitle_panel.cc
timecode.cc
#include "lib/job_manager.h"
#include "lib/job.h"
#include "lib/cross.h"
+#include "lib/server_finder.h"
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE dcpomatic_test
#include <boost/test/unit_test.hpp>
dcpomatic_setup();
Config::instance()->set_num_local_encoding_threads (1);
- Config::instance()->set_servers (vector<ServerDescription> ());
Config::instance()->set_server_port_base (61920);
Config::instance()->set_default_dci_metadata (DCIMetadata ());
Config::instance()->set_default_container (static_cast<Ratio*> (0));
Config::instance()->set_default_dcp_content_type (static_cast<DCPContentType*> (0));
+ ServerFinder::instance()->disable ();
+
ui_signaller = new TestUISignaller ();
}
};