Some fixes to playback of drop-frame content.
[dcpomatic.git] / src / lib / decoder.cc
index 637e0ddb291101af81f28115327f195a3e128116..7f4973737faff0146f971f91c846cc4c8a5dabef 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "film.h"
 #include "decoder.h"
+#include "decoded.h"
 
 #include "i18n.h"
 
@@ -34,5 +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 ();
+       }
+}
+
+void
+Decoder::seek (ContentTime, bool)
+{
+       _pending.clear ();
 }