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"
30 #include "lib/signaller.h"
37 class RGBPlusAlphaImage;
41 class ClosedCaptionsDialog;
44 * @brief A wx widget to view a Film.
46 class FilmViewer : public Signaller
49 FilmViewer (wxWindow *);
52 /** @return the window showing the film's video */
53 wxWindow* panel () const {
54 return _video_view->get();
57 VideoView const * video_view () const {
61 void show_closed_captions ();
63 void set_film (boost::shared_ptr<Film>);
64 boost::shared_ptr<Film> film () const {
68 void seek (dcpomatic::DCPTime t, bool accurate);
69 void seek (boost::shared_ptr<Content> content, dcpomatic::ContentTime p, bool accurate);
70 void seek_by (dcpomatic::DCPTime by, bool accurate);
71 /** @return our `playhead' position; this may not lie exactly on a frame boundary */
72 dcpomatic::DCPTime position () const {
73 return _video_view->position();
75 dcpomatic::DCPTime one_video_frame () const;
82 bool playing () const {
86 void set_coalesce_player_changes (bool c);
87 void set_dcp_decode_reduction (boost::optional<int> reduction);
88 boost::optional<int> dcp_decode_reduction () const;
89 void set_outline_content (bool o);
90 void set_outline_subtitles (boost::optional<dcpomatic::Rect<double> >);
91 void set_eyes (Eyes e);
92 void set_pad_black (bool p);
96 dcpomatic::DCPTime time () const;
97 boost::optional<dcpomatic::DCPTime> audio_time () const;
100 int errored () const;
103 int audio_callback (void* out, unsigned int frames);
105 #ifdef DCPOMATIC_VARIANT_SWAROOP
106 void set_background_image (bool b) {
107 _background_image = b;
108 _video_view->update ();
111 bool background_image () const {
112 return _background_image;
116 StateTimer const & state_timer () const {
117 return _video_view->state_timer ();
120 /* Some accessors and utility methods that VideoView classes need */
121 dcp::Size out_size () const {
124 bool outline_content () const {
125 return _outline_content;
127 boost::optional<dcpomatic::Rect<double> > outline_subtitles () const {
128 return _outline_subtitles;
130 bool pad_black () const {
133 boost::shared_ptr<Butler> butler () const {
136 ClosedCaptionsDialog* closed_captions_dialog () const {
137 return _closed_captions_dialog;
141 bool pending_idle_get () const {
145 boost::signals2::signal<void (boost::weak_ptr<PlayerVideo>)> ImageChanged;
146 boost::signals2::signal<void (dcpomatic::DCPTime)> Started;
147 boost::signals2::signal<void (dcpomatic::DCPTime)> Stopped;
148 /** While playing back we reached the end of the film (emitted from GUI thread) */
149 boost::signals2::signal<void ()> Finished;
151 boost::signals2::signal<bool ()> PlaybackPermitted;
155 void video_view_sized ();
156 void calculate_sizes ();
157 void player_change (ChangeType type, int, bool);
158 void idle_handler ();
159 void request_idle_display_next_frame ();
160 void film_change (ChangeType, Film::Property);
161 void recreate_butler ();
162 void config_changed (Config::Property);
163 void film_length_change ();
166 dcpomatic::DCPTime uncorrected_time () const;
167 Frame average_latency () const;
169 bool quick_refresh ();
171 boost::shared_ptr<Film> _film;
172 boost::shared_ptr<Player> _player;
174 VideoView* _video_view;
175 bool _coalesce_player_changes;
176 std::list<int> _pending_player_changes;
178 /** Size of our output (including padding if we have any) */
183 unsigned int _audio_block_size;
186 boost::shared_ptr<Butler> _butler;
188 std::list<Frame> _latency_history;
189 /** Mutex to protect _latency_history */
190 mutable boost::mutex _latency_history_mutex;
191 int _latency_history_count;
193 boost::optional<int> _dcp_decode_reduction;
195 ClosedCaptionsDialog* _closed_captions_dialog;
197 bool _outline_content;
198 boost::optional<dcpomatic::Rect<double> > _outline_subtitles;
199 /** true to pad the viewer panel with black, false to use
200 the normal window background colour.
204 #ifdef DCPOMATIC_VARIANT_SWAROOP
205 bool _background_image;
208 /** true if an get() is required next time we are idle */
211 boost::signals2::scoped_connection _config_changed_connection;