X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fdecoder.cc;h=0901f73b020027cc733ab325c2085f494db65d45;hb=e6f28e7cda23c1ba3c49cc1bf2dc1491c2f87160;hp=93ce2cdbb2c816d0b388fba69e556c70a27dffed;hpb=c726a221e619d22ad5253eaa6c3429bce557e111;p=dcpomatic.git diff --git a/src/lib/decoder.cc b/src/lib/decoder.cc index 93ce2cdbb..0901f73b0 100644 --- a/src/lib/decoder.cc +++ b/src/lib/decoder.cc @@ -21,44 +21,56 @@ * @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) - : _film (f) - , _opt (o) - , _job (j) +Decoder::Decoder () + : _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 (); + } } -bool -Decoder::seek (SourceFrame f) +void +Decoder::seek (ContentTime, bool) { - throw DecodeError ("decoder does not support seek"); + _pending.clear (); + _done = false; }