Mostly-merge master.
[dcpomatic.git] / src / lib / decoder.cc
index 50770834586f10c1cb5405d7846fa2696d26fd66..0901f73b020027cc733ab325c2085f494db65d45 100644 (file)
  *  @brief Parent class for decoders of content.
  */
 
-#include <iostream>
-#include <stdint.h>
-#include <boost/lexical_cast.hpp>
-#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<Film> f, boost::shared_ptr<const DecodeOptions> o, Job* j)
-       : _film (f)
-       , _opt (o)
-       , _job (j)
+Decoder::Decoder ()
+       : _done (false)
+{
+
+}
+
+struct DecodedSorter
+{
+       bool operator() (shared_ptr<Decoded> a, shared_ptr<Decoded> b)
+       {
+               return a->dcp_time < b->dcp_time;
+       }
+};
+
+shared_ptr<Decoded>
+Decoder::peek ()
+{
+       while (!_done && _pending.empty ()) {
+               _done = pass ();
+       }
+
+       if (_done && _pending.empty ()) {
+               return shared_ptr<Decoded> ();
+       }
+
+       _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;
 }