summaryrefslogtreecommitdiff
path: root/src/wx/player_frame.h
blob: 7663aa110a98e43d2cfd1a5fa78450f2ecbec8d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/*
    Copyright (C) 2017-2026 Carl Hetherington <cth@carlh.net>

    This file is part of DCP-o-matic.

    DCP-o-matic is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    DCP-o-matic is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.

*/


#include "audio_dialog.h"
#include "film_viewer.h"
#include "player_stress_tester.h"
#include "system_information_dialog.h"
#include "wx_ptr.h"
#include "lib/config.h"
#include "lib/http_server.h"
#include "lib/show_playlist_entry.h"
#include <dcp/warnings.h>
LIBDCP_DISABLE_WARNINGS
#include <wx/dnd.h>
#include <wx/wx.h>
LIBDCP_ENABLE_WARNINGS
#include <boost/signals2.hpp>
#include <boost/filesystem.hpp>


class wxPreferencesEditor;
class PlayerInformation;


namespace dcpomatic {
namespace ui {


class PlayerFrame : public wxFrame
{
public:
	class DCPDropTarget : public wxFileDropTarget
	{
	public:
		DCPDropTarget(PlayerFrame* owner);
		bool OnDropFiles(wxCoord, wxCoord, wxArrayString const& filenames) override;

	private:
		PlayerFrame* _frame;
	};

	PlayerFrame();
	~PlayerFrame();

	void close(wxCloseEvent& ev);
	void setup_main_sizer(Config::PlayerMode mode);
	bool playback_permitted();
	void too_many_frames_dropped();
	void set_decode_reduction(boost::optional<int> reduction);
	void load_dcp(boost::filesystem::path dir);

	void set_audio_delay_from_config();
	void load_stress_script(boost::filesystem::path path);
	void idle();

	/** Load some ShowPlaylistEntrys and set our playlist to them
	 *  If we're currently playing, this will stop whatever is
	 *  happening now and start playing this playlist.
	 *  @return true on success, false on failure
	 */
	bool load_playlist(std::vector<ShowPlaylistEntry> const& playlist);
	bool load_pair_playlist(std::vector<std::pair<std::string, boost::optional<float>>> const& playlist);
	void clear_playlist();

	std::vector<std::shared_ptr<Content>> playlist() const;

	bool can_do_next() const;
	void next();
	bool can_do_previous() const;
	void previous();

private:
	void examine_content();
	bool report_errors_from_last_job(wxWindow* parent) const;
	void setup_menu(wxMenuBar* m);
	void file_open();
	void file_add_ov();
	void file_add_kdm();
	void file_save_frame();
	void file_history(wxCommandEvent& event);
	void file_close();
	void file_exit();
	void edit_preferences();
	void view_cpl(wxCommandEvent& ev);
	void view_eye_changed(wxCommandEvent& ev);
	void view_full_screen();
	void view_dual_screen();
	void setup_menu();
	void setup_screen();
	void dual_screen_key_press(wxKeyEvent& ev);
	void view_closed_captions();
	void tools_verify();
	void tools_audio_graph();
	void tools_check_for_updates();
	void tools_timing();
	void tools_system_information();
	void help_about();
	void help_report_a_problem();

	void update_checker_state_changed();
	void config_changed(Config::Property prop);
	void stop_http_server();
	void setup_http_server();
	void setup_internal_player_server();
	void update_from_config(Config::Property prop);
	void set_menu_sensitivity();
	void start_stop_pressed();
	void go_back_frame();
	void go_forward_frame();
	void go_seconds(int s);
	void go_to_start();
	void go_to_end();

	bool take_playlist_entry();
	void prepare_to_play_film(boost::optional<float> crop_to_ratio);
	void viewer_finished();

	wxFrame* _dual_screen = nullptr;
	bool _update_news_requested = false;
	PlayerInformation* _info = nullptr;
	Config::PlayerMode _mode;
	wxPreferencesEditor* _config_dialog = nullptr;
	wxPanel* _overall_panel = nullptr;
	wxMenu* _file_menu = nullptr;
	wxMenuItem* _view_cpl = nullptr;
	wxMenu* _cpl_menu = nullptr;
	wxMenuItem* _view_eye = nullptr;
	wxMenuItem* _view_eye_left = nullptr;
	wxMenu* _view_eye_menu = nullptr;
	int _history_items = 0;
	int _history_position = 0;
	wxMenuItem* _history_separator = nullptr;
	FilmViewer _viewer;
	Controls* _controls;
	wx_ptr<SystemInformationDialog> _system_information_dialog;
	std::shared_ptr<Film> _film;
	std::vector<std::pair<std::shared_ptr<Content>, boost::optional<float>>> _playlist;
	int _playlist_position = 0;
	boost::signals2::scoped_connection _config_changed_connection;
	boost::signals2::scoped_connection _examine_job_connection;
	wxMenuItem* _file_add_ov = nullptr;
	wxMenuItem* _file_add_kdm = nullptr;
	wxMenuItem* _file_save_frame = nullptr;
	wxMenuItem* _tools_verify = nullptr;
	wxMenuItem* _tools_audio_graph = nullptr;
	wxMenuItem* _view_full_screen = nullptr;
	wxMenuItem* _view_dual_screen = nullptr;
	wxSizer* _main_sizer = nullptr;
	PlayerStressTester _stress;
	/** KDMs that have been loaded, so that we can pass them to the verifier */
	std::vector<boost::filesystem::path> _kdms;
	boost::thread _http_server_thread;
	std::unique_ptr<HTTPServer> _http_server;
	struct timeval _last_http_server_update = { 0, 0 };
	wx_ptr<AudioDialog> _audio_dialog;
};


}
}