Various cleanups and thread-safety.
[dcpomatic.git] / src / wx / video_view.h
index 142cfd022d580135bdd530a938a905031add6a61..5d5d3316377c2c3e03a9af08d11254086bf479bd 100644 (file)
 #define DCPOMATIC_VIDEO_VIEW_H
 
 #include "lib/dcpomatic_time.h"
+#include "lib/timer.h"
+#include "lib/types.h"
+#include "lib/exception_store.h"
 #include <boost/shared_ptr.hpp>
 #include <boost/signals2.hpp>
 #include <boost/thread.hpp>
+#include <boost/noncopyable.hpp>
 
 class Image;
 class wxWindow;
 class FilmViewer;
 class PlayerVideo;
 
-class VideoView
+class VideoView : public ExceptionStore, public boost::noncopyable
 {
 public:
-       VideoView (FilmViewer* viewer)
-               : _viewer (viewer)
-#ifdef DCPOMATIC_VARIANT_SWAROOP
-               , _in_watermark (false)
-#endif
-               , _video_frame_rate (0)
-       {}
-
+       VideoView (FilmViewer* viewer);
        virtual ~VideoView () {}
 
        virtual void set_image (boost::shared_ptr<const Image> image) = 0;
        virtual wxWindow* get () const = 0;
+       /** Redraw the view after something has changed like content outlining,
+        *  the film being removed, etc.
+        */
        virtual void update () = 0;
 
-       /* XXX_b: make pure */
-       virtual void start () {}
+       virtual void start ();
        /* XXX_b: make pure */
        virtual void stop () {}
 
@@ -62,6 +61,20 @@ public:
        /* XXX_b: to remove */
        virtual void display_player_video () {}
 
+       int dropped () const {
+               boost::mutex::scoped_lock lm (_mutex);
+               return _dropped;
+       }
+
+       int gets () const {
+               boost::mutex::scoped_lock lm (_mutex);
+               return _gets;
+       }
+
+       StateTimer const & state_timer () const {
+               return _state_timer;
+       }
+
        dcpomatic::DCPTime position () const {
                boost::mutex::scoped_lock lm (_mutex);
                return _player_video.second;
@@ -77,6 +90,16 @@ public:
                _length = len;
        }
 
+       void set_eyes (Eyes eyes) {
+               boost::mutex::scoped_lock lm (_mutex);
+               _eyes = eyes;
+       }
+
+       void set_three_d (bool t) {
+               boost::mutex::scoped_lock lm (_mutex);
+               _three_d = t;
+       }
+
 protected:
        /* XXX_b: to remove */
        friend class FilmViewer;
@@ -100,6 +123,16 @@ protected:
                return _player_video;
        }
 
+       void add_dropped () {
+               boost::mutex::scoped_lock lm (_mutex);
+               ++_dropped;
+       }
+
+       void add_get () {
+               boost::mutex::scoped_lock lm (_mutex);
+               ++_gets;
+       }
+
        FilmViewer* _viewer;
 
 #ifdef DCPOMATIC_VARIANT_SWAROOP
@@ -108,6 +141,8 @@ protected:
        int _watermark_y;
 #endif
 
+       StateTimer _state_timer;
+
 private:
        /** Mutex protecting all the state in VideoView */
        mutable boost::mutex _mutex;
@@ -116,6 +151,11 @@ private:
        int _video_frame_rate;
        /** length of the film we are playing, or 0 if there is none */
        dcpomatic::DCPTime _length;
+       Eyes _eyes;
+       bool _three_d;
+
+       int _dropped;
+       int _gets;
 };
 
 #endif