Fix log display and auto-load KDMs from the configured directory.
[dcpomatic.git] / src / tools / dcpomatic_player.cc
index 3be947cc623bcdec3637ed5488733ba12f7c628c..db9b21d925958cd04f07c98f53a981ce60d6ad01 100644 (file)
@@ -161,7 +161,7 @@ public:
                _overall_panel = new wxPanel (this, wxID_ANY);
 
                _viewer.reset (new FilmViewer (_overall_panel));
-               _controls = new Controls (_overall_panel, _viewer, false, false, false);
+               _controls = new Controls (_overall_panel, _viewer, false);
                _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));
@@ -191,6 +191,8 @@ public:
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::forward_frame, this), ID_forward_frame);
 
                UpdateChecker::instance()->StateChanged.connect (boost::bind (&DOMFrame::update_checker_state_changed, this));
+               _controls->DCPDirectorySelected.connect (boost::bind(&DOMFrame::load_dcp, this, _1));
+               _controls->DCPEjected.connect (boost::bind(&DOMFrame::eject_dcp, this));
 
                setup_screen ();
        }
@@ -289,6 +291,13 @@ public:
                Config::instance()->set_decode_reduction (reduction);
        }
 
+       void eject_dcp ()
+       {
+               _film.reset (new Film (optional<boost::filesystem::path>()));
+               _viewer->set_film (_film);
+               _info->triggered_update ();
+       }
+
        void load_dcp (boost::filesystem::path dir)
        {
                _film.reset (new Film (optional<boost::filesystem::path>()));
@@ -306,6 +315,27 @@ public:
                        return;
                }
 
+               /* The DCP has been examined and loaded */
+
+               optional<boost::filesystem::path> kdm_dir = Config::instance()->player_kdm_directory();
+               if (dcp->needs_kdm() && kdm_dir) {
+                       /* Look for a KDM */
+                       using namespace boost::filesystem;
+                       for (directory_iterator i = directory_iterator(*kdm_dir); i != directory_iterator(); ++i) {
+                               if (file_size(i->path()) < MAX_KDM_SIZE) {
+                                       try {
+                                               dcp::EncryptedKDM kdm(dcp::file_to_string(i->path()));
+                                               if (kdm.cpl_id() == dcp->cpl()) {
+                                                       dcp->add_kdm (kdm);
+                                                       dcp->examine (shared_ptr<Job>());
+                                               }
+                                       } catch (...) {
+                                               /* Hey well */
+                                       }
+                               }
+                       }
+               }
+
                setup_from_dcp (dcp);
 
                if (dcp->three_d()) {
@@ -335,6 +365,8 @@ public:
                        j->Check(!dcp->cpl() || i->id() == *dcp->cpl());
                        ++id;
                }
+
+               _controls->log (wxString::Format(_("Load DCP %s"), dir.filename().string().c_str()));
        }
 
 private:
@@ -576,6 +608,7 @@ private:
        void setup_screen ()
        {
                _controls->Show (_mode != Config::PLAYER_MODE_FULL);
+               _controls->show_extended_player_controls (_mode == Config::PLAYER_MODE_DUAL);
                _info->Show (_mode != Config::PLAYER_MODE_FULL);
                _overall_panel->SetBackgroundColour (_mode == Config::PLAYER_MODE_FULL ? wxColour(0, 0, 0) : wxNullColour);
                ShowFullScreen (_mode == Config::PLAYER_MODE_FULL);