2 Copyright (C) 2012-2017 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 A wx widget to view `thumbnails' of a Film.
26 #include "lib/config.h"
33 class RGBPlusAlphaImage;
39 * @brief A wx widget to view a preview of a Film.
41 class FilmViewer : public wxPanel
44 FilmViewer (wxWindow *, bool outline_content = true, bool jump_to_selected = true);
47 void set_film (boost::shared_ptr<Film>);
48 boost::shared_ptr<Film> film () const {
52 /** @return our `playhead' position; this may not lie exactly on a frame boundary */
53 DCPTime position () const {
54 return _video_position;
57 void set_position (DCPTime p);
58 void set_position (boost::shared_ptr<Content> content, ContentTime p);
59 void set_coalesce_player_changes (bool c);
60 void set_dcp_decode_reduction (boost::optional<int> reduction);
61 boost::optional<int> dcp_decode_reduction () const;
64 bool quick_refresh ();
66 int dropped () const {
72 bool playing () const {
77 void forward_frame ();
79 int audio_callback (void* out, unsigned int frames);
81 boost::signals2::signal<void (boost::weak_ptr<PlayerVideo>)> ImageChanged;
85 void panel_sized (wxSizeEvent &);
86 void slider_moved (bool page);
87 void slider_released ();
90 void captions_changed ();
91 void calculate_sizes ();
92 void check_play_state ();
93 void active_jobs_changed (boost::optional<std::string>);
94 void rewind_clicked (wxMouseEvent &);
95 void back_clicked (wxKeyboardState& s);
96 void forward_clicked (wxKeyboardState &);
97 void player_changed (int, bool);
98 void update_position_label ();
99 void update_position_slider ();
101 void display_player_video ();
102 void seek (DCPTime t, bool accurate);
103 void refresh_panel ();
104 void setup_sensitivity ();
105 void film_changed (Film::Property);
106 DCPTime nudge_amount (wxKeyboardState &);
107 void timecode_clicked ();
108 void frame_number_clicked ();
109 void go_to (DCPTime t);
110 void jump_to_selected_clicked ();
111 void recreate_butler ();
112 void config_changed (Config::Property);
113 DCPTime time () const;
114 Frame average_latency () const;
115 DCPTime one_video_frame () const;
117 boost::shared_ptr<Film> _film;
118 boost::shared_ptr<Player> _player;
121 /** The area that we put our image in */
123 wxCheckBox* _outline_content;
125 wxCheckBox* _jump_to_selected;
128 wxButton* _rewind_button;
129 wxButton* _back_button;
130 wxButton* _forward_button;
131 wxStaticText* _frame_number;
132 wxStaticText* _timecode;
133 wxToggleButton* _play_button;
135 bool _coalesce_player_changes;
136 std::list<int> _pending_player_changes;
137 bool _slider_being_moved;
138 bool _was_running_before_slider;
140 std::pair<boost::shared_ptr<PlayerVideo>, DCPTime> _player_video;
141 boost::shared_ptr<const Image> _frame;
142 DCPTime _video_position;
143 Position<int> _inter_position;
144 dcp::Size _inter_size;
146 /** Size of our output (including padding if we have any) */
148 /** Size of the panel that we have available */
149 dcp::Size _panel_size;
153 unsigned int _audio_block_size;
155 boost::shared_ptr<Butler> _butler;
157 std::list<Frame> _latency_history;
158 /** Mutex to protect _latency_history */
159 mutable boost::mutex _latency_history_mutex;
160 int _latency_history_count;
163 boost::optional<int> _dcp_decode_reduction;
165 boost::signals2::scoped_connection _config_changed_connection;