From 6b1ebeac38cf60142c542bbad30cea5597d7e1e7 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 15 Jun 2024 18:02:27 +0200 Subject: Extract internal player server to separate file and tidy up a bit. --- src/lib/internal_player_server.cc | 48 +++++++++++++++++++++++++++++++++++++++ src/lib/internal_player_server.h | 46 +++++++++++++++++++++++++++++++++++++ src/lib/wscript | 1 + 3 files changed, 95 insertions(+) create mode 100644 src/lib/internal_player_server.cc create mode 100644 src/lib/internal_player_server.h (limited to 'src/lib') 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 + + 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 . + +*/ + + +#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) +{ + try { + uint32_t const length = socket->read_uint32(); + if (length > 65536) { + return; + } + vector buffer(length); + socket->read(buffer.data(), buffer.size()); + string s(reinterpret_cast(buffer.data())); + emit(boost::bind(boost::ref(LoadDCP), s)); + socket->write(reinterpret_cast("OK"), 3); + } catch (...) { + + } +} + diff --git a/src/lib/internal_player_server.h b/src/lib/internal_player_server.h new file mode 100644 index 000000000..0648c9657 --- /dev/null +++ b/src/lib/internal_player_server.h @@ -0,0 +1,46 @@ +/* + Copyright (C) 2024 Carl Hetherington + + 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 . + +*/ + + +#include "config.h" +#include "server.h" +#include "signaller.h" +#include "types.h" +#include +#include + + +/** A server which is always started, that listens for requests from the main + * DCP-o-matic to play a DCP. + */ + +class InternalPlayerServer : public Server, public Signaller +{ +public: + InternalPlayerServer() + : Server(PLAYER_PLAY_PORT) + {} + + boost::signals2::signal LoadDCP; + +private: + void handle(std::shared_ptr socket) override; +}; + diff --git a/src/lib/wscript b/src/lib/wscript index 33e68a108..1c53538a1 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -138,6 +138,7 @@ sources = """ image_png.cc image_proxy.cc image_store.cc + internal_player_server.cc j2k_image_proxy.cc job.cc job_manager.cc -- cgit v1.2.3