using std::dynamic_pointer_cast;
using std::make_shared;
using std::shared_ptr;
+using std::vector;
using boost::optional;
using namespace dcpomatic;
void
Piece::update_pull_to (DCPTime& pull_to) const
{
- if (done) {
+ if (_done) {
return;
}
}
-DCPTime
-Piece::decoder_position () const
-{
- auto t = content_time_to_dcp(_content, std::max(decoder->position(), _content->trim_start()));
- DCPOMATIC_ASSERT (t);
- return *t;
-}
-
-
void
Piece::pass ()
{
LOG_DEBUG_PLAYER ("Calling pass() on %1", _content->path(0));
- done = decoder->pass();
+ _done = decoder->pass();
}
}
-bool
-Piece::has_text () const
-{
- return !decoder->text.empty();
-}
-
-
void
Piece::seek (shared_ptr<const Film> film, DCPTime time, bool accurate)
{
been trimmed to a point between keyframes, or something).
*/
decoder->seek (dcp_to_content_time(position(), film), true);
- done = false;
+ _done = false;
} else if (position() <= time && time < end(film)) {
/* During; seek to position */
decoder->seek (dcp_to_content_time(time, film), accurate);
- done = false;
+ _done = false;
} else {
/* After; this piece is done */
- done = true;
+ _done = true;
}
}
+
+optional<dcpomatic::DCPTime>
+Piece::decoder_before(shared_ptr<const Film> film, optional<dcpomatic::DCPTime> time)
+{
+ if (_done) {
+ return {};
+ }
+
+ auto t = content_time_to_dcp(_content, std::max(decoder->position(), _content->trim_start()));
+ DCPOMATIC_ASSERT (t);
+
+ if (*t > end(film)) {
+ _done = true;
+ } else {
+ /* 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())) {
+ return t;
+ }
+ }
+
+ return {};
+}
+
+vector<dcpomatic::FontData>
+Piece::fonts () const
+{
+ return decoder->fonts();
+}
+