Remove some friends from FilmViewer.
[dcpomatic.git] / src / wx / video_view.h
1 /*
2     Copyright (C) 2019 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
6     DCP-o-matic is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     DCP-o-matic is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21 #ifndef DCPOMATIC_VIDEO_VIEW_H
22 #define DCPOMATIC_VIDEO_VIEW_H
23
24 #include "lib/dcpomatic_time.h"
25 #include "lib/timer.h"
26 #include "lib/types.h"
27 #include <boost/shared_ptr.hpp>
28 #include <boost/signals2.hpp>
29 #include <boost/thread.hpp>
30
31 class Image;
32 class wxWindow;
33 class FilmViewer;
34 class PlayerVideo;
35
36 class VideoView
37 {
38 public:
39         VideoView (FilmViewer* viewer);
40         virtual ~VideoView () {}
41
42         virtual void set_image (boost::shared_ptr<const Image> image) = 0;
43         virtual wxWindow* get () const = 0;
44         /** Redraw the view after something has changed like content outlining,
45          *  the film being removed, etc.
46          */
47         virtual void update () = 0;
48
49         virtual void start ();
50         /* XXX_b: make pure */
51         virtual void stop () {}
52
53         void clear ();
54
55         boost::signals2::signal<void()> Sized;
56
57         virtual bool display_next_frame (bool) = 0;
58
59         /* XXX_b: to remove */
60         virtual void display_player_video () {}
61
62         int dropped () const {
63                 boost::mutex::scoped_lock lm (_mutex);
64                 return _dropped;
65         }
66
67         int gets () const {
68                 boost::mutex::scoped_lock lm (_mutex);
69                 return _gets;
70         }
71
72         StateTimer const & state_timer () const {
73                 return _state_timer;
74         }
75
76         dcpomatic::DCPTime position () const {
77                 boost::mutex::scoped_lock lm (_mutex);
78                 return _player_video.second;
79         }
80
81         void set_video_frame_rate (int r) {
82                 boost::mutex::scoped_lock lm (_mutex);
83                 _video_frame_rate = r;
84         }
85
86         void set_length (dcpomatic::DCPTime len) {
87                 boost::mutex::scoped_lock lm (_mutex);
88                 _length = len;
89         }
90
91         void set_eyes (Eyes eyes) {
92                 boost::mutex::scoped_lock lm (_mutex);
93                 _eyes = eyes;
94         }
95
96 protected:
97         /* XXX_b: to remove */
98         friend class FilmViewer;
99
100         bool get_next_frame (bool non_blocking);
101         int time_until_next_frame () const;
102         dcpomatic::DCPTime one_video_frame () const;
103
104         int video_frame_rate () const {
105                 boost::mutex::scoped_lock lm (_mutex);
106                 return _video_frame_rate;
107         }
108
109         dcpomatic::DCPTime length () const {
110                 boost::mutex::scoped_lock lm (_mutex);
111                 return _length;
112         }
113
114         std::pair<boost::shared_ptr<PlayerVideo>, dcpomatic::DCPTime> player_video () const {
115                 boost::mutex::scoped_lock lm (_mutex);
116                 return _player_video;
117         }
118
119         void add_dropped () {
120                 boost::mutex::scoped_lock lm (_mutex);
121                 ++_dropped;
122         }
123
124         void add_get () {
125                 boost::mutex::scoped_lock lm (_mutex);
126                 ++_gets;
127         }
128
129         FilmViewer* _viewer;
130
131 #ifdef DCPOMATIC_VARIANT_SWAROOP
132         bool _in_watermark;
133         int _watermark_x;
134         int _watermark_y;
135 #endif
136
137         StateTimer _state_timer;
138
139 private:
140         /** Mutex protecting all the state in VideoView */
141         mutable boost::mutex _mutex;
142
143         std::pair<boost::shared_ptr<PlayerVideo>, dcpomatic::DCPTime> _player_video;
144         int _video_frame_rate;
145         /** length of the film we are playing, or 0 if there is none */
146         dcpomatic::DCPTime _length;
147         Eyes _eyes;
148
149         int _dropped;
150         int _gets;
151 };
152
153 #endif