Remove some friends from FilmViewer.
[dcpomatic.git] / src / wx / video_view.cc
index 6478ff2a654ada0b0d58ef0ca32c1d1cd3f9fed6..5dd857fabc4a4089f8aa4ea08a98e09aeb55ba99 100644 (file)
 #include "film_viewer.h"
 #include "lib/butler.h"
 
+VideoView::VideoView (FilmViewer* viewer)
+       : _viewer (viewer)
+#ifdef DCPOMATIC_VARIANT_SWAROOP
+       , _in_watermark (false)
+#endif
+       , _state_timer ("viewer")
+       , _video_frame_rate (0)
+       , _eyes (EYES_LEFT)
+       , _dropped (0)
+       , _gets (0)
+{
+
+}
+
 void
 VideoView::clear ()
 {
@@ -37,8 +51,12 @@ VideoView::clear ()
 bool
 VideoView::get_next_frame (bool non_blocking)
 {
+       if (_length == dcpomatic::DCPTime()) {
+               return true;
+       }
+
        DCPOMATIC_ASSERT (_viewer->butler());
-       _viewer->_gets++;
+       add_get ();
 
        boost::mutex::scoped_lock lm (_mutex);
 
@@ -51,16 +69,10 @@ VideoView::get_next_frame (bool non_blocking)
        } while (
                _player_video.first &&
                _viewer->film()->three_d() &&
-               _viewer->_eyes != _player_video.first->eyes() &&
+               _eyes != _player_video.first->eyes() &&
                _player_video.first->eyes() != EYES_BOTH
                );
 
-       try {
-               _viewer->butler()->rethrow ();
-       } catch (DecodeError& e) {
-               error_dialog (get(), e.what());
-       }
-
        return true;
 }
 
@@ -70,16 +82,26 @@ VideoView::one_video_frame () const
        return dcpomatic::DCPTime::from_frames (1, video_frame_rate());
 }
 
-/* XXX_b: comment */
+/** @return Time in ms until the next frame is due */
 int
 VideoView::time_until_next_frame () const
 {
+       if (length() == dcpomatic::DCPTime()) {
+               /* There's no content, so this doesn't matter */
+               return 0;
+       }
+
        dcpomatic::DCPTime const next = position() + one_video_frame();
        dcpomatic::DCPTime const time = _viewer->audio_time().get_value_or(position());
-       std::cout << to_string(next) << " " << to_string(time) << " " << ((next.seconds() - time.seconds()) * 1000) << "\n";
        if (next < time) {
                return 0;
        }
        return (next.seconds() - time.seconds()) * 1000;
 }
 
+void
+VideoView::start ()
+{
+       boost::mutex::scoped_lock lm (_mutex);
+       _dropped = 0;
+}