X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fdecoder.cc;h=ee03a1579c59bfe399927fb76a85e316fba21edb;hb=89aa9d4ba69e471949f791cdafe4ae20cea554d2;hp=18c5acd3551b3442eea6e8882d16f08f658f48b2;hpb=a5b59faff75265d3256ad0dbd9f0c69e51e31ce4;p=dcpomatic.git diff --git a/src/lib/decoder.cc b/src/lib/decoder.cc index 18c5acd35..ee03a1579 100644 --- a/src/lib/decoder.cc +++ b/src/lib/decoder.cc @@ -1,67 +1,57 @@ /* - 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 "video_decoder.h" +#include "audio_decoder.h" +#include "subtitle_decoder.h" +#include +#include -#include "i18n.h" - -using boost::shared_ptr; +using std::cout; +using boost::optional; -/** @param f Film. - * @param o Decode options. - */ -Decoder::Decoder (shared_ptr f) - : _film (f) +ContentTime +Decoder::position () const { + optional pos; -} - -shared_ptr -Decoder::peek () -{ - while (_pending.empty () && !pass ()) {} - - if (_pending.empty ()) { - return shared_ptr (); + if (video && (!pos || video->position() < *pos)) { + pos = video->position(); } - return _pending.front (); -} + if (audio && (!pos || audio->position() < *pos)) { + pos = audio->position(); + } -shared_ptr -Decoder::get () -{ - shared_ptr d = peek (); - if (d) { - _pending.pop_front (); + if (subtitle && (!pos || subtitle->position() < *pos)) { + pos = subtitle->position(); } - return d; + return pos.get_value_or(ContentTime()); } void -Decoder::seek (ContentTime, bool) +Decoder::seek (ContentTime time, bool accurate) { - _pending.clear (); + if (audio) { + audio->seek (); + } }