2 Copyright (C) 2012-2019 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
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.
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.
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/>.
21 /** @file src/film_viewer.h
22 * @brief FilmViewer class.
25 #include "video_view.h"
27 #include "lib/config.h"
28 #include "lib/player_text.h"
29 #include "lib/timer.h"
36 class RGBPlusAlphaImage;
40 class ClosedCaptionsDialog;
43 * @brief A wx widget to view a Film.
48 FilmViewer (wxWindow *);
51 /** @return the window showing the film's video */
52 wxWindow* panel () const {
53 return _video_view->get();
56 void show_closed_captions ();
58 void set_film (boost::shared_ptr<Film>);
59 boost::shared_ptr<Film> film () const {
63 void seek (dcpomatic::DCPTime t, bool accurate);
64 void seek (boost::shared_ptr<Content> content, dcpomatic::ContentTime p, bool accurate);
65 void seek_by (dcpomatic::DCPTime by, bool accurate);
66 /** @return our `playhead' position; this may not lie exactly on a frame boundary */
67 dcpomatic::DCPTime position () const {
68 return _video_position;
70 dcpomatic::DCPTime one_video_frame () const;
74 bool playing () const {
78 void set_coalesce_player_changes (bool c);
79 void set_dcp_decode_reduction (boost::optional<int> reduction);
80 boost::optional<int> dcp_decode_reduction () const;
81 void set_outline_content (bool o);
82 void set_eyes (Eyes e);
83 void set_pad_black (bool p);
87 int dropped () const {
91 int audio_callback (void* out, unsigned int frames);
93 #ifdef DCPOMATIC_VARIANT_SWAROOP
94 void set_background_image (bool b) {
95 _background_image = b;
99 bool background_image () const {
100 return _background_image;
104 StateTimer const & state_timer () const {
108 StateTimer& state_timer () {
116 /* Some accessors that VideoView classes need */
117 dcp::Size out_size () const {
120 dcp::Size inter_size () const {
123 Position<int> inter_position () const {
124 return _inter_position;
126 bool outline_content () const {
127 return _outline_content;
129 bool pad_black () const {
132 dcpomatic::DCPTime video_position () const {
133 return _video_position;
136 boost::signals2::signal<void (boost::weak_ptr<PlayerVideo>)> ImageChanged;
137 boost::signals2::signal<void ()> PositionChanged;
138 boost::signals2::signal<void (dcpomatic::DCPTime)> Started;
139 boost::signals2::signal<void (dcpomatic::DCPTime)> Stopped;
140 /** While playing back we reached the end of the film (emitted from GUI thread) */
141 boost::signals2::signal<void ()> Finished;
143 boost::signals2::signal<bool ()> PlaybackPermitted;
146 void video_view_sized ();
148 void calculate_sizes ();
149 void player_change (ChangeType type, int, bool);
151 void display_player_video ();
152 void film_change (ChangeType, Film::Property);
153 void recreate_butler ();
154 void config_changed (Config::Property);
156 dcpomatic::DCPTime time () const;
157 dcpomatic::DCPTime uncorrected_time () const;
158 Frame average_latency () const;
160 void refresh_view ();
161 bool quick_refresh ();
163 boost::shared_ptr<Film> _film;
164 boost::shared_ptr<Player> _player;
166 VideoView* _video_view;
168 bool _coalesce_player_changes;
169 std::list<int> _pending_player_changes;
171 std::pair<boost::shared_ptr<PlayerVideo>, dcpomatic::DCPTime> _player_video;
172 dcpomatic::DCPTime _video_position;
173 Position<int> _inter_position;
174 dcp::Size _inter_size;
176 /** Size of our output (including padding if we have any) */
181 unsigned int _audio_block_size;
183 boost::shared_ptr<Butler> _butler;
185 std::list<Frame> _latency_history;
186 /** Mutex to protect _latency_history */
187 mutable boost::mutex _latency_history_mutex;
188 int _latency_history_count;
191 boost::optional<int> _dcp_decode_reduction;
193 ClosedCaptionsDialog* _closed_captions_dialog;
195 bool _outline_content;
197 /** true to pad the viewer panel with black, false to use
198 the normal window background colour.
202 #ifdef DCPOMATIC_VARIANT_SWAROOP
203 bool _background_image;
206 StateTimer _state_timer;
209 boost::signals2::scoped_connection _config_changed_connection;