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_coalesce_player_changes (bool c);
59 void set_dcp_decode_reduction (boost::optional<int> reduction);
60 boost::optional<int> dcp_decode_reduction () const;
64 int dropped () const {
68 int audio_callback (void* out, unsigned int frames);
70 boost::signals2::signal<void (boost::weak_ptr<PlayerVideo>)> ImageChanged;
74 void panel_sized (wxSizeEvent &);
75 void slider_moved (bool page);
76 void slider_released ();
79 void calculate_sizes ();
80 void check_play_state ();
81 void active_jobs_changed (boost::optional<std::string>);
82 void rewind_clicked (wxMouseEvent &);
83 void back_clicked (wxMouseEvent &);
84 void forward_clicked (wxMouseEvent &);
85 void player_changed (bool);
86 void update_position_label ();
87 void update_position_slider ();
89 void seek (DCPTime t, bool accurate);
90 void refresh_panel ();
91 void setup_sensitivity ();
92 void film_changed (Film::Property);
93 DCPTime nudge_amount (wxMouseEvent &);
94 void timecode_clicked ();
95 void frame_number_clicked ();
96 void go_to (DCPTime t);
97 void jump_to_selected_clicked ();
98 void recreate_butler ();
99 void config_changed (Config::Property);
100 DCPTime time () const;
103 Frame average_latency () const;
104 DCPTime one_video_frame () const;
106 boost::shared_ptr<Film> _film;
107 boost::shared_ptr<Player> _player;
110 /** The area that we put our image in */
112 wxCheckBox* _outline_content;
113 wxRadioButton* _left_eye;
114 wxRadioButton* _right_eye;
115 wxCheckBox* _jump_to_selected;
117 wxButton* _rewind_button;
118 wxButton* _back_button;
119 wxButton* _forward_button;
120 wxStaticText* _frame_number;
121 wxStaticText* _timecode;
122 wxToggleButton* _play_button;
124 bool _coalesce_player_changes;
125 bool _pending_player_change;
126 bool _slider_being_moved;
127 bool _was_running_before_slider;
129 boost::shared_ptr<const Image> _frame;
130 DCPTime _video_position;
131 Position<int> _inter_position;
132 dcp::Size _inter_size;
134 /** Size of our output (including padding if we have any) */
136 /** Size of the panel that we have available */
137 dcp::Size _panel_size;
141 unsigned int _audio_block_size;
143 boost::shared_ptr<Butler> _butler;
145 std::list<Frame> _latency_history;
146 /** Mutex to protect _latency_history */
147 mutable boost::mutex _latency_history_mutex;
148 int _latency_history_count;
151 boost::optional<int> _dcp_decode_reduction;
153 boost::signals2::scoped_connection _config_changed_connection;