X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fdecoder.cc;h=1b281f718fe68e7dfc65d906171ebe1a3a2a4c6f;hb=97632e5e91fc0e2c0a3dd84ed9a167f79e4bd14d;hp=53a0c31e140d6ceab0a3d2f222fe419bda88237b;hpb=4e5d5c7dcc6470b8dc918d03a00e30c07df60efe;p=dcpomatic.git diff --git a/src/lib/decoder.cc b/src/lib/decoder.cc index 53a0c31e1..1b281f718 100644 --- a/src/lib/decoder.cc +++ b/src/lib/decoder.cc @@ -1,79 +1,58 @@ /* - 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 "decoded.h" - -#include "i18n.h" +#include "video_decoder.h" +#include "audio_decoder.h" +#include "subtitle_decoder.h" +#include +#include using std::cout; -using boost::shared_ptr; +using boost::optional; -/** @param f Film. - * @param o Decode options. - */ -Decoder::Decoder (shared_ptr f) - : _film (f) - , _done (false) +/** @return Earliest time of content that the next pass() will emit */ +ContentTime +Decoder::position () const { + optional pos; -} - -struct DecodedSorter -{ - bool operator() (shared_ptr a, shared_ptr b) - { - return a->dcp_time < b->dcp_time; + if (video && (!pos || video->position() < *pos)) { + pos = video->position(); } -}; -shared_ptr -Decoder::peek () -{ - while (!_done && _pending.empty ()) { - _done = pass (); + if (audio && (!pos || audio->position() < *pos)) { + pos = audio->position(); } - if (_done && _pending.empty ()) { - return shared_ptr (); + if (subtitle && (!pos || subtitle->position() < *pos)) { + pos = subtitle->position(); } - _pending.sort (DecodedSorter ()); - return _pending.front (); -} - -void -Decoder::consume () -{ - if (!_pending.empty ()) { - _pending.pop_front (); - } + return pos.get_value_or(ContentTime()); } void Decoder::seek (ContentTime, bool) { - _pending.clear (); - _done = false; + if (audio) { + audio->seek (); + } }