X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Ftools%2Fdcpomatic_player.cc;h=7009d17ce652c864c04e8f199c261fe50752febd;hb=b029cb06c4e0fca1fad9fecd78939efe5532fa9a;hp=f68d0ead27bad93741e5cd54eca261f33baf199a;hpb=a9229a4a3c7e33152845dac516febeaeb6eca446;p=dcpomatic.git diff --git a/src/tools/dcpomatic_player.cc b/src/tools/dcpomatic_player.cc index f68d0ead2..7009d17ce 100644 --- a/src/tools/dcpomatic_player.cc +++ b/src/tools/dcpomatic_player.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2017-2019 Carl Hetherington + Copyright (C) 2017-2020 Carl Hetherington This file is part of DCP-o-matic. @@ -28,9 +28,13 @@ #include "wx/player_config_dialog.h" #include "wx/verify_dcp_dialog.h" #include "wx/standard_controls.h" +#include "wx/playlist_controls.h" +#ifdef DCPOMATIC_VARIANT_SWAROOP #include "wx/swaroop_controls.h" +#endif #include "wx/timer_display.h" #include "wx/system_information_dialog.h" +#include "wx/player_stress_tester.h" #include "lib/cross.h" #include "lib/config.h" #include "lib/util.h" @@ -66,10 +70,14 @@ #include #include #include +#ifdef __WXGTK__ +#include +#endif #ifdef __WXOSX__ #include #endif #include +#include #include #ifdef check @@ -90,6 +98,7 @@ using boost::optional; using boost::dynamic_pointer_cast; using boost::thread; using boost::bind; +using dcp::raw_convert; using namespace dcpomatic; enum { @@ -136,7 +145,7 @@ public: , _system_information_dialog (0) , _view_full_screen (0) , _view_dual_screen (0) - { +{ dcpomatic_log.reset (new NullLog()); #if defined(DCPOMATIC_WINDOWS) @@ -188,7 +197,13 @@ public: _controls = sc; sc->ResetFilm.connect (bind(&DOMFrame::reset_film_weak, this, _1)); #else - _controls = new StandardControls (_overall_panel, _viewer, false); + if (Config::instance()->player_mode() == Config::PLAYER_MODE_DUAL) { + PlaylistControls* pc = new PlaylistControls (_overall_panel, _viewer); + _controls = pc; + pc->ResetFilm.connect (bind(&DOMFrame::reset_film_weak, this, _1)); + } else { + _controls = new StandardControls (_overall_panel, _viewer, false); + } #endif _viewer->set_dcp_decode_reduction (Config::instance()->decode_reduction ()); _viewer->PlaybackPermitted.connect (bind(&DOMFrame::playback_permitted, this)); @@ -202,6 +217,8 @@ public: int accelerators = 3; #endif + _stress.setup (this, _controls); + wxAcceleratorEntry* accel = new wxAcceleratorEntry[accelerators]; accel[0].Set(wxACCEL_NORMAL, WXK_SPACE, ID_start_stop); accel[1].Set(wxACCEL_NORMAL, WXK_LEFT, ID_back_frame); @@ -228,6 +245,8 @@ public: #endif setup_screen (); + _stress.LoadDCP.connect (boost::bind(&DOMFrame::load_dcp, this, _1)); + #ifdef DCPOMATIC_VARIANT_SWAROOP sc->check_restart (); #endif @@ -369,8 +388,11 @@ public: reset_film (); try { + _stress.set_suspended (true); shared_ptr dcp (new DCPContent(dir)); - _film->examine_and_add_content (dcp, true); + shared_ptr job (new ExamineContentJob(_film, dcp)); + _examine_job_connection = job->Finished.connect(bind(&DOMFrame::add_dcp_to_film, this, weak_ptr(job), weak_ptr(dcp))); + JobManager::instance()->add (job); bool const ok = display_progress (_("DCP-o-matic Player"), _("Loading content")); if (!ok || !report_errors_from_last_job(this)) { return; @@ -378,11 +400,27 @@ public: #ifndef DCPOMATIC_VARIANT_SWAROOP Config::instance()->add_to_player_history (dir); #endif - } catch (dcp::DCPReadError& e) { + } catch (dcp::ReadError& e) { error_dialog (this, wxString::Format(_("Could not load a DCP from %s"), std_to_wx(dir.string())), std_to_wx(e.what())); } } + void add_dcp_to_film (weak_ptr weak_job, weak_ptr weak_content) + { + shared_ptr job = weak_job.lock (); + if (!job || !job->finished_ok()) { + return; + } + + shared_ptr content = weak_content.lock (); + if (!content) { + return; + } + + _film->add_content (content); + _stress.set_suspended (false); + } + void reset_film_weak (weak_ptr weak_film) { shared_ptr film = weak_film.lock (); @@ -464,6 +502,11 @@ public: } } + void load_stress_script (boost::filesystem::path path) + { + _stress.load_script (path); + } + private: bool report_errors_from_last_job (wxWindow* parent) const @@ -977,8 +1020,6 @@ private: _viewer->seek_by (_viewer->one_video_frame(), true); } -private: - wxFrame* _dual_screen; bool _update_news_requested; PlayerInformation* _info; @@ -996,16 +1037,19 @@ private: SystemInformationDialog* _system_information_dialog; boost::shared_ptr _film; boost::signals2::scoped_connection _config_changed_connection; + boost::signals2::scoped_connection _examine_job_connection; wxMenuItem* _file_add_ov; wxMenuItem* _file_add_kdm; wxMenuItem* _tools_verify; wxMenuItem* _view_full_screen; wxMenuItem* _view_dual_screen; + PlayerStressTester _stress; }; static const wxCmdLineEntryDesc command_line_description[] = { { wxCMD_LINE_PARAM, 0, 0, "DCP to load or create", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_OPTION, "c", "config", "Directory containing config.xml", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, + { wxCMD_LINE_OPTION, "s", "stress", "File containing description of stress test", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, { wxCMD_LINE_NONE, "", "", "", wxCmdLineParamType (0), 0 } }; @@ -1044,7 +1088,11 @@ public: App () : wxApp () , _frame (0) - {} + { +#ifdef DCPOMATIC_LINUX + XInitThreads (); +#endif + } private: @@ -1117,6 +1165,14 @@ private: } } + if (_stress) { + try { + _frame->load_stress_script (*_stress); + } catch (exception& e) { + error_dialog (0, wxString::Format("Could not load stress test file %s", std_to_wx(*_stress))); + } + } + Bind (wxEVT_IDLE, boost::bind (&App::idle, this)); if (Config::instance()->check_for_updates ()) { @@ -1150,6 +1206,10 @@ private: if (parser.Found("c", &config)) { Config::override_path = wx_to_std (config); } + wxString stress; + if (parser.Found("s", &stress)) { + _stress = wx_to_std (stress); + } return true; } @@ -1210,6 +1270,7 @@ private: DOMFrame* _frame; string _dcp_to_load; + boost::optional _stress; }; IMPLEMENT_APP (App)