Some more piece layer stuff.
authorCarl Hetherington <cth@carlh.net>
Mon, 22 Jun 2020 22:58:23 +0000 (00:58 +0200)
committerCarl Hetherington <cth@carlh.net>
Mon, 22 Jun 2020 22:58:23 +0000 (00:58 +0200)
src/lib/piece.cc
src/lib/piece.h
src/lib/player.cc

index 57e00334b1b96c7faff2899899efed89fa2070f0..84d0968c24185c7ee5050adc93f6bebaf02824fc 100644 (file)
 */
 
 
+#include "audio_content.h"
 #include "film.h"
 #include "piece.h"
 
 
+using boost::optional;
 using boost::shared_ptr;
 using namespace dcpomatic;
 
@@ -88,3 +90,52 @@ Piece::dcp_to_content_time (shared_ptr<const Film> film, DCPTime t) const
        return max(ContentTime(), ContentTime(s, frc) + content->trim_start());
 }
 
+
+bool
+Piece::video_use () const
+{
+       return content->video->use();
+}
+
+
+optional<double>
+Piece::video_fade (shared_ptr<const Film> film, Frame frame) const
+{
+       return content->video->fade (film, frame);
+}
+
+
+dcp::Size
+Piece::video_scaled_size (dcp::Size container_size)
+{
+       return content->video->scaled_size(container_size);
+}
+
+
+optional<ColourConversion>
+Piece::video_colour_conversion () const
+{
+       return content->video->colour_conversion();
+}
+
+
+VideoRange
+Piece::video_range () const
+{
+       return content->video->range();
+}
+
+
+int
+Piece::audio_resampled_frame_rate (boost::shared_ptr<const Film> film) const
+{
+       return content->audio->resampled_frame_rate (film);
+}
+
+
+double
+Piece::audio_gain () const
+{
+       return content->audio->gain();
+}
+
index aa67316f16648dbff7e7a7713498b7ba292f4c1b..dd7867227dc4ef6ed403278e24ea67dc54ae01ab 100644 (file)
@@ -48,6 +48,14 @@ public:
        dcpomatic::ContentTime dcp_to_content_time (boost::shared_ptr<const Film> film, dcpomatic::DCPTime t) const;
 
        Crop video_crop () const;
+       bool video_use () const;
+       boost::optional<double> video_fade (boost::shared_ptr<const Film> film, Frame frame) const;
+       dcp::Size video_scaled_size (dcp::Size container_size);
+       boost::optional<ColourConversion> video_colour_conversion () const;
+       VideoRange video_range () const;
+
+       int audio_resampled_frame_rate (boost::shared_ptr<const Film> film) const;
+       double audio_gain () const;
 
        boost::shared_ptr<Content> content;
        boost::shared_ptr<Decoder> decoder;
index 9630e6a9c5c1db45e595daabf6633c5d96b85749..0cf47263d92d2657c89735237a0f05987b5f9f69 100644 (file)
@@ -741,7 +741,7 @@ Player::video (weak_ptr<Piece> wp, ContentVideo video)
                return;
        }
 
-       if (!piece->content->video->use()) {
+       if (!piece->video_use()) {
                return;
        }
 
@@ -816,13 +816,13 @@ Player::video (weak_ptr<Piece> wp, ContentVideo video)
                new PlayerVideo (
                        video.image,
                        piece->video_crop(),
-                       piece->content->video->fade (_film, video.frame),
-                       scale_for_display(piece->content->video->scaled_size(_film->frame_size()), _video_container_size, _film->frame_size()),
+                       piece->video_fade(_film, video.frame),
+                       scale_for_display(piece->video_scaled_size(_film->frame_size()), _video_container_size, _film->frame_size()),
                        _video_container_size,
                        video.eyes,
                        video.part,
-                       piece->content->video->colour_conversion(),
-                       piece->content->video->range(),
+                       piece->video_colour_conversion(),
+                       piece->video_range(),
                        piece->content,
                        video.frame,
                        false
@@ -848,10 +848,7 @@ Player::audio (weak_ptr<Piece> wp, AudioStreamPtr stream, ContentAudio content_a
                return;
        }
 
-       shared_ptr<AudioContent> content = piece->content->audio;
-       DCPOMATIC_ASSERT (content);
-
-       int const rfr = content->resampled_frame_rate (_film);
+       int const rfr = piece->audio_resampled_frame_rate (_film);
 
        /* Compute time in the DCP */
        DCPTime time = piece->resampled_audio_to_dcp (_film, content_audio.frame);
@@ -882,9 +879,9 @@ Player::audio (weak_ptr<Piece> wp, AudioStreamPtr stream, ContentAudio content_a
 
        /* Gain */
 
-       if (content->gain() != 0) {
+       if (piece->audio_gain() != 0) {
                shared_ptr<AudioBuffers> gain (new AudioBuffers (content_audio.audio));
-               gain->apply_gain (content->gain ());
+               gain->apply_gain (piece->audio_gain());
                content_audio.audio = gain;
        }