Some fixes to playback of drop-frame content.
[dcpomatic.git] / src / lib / decoder.cc
index 2308bbd98fe5d3a3a7dedba52bd9a32b90c42e96..7f4973737faff0146f971f91c846cc4c8a5dabef 100644 (file)
  *  @brief Parent class for decoders of content.
  */
 
-#include <iostream>
 #include "film.h"
-#include "exceptions.h"
-#include "util.h"
 #include "decoder.h"
+#include "decoded.h"
 
 #include "i18n.h"
 
-using std::string;
 using boost::shared_ptr;
 
 /** @param f Film.
@@ -38,12 +35,40 @@ using boost::shared_ptr;
 Decoder::Decoder (shared_ptr<const Film> f)
        : _film (f)
 {
-       _film_connection = f->Changed.connect (bind (&Decoder::film_changed, this, _1));
+
+}
+
+class DecodedSorter
+{
+public:
+       bool operator() (shared_ptr<Decoded> a, shared_ptr<Decoded> b)
+       {
+               return a->dcp_time < b->dcp_time;
+       }
+};
+
+shared_ptr<Decoded>
+Decoder::peek ()
+{
+       while (_pending.empty() && !pass ()) {}
+
+       if (_pending.empty ()) {
+               return shared_ptr<Decoded> ();
+       }
+
+       return _pending.front ();
+}
+
+void
+Decoder::consume ()
+{
+       if (!_pending.empty ()) {
+               _pending.pop_front ();
+       }
 }
 
-/** @return true on error */
-bool
-Decoder::seek (Time)
+void
+Decoder::seek (ContentTime, bool)
 {
-       throw DecodeError (N_("decoder does not support seek"));
+       _pending.clear ();
 }