diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-12-06 19:59:47 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-12-11 11:56:22 +0000 |
| commit | 17df947ac256397311a11894062070f8069c7e75 (patch) | |
| tree | bb84d231ae31cab2e7e4d6546c62fcd88150b4d8 /src/lib | |
| parent | d499ec381ea5fbbae954531be9d66c9cc723c230 (diff) | |
Rename Server -> EncodeServer, ServerFinder -> EncodeServerFinder, ServerDescription -> EncodeServerDescription.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/config.cc | 2 | ||||
| -rw-r--r-- | src/lib/dcp_video.cc | 4 | ||||
| -rw-r--r-- | src/lib/dcp_video.h | 4 | ||||
| -rw-r--r-- | src/lib/encode_server.cc (renamed from src/lib/server.cc) | 32 | ||||
| -rw-r--r-- | src/lib/encode_server.h (renamed from src/lib/server.h) | 16 | ||||
| -rw-r--r-- | src/lib/encode_server_description.h (renamed from src/lib/server_description.h) | 14 | ||||
| -rw-r--r-- | src/lib/encode_server_finder.cc (renamed from src/lib/server_finder.cc) | 48 | ||||
| -rw-r--r-- | src/lib/encode_server_finder.h (renamed from src/lib/server_finder.h) | 20 | ||||
| -rw-r--r-- | src/lib/encoder.cc | 15 | ||||
| -rw-r--r-- | src/lib/encoder.h | 4 | ||||
| -rw-r--r-- | src/lib/wscript | 4 |
11 files changed, 81 insertions, 82 deletions
diff --git a/src/lib/config.cc b/src/lib/config.cc index 43a3e63c9..b9e25e37a 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -18,7 +18,6 @@ */ #include "config.h" -#include "server.h" #include "filter.h" #include "ratio.h" #include "types.h" @@ -38,6 +37,7 @@ #include <boost/filesystem.hpp> #include <boost/algorithm/string.hpp> #include <boost/foreach.hpp> +#include <boost/thread.hpp> #include <cstdlib> #include <fstream> #include <iostream> diff --git a/src/lib/dcp_video.cc b/src/lib/dcp_video.cc index 26113a184..cd7d5229e 100644 --- a/src/lib/dcp_video.cc +++ b/src/lib/dcp_video.cc @@ -31,7 +31,7 @@ #include "dcp_video.h" #include "config.h" #include "exceptions.h" -#include "server_description.h" +#include "encode_server_description.h" #include "dcpomatic_socket.h" #include "image.h" #include "log.h" @@ -151,7 +151,7 @@ DCPVideo::encode_locally (dcp::NoteHandler note) * @return Encoded data. */ Data -DCPVideo::encode_remotely (ServerDescription serv, int timeout) +DCPVideo::encode_remotely (EncodeServerDescription serv, int timeout) { boost::asio::io_service io_service; boost::asio::ip::tcp::resolver resolver (io_service); diff --git a/src/lib/dcp_video.h b/src/lib/dcp_video.h index 05aa0ff7c..a61a757bd 100644 --- a/src/lib/dcp_video.h +++ b/src/lib/dcp_video.h @@ -19,7 +19,7 @@ */ #include "types.h" -#include "server_description.h" +#include "encode_server_description.h" #include <libcxml/cxml.h> #include <dcp/data.h> @@ -46,7 +46,7 @@ public: DCPVideo (boost::shared_ptr<const PlayerVideo>, cxml::ConstNodePtr, boost::shared_ptr<Log>); dcp::Data encode_locally (dcp::NoteHandler note); - dcp::Data encode_remotely (ServerDescription, int timeout = 30); + dcp::Data encode_remotely (EncodeServerDescription, int timeout = 30); int index () const { return _index; diff --git a/src/lib/server.cc b/src/lib/encode_server.cc index 7879d0fc8..3f30a361a 100644 --- a/src/lib/server.cc +++ b/src/lib/encode_server.cc @@ -17,12 +17,12 @@ */ -/** @file src/server.cc +/** @file src/encode_server.cc * @brief Class to describe a server to which we can send * encoding work, and a class to implement such a server. */ -#include "server.h" +#include "encode_server.h" #include "util.h" #include "dcpomatic_socket.h" #include "image.h" @@ -65,7 +65,7 @@ using boost::optional; using dcp::Size; using dcp::Data; -Server::Server (shared_ptr<Log> log, bool verbose) +EncodeServer::EncodeServer (shared_ptr<Log> log, bool verbose) : _terminate (false) , _log (log) , _verbose (verbose) @@ -74,7 +74,7 @@ Server::Server (shared_ptr<Log> log, bool verbose) } -Server::~Server () +EncodeServer::~EncodeServer () { { boost::mutex::scoped_lock lm (_worker_mutex); @@ -102,7 +102,7 @@ Server::~Server () * @param after_encode Filled in with gettimeofday() after encoding the image. */ int -Server::process (shared_ptr<Socket> socket, struct timeval& after_read, struct timeval& after_encode) +EncodeServer::process (shared_ptr<Socket> socket, struct timeval& after_read, struct timeval& after_encode) { uint32_t length = socket->read_uint32 (); scoped_array<char> buffer (new char[length]); @@ -143,7 +143,7 @@ Server::process (shared_ptr<Socket> socket, struct timeval& after_read, struct t } void -Server::worker_thread () +EncodeServer::worker_thread () { while (true) { boost::mutex::scoped_lock lock (_worker_mutex); @@ -209,7 +209,7 @@ Server::worker_thread () } void -Server::run (int num_threads) +EncodeServer::run (int num_threads) { LOG_GENERAL ("Server starting with %1 threads", num_threads); if (_verbose) { @@ -217,17 +217,17 @@ Server::run (int num_threads) } for (int i = 0; i < num_threads; ++i) { - _worker_threads.push_back (new thread (bind (&Server::worker_thread, this))); + _worker_threads.push_back (new thread (bind (&EncodeServer::worker_thread, this))); } - _broadcast.thread = new thread (bind (&Server::broadcast_thread, this)); + _broadcast.thread = new thread (bind (&EncodeServer::broadcast_thread, this)); start_accept (); _io_service.run (); } void -Server::broadcast_thread () +EncodeServer::broadcast_thread () try { boost::asio::ip::address address = boost::asio::ip::address_v4::any (); @@ -240,7 +240,7 @@ try _broadcast.socket->async_receive_from ( boost::asio::buffer (_broadcast.buffer, sizeof (_broadcast.buffer)), _broadcast.send_endpoint, - boost::bind (&Server::broadcast_received, this) + boost::bind (&EncodeServer::broadcast_received, this) ); _broadcast.io_service.run (); @@ -251,7 +251,7 @@ catch (...) } void -Server::broadcast_received () +EncodeServer::broadcast_received () { _broadcast.buffer[sizeof(_broadcast.buffer) - 1] = '\0'; @@ -278,23 +278,23 @@ Server::broadcast_received () _broadcast.socket->async_receive_from ( boost::asio::buffer (_broadcast.buffer, sizeof (_broadcast.buffer)), - _broadcast.send_endpoint, boost::bind (&Server::broadcast_received, this) + _broadcast.send_endpoint, boost::bind (&EncodeServer::broadcast_received, this) ); } void -Server::start_accept () +EncodeServer::start_accept () { if (_terminate) { return; } shared_ptr<Socket> socket (new Socket); - _acceptor.async_accept (socket->socket (), boost::bind (&Server::handle_accept, this, socket, boost::asio::placeholders::error)); + _acceptor.async_accept (socket->socket (), boost::bind (&EncodeServer::handle_accept, this, socket, boost::asio::placeholders::error)); } void -Server::handle_accept (shared_ptr<Socket> socket, boost::system::error_code const & error) +EncodeServer::handle_accept (shared_ptr<Socket> socket, boost::system::error_code const & error) { if (error) { return; diff --git a/src/lib/server.h b/src/lib/encode_server.h index 97bc26fd8..f6f1fc9b9 100644 --- a/src/lib/server.h +++ b/src/lib/encode_server.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2015 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 @@ -17,10 +17,10 @@ */ -#ifndef DCPOMATIC_SERVER_H -#define DCPOMATIC_SERVER_H +#ifndef DCPOMATIC_ENCODE_SERVER_H +#define DCPOMATIC_ENCODE_SERVER_H -/** @file src/server.h +/** @file src/encode_server.h * @brief Server class. */ @@ -33,15 +33,15 @@ class Socket; class Log; -/** @class Server +/** @class EncodeServer * @brief A class to run a server which can accept requests to perform JPEG2000 * encoding work. */ -class Server : public ExceptionStore, public boost::noncopyable +class EncodeServer : public ExceptionStore, public boost::noncopyable { public: - Server (boost::shared_ptr<Log> log, bool verbose); - ~Server (); + EncodeServer (boost::shared_ptr<Log> log, bool verbose); + ~EncodeServer (); void run (int num_threads); diff --git a/src/lib/server_description.h b/src/lib/encode_server_description.h index 35d2df356..2ff1b80f1 100644 --- a/src/lib/server_description.h +++ b/src/lib/encode_server_description.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2015 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 @@ -17,16 +17,16 @@ */ -#ifndef DCPOMATIC_SERVER_DESCRIPTION_H -#define DCPOMATIC_SERVER_DESCRIPTION_H +#ifndef DCPOMATIC_ENCODE_SERVER_DESCRIPTION_H +#define DCPOMATIC_ENCODE_SERVER_DESCRIPTION_H -/** @class ServerDescription +/** @class EncodeServerDescription * @brief Class to describe a server to which we can send encoding work. */ -class ServerDescription +class EncodeServerDescription { public: - ServerDescription () + EncodeServerDescription () : _host_name ("") , _threads (1) {} @@ -34,7 +34,7 @@ public: /** @param h Server host name or IP address in string form. * @param t Number of threads to use on the server. */ - ServerDescription (std::string h, int t) + EncodeServerDescription (std::string h, int t) : _host_name (h) , _threads (t) {} diff --git a/src/lib/server_finder.cc b/src/lib/encode_server_finder.cc index 8685c830f..aa76e396b 100644 --- a/src/lib/server_finder.cc +++ b/src/lib/encode_server_finder.cc @@ -17,12 +17,12 @@ */ -#include "server_finder.h" +#include "encode_server_finder.h" #include "exceptions.h" #include "util.h" #include "config.h" #include "cross.h" -#include "server_description.h" +#include "encode_server_description.h" #include "dcpomatic_socket.h" #include "raw_convert.h" #include <libcxml/cxml.h> @@ -39,25 +39,25 @@ using boost::shared_ptr; using boost::scoped_array; using boost::weak_ptr; -ServerFinder* ServerFinder::_instance = 0; +EncodeServerFinder* EncodeServerFinder::_instance = 0; -ServerFinder::ServerFinder () +EncodeServerFinder::EncodeServerFinder () : _disabled (false) , _search_thread (0) , _listen_thread (0) , _stop (false) { - Config::instance()->Changed.connect (boost::bind (&ServerFinder::config_changed, this, _1)); + Config::instance()->Changed.connect (boost::bind (&EncodeServerFinder::config_changed, this, _1)); } void -ServerFinder::start () +EncodeServerFinder::start () { - _search_thread = new boost::thread (boost::bind (&ServerFinder::search_thread, this)); - _listen_thread = new boost::thread (boost::bind (&ServerFinder::listen_thread, this)); + _search_thread = new boost::thread (boost::bind (&EncodeServerFinder::search_thread, this)); + _listen_thread = new boost::thread (boost::bind (&EncodeServerFinder::listen_thread, this)); } -ServerFinder::~ServerFinder () +EncodeServerFinder::~EncodeServerFinder () { _stop = true; @@ -75,7 +75,7 @@ ServerFinder::~ServerFinder () } void -ServerFinder::search_thread () +EncodeServerFinder::search_thread () try { boost::system::error_code error; @@ -129,7 +129,7 @@ catch (...) } void -ServerFinder::listen_thread () +EncodeServerFinder::listen_thread () try { using namespace boost::asio::ip; @@ -148,17 +148,17 @@ catch (...) } void -ServerFinder::start_accept () +EncodeServerFinder::start_accept () { shared_ptr<Socket> socket (new Socket ()); _listen_acceptor->async_accept ( socket->socket(), - boost::bind (&ServerFinder::handle_accept, this, boost::asio::placeholders::error, socket) + boost::bind (&EncodeServerFinder::handle_accept, this, boost::asio::placeholders::error, socket) ); } void -ServerFinder::handle_accept (boost::system::error_code ec, shared_ptr<Socket> socket) +EncodeServerFinder::handle_accept (boost::system::error_code ec, shared_ptr<Socket> socket) { if (ec) { start_accept (); @@ -178,7 +178,7 @@ ServerFinder::handle_accept (boost::system::error_code ec, shared_ptr<Socket> so string const ip = socket->socket().remote_endpoint().address().to_string (); if (!server_found (ip) && xml->optional_number_child<int>("Version").get_value_or (0) == SERVER_LINK_VERSION) { - ServerDescription sd (ip, xml->number_child<int> ("Threads")); + EncodeServerDescription sd (ip, xml->number_child<int> ("Threads")); { boost::mutex::scoped_lock lm (_servers_mutex); _servers.push_back (sd); @@ -190,10 +190,10 @@ ServerFinder::handle_accept (boost::system::error_code ec, shared_ptr<Socket> so } bool -ServerFinder::server_found (string ip) const +EncodeServerFinder::server_found (string ip) const { boost::mutex::scoped_lock lm (_servers_mutex); - list<ServerDescription>::const_iterator i = _servers.begin(); + list<EncodeServerDescription>::const_iterator i = _servers.begin(); while (i != _servers.end() && i->host_name() != ip) { ++i; } @@ -201,11 +201,11 @@ ServerFinder::server_found (string ip) const return i != _servers.end (); } -ServerFinder* -ServerFinder::instance () +EncodeServerFinder* +EncodeServerFinder::instance () { if (!_instance) { - _instance = new ServerFinder (); + _instance = new EncodeServerFinder (); _instance->start (); } @@ -213,21 +213,21 @@ ServerFinder::instance () } void -ServerFinder::drop () +EncodeServerFinder::drop () { delete _instance; _instance = 0; } -list<ServerDescription> -ServerFinder::servers () const +list<EncodeServerDescription> +EncodeServerFinder::servers () const { boost::mutex::scoped_lock lm (_servers_mutex); return _servers; } void -ServerFinder::config_changed (Config::Property what) +EncodeServerFinder::config_changed (Config::Property what) { if (what == Config::USE_ANY_SERVERS || what == Config::SERVERS) { { diff --git a/src/lib/server_finder.h b/src/lib/encode_server_finder.h index 08e138b82..49433ad42 100644 --- a/src/lib/server_finder.h +++ b/src/lib/encode_server_finder.h @@ -17,12 +17,12 @@ */ -/** @file src/lib/server_finder.h - * @brief ServerFinder class. +/** @file src/lib/encode_server_finder.h + * @brief EncodeServerFinder class. */ #include "signaller.h" -#include "server_description.h" +#include "encode_server_description.h" #include "config.h" #include "exception_store.h" #include <boost/signals2.hpp> @@ -30,10 +30,10 @@ class Socket; -class ServerFinder : public Signaller, public ExceptionStore +class EncodeServerFinder : public Signaller, public ExceptionStore { public: - static ServerFinder* instance (); + static EncodeServerFinder* instance (); static void drop (); void disable () { @@ -44,14 +44,14 @@ public: return _disabled; } - std::list<ServerDescription> servers () const; + std::list<EncodeServerDescription> servers () const; /** Emitted whenever the list of servers changes */ boost::signals2::signal<void ()> ServersListChanged; private: - ServerFinder (); - ~ServerFinder (); + EncodeServerFinder (); + ~EncodeServerFinder (); void start (); @@ -71,7 +71,7 @@ private: /** Thread to listen to the responses from servers */ boost::thread* _listen_thread; - std::list<ServerDescription> _servers; + std::list<EncodeServerDescription> _servers; mutable boost::mutex _servers_mutex; boost::asio::io_service _listen_io_service; @@ -81,5 +81,5 @@ private: boost::condition _search_condition; boost::mutex _search_condition_mutex; - static ServerFinder* _instance; + static EncodeServerFinder* _instance; }; diff --git a/src/lib/encoder.cc b/src/lib/encoder.cc index bfb96f41b..8ba794a8e 100644 --- a/src/lib/encoder.cc +++ b/src/lib/encoder.cc @@ -27,13 +27,12 @@ #include "log.h" #include "config.h" #include "dcp_video.h" -#include "server.h" #include "cross.h" #include "writer.h" -#include "server_finder.h" +#include "encode_server_finder.h" #include "player.h" #include "player_video.h" -#include "server_description.h" +#include "encode_server_description.h" #include "compose.hpp" #include <libcxml/cxml.h> #include <boost/foreach.hpp> @@ -79,8 +78,8 @@ Encoder::~Encoder () void Encoder::begin () { - if (!ServerFinder::instance()->disabled ()) { - _server_found_connection = ServerFinder::instance()->ServersListChanged.connect (boost::bind (&Encoder::servers_list_changed, this)); + if (!EncodeServerFinder::instance()->disabled ()) { + _server_found_connection = EncodeServerFinder::instance()->ServersListChanged.connect (boost::bind (&Encoder::servers_list_changed, this)); } } @@ -277,7 +276,7 @@ Encoder::terminate_threads () } void -Encoder::encoder_thread (optional<ServerDescription> server) +Encoder::encoder_thread (optional<EncodeServerDescription> server) try { if (server) { @@ -384,11 +383,11 @@ Encoder::servers_list_changed () if (!Config::instance()->only_servers_encode ()) { for (int i = 0; i < Config::instance()->num_local_encoding_threads (); ++i) { - _threads.push_back (new boost::thread (boost::bind (&Encoder::encoder_thread, this, optional<ServerDescription> ()))); + _threads.push_back (new boost::thread (boost::bind (&Encoder::encoder_thread, this, optional<EncodeServerDescription> ()))); } } - BOOST_FOREACH (ServerDescription i, ServerFinder::instance()->servers ()) { + BOOST_FOREACH (EncodeServerDescription i, EncodeServerFinder::instance()->servers ()) { LOG_GENERAL (N_("Adding %1 worker threads for remote %2"), i.threads(), i.host_name ()); for (int j = 0; j < i.threads(); ++j) { _threads.push_back (new boost::thread (boost::bind (&Encoder::encoder_thread, this, i))); diff --git a/src/lib/encoder.h b/src/lib/encoder.h index d5b1455d7..20f2951b6 100644 --- a/src/lib/encoder.h +++ b/src/lib/encoder.h @@ -37,7 +37,7 @@ #include <stdint.h> class Film; -class ServerDescription; +class EncodeServerDescription; class DCPVideo; class Writer; class Job; @@ -75,7 +75,7 @@ private: void enqueue (boost::shared_ptr<PlayerVideo> f); void frame_done (); - void encoder_thread (boost::optional<ServerDescription>); + void encoder_thread (boost::optional<EncodeServerDescription>); void terminate_threads (); void servers_list_changed (); diff --git a/src/lib/wscript b/src/lib/wscript index 7b272f566..0f0b0c14f 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -55,6 +55,8 @@ sources = """ dolby_cp750.cc emailer.cc encoder.cc + encode_server.cc + encode_server_finder.cc encoded_log_entry.cc environment_info.cc examine_content_job.cc @@ -107,8 +109,6 @@ sources = """ screen_kdm.cc send_kdm_email_job.cc send_problem_report_job.cc - server.cc - server_finder.cc single_stream_audio_content.cc sndfile_base.cc sndfile_content.cc |
