std::shared_ptr
[dcpomatic.git] / src / tools / dcpomatic_player.cc
index a73fa4d304da174cfd7fc049c4f6c771ac826cfb..5b2c9a56af2b65366cda57673c53d904f6d6e66b 100644 (file)
 #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 "wx/verify_dcp_progress_dialog.h"
 #include "lib/cross.h"
 #include "lib/config.h"
 #include "lib/util.h"
@@ -55,8 +53,6 @@
 #include "lib/server.h"
 #include "lib/dcpomatic_socket.h"
 #include "lib/scoped_temporary.h"
-#include "lib/monitor_checker.h"
-#include "lib/lock_file_checker.h"
 #include "lib/ffmpeg_content.h"
 #include "lib/dcpomatic_log.h"
 #include "lib/file_log.h"
@@ -73,7 +69,7 @@
 #ifdef __WXGTK__
 #include <X11/Xlib.h>
 #endif
-#include <boost/bind.hpp>
+#include <boost/bind/bind.hpp>
 #include <boost/algorithm/string.hpp>
 #include <iostream>
 
@@ -88,13 +84,16 @@ using std::cout;
 using std::list;
 using std::exception;
 using std::vector;
-using boost::shared_ptr;
-using boost::weak_ptr;
+using std::shared_ptr;
+using std::weak_ptr;
 using boost::scoped_array;
 using boost::optional;
-using boost::dynamic_pointer_cast;
+using std::dynamic_pointer_cast;
 using boost::thread;
 using boost::bind;
+#if BOOST_VERSION >= 106100
+using namespace boost::placeholders;
+#endif
 using dcp::raw_convert;
 using namespace dcpomatic;
 
@@ -198,11 +197,6 @@ public:
                _overall_panel = new wxPanel (this, wxID_ANY);
 
                _viewer.reset (new FilmViewer (_overall_panel));
-#ifdef DCPOMATIC_VARIANT_SWAROOP
-               SwaroopControls* sc = new SwaroopControls (_overall_panel, _viewer);
-               _controls = sc;
-               sc->ResetFilm.connect (bind(&DOMFrame::reset_film_weak, this, _1));
-#else
                if (Config::instance()->player_mode() == Config::PLAYER_MODE_DUAL) {
                        PlaylistControls* pc = new PlaylistControls (_overall_panel, _viewer);
                        _controls = pc;
@@ -210,7 +204,6 @@ public:
                } 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));
                _viewer->Started.connect (bind(&DOMFrame::playback_started, this, _1));
@@ -259,39 +252,11 @@ public:
                reset_film ();
 
                UpdateChecker::instance()->StateChanged.connect (boost::bind (&DOMFrame::update_checker_state_changed, this));
-#ifdef DCPOMATIC_VARIANT_SWAROOP
-               MonitorChecker::instance()->StateChanged.connect(boost::bind(&DOMFrame::monitor_checker_state_changed, this));
-               MonitorChecker::instance()->run ();
-               LockFileChecker::instance()->StateChanged.connect(boost::bind(&DOMFrame::lock_checker_state_changed, this));
-               LockFileChecker::instance()->run ();
-#endif
                setup_screen ();
 
                _stress.LoadDCP.connect (boost::bind(&DOMFrame::load_dcp, this, _1));
-
-#ifdef DCPOMATIC_VARIANT_SWAROOP
-               sc->check_restart ();
-#endif
-       }
-
-#ifdef DCPOMATIC_VARIANT_SWAROOP
-       void monitor_checker_state_changed ()
-       {
-               if (!MonitorChecker::instance()->ok()) {
-                       _viewer->stop ();
-                       error_dialog (this, _("The required display devices are not connected correctly."));
-               }
        }
 
-       void lock_checker_state_changed ()
-       {
-               if (!LockFileChecker::instance()->ok()) {
-                       _viewer->stop ();
-                       error_dialog (this, _("The lock file is not present."));
-               }
-       }
-#endif
-
        void setup_main_sizer (Config::PlayerMode mode)
        {
                _main_sizer->Detach (_viewer->panel());
@@ -308,16 +273,6 @@ public:
 
        bool playback_permitted ()
        {
-#ifdef DCPOMATIC_VARIANT_SWAROOP
-               if (!MonitorChecker::instance()->ok()) {
-                       error_dialog (this, _("The required display devices are not connected correctly."));
-                       return false;
-               }
-               if (!LockFileChecker::instance()->ok()) {
-                       error_dialog (this, _("The lock file is not present."));
-                       return false;
-               }
-#endif
                if (!_film || !Config::instance()->respect_kdm_validity_periods()) {
                        return true;
                }
@@ -330,15 +285,6 @@ public:
                        }
                }
 
-#ifdef DCPOMATIC_VARIANT_SWAROOP
-               BOOST_FOREACH (shared_ptr<Content> i, _film->content()) {
-                       shared_ptr<FFmpegContent> c = dynamic_pointer_cast<FFmpegContent>(i);
-                       if (c && !c->kdm_timing_window_valid()) {
-                               ok = false;
-                       }
-               }
-#endif
-
                if (!ok) {
                        error_dialog (this, _("The KDM does not allow playback of this content at this time."));
                }
@@ -388,14 +334,6 @@ public:
 
        void playback_stopped (DCPTime time)
        {
-#ifdef DCPOMATIC_VARIANT_SWAROOP
-               try {
-                       boost::filesystem::remove (Config::path("position"));
-               } catch (...) {
-                       /* Never mind */
-               }
-#endif
-
                _controls->log (wxString::Format("playback-stopped %s", time.timecode(_film->video_frame_rate()).c_str()));
        }
 
@@ -421,9 +359,7 @@ public:
                        if (!ok || !report_errors_from_last_job(this)) {
                                return;
                        }
-#ifndef DCPOMATIC_VARIANT_SWAROOP
                        Config::instance()->add_to_player_history (dir);
-#endif
                } 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()));
                } catch (DCPError& e) {
@@ -584,10 +520,8 @@ private:
                optional<int> c = Config::instance()->decode_reduction();
                _view_cpl = view->Append(ID_view_cpl, _("CPL"), _cpl_menu);
                view->AppendSeparator();
-#ifndef DCPOMATIC_VARIANT_SWAROOP
                _view_full_screen = view->AppendCheckItem(ID_view_full_screen, _("Full screen\tF11"));
                _view_dual_screen = view->AppendCheckItem(ID_view_dual_screen, _("Dual screen\tShift+F11"));
-#endif
                setup_menu ();
                view->AppendSeparator();
                view->Append(ID_view_closed_captions, _("Closed captions..."));
@@ -670,7 +604,7 @@ private:
 
                if (r == wxID_OK) {
                        DCPOMATIC_ASSERT (_film);
-                       shared_ptr<DCPContent> dcp = boost::dynamic_pointer_cast<DCPContent>(_film->content().front());
+                       shared_ptr<DCPContent> dcp = std::dynamic_pointer_cast<DCPContent>(_film->content().front());
                        DCPOMATIC_ASSERT (dcp);
                        dcp->add_ov (wx_to_std(c->GetPath()));
                        JobManager::instance()->add(shared_ptr<Job>(new ExamineContentJob (_film, dcp)));
@@ -699,22 +633,8 @@ private:
 
                if (d->ShowModal() == wxID_OK) {
                        DCPOMATIC_ASSERT (_film);
-#ifdef DCPOMATIC_VARIANT_SWAROOP
-                       shared_ptr<FFmpegContent> ffmpeg = boost::dynamic_pointer_cast<FFmpegContent>(_film->content().front());
-                       if (ffmpeg) {
-                               try {
-                                       ffmpeg->add_kdm (EncryptedECinemaKDM(dcp::file_to_string(wx_to_std(d->GetPath()), MAX_KDM_SIZE)));
-                               } catch (exception& e) {
-                                       error_dialog (this, wxString::Format(_("Could not load KDM.")), std_to_wx(e.what()));
-                                       d->Destroy();
-                                       return;
-                               }
-                       }
-#endif
-                       shared_ptr<DCPContent> dcp = boost::dynamic_pointer_cast<DCPContent>(_film->content().front());
-#ifndef DCPOMATIC_VARIANT_SWAROOP
+                       shared_ptr<DCPContent> dcp = std::dynamic_pointer_cast<DCPContent>(_film->content().front());
                        DCPOMATIC_ASSERT (dcp);
-#endif
                        try {
                                if (dcp) {
                                        dcp->add_kdm (dcp::EncryptedKDM(dcp::file_to_string(wx_to_std(d->GetPath()), MAX_KDM_SIZE)));
@@ -770,7 +690,7 @@ private:
 
        void view_cpl (wxCommandEvent& ev)
        {
-               shared_ptr<DCPContent> dcp = boost::dynamic_pointer_cast<DCPContent>(_film->content().front());
+               shared_ptr<DCPContent> dcp = std::dynamic_pointer_cast<DCPContent>(_film->content().front());
                DCPOMATIC_ASSERT (dcp);
                DCPExaminer ex (dcp, true);
                int id = ev.GetId() - ID_view_cpl;
@@ -785,6 +705,7 @@ private:
 
                dcp->set_cpl ((*i)->id());
                dcp->examine (_film, shared_ptr<Job>());
+               _info->triggered_update ();
        }
 
        void view_full_screen ()
@@ -864,21 +785,18 @@ private:
 
        void tools_verify ()
        {
-               shared_ptr<DCPContent> dcp = boost::dynamic_pointer_cast<DCPContent>(_film->content().front());
+               shared_ptr<DCPContent> dcp = std::dynamic_pointer_cast<DCPContent>(_film->content().front());
                DCPOMATIC_ASSERT (dcp);
 
-               JobManager* jm = JobManager::instance ();
-               jm->add (shared_ptr<Job> (new VerifyDCPJob (dcp->directories())));
-               bool const ok = display_progress (_("DCP-o-matic Player"), _("Verifying DCP"));
-               if (!ok) {
+               shared_ptr<VerifyDCPJob> job (new VerifyDCPJob(dcp->directories()));
+               VerifyDCPProgressDialog* progress = new VerifyDCPProgressDialog(this, _("DCP-o-matic Player"));
+               bool const completed = progress->run (job);
+               progress->Destroy ();
+               if (!completed) {
                        return;
                }
 
-               DCPOMATIC_ASSERT (!jm->get().empty());
-               shared_ptr<VerifyDCPJob> last = dynamic_pointer_cast<VerifyDCPJob> (jm->get().back());
-               DCPOMATIC_ASSERT (last);
-
-               VerifyDCPDialog* d = new VerifyDCPDialog (this, last);
+               VerifyDCPDialog* d = new VerifyDCPDialog (this, job);
                d->ShowModal ();
                d->Destroy ();
        }
@@ -1076,7 +994,7 @@ private:
        shared_ptr<FilmViewer> _viewer;
        Controls* _controls;
        SystemInformationDialog* _system_information_dialog;
-       boost::shared_ptr<Film> _film;
+       std::shared_ptr<Film> _film;
        boost::signals2::scoped_connection _config_changed_connection;
        boost::signals2::scoped_connection _examine_job_connection;
        wxMenuItem* _file_add_ov;