X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Flib%2Fdecoder.cc;h=0d4f4babfa9db0831650529ae4ead927260dc7f3;hb=35e9a698ba3ca35fd488b3622e441956632261cf;hp=18c5acd3551b3442eea6e8882d16f08f658f48b2;hpb=e194f0003b60b2607da0822485c56cd8267e78dc;p=dcpomatic.git diff --git a/src/lib/decoder.cc b/src/lib/decoder.cc index 18c5acd35..0d4f4babf 100644 --- a/src/lib/decoder.cc +++ b/src/lib/decoder.cc @@ -1,67 +1,61 @@ /* - Copyright (C) 2012 Carl Hetherington + Copyright (C) 2012-2016 Carl Hetherington - This program is free software; you can redistribute it and/or modify + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, + DCP-o-matic is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with DCP-o-matic. If not, see . */ -/** @file src/decoder.cc - * @brief Parent class for decoders of content. - */ - -#include "film.h" #include "decoder.h" - -#include "i18n.h" - -using boost::shared_ptr; - -/** @param f Film. - * @param o Decode options. - */ -Decoder::Decoder (shared_ptr f) - : _film (f) -{ - -} - -shared_ptr -Decoder::peek () +#include "video_decoder.h" +#include "audio_decoder.h" +#include "subtitle_decoder.h" +#include +#include + +using std::cout; +using boost::optional; + +/** @return Earliest time of content that the next pass() will emit */ +ContentTime +Decoder::position () const { - while (_pending.empty () && !pass ()) {} + optional pos; - if (_pending.empty ()) { - return shared_ptr (); + if (video && !video->ignore() && (!pos || video->position() < *pos)) { + pos = video->position(); } - return _pending.front (); -} + if (audio && !audio->ignore() && (!pos || audio->position() < *pos)) { + pos = audio->position(); + } -shared_ptr -Decoder::get () -{ - shared_ptr d = peek (); - if (d) { - _pending.pop_front (); + if (subtitle && !subtitle->ignore() && (!pos || subtitle->position() < *pos)) { + pos = subtitle->position(); } - return d; + return pos.get_value_or(ContentTime()); } void Decoder::seek (ContentTime, bool) { - _pending.clear (); + if (audio) { + audio->seek (); + } + if (subtitle) { + subtitle->seek (); + } }