Move _state_timer into VideoView.
[dcpomatic.git] / src / wx / video_view.cc
index e1a8b7306681b12972b63abb5c5780f92ef0cf2b..e6588865641670b388a2643c761d7d070547902a 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)
+       , _dropped (0)
+{
+
+}
+
 void
 VideoView::clear ()
 {
@@ -37,6 +49,10 @@ VideoView::clear ()
 bool
 VideoView::get_next_frame (bool non_blocking)
 {
+       if (_length == dcpomatic::DCPTime()) {
+               return true;
+       }
+
        DCPOMATIC_ASSERT (_viewer->butler());
        _viewer->_gets++;
 
@@ -55,31 +71,35 @@ VideoView::get_next_frame (bool non_blocking)
                _player_video.first->eyes() != EYES_BOTH
                );
 
-       try {
-               _viewer->butler()->rethrow ();
-       } catch (DecodeError& e) {
-               error_dialog (get(), e.what());
-       }
-
        return true;
 }
 
 dcpomatic::DCPTime
 VideoView::one_video_frame () const
 {
-       return dcpomatic::DCPTime::from_frames (1, film()->video_frame_rate());
+       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;
+}