summaryrefslogtreecommitdiff
path: root/src/lib/internal_player_server.cc
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/lib/internal_player_server.cc
parent321380eeb8a9ba4853a982558c9076d26aafdf82 (diff)
Extract internal player server to separate file and tidy up a bit.
Diffstat (limited to 'src/lib/internal_player_server.cc')
-rw-r--r--src/lib/internal_player_server.cc48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/lib/internal_player_server.cc b/src/lib/internal_player_server.cc
new file mode 100644
index 000000000..676cfa412
--- /dev/null
+++ b/src/lib/internal_player_server.cc
@@ -0,0 +1,48 @@
+/*
+ Copyright (C) 2024 Carl Hetherington <cth@carlh.net>
+
+ 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.
+
+ 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 DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#include "dcpomatic_socket.h"
+#include "internal_player_server.h"
+
+
+using std::shared_ptr;
+using std::string;
+using std::vector;
+
+
+void
+InternalPlayerServer::handle(shared_ptr<Socket> socket)
+{
+ try {
+ uint32_t const length = socket->read_uint32();
+ if (length > 65536) {
+ return;
+ }
+ vector<uint8_t> buffer(length);
+ socket->read(buffer.data(), buffer.size());
+ string s(reinterpret_cast<char*>(buffer.data()));
+ emit(boost::bind(boost::ref(LoadDCP), s));
+ socket->write(reinterpret_cast<uint8_t const *>("OK"), 3);
+ } catch (...) {
+
+ }
+}
+