Allow player to handle VF/OV and KDMs.
authorCarl Hetherington <cth@carlh.net>
Sat, 19 Aug 2017 23:17:46 +0000 (00:17 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 19 Aug 2017 23:17:46 +0000 (00:17 +0100)
ChangeLog
src/lib/dcp_content.cc
src/tools/dcpomatic_player.cc
src/wx/player_information.cc
src/wx/player_information.h

index 2ebc966a2d541ee881fd15f9173106e5c090f556..0f0b85f562de4a7bb1f0e03e2bf74745324479b8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2017-08-20  Carl Hetherington  <cth@carlh.net>
+
+       * Add VF/OV and KDM support to player.
+
 2017-08-19  Carl Hetherington  <cth@carlh.net>
 
        * Deal with newly-invalid configured default container ratios
index 70914b39cd022ecc03f1f80d9047a44b5f1cb756..18f88b3d3dba31344ed91c6d01d537939caf2124 100644 (file)
@@ -146,7 +146,9 @@ DCPContent::examine (shared_ptr<Job> job)
        string const old_name = name ();
        bool had_subtitles = static_cast<bool> (subtitle);
 
-       job->set_progress_unknown ();
+       if (job) {
+               job->set_progress_unknown ();
+       }
        Content::examine (job);
 
        shared_ptr<DCPExaminer> examiner (new DCPExaminer (shared_from_this ()));
index 2dd29c3edb6874ba7d094151e08d4386039a7704..959b5709cac5b13be4ae5b4666827ee0daddb7d8 100644 (file)
@@ -59,6 +59,8 @@ using boost::optional;
 
 enum {
        ID_file_open = 1,
+       ID_file_add_ov,
+       ID_file_add_kdm,
        ID_view_scale_appropriate,
        ID_view_scale_full,
        ID_view_scale_half,
@@ -94,6 +96,8 @@ public:
                _config_changed_connection = Config::instance()->Changed.connect (boost::bind (&DOMFrame::config_changed, this));
 
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_open, this), ID_file_open);
+               Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_add_ov, this), ID_file_add_ov);
+               Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_add_kdm, this), ID_file_add_kdm);
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_exit, this), wxID_EXIT);
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::edit_preferences, this), wxID_PREFERENCES);
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::set_decode_reduction, this, optional<int>()), ID_view_scale_appropriate);
@@ -160,6 +164,8 @@ private:
        {
                wxMenu* file = new wxMenu;
                file->Append (ID_file_open, _("&Open...\tCtrl-O"));
+               file->Append (ID_file_add_ov, _("&Add OV..."));
+               file->Append (ID_file_add_kdm, _("&Add KDM..."));
 
 #ifdef __WXOSX__
                file->Append (wxID_EXIT, _("&Exit"));
@@ -226,6 +232,58 @@ private:
                c->Destroy ();
        }
 
+       void file_add_ov ()
+       {
+               wxDirDialog* c = new wxDirDialog (
+                       this,
+                       _("Select DCP to open as OV"),
+                       wxStandardPaths::Get().GetDocumentsDir(),
+                       wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST
+                       );
+
+               int r;
+               while (true) {
+                       r = c->ShowModal ();
+                       if (r == wxID_OK && c->GetPath() == wxStandardPaths::Get().GetDocumentsDir()) {
+                               error_dialog (this, _("You did not select a folder.  Make sure that you select a folder before clicking Open."));
+                       } else {
+                               break;
+                       }
+               }
+
+               if (r == wxID_OK) {
+                       shared_ptr<DCPContent> dcp = boost::dynamic_pointer_cast<DCPContent>(_film->content().front());
+                       DCPOMATIC_ASSERT (dcp);
+                       dcp->add_ov (wx_to_std(c->GetPath()));
+                       dcp->examine (shared_ptr<Job>());
+               }
+
+               c->Destroy ();
+               _info->triggered_update ();
+       }
+
+       void file_add_kdm ()
+       {
+               wxFileDialog* d = new wxFileDialog (this, _("Select KDM"));
+
+               if (d->ShowModal() == wxID_OK) {
+                       shared_ptr<DCPContent> dcp = boost::dynamic_pointer_cast<DCPContent>(_film->content().front());
+                       DCPOMATIC_ASSERT (dcp);
+                       try {
+                               dcp->add_kdm (dcp::EncryptedKDM (dcp::file_to_string (wx_to_std (d->GetPath ()), MAX_KDM_SIZE)));
+                       } catch (exception& e) {
+                               error_dialog (this, wxString::Format (_("Could not load KDM (%s)"), e.what ()));
+                               d->Destroy ();
+                               return;
+                       }
+
+                       dcp->examine (shared_ptr<Job>());
+               }
+
+               d->Destroy ();
+               _info->triggered_update ();
+       }
+
        void file_exit ()
        {
                Close ();
index 0a2921227c7e819947380117b35e58e30d312a14..1b3d2809bbb286e212c54f5cb16cafb5e0589b89 100644 (file)
@@ -30,6 +30,8 @@ using boost::shared_ptr;
 using boost::dynamic_pointer_cast;
 using boost::optional;
 
+static int const dcp_lines = 4;
+
 PlayerInformation::PlayerInformation (wxWindow* parent, FilmViewer* viewer)
        : wxPanel (parent)
        , _viewer (viewer)
@@ -38,12 +40,14 @@ PlayerInformation::PlayerInformation (wxWindow* parent, FilmViewer* viewer)
        wxFont title_font (*wxNORMAL_FONT);
        title_font.SetWeight (wxFONTWEIGHT_BOLD);
 
+       _dcp = new wxStaticText*[dcp_lines];
+
        {
                wxSizer* s = new wxBoxSizer (wxVERTICAL);
                add_label_to_sizer(s, this, _("DCP"), false, 0)->SetFont(title_font);
-               _cpl_name = add_label_to_sizer(s, this, wxT(""), false, 0);
-               _size = add_label_to_sizer(s, this, wxT(""), false, 0);
-               _length = add_label_to_sizer(s, this, wxT(""), false, 0);
+               for (int i = 0; i < dcp_lines; ++i) {
+                       _dcp[i] = add_label_to_sizer(s, this, wxT(""), false, 0);
+               }
                _sizer->Add (s, 1, wxEXPAND | wxALL, 6);
        }
 
@@ -81,22 +85,35 @@ PlayerInformation::triggered_update ()
        }
 
        if (!dcp) {
-               checked_set (_cpl_name, _("No DCP loaded."));
-               checked_set (_size, wxT(""));
-               checked_set (_length, wxT(""));
+               checked_set (_dcp[0], _("No DCP loaded."));
+               for (int r = 1; r < dcp_lines; ++r) {
+                       checked_set (_dcp[r], wxT(""));
+               }
+               return;
+       }
+
+       int r = 0;
+       checked_set (_dcp[r++], std_to_wx(dcp->name()));
+
+       if (dcp->needs_assets()) {
+               checked_set (_dcp[r], _("Needs OV"));
+               return;
+       }
+
+       if (dcp->needs_kdm()) {
+               checked_set (_dcp[r], _("Needs KDM"));
                return;
        }
 
        DCPOMATIC_ASSERT (dcp->video);
 
-       checked_set (_cpl_name, std_to_wx(dcp->name()));
-       checked_set (_size, wxString::Format(_("Size: %dx%d"), dcp->video->size().width, dcp->video->size().height));
+       checked_set (_dcp[r++], wxString::Format(_("Size: %dx%d"), dcp->video->size().width, dcp->video->size().height));
 
        optional<double> vfr;
        vfr = dcp->video_frame_rate ();
        DCPOMATIC_ASSERT (vfr);
        checked_set (
-               _length,
+               _dcp[r++],
                wxString::Format(
                        _("Length: %s (%ld frames)"),
                        std_to_wx(time_to_hmsf(dcp->full_length(), lrint(*vfr))).data(),
index 7eafeb122cfb25f3f61c3fedce044a4133ab9871..0fcbb15ee840920e99b9cbd402fbe96c455cdb29 100644 (file)
@@ -36,9 +36,7 @@ private:
 
        FilmViewer* _viewer;
        wxSizer* _sizer;
-       wxStaticText* _cpl_name;
-       wxStaticText* _size;
-       wxStaticText* _length;
+       wxStaticText** _dcp;
        wxStaticText* _dropped;
        boost::scoped_ptr<wxTimer> _timer;
 };