X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Fplayer_information.cc;h=ca3a05ea47039a3d60cadca1903bd5daa1280220;hb=1cd2c956234dac14c0cd22883bf0575b3c7faf8f;hp=c66c6c1e937fc19c8a29f72184ab7c46eb016d59;hpb=54ef7357a87885ec329a25e758fb6b132816ec67;p=dcpomatic.git diff --git a/src/wx/player_information.cc b/src/wx/player_information.cc index c66c6c1e9..ca3a05ea4 100644 --- a/src/wx/player_information.cc +++ b/src/wx/player_information.cc @@ -18,9 +18,10 @@ */ + #include "player_information.h" #include "wx_util.h" -#include "control_film_viewer.h" +#include "film_viewer.h" #include "lib/playlist.h" #include "lib/compose.hpp" #include "lib/video_content.h" @@ -28,16 +29,20 @@ #include "lib/dcp_content.h" #include "lib/film.h" + using std::cout; +using std::dynamic_pointer_cast; +using std::shared_ptr; using std::string; -using boost::shared_ptr; -using boost::dynamic_pointer_cast; +using std::weak_ptr; using boost::optional; + /* This should be even */ static int const dcp_lines = 6; -PlayerInformation::PlayerInformation (wxWindow* parent, ControlFilmViewer* viewer) + +PlayerInformation::PlayerInformation (wxWindow* parent, weak_ptr viewer) : wxPanel (parent) , _viewer (viewer) , _sizer (new wxBoxSizer (wxHORIZONTAL)) @@ -50,7 +55,7 @@ PlayerInformation::PlayerInformation (wxWindow* parent, ControlFilmViewer* viewe DCPOMATIC_ASSERT ((dcp_lines % 2) == 0); { - wxSizer* s = new wxBoxSizer (wxVERTICAL); + auto s = new wxBoxSizer (wxVERTICAL); add_label_to_sizer(s, this, _("DCP"), false, 0)->SetFont(title_font); for (int i = 0; i < dcp_lines / 2; ++i) { _dcp[i] = add_label_to_sizer(s, this, wxT(""), false, 0); @@ -59,7 +64,7 @@ PlayerInformation::PlayerInformation (wxWindow* parent, ControlFilmViewer* viewe } { - wxSizer* s = new wxBoxSizer (wxVERTICAL); + auto s = new wxBoxSizer (wxVERTICAL); add_label_to_sizer(s, this, wxT(" "), false, 0); for (int i = dcp_lines / 2; i < dcp_lines; ++i) { _dcp[i] = add_label_to_sizer(s, this, wxT(""), false, 0); @@ -68,7 +73,22 @@ PlayerInformation::PlayerInformation (wxWindow* parent, ControlFilmViewer* viewe } { - wxSizer* s = new wxBoxSizer (wxVERTICAL); + _kdm_panel = new wxPanel(this, wxID_ANY); + auto s = new wxBoxSizer(wxVERTICAL); + add_label_to_sizer(s, _kdm_panel, _("KDM"), false, 0)->SetFont(title_font); + auto g = new wxGridBagSizer(0, DCPOMATIC_SIZER_GAP); + add_label_to_sizer(g, _kdm_panel, _("Valid from"), true, wxGBPosition(0, 0)); + _kdm_from = add_label_to_sizer(g, _kdm_panel, wxT(""), false, wxGBPosition(0, 1)); + add_label_to_sizer(g, _kdm_panel, _("Valid to"), true, wxGBPosition(1, 0)); + _kdm_to = add_label_to_sizer(g, _kdm_panel, wxT(""), false, wxGBPosition(1, 1)); + auto pad = new wxBoxSizer(wxVERTICAL); + s->Add(g, 1, wxEXPAND | wxLEFT, DCPOMATIC_SIZER_GAP); + _kdm_panel->SetSizer(s); + _sizer->Add(_kdm_panel, 1, wxEXPAND | wxALL, 6); + } + + { + auto s = new wxBoxSizer (wxVERTICAL); add_label_to_sizer(s, this, _("Performance"), false, 0)->SetFont(title_font); _dropped = add_label_to_sizer(s, this, wxT(""), false, 0); _decode_resolution = add_label_to_sizer(s, this, wxT(""), false, 0); @@ -84,18 +104,34 @@ PlayerInformation::PlayerInformation (wxWindow* parent, ControlFilmViewer* viewe _timer->Start (500); } + void PlayerInformation::periodic_update () { - checked_set (_dropped, wxString::Format(_("Dropped frames: %d"), _viewer->dropped())); + auto fv = _viewer.lock (); + if (fv) { + auto s = wxString::Format(_("Dropped frames: %d"), fv->dropped() + fv->errored()); + if (fv->errored() == 1) { + s += wxString::Format(_(" (%d error)"), fv->errored()); + } else if (fv->errored() > 1) { + s += wxString::Format(_(" (%d errors)"), fv->errored()); + } + checked_set (_dropped, s); + } } + void PlayerInformation::triggered_update () { + auto fv = _viewer.lock (); + if (!fv) { + return; + } + shared_ptr dcp; - if (_viewer->film()) { - ContentList content = _viewer->film()->content(); + if (fv->film()) { + auto content = fv->film()->content(); if (content.size() == 1) { dcp = dynamic_pointer_cast(content.front()); } @@ -107,6 +143,7 @@ PlayerInformation::triggered_update () checked_set (_dcp[r], wxT("")); } checked_set (_decode_resolution, wxT("")); + _kdm_panel->Hide(); return; } @@ -142,16 +179,16 @@ PlayerInformation::triggered_update () vfr = dcp->video_frame_rate (); DCPOMATIC_ASSERT (vfr); - string const len = String::compose( + auto const len = String::compose( wx_to_std(_("Length: %1 (%2 frames)")), - time_to_hmsf(dcp->full_length(), lrint(*vfr)), - dcp->full_length().frames_round(*vfr) + time_to_hmsf(dcp->full_length(fv->film()), lrint(*vfr)), + dcp->full_length(fv->film()).frames_round(*vfr) ); checked_set (_dcp[r++], std_to_wx(len)); - dcp::Size decode = dcp->video->size(); - optional reduction = _viewer->dcp_decode_reduction(); + auto decode = dcp->video->size(); + auto reduction = fv->dcp_decode_reduction(); if (reduction) { decode.width /= pow(2, *reduction); decode.height /= pow(2, *reduction); @@ -161,5 +198,16 @@ PlayerInformation::triggered_update () DCPOMATIC_ASSERT(r <= dcp_lines); + if (dcp->encrypted() && dcp->kdm()) { + _kdm_panel->Show(); + auto const kdm = *dcp->kdm(); + auto const before = kdm.not_valid_before(); + checked_set(_kdm_from, wxString::Format(_("%s %s"), std_to_wx(before.date()), std_to_wx(before.time_of_day(true, false)))); + auto const after = kdm.not_valid_after(); + checked_set(_kdm_to, wxString::Format(_("%s %s"), std_to_wx(after.date()), std_to_wx(after.time_of_day(true, false)))); + } else { + _kdm_panel->Hide(); + } + _sizer->Layout (); }