From 4513308f3c08579d53a0eee91b470dca3a28cbc2 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 9 Jun 2018 23:43:58 +0100 Subject: [PATCH] Add option to open a DCP in the player (#1312). --- ChangeLog | 6 +++++- src/lib/cross.cc | 8 +++++++- src/lib/cross.h | 3 ++- src/lib/types.h | 2 ++ src/tools/dcpomatic.cc | 14 ++++++++++++++ src/tools/dcpomatic_player.cc | 33 +++++++++++++++++++++++++++++++++ 6 files changed, 63 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 842ac5a2a..85b0f21a9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,8 @@ -2018-06-08 Carl Hetherington +2018-06-09 Carl Hetherington + + * Add option to open a DCP in the player (#1312). + +a2018-06-08 Carl Hetherington * Add support for rotation and flipping of video sources, and auto-detect when this is necessary (#966). diff --git a/src/lib/cross.cc b/src/lib/cross.cc index 4991d9ae3..75205dc1a 100644 --- a/src/lib/cross.cc +++ b/src/lib/cross.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2015 Carl Hetherington + Copyright (C) 2012-2018 Carl Hetherington This file is part of DCP-o-matic. @@ -414,6 +414,12 @@ start_batch_converter (boost::filesystem::path dcpomatic) start_tool (dcpomatic, "dcpomatic2_batch", "DCP-o-matic\\ 2\\ Batch\\ Converter.app"); } +void +start_player (boost::filesystem::path dcpomatic) +{ + start_tool (dcpomatic, "dcpomatic2_player", "DCP-o-matic\\ 2\\ Player.app"); +} + uint64_t thread_id () { diff --git a/src/lib/cross.h b/src/lib/cross.h index 8c1df998b..f1af03346 100644 --- a/src/lib/cross.h +++ b/src/lib/cross.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2015 Carl Hetherington + Copyright (C) 2012-2018 Carl Hetherington This file is part of DCP-o-matic. @@ -52,6 +52,7 @@ extern boost::filesystem::path shared_path (); extern FILE * fopen_boost (boost::filesystem::path, std::string); extern int dcpomatic_fseek (FILE *, int64_t, int); extern void start_batch_converter (boost::filesystem::path dcpomatic); +extern void start_player (boost::filesystem::path dcpomatic); extern uint64_t thread_id (); extern int avio_open_boost (AVIOContext** s, boost::filesystem::path file, int flags); diff --git a/src/lib/types.h b/src/lib/types.h index ed3746f45..dfce6aec5 100644 --- a/src/lib/types.h +++ b/src/lib/types.h @@ -80,6 +80,8 @@ namespace xmlpp { #define BATCH_SERVER_PRESENCE_PORT (Config::instance()->server_port_base()+3) /** Port on which batch converter listens for job requests */ #define BATCH_JOB_PORT (Config::instance()->server_port_base()+4) +/** Port on which player listens for play requests */ +#define PLAYER_PLAY_PORT (Config::instance()->server_port_base()+5) typedef std::vector > ContentList; typedef std::vector > FFmpegContentList; diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index f349a7cf3..64c11281c 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -211,6 +211,7 @@ enum { ID_jobs_export, ID_jobs_send_dcp_to_tms, ID_jobs_show_dcp, + ID_jobs_open_dcp_in_player, ID_tools_video_waveform, ID_tools_hints, ID_tools_encoding_servers, @@ -295,6 +296,7 @@ public: Bind (wxEVT_MENU, boost::bind (&DOMFrame::jobs_export, this), ID_jobs_export); Bind (wxEVT_MENU, boost::bind (&DOMFrame::jobs_send_dcp_to_tms, this), ID_jobs_send_dcp_to_tms); Bind (wxEVT_MENU, boost::bind (&DOMFrame::jobs_show_dcp, this), ID_jobs_show_dcp); + Bind (wxEVT_MENU, boost::bind (&DOMFrame::jobs_open_dcp_in_player, this), ID_jobs_open_dcp_in_player); Bind (wxEVT_MENU, boost::bind (&DOMFrame::tools_video_waveform, this), ID_tools_video_waveform); Bind (wxEVT_MENU, boost::bind (&DOMFrame::tools_hints, this), ID_tools_hints); Bind (wxEVT_MENU, boost::bind (&DOMFrame::tools_encoding_servers, this), ID_tools_encoding_servers); @@ -739,6 +741,17 @@ private: } } + void jobs_open_dcp_in_player () + { + if (!_film) { + return; + } + + if (send_to_other_tool (PLAYER_PLAY_PORT, bind (&start_player, _1), _film->dir(_film->dcp_name(false)).string())) { + error_dialog (this, _("Could not find player.")); + } + } + void jobs_make_self_dkdm () { if (!_film) { @@ -1120,6 +1133,7 @@ private: jobs_menu->AppendSeparator (); add_item (jobs_menu, _("&Send DCP to TMS"), ID_jobs_send_dcp_to_tms, NEEDS_FILM | NOT_DURING_DCP_CREATION | NEEDS_CPL); add_item (jobs_menu, _("S&how DCP"), ID_jobs_show_dcp, NEEDS_FILM | NOT_DURING_DCP_CREATION | NEEDS_CPL); + add_item (jobs_menu, _("Open DCP in &player"), ID_jobs_open_dcp_in_player, NEEDS_FILM | NOT_DURING_DCP_CREATION | NEEDS_CPL); wxMenu* tools = new wxMenu; add_item (tools, _("Video waveform..."), ID_tools_video_waveform, NEEDS_FILM); 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) + { + try { + int const length = socket->read_uint32 (); + scoped_array buffer (new char[length]); + socket->read (reinterpret_cast (buffer.get()), length); + string s (buffer.get()); + signal_manager->when_idle (bind (&DOMFrame::load_dcp, _frame, s)); + socket->write (reinterpret_cast ("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); -- 2.30.2