2 Copyright (C) 2012-2018 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.
26 #include "lib/config.h"
27 #include "lib/player_text.h"
34 class RGBPlusAlphaImage;
38 class ClosedCaptionsDialog;
41 * @brief A wx widget to view a Film.
46 FilmViewer (wxWindow *);
49 /** @return the panel showing the film's video */
50 wxPanel* panel () const {
54 void show_closed_captions ();
56 void set_film (boost::shared_ptr<Film>);
57 boost::shared_ptr<Film> film () const {
61 void seek (DCPTime t, bool accurate);
62 void seek (boost::shared_ptr<Content> content, ContentTime p, bool accurate);
63 void seek_by (DCPTime by, bool accurate);
64 /** @return our `playhead' position; this may not lie exactly on a frame boundary */
65 DCPTime position () const {
66 return _video_position;
68 DCPTime one_video_frame () const;
72 bool playing () const {
76 void set_coalesce_player_changes (bool c);
77 void set_dcp_decode_reduction (boost::optional<int> reduction);
78 boost::optional<int> dcp_decode_reduction () const;
79 void set_outline_content (bool o);
80 void set_eyes (Eyes e);
81 void set_pad_black (bool p);
85 int dropped () const {
89 int audio_callback (void* out, unsigned int frames);
91 boost::signals2::signal<void (boost::weak_ptr<PlayerVideo>)> ImageChanged;
92 boost::signals2::signal<void ()> PositionChanged;
93 boost::signals2::signal<void (DCPTime)> Started;
94 boost::signals2::signal<void (DCPTime)> Stopped;
95 /** While playing back we reached the end of the film (emitted from GUI thread) */
96 boost::signals2::signal<void ()> Finished;
98 boost::signals2::signal<bool ()> PlaybackPermitted;
102 void panel_sized (wxSizeEvent &);
104 void calculate_sizes ();
105 void player_change (ChangeType type, int, bool);
107 void display_player_video ();
108 void film_change (ChangeType, Film::Property);
109 void recreate_butler ();
110 void config_changed (Config::Property);
111 bool maybe_draw_background_image (wxPaintDC& dc);
113 DCPTime time () const;
114 DCPTime uncorrected_time () const;
115 Frame average_latency () const;
117 void refresh_panel ();
118 bool quick_refresh ();
120 boost::shared_ptr<Film> _film;
121 boost::shared_ptr<Player> _player;
123 /** The area that we put our image in */
126 bool _coalesce_player_changes;
127 std::list<int> _pending_player_changes;
129 std::pair<boost::shared_ptr<PlayerVideo>, DCPTime> _player_video;
130 boost::shared_ptr<const Image> _frame;
131 DCPTime _video_position;
132 Position<int> _inter_position;
133 dcp::Size _inter_size;
135 /** Size of our output (including padding if we have any) */
137 /** Size of the panel that we have available */
138 dcp::Size _panel_size;
142 unsigned int _audio_block_size;
144 boost::shared_ptr<Butler> _butler;
146 std::list<Frame> _latency_history;
147 /** Mutex to protect _latency_history */
148 mutable boost::mutex _latency_history_mutex;
149 int _latency_history_count;
152 boost::optional<int> _dcp_decode_reduction;
154 ClosedCaptionsDialog* _closed_captions_dialog;
156 bool _outline_content;
158 /** true to pad the viewer panel with black, false to use
159 the normal window background colour.
163 #ifdef DCPOMATIC_VARIANT_SWAROOP
169 boost::signals2::scoped_connection _config_changed_connection;