summaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-06-15 18:02:27 +0200
committerCarl Hetherington <cth@carlh.net>2024-06-23 19:51:28 +0200
commit6b1ebeac38cf60142c542bbad30cea5597d7e1e7 (patch)
tree11a5130a58f6ec2086204b9e7462ef43e81593bb /src/tools
parent321380eeb8a9ba4853a982558c9076d26aafdf82 (diff)
Extract internal player server to separate file and tidy up a bit.
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/dcpomatic_player.cc55
1 files changed, 17 insertions, 38 deletions
diff --git a/src/tools/dcpomatic_player.cc b/src/tools/dcpomatic_player.cc
index d462c7271..f6e052b41 100644
--- a/src/tools/dcpomatic_player.cc
+++ b/src/tools/dcpomatic_player.cc
@@ -54,6 +54,7 @@
#include "lib/image.h"
#include "lib/image_jpeg.h"
#include "lib/image_png.h"
+#include "lib/internal_player_server.h"
#include "lib/internet.h"
#include "lib/job.h"
#include "lib/job_manager.h"
@@ -310,6 +311,8 @@ public:
_stress.LoadDCP.connect (boost::bind(&DOMFrame::load_dcp, this, _1));
+ setup_internal_player_server();
+
SetDropTarget(new DCPDropTarget(this));
}
@@ -1039,6 +1042,20 @@ private:
update_from_config (prop);
}
+ void setup_internal_player_server()
+ {
+ try {
+ auto server = new InternalPlayerServer();
+ server->LoadDCP.connect(boost::bind(&DOMFrame::load_dcp, this, _1));
+ new thread(boost::bind(&InternalPlayerServer::run, server));
+ } catch (std::exception& e) {
+ /* This is not the end of the world; probably a failure to bind the server socket
+ * because there's already another player running.
+ */
+ LOG_DEBUG_PLAYER("Failed to start internal player server (%1)", e.what());
+ }
+ }
+
void update_from_config (Config::Property prop)
{
for (int i = 0; i < _history_items; ++i) {
@@ -1164,34 +1181,6 @@ static const wxCmdLineEntryDesc command_line_description[] = {
{ wxCMD_LINE_NONE, "", "", "", wxCmdLineParamType (0), 0 }
};
-class PlayServer : public Server
-{
-public:
- explicit PlayServer (DOMFrame* frame)
- : Server (PLAYER_PLAY_PORT)
- , _frame (frame)
- {}
-
- void handle (shared_ptr<Socket> socket) override
- {
- try {
- uint32_t const length = socket->read_uint32 ();
- if (length > 65536) {
- return;
- }
- scoped_array<char> buffer (new char[length]);
- socket->read (reinterpret_cast<uint8_t*> (buffer.get()), length);
- string s (buffer.get());
- signal_manager->when_idle (bind (&DOMFrame::load_dcp, _frame, s));
- socket->write (reinterpret_cast<uint8_t const *> ("OK"), 3);
- } catch (...) {
-
- }
- }
-
-private:
- DOMFrame* _frame;
-};
/** @class App
* @brief The magic App class for wxWidgets.
@@ -1265,16 +1254,6 @@ private:
}
_frame->Show ();
- try {
- auto server = new PlayServer (_frame);
- new thread (boost::bind (&PlayServer::run, server));
- } catch (std::exception& e) {
- /* This is not the end of the world; probably a failure to bind the server socket
- * because there's already another player running.
- */
- LOG_DEBUG_PLAYER ("Failed to start play server (%1)", e.what());
- }
-
if (!_dcp_to_load.empty() && dcp::filesystem::is_directory(_dcp_to_load)) {
try {
_frame->load_dcp (_dcp_to_load);