diff options
| author | Carl Hetherington <cth@carlh.net> | 2018-07-23 01:21:07 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2018-07-23 01:21:07 +0100 |
| commit | ded71cffd18962ebb6b9611a5eb6dfafe9e8e4ec (patch) | |
| tree | 6da7f5da15b7b4cdeb82f7099b549abf537bf4fa /src/lib/active_captions.cc | |
| parent | 07d75f41aed77e340d927cc092dc4e7d74d03897 (diff) | |
Get ccaps by asking the Player, rather than by listening to its emissions,
which is slightly cleaner and works when subtitles are emitted with an
unknown end time. Also add CCAPs to the player.
Diffstat (limited to 'src/lib/active_captions.cc')
| -rw-r--r-- | src/lib/active_captions.cc | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/src/lib/active_captions.cc b/src/lib/active_captions.cc index b4252e0c3..1d3a53609 100644 --- a/src/lib/active_captions.cc +++ b/src/lib/active_captions.cc @@ -30,7 +30,37 @@ using boost::weak_ptr; using boost::shared_ptr; using boost::optional; -/** Get the subtitles that should be burnt into a given period. +void +ActiveCaptions::add (DCPTimePeriod period, list<PlayerCaption>& pc, list<Period> p) const +{ + BOOST_FOREACH (Period i, p) { + DCPTimePeriod test (i.from, i.to.get_value_or(DCPTime::max())); + optional<DCPTimePeriod> overlap = period.overlap (test); + if (overlap && overlap->duration() > DCPTime(period.duration().get() / 2)) { + pc.push_back (i.subs); + } + } +} + +list<PlayerCaption> +ActiveCaptions::get (DCPTimePeriod period) const +{ + list<PlayerCaption> ps; + + for (Map::const_iterator i = _data.begin(); i != _data.end(); ++i) { + + shared_ptr<const CaptionContent> caption = i->first.lock (); + if (!caption || !caption->use()) { + continue; + } + + add (period, ps, i->second); + } + + return ps; +} + +/** Get the open captions that should be burnt into a given period. * @param period Period of interest. * @param always_burn_captions Always burn captions even if their content is not set to burn. */ @@ -51,13 +81,7 @@ ActiveCaptions::get_burnt (DCPTimePeriod period, bool always_burn_captions) cons continue; } - BOOST_FOREACH (Period j, i->second) { - DCPTimePeriod test (j.from, j.to.get_value_or(DCPTime::max())); - optional<DCPTimePeriod> overlap = period.overlap (test); - if (overlap && overlap->duration() > DCPTime(period.duration().get() / 2)) { - ps.push_back (j.subs); - } - } + add (period, ps, i->second); } return ps; |
