using boost::optional;
using namespace dcpomatic;
+
/** 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.
list<PlayerText> ps;
- for (Map::const_iterator i = _data.begin(); i != _data.end(); ++i) {
+ for (auto const& i: _data) {
- shared_ptr<const TextContent> caption = i->first.lock ();
+ auto caption = i.first.lock ();
if (!caption) {
continue;
}
continue;
}
- for (auto j: i->second) {
+ for (auto j: i.second) {
DCPTimePeriod test (j.from, j.to.get_value_or(DCPTime::max()));
- optional<DCPTimePeriod> overlap = period.overlap (test);
+ auto overlap = period.overlap (test);
if (overlap && overlap->duration() > DCPTime(period.duration().get() / 2)) {
ps.push_back (j.subs);
}
return ps;
}
+
/** Remove subtitles that finish before a given time from our list.
* @param time Time to remove before.
*/
boost::mutex::scoped_lock lm (_mutex);
Map updated;
- for (Map::const_iterator i = _data.begin(); i != _data.end(); ++i) {
+ for (auto const& i: _data) {
list<Period> as;
- for (auto j: i->second) {
+ for (auto j: i.second) {
if (!j.to || j.to.get() >= time) {
as.push_back (j);
}
}
if (!as.empty ()) {
- updated[i->first] = as;
+ updated[i.first] = as;
}
}
_data = updated;
}
+
/** Add a new subtitle with a from time.
* @param content Content that the subtitle is from.
* @param ps Subtitles.
_data[content].push_back (Period (ps, from));
}
+
/** Add the to time for the last subtitle added from a piece of content.
* @param content Content that the subtitle is from.
* @param to To time for the last subtitle submitted to add_from for this content.
return make_pair (_data[content].back().subs, _data[content].back().from);
}
+
/** @param content Some content.
* @return true if we have any active subtitles from this content.
*/
{
boost::mutex::scoped_lock lm (_mutex);
- Map::const_iterator i = _data.find(content);
+ auto i = _data.find(content);
if (i == _data.end()) {
return false;
}
return !i->second.empty();
}
+
void
ActiveText::clear ()
{