2 Copyright (C) 2012-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/>.
23 #include "video_decoder.h"
24 #include "audio_decoder.h"
25 #include "text_decoder.h"
26 #include <boost/optional.hpp>
31 using boost::optional;
32 using std::shared_ptr;
34 using namespace dcpomatic;
37 Decoder::Decoder (weak_ptr<const Film> film)
38 : WeakConstFilm (film)
44 /** @return Earliest time of content that the next pass() will emit */
46 Decoder::position () const
48 optional<ContentTime> pos;
51 if (video && !video->ignore() && (!pos || video->position(f).get_value_or(ContentTime()) < *pos)) {
52 pos = video->position(f);
55 if (audio && !audio->ignore() && (!pos || audio->position(f).get_value_or(ContentTime()) < *pos)) {
56 pos = audio->position(f);
59 /* Only decide position based on subtitle sources if there is nothing else
60 to go on. Otherwise we can have problems with muxed sources which have
61 (for example) video, audio and a subtitle. If the subtitle data runs out
62 before the video/audio the position() call will return the position of the
63 end of the subs. This causes this file to be pass()ed in favour of others,
64 which can cause bugs like #1581.
68 if (!i->ignore() && (!pos || i->position(f) < *pos)) {
74 return pos.get_value_or(ContentTime());
79 Decoder::seek (ContentTime, bool)
93 shared_ptr<TextDecoder>
94 Decoder::only_text () const
96 DCPOMATIC_ASSERT (text.size() < 2);