X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Flib%2Fencode_server_finder.h;h=abfcc6d35c5512526aec86af38aeda773007a746;hp=49433ad42fe2a9cd24aa7e6d872ec326cf9f9c07;hb=9106e6ed551b13e1b7c7ee2088d54ce0ae430bcf;hpb=17df947ac256397311a11894062070f8069c7e75 diff --git a/src/lib/encode_server_finder.h b/src/lib/encode_server_finder.h index 49433ad42..abfcc6d35 100644 --- a/src/lib/encode_server_finder.h +++ b/src/lib/encode_server_finder.h @@ -1,19 +1,20 @@ /* - Copyright (C) 2013-2015 Carl Hetherington + Copyright (C) 2013-2018 Carl Hetherington - This program is free software; you can redistribute it and/or modify + This file is part of DCP-o-matic. + + DCP-o-matic 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, + DCP-o-matic 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. + along with DCP-o-matic. If not, see . */ @@ -30,19 +31,22 @@ class Socket; +/** @class EncodeServerFinder + * @brief Locater of encoding servers. + * + * This class finds active (i.e. responding) encode servers. Depending on + * configuration it finds servers by: + * + * 1. broadcasting a request to the local subnet and + * 2. checking to see if any of the configured server hosts are up. + */ class EncodeServerFinder : public Signaller, public ExceptionStore { public: static EncodeServerFinder* instance (); static void drop (); - void disable () { - _disabled = true; - } - - bool disabled () const { - return _disabled; - } + void stop (); std::list servers () const; @@ -58,20 +62,20 @@ private: void search_thread (); void listen_thread (); - bool server_found (std::string) const; + boost::optional::iterator> server_found (std::string); void start_accept (); void handle_accept (boost::system::error_code ec, boost::shared_ptr socket); void config_changed (Config::Property what); - bool _disabled; - /** Thread to periodically issue broadcasts and requests to find encoding servers */ boost::thread* _search_thread; /** Thread to listen to the responses from servers */ boost::thread* _listen_thread; + /** Available servers */ std::list _servers; + /** Mutex for _servers */ mutable boost::mutex _servers_mutex; boost::asio::io_service _listen_io_service;