diff options
| author | Carl Hetherington <cth@carlh.net> | 2018-06-09 23:43:58 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2018-06-09 23:43:58 +0100 |
| commit | 4513308f3c08579d53a0eee91b470dca3a28cbc2 (patch) | |
| tree | 71708f4825f779e092e2868469901347a21f76fc /src/tools/dcpomatic_player.cc | |
| parent | 85fedd82ef6f1b2330534ce91ca64c46910e8e57 (diff) | |
Add option to open a DCP in the player (#1312).
Diffstat (limited to 'src/tools/dcpomatic_player.cc')
| -rw-r--r-- | src/tools/dcpomatic_player.cc | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/tools/dcpomatic_player.cc b/src/tools/dcpomatic_player.cc index 5c8c7d1d5..839886c87 100644 --- a/src/tools/dcpomatic_player.cc +++ b/src/tools/dcpomatic_player.cc @@ -32,6 +32,8 @@ #include "lib/verify_dcp_job.h" #include "lib/dcp_examiner.h" #include "lib/examine_content_job.h" +#include "lib/server.h" +#include "lib/dcpomatic_socket.h" #include "wx/wx_signal_manager.h" #include "wx/wx_util.h" #include "wx/about_dialog.h" @@ -65,8 +67,10 @@ using std::list; using std::exception; using std::vector; using boost::shared_ptr; +using boost::scoped_array; using boost::optional; using boost::dynamic_pointer_cast; +using boost::thread; enum { ID_file_open = 1, @@ -647,6 +651,32 @@ 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) + { + try { + int const length = socket->read_uint32 (); + 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. */ @@ -716,6 +746,9 @@ private: signal_manager = new wxSignalManager (this); + PlayServer* server = new PlayServer (_frame); + new thread (boost::bind (&PlayServer::run, server)); + if (!_dcp_to_load.empty() && boost::filesystem::is_directory (_dcp_to_load)) { try { _frame->load_dcp (_dcp_to_load); |
