diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-04-25 17:33:20 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-05-07 09:29:59 +0200 |
| commit | ca3343840b28c258c91635cedc133ee064d9d03d (patch) | |
| tree | a6903fabc6dc7625e6345ed3d6337d32d8039eeb | |
| parent | fd49966b7fb987f074c703441d5bb1f2d2a75fcf (diff) | |
Add Piece::seek().
| -rw-r--r-- | src/lib/piece.cc | 22 | ||||
| -rw-r--r-- | src/lib/piece.h | 1 | ||||
| -rw-r--r-- | src/lib/player.cc | 17 |
3 files changed, 24 insertions, 16 deletions
diff --git a/src/lib/piece.cc b/src/lib/piece.cc index 2a3adcd40..2cdc20a50 100644 --- a/src/lib/piece.cc +++ b/src/lib/piece.cc @@ -224,3 +224,25 @@ Piece::has_text () const return !decoder->text.empty(); } + +void +Piece::seek (shared_ptr<const Film> film, DCPTime time, bool accurate) +{ + if (time < position()) { + /* Before; seek to the start of the content. Even if this request is for an inaccurate seek + we must seek this (following) content accurately, otherwise when we come to the end of the current + 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); + done = false; + } else if (position() <= time && time < end(film)) { + /* During; seek to position */ + decoder->seek (dcp_to_content_time(time, film), accurate); + done = false; + } else { + /* After; this piece is done */ + done = true; + } +} + diff --git a/src/lib/piece.h b/src/lib/piece.h index 6c0df23c2..56b16fb28 100644 --- a/src/lib/piece.h +++ b/src/lib/piece.h @@ -72,6 +72,7 @@ public: dcpomatic::DCPTime decoder_position () const; bool has_text () const; + void seek (std::shared_ptr<const Film> film, dcpomatic::DCPTime time, bool accurate); std::shared_ptr<Decoder> decoder; boost::optional<dcpomatic::DCPTimePeriod> ignore_video; diff --git a/src/lib/player.cc b/src/lib/player.cc index 23db8433f..5951e179d 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -1090,22 +1090,7 @@ Player::seek (DCPTime time, bool accurate) } for (auto i: _pieces) { - if (time < i->position()) { - /* Before; seek to the start of the content. Even if this request is for an inaccurate seek - we must seek this (following) content accurately, otherwise when we come to the end of the current - 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). - */ - i->decoder->seek (i->dcp_to_content_time(i->position(), _film), true); - i->done = false; - } else if (i->position() <= time && time < i->end(_film)) { - /* During; seek to position */ - i->decoder->seek (i->dcp_to_content_time(time, _film), accurate); - i->done = false; - } else { - /* After; this piece is done */ - i->done = true; - } + i->seek (_film, time, accurate); } if (accurate) { |
