diff options
| author | Carl Hetherington <cth@carlh.net> | 2024-05-12 15:22:28 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2024-05-15 23:49:51 +0200 |
| commit | 26678a922a1808db33954e002c165678d8191fc6 (patch) | |
| tree | 03404face5f2db2e4afae05de84fe2fd884a02d4 /src/lib/player.cc | |
| parent | 6d88d2246881d0fd8828786dd4a25a73fafe575e (diff) | |
Get DCP transcode progress from the player (#2804).
Diffstat (limited to 'src/lib/player.cc')
| -rw-r--r-- | src/lib/player.cc | 67 |
1 files changed, 47 insertions, 20 deletions
diff --git a/src/lib/player.cc b/src/lib/player.cc index c03cb97a5..2e96e4bee 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -688,6 +688,39 @@ Player::set_play_referenced () } +pair<shared_ptr<Piece>, optional<DCPTime>> +Player::earliest_piece_and_time() const +{ + auto film = _film.lock(); + DCPOMATIC_ASSERT(film); + + shared_ptr<Piece> earliest_content; + optional<DCPTime> earliest_time; + + for (auto const& piece: _pieces) { + if (piece->done) { + continue; + } + + auto const t = content_time_to_dcp(piece, max(piece->decoder->position(), piece->content->trim_start())); + if (t > piece->content->end(film)) { + piece->done = true; + } else { + + /* Given two choices at the same time, pick the one with texts so we see it before + the video. + */ + if (!earliest_time || t < *earliest_time || (t == *earliest_time && !piece->decoder->text.empty())) { + earliest_time = t; + earliest_content = piece; + } + } + } + + return { earliest_content, earliest_time }; +} + + bool Player::pass () { @@ -711,26 +744,7 @@ Player::pass () shared_ptr<Piece> earliest_content; optional<DCPTime> earliest_time; - - for (auto i: _pieces) { - if (i->done) { - continue; - } - - auto const t = content_time_to_dcp (i, max(i->decoder->position(), i->content->trim_start())); - if (t > i->content->end(film)) { - i->done = true; - } else { - - /* Given two choices at the same time, pick the one with texts so we see it before - the video. - */ - if (!earliest_time || t < *earliest_time || (t == *earliest_time && !i->decoder->text.empty())) { - earliest_time = t; - earliest_content = i; - } - } - } + std::tie(earliest_content, earliest_time) = earliest_piece_and_time(); bool done = false; @@ -1644,3 +1658,16 @@ Player::set_disable_audio_processor() _disable_audio_processor = true; } + +Frame +Player::frames_done() const +{ + auto film = _film.lock(); + DCPOMATIC_ASSERT(film); + + shared_ptr<Piece> earliest_content; + optional<DCPTime> earliest_time; + std::tie(earliest_content, earliest_time) = earliest_piece_and_time(); + + return earliest_time.get_value_or({}).frames_round(film->video_frame_rate()); +} |
