Allow player to handle VF/OV and KDMs.
[dcpomatic.git] / src / wx / player_information.cc
index e79e716227286ea6c5bcbde67cc83833e5d58971..1b3d2809bbb286e212c54f5cb16cafb5e0589b89 100644 (file)
 #include "wx_util.h"
 #include "film_viewer.h"
 #include "lib/playlist.h"
+#include "lib/video_content.h"
 #include "lib/dcp_content.h"
 
 using std::cout;
 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)
@@ -36,38 +40,84 @@ 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);
+               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);
        }
 
        {
                wxSizer* s = new wxBoxSizer (wxVERTICAL);
                add_label_to_sizer(s, this, _("Performance"), false, 0)->SetFont(title_font);
-               _decoded_fps = add_label_to_sizer(s, this, wxT(""), false, 0);
+               _dropped = add_label_to_sizer(s, this, wxT(""), false, 0);
                _sizer->Add (s, 1, wxEXPAND | wxALL, 6);
        }
 
        SetSizerAndFit (_sizer);
 
-       update ();
+       triggered_update ();
+
+       Bind (wxEVT_TIMER, boost::bind (&PlayerInformation::periodic_update, this));
+       _timer.reset (new wxTimer (this));
+       _timer->Start (500);
 }
 
 void
-PlayerInformation::update ()
+PlayerInformation::periodic_update ()
 {
-       wxString cpl_name;
+       checked_set (_dropped, wxString::Format(_("Dropped frames: %d"), _viewer->dropped()));
+}
+
+void
+PlayerInformation::triggered_update ()
+{
+       shared_ptr<DCPContent> dcp;
        if (_viewer->film()) {
                ContentList content = _viewer->film()->content();
                if (content.size() == 1) {
-                       shared_ptr<DCPContent> dcp = dynamic_pointer_cast<DCPContent>(content.front());
-                       if (dcp) {
-                               cpl_name = std_to_wx (dcp->name());
-                       }
+                       dcp = dynamic_pointer_cast<DCPContent>(content.front());
+               }
+       }
+
+       if (!dcp) {
+               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;
        }
 
-       checked_set (_cpl_name, cpl_name);
+       if (dcp->needs_kdm()) {
+               checked_set (_dcp[r], _("Needs KDM"));
+               return;
+       }
+
+       DCPOMATIC_ASSERT (dcp->video);
+
+       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 (
+               _dcp[r++],
+               wxString::Format(
+                       _("Length: %s (%ld frames)"),
+                       std_to_wx(time_to_hmsf(dcp->full_length(), lrint(*vfr))).data(),
+                       dcp->full_length().frames_round(*vfr)
+                       )
+               );
 }