diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-02-18 17:42:58 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-02-18 17:42:58 +0000 |
| commit | d8a19dca28268e3ac92f117d00c1064c0b06515c (patch) | |
| tree | c3a9d9d6b25689c828578300c46361444bb72c1b /src/lib | |
| parent | 1b81ba7c24e7f117d1960021d7e28c8f0147009f (diff) | |
Various improvements to the content properties dialogue (including #791).
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/audio_content.cc | 45 | ||||
| -rw-r--r-- | src/lib/audio_content.h | 2 | ||||
| -rw-r--r-- | src/lib/content.cc | 10 | ||||
| -rw-r--r-- | src/lib/content.h | 25 | ||||
| -rw-r--r-- | src/lib/dcp_content.cc | 2 | ||||
| -rw-r--r-- | src/lib/dcp_content.h | 2 | ||||
| -rw-r--r-- | src/lib/ffmpeg_content.cc | 26 | ||||
| -rw-r--r-- | src/lib/ffmpeg_content.h | 2 | ||||
| -rw-r--r-- | src/lib/single_stream_audio_content.cc | 8 | ||||
| -rw-r--r-- | src/lib/single_stream_audio_content.h | 2 | ||||
| -rw-r--r-- | src/lib/video_content.cc | 8 | ||||
| -rw-r--r-- | src/lib/video_content.h | 2 |
12 files changed, 93 insertions, 41 deletions
diff --git a/src/lib/audio_content.cc b/src/lib/audio_content.cc index 87a1d1803..c17893c5a 100644 --- a/src/lib/audio_content.cc +++ b/src/lib/audio_content.cc @@ -296,7 +296,48 @@ AudioContent::audio_channel_names () const } void -AudioContent::add_properties (list<pair<string, string> >& p) const +AudioContent::add_properties (list<UserProperty>& p) const { - p.push_back (make_pair (_("DCP audio frame rate"), raw_convert<string> (resampled_audio_frame_rate ()))); + shared_ptr<const AudioStream> stream; + if (audio_streams().size() == 1) { + stream = audio_streams().front (); + } + + if (stream) { + p.push_back (UserProperty (_("Audio"), _("Channels"), stream->channels ())); + p.push_back (UserProperty (_("Audio"), _("Content audio frame rate"), stream->frame_rate(), _("Hz"))); + } + + shared_ptr<const Film> film = _film.lock (); + DCPOMATIC_ASSERT (film); + + FrameRateChange const frc = film->active_frame_rate_change (position ()); + ContentTime const c (full_length(), frc); + + p.push_back ( + UserProperty (_("Length"), _("Full length in video frames at content rate"), c.frames_round(frc.source)) + ); + + if (stream) { + p.push_back ( + UserProperty ( + _("Length"), + _("Full length in audio frames at content rate"), + c.frames_round (stream->frame_rate ()) + ) + ); + } + + p.push_back (UserProperty (_("Audio"), _("DCP frame rate"), resampled_audio_frame_rate ())); + p.push_back (UserProperty (_("Length"), _("Full length in video frames at DCP rate"), c.frames_round (frc.dcp))); + + if (stream) { + p.push_back ( + UserProperty ( + _("Length"), + _("Full length in audio frames at DCP rate"), + c.frames_round (resampled_audio_frame_rate ()) + ) + ); + } } diff --git a/src/lib/audio_content.h b/src/lib/audio_content.h index 95231a7d7..33c52aa73 100644 --- a/src/lib/audio_content.h +++ b/src/lib/audio_content.h @@ -79,7 +79,7 @@ public: protected: - void add_properties (std::list<std::pair<std::string, std::string> > &) const; + void add_properties (std::list<UserProperty> &) const; private: /** Gain to apply to audio in dB */ diff --git a/src/lib/content.cc b/src/lib/content.cc index 2c89f7c34..724cabb6c 100644 --- a/src/lib/content.cc +++ b/src/lib/content.cc @@ -277,13 +277,11 @@ Content::path_summary () const return s; } -/** @return a list of properties that might be interesting to the user; first string is the property name, - * second is the value. - */ -list<pair<string, string> > -Content::properties () const +/** @return a list of properties that might be interesting to the user */ +list<Content::UserProperty> +Content::user_properties () const { - list<pair<string, string> > p; + list<UserProperty> p; add_properties (p); return p; } diff --git a/src/lib/content.h b/src/lib/content.h index 283889485..d87ae13d7 100644 --- a/src/lib/content.h +++ b/src/lib/content.h @@ -27,6 +27,7 @@ #include "types.h" #include "signaller.h" #include "dcpomatic_time.h" +#include "raw_convert.h" #include <libcxml/cxml.h> #include <boost/filesystem.hpp> #include <boost/signals2.hpp> @@ -91,8 +92,6 @@ public: */ virtual std::list<DCPTime> reel_split_points () const; - std::list<std::pair<std::string, std::string> > properties () const; - boost::shared_ptr<Content> clone () const; void set_path (boost::filesystem::path); @@ -162,11 +161,31 @@ public: boost::shared_ptr<const Film> film () const; + class UserProperty + { + public: + template <class T> + UserProperty (std::string category_, std::string key_, T value_, std::string unit_ = "") + : category (category_) + , key (key_) + , value (raw_convert<std::string> (value_)) + , unit (unit_) + {} + + std::string category; + std::string key; + std::string value; + std::string unit; + }; + + std::list<UserProperty> user_properties () const; + boost::signals2::signal<void (boost::weak_ptr<Content>, int, bool)> Changed; protected: void signal_changed (int); - virtual void add_properties (std::list<std::pair<std::string, std::string> > &) const {} + + virtual void add_properties (std::list<UserProperty> &) const {} boost::weak_ptr<const Film> _film; diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc index 84c864d99..8698c4ecd 100644 --- a/src/lib/dcp_content.cc +++ b/src/lib/dcp_content.cc @@ -205,7 +205,7 @@ DCPContent::directory () const } void -DCPContent::add_properties (list<pair<string, string> >& p) const +DCPContent::add_properties (list<UserProperty>& p) const { SingleStreamAudioContent::add_properties (p); } diff --git a/src/lib/dcp_content.h b/src/lib/dcp_content.h index 78c97bec5..26c1802ba 100644 --- a/src/lib/dcp_content.h +++ b/src/lib/dcp_content.h @@ -125,7 +125,7 @@ public: bool can_reference_subtitle (std::list<std::string> &) const; protected: - void add_properties (std::list<std::pair<std::string, std::string> >& p) const; + void add_properties (std::list<UserProperty>& p) const; private: void read_directory (boost::filesystem::path); diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc index f2fe06f36..9cd0395f2 100644 --- a/src/lib/ffmpeg_content.cc +++ b/src/lib/ffmpeg_content.cc @@ -392,7 +392,7 @@ FFmpegContent::audio_streams () const } void -FFmpegContent::add_properties (list<pair<string, string> >& p) const +FFmpegContent::add_properties (list<UserProperty>& p) const { VideoContent::add_properties (p); AudioContent::add_properties (p); @@ -405,17 +405,21 @@ FFmpegContent::add_properties (list<pair<string, string> >& p) const case AVCOL_RANGE_UNSPECIFIED: /// TRANSLATORS: this means that the range of pixel values used in this /// file is unknown (not specified in the file). - p.push_back (make_pair (_("Colour range"), _("Unspecified"))); + p.push_back (UserProperty (_("Video"), _("Colour range"), _("Unspecified"))); break; case AVCOL_RANGE_MPEG: /// TRANSLATORS: this means that the range of pixel values used in this /// file is limited, so that not all possible values are valid. - p.push_back (make_pair (_("Colour range"), String::compose (_("Limited (%1-%2)"), (total - sub) / 2, (total + sub) / 2))); + p.push_back ( + UserProperty ( + _("Video"), _("Colour range"), String::compose (_("Limited (%1-%2)"), (total - sub) / 2, (total + sub) / 2) + ) + ); break; case AVCOL_RANGE_JPEG: /// TRANSLATORS: this means that the range of pixel values used in this /// file is full, so that all possible pixel values are valid. - p.push_back (make_pair (_("Colour range"), String::compose (_("Full (0-%1)"), total))); + p.push_back (UserProperty (_("Video"), _("Colour range"), String::compose (_("Full (0-%1)"), total))); break; default: DCPOMATIC_ASSERT (false); @@ -425,17 +429,17 @@ FFmpegContent::add_properties (list<pair<string, string> >& p) const case AVCOL_RANGE_UNSPECIFIED: /// TRANSLATORS: this means that the range of pixel values used in this /// file is unknown (not specified in the file). - p.push_back (make_pair (_("Colour range"), _("Unspecified"))); + p.push_back (UserProperty (_("Video"), _("Colour range"), _("Unspecified"))); break; case AVCOL_RANGE_MPEG: /// TRANSLATORS: this means that the range of pixel values used in this /// file is limited, so that not all possible values are valid. - p.push_back (make_pair (_("Colour range"), _("Limited"))); + p.push_back (UserProperty (_("Video"), _("Colour range"), _("Limited"))); break; case AVCOL_RANGE_JPEG: /// TRANSLATORS: this means that the range of pixel values used in this /// file is full, so that all possible pixel values are valid. - p.push_back (make_pair (_("Colour range"), _("Full"))); + p.push_back (UserProperty (_("Video"), _("Colour range"), _("Full"))); break; default: DCPOMATIC_ASSERT (false); @@ -456,7 +460,7 @@ FFmpegContent::add_properties (list<pair<string, string> >& p) const }; DCPOMATIC_ASSERT (AVCOL_PRI_NB == 10); - p.push_back (make_pair (_("Colour primaries"), primaries[_color_primaries])); + p.push_back (UserProperty (_("Video"), _("Colour primaries"), primaries[_color_primaries])); char const * transfers[] = { _("Unspecified"), @@ -478,7 +482,7 @@ FFmpegContent::add_properties (list<pair<string, string> >& p) const }; DCPOMATIC_ASSERT (AVCOL_TRC_NB == 16); - p.push_back (make_pair (_("Colour transfer characteristic"), transfers[_color_trc])); + p.push_back (UserProperty (_("Video"), _("Colour transfer characteristic"), transfers[_color_trc])); char const * spaces[] = { _("RGB / sRGB (IEC61966-2-1)"), @@ -495,9 +499,9 @@ FFmpegContent::add_properties (list<pair<string, string> >& p) const }; DCPOMATIC_ASSERT (AVCOL_SPC_NB == 11); - p.push_back (make_pair (_("Colourspace"), spaces[_colorspace])); + p.push_back (UserProperty (_("Video"), _("Colourspace"), spaces[_colorspace])); if (_bits_per_pixel) { - p.push_back (make_pair (_("Bits per pixel"), raw_convert<string> (_bits_per_pixel.get ()))); + p.push_back (UserProperty (_("Video"), _("Bits per pixel"), raw_convert<string> (_bits_per_pixel.get ()))); } } diff --git a/src/lib/ffmpeg_content.h b/src/lib/ffmpeg_content.h index 8bd84c144..c7dc374fd 100644 --- a/src/lib/ffmpeg_content.h +++ b/src/lib/ffmpeg_content.h @@ -106,7 +106,7 @@ public: std::list<ContentTimePeriod> text_subtitles_during (ContentTimePeriod, bool starting) const; protected: - void add_properties (std::list<std::pair<std::string, std::string> > &) const; + void add_properties (std::list<UserProperty> &) const; private: friend struct ffmpeg_pts_offset_test; diff --git a/src/lib/single_stream_audio_content.cc b/src/lib/single_stream_audio_content.cc index b3c74d901..b1291df45 100644 --- a/src/lib/single_stream_audio_content.cc +++ b/src/lib/single_stream_audio_content.cc @@ -85,11 +85,3 @@ SingleStreamAudioContent::audio_streams () const return s; } -void -SingleStreamAudioContent::add_properties (list<pair<string, string> >& p) const -{ - p.push_back (make_pair (_("Audio channels"), raw_convert<string> (audio_stream()->channels ()))); - p.push_back (make_pair (_("Content audio frame rate"), raw_convert<string> (audio_stream()->frame_rate ()))); - - AudioContent::add_properties (p); -} diff --git a/src/lib/single_stream_audio_content.h b/src/lib/single_stream_audio_content.h index ad4de46ea..7ae6dbaa4 100644 --- a/src/lib/single_stream_audio_content.h +++ b/src/lib/single_stream_audio_content.h @@ -49,8 +49,6 @@ public: void take_from_audio_examiner (boost::shared_ptr<AudioExaminer>); protected: - void add_properties (std::list<std::pair<std::string, std::string> > &) const; - boost::shared_ptr<AudioStream> _audio_stream; }; diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc index 514ecae2e..0fbcba7e0 100644 --- a/src/lib/video_content.cc +++ b/src/lib/video_content.cc @@ -579,11 +579,11 @@ VideoContent::processing_description () const } void -VideoContent::add_properties (list<pair<string, string> >& p) const +VideoContent::add_properties (list<UserProperty>& p) const { - p.push_back (make_pair (_("Video length"), raw_convert<string> (video_length ()) + " " + _("video frames"))); - p.push_back (make_pair (_("Video size"), raw_convert<string> (video_size().width) + "x" + raw_convert<string> (video_size().height))); - p.push_back (make_pair (_("Video frame rate"), raw_convert<string> (video_frame_rate()) + " " + _("frames per second"))); + p.push_back (UserProperty (_("Video"), _("Length"), raw_convert<string> (video_length ()), _("video frames"))); + p.push_back (UserProperty (_("Video"), _("Size"), raw_convert<string> (video_size().width) + "x" + raw_convert<string> (video_size().height))); + p.push_back (UserProperty (_("Video"), _("Frame rate"), raw_convert<string> (video_frame_rate()), _("frames per second"))); } double diff --git a/src/lib/video_content.h b/src/lib/video_content.h index 0e58bd1b1..f672e37b5 100644 --- a/src/lib/video_content.h +++ b/src/lib/video_content.h @@ -174,7 +174,7 @@ public: protected: void take_from_video_examiner (boost::shared_ptr<VideoExaminer>); - void add_properties (std::list<std::pair<std::string, std::string> > &) const; + void add_properties (std::list<UserProperty> &) const; Frame _video_length; /** Video frame rate, or not set if this content should use the DCP's frame rate */ |
