X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Fwx%2Fplayer_information.cc;h=6bb138c055587e98047a95e5eba4c9b5eefbc73a;hp=0a2921227c7e819947380117b35e58e30d312a14;hb=e20996d81f0bb17ca922c065ef7480ab43de1b0e;hpb=0b7c380031db6aa2ce546a2a0c89926f40eae6b5 diff --git a/src/wx/player_information.cc b/src/wx/player_information.cc index 0a2921227..6bb138c05 100644 --- a/src/wx/player_information.cc +++ b/src/wx/player_information.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2017 Carl Hetherington + Copyright (C) 2017-2018 Carl Hetherington This file is part of DCP-o-matic. @@ -18,19 +18,31 @@ */ + #include "player_information.h" #include "wx_util.h" #include "film_viewer.h" #include "lib/playlist.h" +#include "lib/compose.hpp" #include "lib/video_content.h" +#include "lib/audio_content.h" #include "lib/dcp_content.h" +#include "lib/film.h" + using std::cout; -using boost::shared_ptr; -using boost::dynamic_pointer_cast; +using std::dynamic_pointer_cast; +using std::shared_ptr; +using std::string; +using std::weak_ptr; using boost::optional; -PlayerInformation::PlayerInformation (wxWindow* parent, FilmViewer* viewer) + +/* This should be even */ +static int const dcp_lines = 6; + + +PlayerInformation::PlayerInformation (wxWindow* parent, weak_ptr viewer) : wxPanel (parent) , _viewer (viewer) , _sizer (new wxBoxSizer (wxHORIZONTAL)) @@ -38,20 +50,34 @@ PlayerInformation::PlayerInformation (wxWindow* parent, FilmViewer* viewer) wxFont title_font (*wxNORMAL_FONT); title_font.SetWeight (wxFONTWEIGHT_BOLD); + _dcp = new wxStaticText*[dcp_lines]; + + 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); - _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 / 2; ++i) { + _dcp[i] = add_label_to_sizer(s, this, wxT(""), false, 0); + } + _sizer->Add (s, 1, wxEXPAND | wxALL, 6); + } + + { + 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); + } _sizer->Add (s, 1, wxEXPAND | wxALL, 6); } { - wxSizer* s = new wxBoxSizer (wxVERTICAL); + 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); - _sizer->Add (s, 1, wxEXPAND | wxALL, 6); + _decode_resolution = add_label_to_sizer(s, this, wxT(""), false, 0); + _sizer->Add (s, 2, wxEXPAND | wxALL, 6); } SetSizerAndFit (_sizer); @@ -63,44 +89,98 @@ PlayerInformation::PlayerInformation (wxWindow* parent, FilmViewer* viewer) _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()); } } 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("")); + } + checked_set (_decode_resolution, 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)); + if (dcp->video_frame_rate()) { + checked_set (_dcp[r++], wxString::Format(_("Frame rate: %d"), (int) lrint(*dcp->video_frame_rate()))); + } + if (dcp->audio && !dcp->audio->streams().empty()) { + checked_set (_dcp[r++], wxString::Format(_("Audio channels: %d"), dcp->audio->streams().front()->channels())); + } + if (!dcp->text.empty()) { + checked_set (_dcp[r++], _("Subtitles: yes")); + } else { + checked_set (_dcp[r++], _("Subtitles: no")); + } optional vfr; vfr = dcp->video_frame_rate (); DCPOMATIC_ASSERT (vfr); - checked_set ( - _length, - wxString::Format( - _("Length: %s (%ld frames)"), - std_to_wx(time_to_hmsf(dcp->full_length(), lrint(*vfr))).data(), - dcp->full_length().frames_round(*vfr) - ) + + auto const len = String::compose( + wx_to_std(_("Length: %1 (%2 frames)")), + 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)); + + auto decode = dcp->video->size(); + auto reduction = fv->dcp_decode_reduction(); + if (reduction) { + decode.width /= pow(2, *reduction); + decode.height /= pow(2, *reduction); + } + + checked_set (_decode_resolution, wxString::Format(_("Decode resolution: %dx%d"), decode.width, decode.height)); + + DCPOMATIC_ASSERT(r <= dcp_lines); + + _sizer->Layout (); }