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"
31 #include "lib/warnings.h"
33 DCPOMATIC_DISABLE_WARNINGS
35 DCPOMATIC_ENABLE_WARNINGS
40 class RGBPlusAlphaImage;
44 class ClosedCaptionsDialog;
47 * @brief A wx widget to view a Film.
49 class FilmViewer : public Signaller
52 FilmViewer (wxWindow *);
55 /** @return the window showing the film's video */
56 wxWindow* panel () const {
57 return _video_view->get();
60 VideoView const * video_view () const {
64 void show_closed_captions ();
66 void set_film (boost::shared_ptr<Film>);
67 boost::shared_ptr<Film> film () const {
71 void seek (dcpomatic::DCPTime t, bool accurate);
72 void seek (boost::shared_ptr<Content> content, dcpomatic::ContentTime p, bool accurate);
73 void seek_by (dcpomatic::DCPTime by, bool accurate);
74 /** @return our `playhead' position; this may not lie exactly on a frame boundary */
75 dcpomatic::DCPTime position () const {
76 return _video_view->position();
78 dcpomatic::DCPTime one_video_frame () const;
85 bool playing () const {
89 void set_coalesce_player_changes (bool c);
90 void set_dcp_decode_reduction (boost::optional<int> reduction);
91 boost::optional<int> dcp_decode_reduction () const;
92 void set_outline_content (bool o);
93 void set_outline_subtitles (boost::optional<dcpomatic::Rect<double> >);
94 void set_eyes (Eyes e);
95 void set_pad_black (bool p);
99 dcpomatic::DCPTime time () const;
100 boost::optional<dcpomatic::DCPTime> audio_time () const;
102 int dropped () const;
103 int errored () const;
106 int audio_callback (void* out, unsigned int frames);
108 StateTimer const & state_timer () const {
109 return _video_view->state_timer ();
112 /* Some accessors and utility methods that VideoView classes need */
113 dcp::Size out_size () const {
116 bool outline_content () const {
117 return _outline_content;
119 boost::optional<dcpomatic::Rect<double> > outline_subtitles () const {
120 return _outline_subtitles;
122 bool pad_black () const {
125 boost::shared_ptr<Butler> butler () const {
128 ClosedCaptionsDialog* closed_captions_dialog () const {
129 return _closed_captions_dialog;
132 void image_changed (boost::shared_ptr<PlayerVideo> video);
134 bool pending_idle_get () const {
138 boost::signals2::signal<void (boost::shared_ptr<PlayerVideo>)> ImageChanged;
139 boost::signals2::signal<void (dcpomatic::DCPTime)> Started;
140 boost::signals2::signal<void (dcpomatic::DCPTime)> Stopped;
141 /** While playing back we reached the end of the film (emitted from GUI thread) */
142 boost::signals2::signal<void ()> Finished;
144 boost::signals2::signal<bool ()> PlaybackPermitted;
148 void video_view_sized ();
149 void calculate_sizes ();
150 void player_change (ChangeType type, int, bool);
151 void idle_handler ();
152 void request_idle_display_next_frame ();
153 void film_change (ChangeType, Film::Property);
154 void content_change (ChangeType, int property);
155 void recreate_butler ();
156 void config_changed (Config::Property);
157 void film_length_change ();
160 dcpomatic::DCPTime uncorrected_time () const;
161 Frame average_latency () const;
163 bool quick_refresh ();
165 boost::shared_ptr<Film> _film;
166 boost::shared_ptr<Player> _player;
168 VideoView* _video_view;
169 bool _coalesce_player_changes;
170 std::list<int> _pending_player_changes;
172 /** Size of our output (including padding if we have any) */
177 unsigned int _audio_block_size;
180 boost::shared_ptr<Butler> _butler;
182 std::list<Frame> _latency_history;
183 /** Mutex to protect _latency_history */
184 mutable boost::mutex _latency_history_mutex;
185 int _latency_history_count;
187 boost::optional<int> _dcp_decode_reduction;
189 ClosedCaptionsDialog* _closed_captions_dialog;
191 bool _outline_content;
192 boost::optional<dcpomatic::Rect<double> > _outline_subtitles;
193 /** true to pad the viewer panel with black, false to use
194 the normal window background colour.
198 /** true if an get() is required next time we are idle */
201 boost::signals2::scoped_connection _config_changed_connection;