X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fdecoder.cc;h=53a0c31e140d6ceab0a3d2f222fe419bda88237b;hb=4ba8772aef261da209bbb882325fd61a8b479fd7;hp=5778949963ccb63cff592626b96094da2e4a6cc5;hpb=9c58fcdb6fd8131c17456dd71c5c277a6b0ae053;p=dcpomatic.git diff --git a/src/lib/decoder.cc b/src/lib/decoder.cc index 577894996..53a0c31e1 100644 --- a/src/lib/decoder.cc +++ b/src/lib/decoder.cc @@ -21,44 +21,59 @@ * @brief Parent class for decoders of content. */ -#include -#include -#include #include "film.h" -#include "format.h" -#include "job.h" -#include "options.h" -#include "exceptions.h" -#include "image.h" -#include "util.h" -#include "log.h" #include "decoder.h" -#include "delay_line.h" -#include "subtitle.h" -#include "filter_graph.h" - -using std::string; -using std::stringstream; -using std::min; -using std::pair; -using std::list; +#include "decoded.h" + +#include "i18n.h" + +using std::cout; using boost::shared_ptr; -using boost::optional; /** @param f Film. - * @param o Options. - * @param j Job that we are running within, or 0 + * @param o Decode options. */ -Decoder::Decoder (boost::shared_ptr f, boost::shared_ptr o, Job* j) +Decoder::Decoder (shared_ptr f) : _film (f) - , _opt (o) - , _job (j) + , _done (false) +{ + +} + +struct DecodedSorter +{ + bool operator() (shared_ptr a, shared_ptr b) + { + return a->dcp_time < b->dcp_time; + } +}; + +shared_ptr +Decoder::peek () +{ + while (!_done && _pending.empty ()) { + _done = pass (); + } + + if (_done && _pending.empty ()) { + return shared_ptr (); + } + + _pending.sort (DecodedSorter ()); + return _pending.front (); +} + +void +Decoder::consume () { - + if (!_pending.empty ()) { + _pending.pop_front (); + } } void -Decoder::seek (SourceFrame f) +Decoder::seek (ContentTime, bool) { - throw DecodeError ("decoder does not support seek"); + _pending.clear (); + _done = false; }