2 Copyright (C) 2017-2021 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
26 #include "content_part.h"
27 #include "dcp_content.h"
28 #include "dcpomatic_time_coalesce.h"
35 using std::shared_ptr;
36 using std::dynamic_pointer_cast;
38 using namespace dcpomatic;
41 Empty::Empty (shared_ptr<const Film> film, shared_ptr<const Playlist> playlist, function<bool (shared_ptr<const Content>)> part, DCPTime length)
43 list<DCPTimePeriod> full;
44 for (auto i: playlist->content()) {
45 if (part(i) && i->paths_valid()) {
46 full.push_back(i->period(film));
50 _periods = subtract (DCPTimePeriod(DCPTime(), length), coalesce(full));
52 if (!_periods.empty()) {
53 _position = _periods.front().from;
59 Empty::set_position (DCPTime position)
63 for (auto i: _periods) {
64 if (i.contains(_position)) {
69 for (auto i: _periods) {
70 if (i.from > _position) {
79 Empty::period_at_position () const
81 for (auto i: _periods) {
82 if (i.contains(_position)) {
83 return DCPTimePeriod (_position, i.to);
87 DCPOMATIC_ASSERT (false);
95 for (auto i: _periods) {
96 latest = max (latest, i.to);
99 return _position >= latest;