Add Piece::period().
[dcpomatic.git] / src / lib / piece.cc
index 16fcb32bcc72724f4c66fa454c22c0807fcf61ef..0dbb7173ca3cdb5546df4c740e58063ceb430622 100644 (file)
 using std::dynamic_pointer_cast;
 using std::make_shared;
 using std::shared_ptr;
+using std::vector;
 using boost::optional;
 using namespace dcpomatic;
 
 
 Piece::Piece (shared_ptr<Content> c, shared_ptr<Decoder> d, FrameRateChange f)
        : _content (c)
-       , decoder (d)
+       , _decoder (d)
        , _frc (f)
 {
        if (_content->audio) {
@@ -186,7 +187,7 @@ shared_ptr<Decoder>
 Piece::decoder_for (shared_ptr<Content> content) const
 {
        if (content == _content) {
-               return decoder;
+               return _decoder;
        }
 
        return {};
@@ -197,7 +198,7 @@ void
 Piece::pass ()
 {
        LOG_DEBUG_PLAYER ("Calling pass() on %1", _content->path(0));
-       _done = decoder->pass();
+       _done = _decoder->pass();
 }
 
 
@@ -218,11 +219,11 @@ Piece::seek (shared_ptr<const Film> film, DCPTime time, bool accurate)
                   content we may not start right at the beginning of the next, causing a gap (if the next content has
                   been trimmed to a point between keyframes, or something).
                   */
-               decoder->seek (dcp_to_content_time(position(), film), true);
+               _decoder->seek (dcp_to_content_time(position(), film), true);
                _done = false;
        } else if (position() <= time && time < end(film)) {
                /* During; seek to position */
-               decoder->seek (dcp_to_content_time(time, film), accurate);
+               _decoder->seek (dcp_to_content_time(time, film), accurate);
                _done = false;
        } else {
                /* After; this piece is done */
@@ -238,7 +239,7 @@ Piece::decoder_before(shared_ptr<const Film> film, optional<dcpomatic::DCPTime>
                return {};
        }
 
-       auto t = content_time_to_dcp(_content, std::max(decoder->position(), _content->trim_start()));
+       auto t = content_time_to_dcp(_content, std::max(_decoder->position(), _content->trim_start()));
        DCPOMATIC_ASSERT (t);
 
        if (*t > end(film)) {
@@ -247,7 +248,7 @@ Piece::decoder_before(shared_ptr<const Film> film, optional<dcpomatic::DCPTime>
                /* Given two choices at the same time, pick the one with texts so we see it before
                   the video.
                   */
-               if (!time || t < *time || (t == *time && !decoder->text.empty())) {
+               if (!time || t < *time || (t == *time && !_decoder->text.empty())) {
                        return t;
                }
        }
@@ -255,3 +256,23 @@ Piece::decoder_before(shared_ptr<const Film> film, optional<dcpomatic::DCPTime>
        return {};
 }
 
+vector<dcpomatic::FontData>
+Piece::fonts () const
+{
+       return _decoder->fonts();
+}
+
+
+bool
+Piece::ignore_video_at (DCPTime time) const
+{
+       return _ignore_video && _ignore_video->contains(time);
+}
+
+
+DCPTimePeriod
+Piece::period (shared_ptr<const Film> film) const
+{
+       return DCPTimePeriod(position(), end(film));
+}
+