X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fdecoder.cc;h=7f4973737faff0146f971f91c846cc4c8a5dabef;hb=64dc289b343641fc37db51fcd6b3069078cb5edf;hp=fd0abee4183e540b4a4db5c5a9cb3588e5d8a34c;hpb=039ac5848730d154e0b3f3dd841a55e45ba922d8;p=dcpomatic.git diff --git a/src/lib/decoder.cc b/src/lib/decoder.cc index fd0abee41..7f4973737 100644 --- a/src/lib/decoder.cc +++ b/src/lib/decoder.cc @@ -21,56 +21,54 @@ * @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 boost::shared_ptr; -using boost::optional; /** @param f Film. * @param o Decode options. - * @param j Job that we are running within, or 0 */ -Decoder::Decoder (boost::shared_ptr f, DecodeOptions o, Job* j) +Decoder::Decoder (shared_ptr f) : _film (f) - , _opt (o) - , _job (j) { - _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) +class DecodedSorter +{ +public: + 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 (_pending.empty() && !pass ()) {} + + if (_pending.empty ()) { + return shared_ptr (); + } + + 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 (); }