Some fixes to playback of drop-frame content.
[dcpomatic.git] / src / lib / decoder.cc
index 52b22fa067955b48341b40947a728161f65c6152..7f4973737faff0146f971f91c846cc4c8a5dabef 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 "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"
+#include "decoded.h"
 
 #include "i18n.h"
 
-using std::string;
-using std::stringstream;
-using std::min;
-using std::pair;
-using std::list;
 using boost::shared_ptr;
-using boost::optional;
 
 /** @param f Film.
  *  @param o Decode options.
  */
-Decoder::Decoder (boost::shared_ptr<Film> f, DecodeOptions o)
+Decoder::Decoder (shared_ptr<const Film> f)
        : _film (f)
-       , _opt (o)
 {
-       _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<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 ()
 {
-       throw DecodeError (N_("decoder does not support seek"));
+       if (!_pending.empty ()) {
+               _pending.pop_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::seek (ContentTime, bool)
 {
-       throw DecodeError (N_("decoder does not support seek"));
+       _pending.clear ();
 }