From 35e9a698ba3ca35fd488b3622e441956632261cf Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 20 Aug 2017 00:17:46 +0100 Subject: [PATCH] Allow player to handle VF/OV and KDMs. --- ChangeLog | 4 +++ src/lib/dcp_content.cc | 4 ++- src/tools/dcpomatic_player.cc | 58 +++++++++++++++++++++++++++++++++++ src/wx/player_information.cc | 35 +++++++++++++++------ src/wx/player_information.h | 4 +-- 5 files changed, 92 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2ebc966a2..0f0b85f56 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2017-08-20 Carl Hetherington + + * Add VF/OV and KDM support to player. + 2017-08-19 Carl Hetherington * Deal with newly-invalid configured default container ratios diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc index 70914b39c..18f88b3d3 100644 --- a/src/lib/dcp_content.cc +++ b/src/lib/dcp_content.cc @@ -146,7 +146,9 @@ DCPContent::examine (shared_ptr job) string const old_name = name (); bool had_subtitles = static_cast (subtitle); - job->set_progress_unknown (); + if (job) { + job->set_progress_unknown (); + } Content::examine (job); shared_ptr examiner (new DCPExaminer (shared_from_this ())); diff --git a/src/tools/dcpomatic_player.cc b/src/tools/dcpomatic_player.cc index 2dd29c3ed..959b5709c 100644 --- a/src/tools/dcpomatic_player.cc +++ b/src/tools/dcpomatic_player.cc @@ -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()), 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 dcp = boost::dynamic_pointer_cast(_film->content().front()); + DCPOMATIC_ASSERT (dcp); + dcp->add_ov (wx_to_std(c->GetPath())); + dcp->examine (shared_ptr()); + } + + c->Destroy (); + _info->triggered_update (); + } + + void file_add_kdm () + { + wxFileDialog* d = new wxFileDialog (this, _("Select KDM")); + + if (d->ShowModal() == wxID_OK) { + shared_ptr dcp = boost::dynamic_pointer_cast(_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()); + } + + d->Destroy (); + _info->triggered_update (); + } + void file_exit () { Close (); diff --git a/src/wx/player_information.cc b/src/wx/player_information.cc index 0a2921227..1b3d2809b 100644 --- a/src/wx/player_information.cc +++ b/src/wx/player_information.cc @@ -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 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(), diff --git a/src/wx/player_information.h b/src/wx/player_information.h index 7eafeb122..0fcbb15ee 100644 --- a/src/wx/player_information.h +++ b/src/wx/player_information.h @@ -36,9 +36,7 @@ private: FilmViewer* _viewer; wxSizer* _sizer; - wxStaticText* _cpl_name; - wxStaticText* _size; - wxStaticText* _length; + wxStaticText** _dcp; wxStaticText* _dropped; boost::scoped_ptr _timer; }; -- 2.30.2