X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fdecoder.cc;h=0901f73b020027cc733ab325c2085f494db65d45;hb=1f8b45c7fd49714628009f5ed2161fbaa2b4d729;hp=fd0abee4183e540b4a4db5c5a9cb3588e5d8a34c;hpb=9db7ed5f6499de903313a85d59bb70302e97e7ff;p=dcpomatic.git diff --git a/src/lib/decoder.cc b/src/lib/decoder.cc index fd0abee41..0901f73b0 100644 --- a/src/lib/decoder.cc +++ b/src/lib/decoder.cc @@ -21,56 +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 Decode options. - * @param j Job that we are running within, or 0 +/** @param o Decode options. */ -Decoder::Decoder (boost::shared_ptr f, DecodeOptions o, Job* j) - : _film (f) - , _opt (o) - , _job (j) +Decoder::Decoder () + : _done (false) { - _film_connection = f->Changed.connect (bind (&Decoder::film_changed, this, _1)); + } -/** Seek to a position as a source timestamp in seconds. - * @return true on error. - */ -bool -Decoder::seek (double) +struct DecodedSorter +{ + bool operator() (shared_ptr a, shared_ptr b) + { + return a->dcp_time < b->dcp_time; + } +}; + +shared_ptr +Decoder::peek () { - throw DecodeError ("decoder does not support seek"); + while (!_done && _pending.empty ()) { + _done = pass (); + } + + if (_done && _pending.empty ()) { + return shared_ptr (); + } + + _pending.sort (DecodedSorter ()); + return _pending.front (); } -/** Seek so that the next frame we will produce is the same as the last one. - * @return true on error. - */ -bool -Decoder::seek_to_last () +void +Decoder::consume () +{ + if (!_pending.empty ()) { + _pending.pop_front (); + } +} + +void +Decoder::seek (ContentTime, bool) { - throw DecodeError ("decoder does not support seek"); + _pending.clear (); + _done = false; }