summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2017-08-03 17:03:22 +0100
committerCarl Hetherington <cth@carlh.net>2017-08-14 21:07:49 +0100
commite0c524cbc4f006a4319c3ce8aa7625f9d70d054a (patch)
tree92d11ab7ce01416a70c8389bd1ebbe8fffff0e13 /src
parentcd06ec145bf9617615fae7d620cf51ad5b486293 (diff)
Add DCP size and length to player.
Diffstat (limited to 'src')
-rw-r--r--src/lib/util.cc16
-rw-r--r--src/lib/util.h1
-rw-r--r--src/tools/dcpomatic_player.cc1
-rw-r--r--src/wx/film_viewer.h1
-rw-r--r--src/wx/player_information.cc36
-rw-r--r--src/wx/player_information.h3
6 files changed, 50 insertions, 8 deletions
diff --git a/src/lib/util.cc b/src/lib/util.cc
index 4ffe3bd12..1f5b29101 100644
--- a/src/lib/util.cc
+++ b/src/lib/util.cc
@@ -127,6 +127,22 @@ seconds_to_hms (int s)
return buffer;
}
+string
+time_to_hmsf (DCPTime time, Frame rate)
+{
+ Frame f = time.frames_round (rate);
+ int s = f / rate;
+ f -= (s * rate);
+ int m = s / 60;
+ s -= m * 60;
+ int h = m / 60;
+ m -= h * 60;
+
+ char buffer[64];
+ snprintf (buffer, sizeof(buffer), "%d:%02d:%02d.%d", h, m, s, static_cast<int>(f));
+ return buffer;
+}
+
/** @param s Number of seconds.
* @return String containing an approximate description of s (e.g. "about 2 hours")
*/
diff --git a/src/lib/util.h b/src/lib/util.h
index b152b67b5..d4616a7c9 100644
--- a/src/lib/util.h
+++ b/src/lib/util.h
@@ -60,6 +60,7 @@ struct AVSubtitle;
class AudioBuffers;
extern std::string seconds_to_hms (int);
+extern std::string time_to_hmsf (DCPTime time, Frame rate);
extern std::string seconds_to_approximate_hms (int);
extern double seconds (struct timeval);
extern void dcpomatic_setup ();
diff --git a/src/tools/dcpomatic_player.cc b/src/tools/dcpomatic_player.cc
index fb962d1bb..3a7c18f02 100644
--- a/src/tools/dcpomatic_player.cc
+++ b/src/tools/dcpomatic_player.cc
@@ -27,6 +27,7 @@
#include "lib/dcp_content.h"
#include "lib/job_manager.h"
#include "lib/job.h"
+#include "lib/video_content.h"
#include "wx/wx_signal_manager.h"
#include "wx/wx_util.h"
#include "wx/about_dialog.h"
diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h
index b445528b1..f8658be38 100644
--- a/src/wx/film_viewer.h
+++ b/src/wx/film_viewer.h
@@ -98,6 +98,7 @@ private:
boost::shared_ptr<Player> _player;
wxSizer* _v_sizer;
+ /** The area that we put our image in */
wxPanel* _panel;
wxCheckBox* _outline_content;
wxRadioButton* _left_eye;
diff --git a/src/wx/player_information.cc b/src/wx/player_information.cc
index e79e71622..baeae838c 100644
--- a/src/wx/player_information.cc
+++ b/src/wx/player_information.cc
@@ -22,11 +22,13 @@
#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;
PlayerInformation::PlayerInformation (wxWindow* parent, FilmViewer* viewer)
: wxPanel (parent)
@@ -40,13 +42,14 @@ PlayerInformation::PlayerInformation (wxWindow* parent, FilmViewer* viewer)
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);
_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);
_sizer->Add (s, 1, wxEXPAND | wxALL, 6);
}
@@ -58,16 +61,35 @@ PlayerInformation::PlayerInformation (wxWindow* parent, FilmViewer* viewer)
void
PlayerInformation::update ()
{
- wxString cpl_name;
+ 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());
}
}
- checked_set (_cpl_name, cpl_name);
+ if (!dcp) {
+ checked_set (_cpl_name, _("No DCP loaded."));
+ checked_set (_size, wxT(""));
+ checked_set (_length, wxT(""));
+ 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));
+
+ optional<double> 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)
+ )
+ );
}
diff --git a/src/wx/player_information.h b/src/wx/player_information.h
index 7d784d715..af18cfb76 100644
--- a/src/wx/player_information.h
+++ b/src/wx/player_information.h
@@ -34,5 +34,6 @@ private:
FilmViewer* _viewer;
wxSizer* _sizer;
wxStaticText* _cpl_name;
- wxStaticText* _decoded_fps;
+ wxStaticText* _size;
+ wxStaticText* _length;
};