From 5e2b926c116bbce2800fe3459e5a654101355482 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 9 May 2019 01:36:11 +0100 Subject: [PATCH] Make video view type configurable. --- src/lib/config.cc | 15 +++++++++++++++ src/lib/config.h | 14 ++++++++++++++ src/wx/film_viewer.cc | 14 ++++++++++---- src/wx/full_config_dialog.cc | 37 ++++++++++++++++++++++++++++++++---- 4 files changed, 72 insertions(+), 8 deletions(-) diff --git a/src/lib/config.cc b/src/lib/config.cc index 74f916b21..fdd051662 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -167,6 +167,7 @@ Config::set_defaults () _interface_complexity = INTERFACE_SIMPLE; _player_mode = PLAYER_MODE_WINDOW; _image_display = 0; + _video_view_type = VIDEO_VIEW_SIMPLE; _respect_kdm_validity_periods = true; _player_activity_log_file = boost::none; _player_debug_log_file = boost::none; @@ -583,6 +584,12 @@ try } _image_display = f.optional_number_child("ImageDisplay").get_value_or(0); + optional vc = f.optional_string_child("VideoViewType"); + if (vc && *vc == "opengl") { + _video_view_type = VIDEO_VIEW_OPENGL; + } else if (vc && *vc == "simple") { + _video_view_type = VIDEO_VIEW_SIMPLE; + } _respect_kdm_validity_periods = f.optional_bool_child("RespectKDMValidityPeriods").get_value_or(true); /* PlayerLogFile is old name */ _player_activity_log_file = f.optional_string_child("PlayerLogFile"); @@ -1014,6 +1021,14 @@ Config::write_config () const /* [XML] ImageDisplay Screen number to put image on in dual-screen player mode. */ root->add_child("ImageDisplay")->add_child_text(raw_convert(_image_display)); + switch (_video_view_type) { + case VIDEO_VIEW_SIMPLE: + root->add_child("VideoViewType")->add_child_text("simple"); + break; + case VIDEO_VIEW_OPENGL: + root->add_child("VideoViewType")->add_child_text("opengl"); + break; + } /* [XML] RespectKDMValidityPeriods 1 to refuse to use KDMs that are out of date, 0 to ignore KDM dates. */ root->add_child("RespectKDMValidityPeriods")->add_child_text(_respect_kdm_validity_periods ? "1" : "0"); if (_player_activity_log_file) { diff --git a/src/lib/config.h b/src/lib/config.h index a8427663d..e25cb06da 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -488,6 +488,15 @@ public: return _image_display; } + enum VideoViewType { + VIDEO_VIEW_SIMPLE, + VIDEO_VIEW_OPENGL + }; + + VideoViewType video_view_type () const { + return _video_view_type; + } + bool respect_kdm_validity_periods () const { return _respect_kdm_validity_periods; } @@ -954,6 +963,10 @@ public: maybe_set (_image_display, n); } + void set_video_view_type (VideoViewType v) { + maybe_set (_video_view_type, v); + } + void set_respect_kdm_validity_periods (bool r) { maybe_set (_respect_kdm_validity_periods, r); } @@ -1260,6 +1273,7 @@ private: Interface _interface_complexity; PlayerMode _player_mode; int _image_display; + VideoViewType _video_view_type; bool _respect_kdm_validity_periods; /** Log file containing things the player does (e.g. started, stopped, loaded playlist etc.) Does not contain debugging information. diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index 5b2c5ff95..4066710e7 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -79,10 +79,7 @@ rtaudio_callback (void* out, void *, unsigned int frames, double, RtAudioStreamS } FilmViewer::FilmViewer (wxWindow* p) - /* XXX: make this configurable */ -// : _video_view (new GLVideoView(p)) - : _video_view (new SimpleVideoView(this, p)) - , _coalesce_player_changes (false) + : _coalesce_player_changes (false) , _audio (DCPOMATIC_RTAUDIO_API) , _audio_channels (0) , _audio_block_size (1024) @@ -100,6 +97,15 @@ FilmViewer::FilmViewer (wxWindow* p) , _state_timer ("viewer") , _gets (0) { + switch (Config::instance()->video_view_type()) { + case Config::VIDEO_VIEW_OPENGL: + _video_view = new GLVideoView (p); + break; + case Config::VIDEO_VIEW_SIMPLE: + _video_view = new SimpleVideoView (this, p); + break; + } + /* XXX: maybe this should be proxied through the VideoView */ _video_view->get()->Bind (wxEVT_SIZE, boost::bind (&FilmViewer::video_view_sized, this)); _timer.Bind (wxEVT_TIMER, boost::bind (&FilmViewer::timer, this)); diff --git a/src/wx/full_config_dialog.cc b/src/wx/full_config_dialog.cc index 27c969cc2..ffe7b4749 100644 --- a/src/wx/full_config_dialog.cc +++ b/src/wx/full_config_dialog.cc @@ -1405,6 +1405,17 @@ private: table->Add (s, 1); } + add_label_to_sizer (table, _panel, _("Video display mode"), true); + _video_display_mode = new wxChoice (_panel, wxID_ANY); + table->Add (_video_display_mode); + + wxStaticText* restart = add_label_to_sizer (table, _panel, _("(restart DCP-o-matic to change display mode)"), false); + wxFont font = restart->GetFont(); + font.SetStyle (wxFONTSTYLE_ITALIC); + font.SetPointSize (font.GetPointSize() - 1); + restart->SetFont (font); + table->AddSpacer (0); + _allow_any_dcp_frame_rate = new CheckBox (_panel, _("Allow any DCP frame rate")); table->Add (_allow_any_dcp_frame_rate, 1, wxEXPAND | wxALL); table->AddSpacer (0); @@ -1413,10 +1424,7 @@ private: table->Add (_allow_any_container, 1, wxEXPAND | wxALL); table->AddSpacer (0); - wxStaticText* restart = add_label_to_sizer (table, _panel, _("(restart DCP-o-matic to see all ratios)"), false); - wxFont font = restart->GetFont(); - font.SetStyle (wxFONTSTYLE_ITALIC); - font.SetPointSize (font.GetPointSize() - 1); + restart = add_label_to_sizer (table, _panel, _("(restart DCP-o-matic to see all ratios)"), false); restart->SetFont (font); table->AddSpacer (0); @@ -1491,6 +1499,9 @@ private: _maximum_j2k_bandwidth->SetRange (1, 1000); _maximum_j2k_bandwidth->Bind (wxEVT_SPINCTRL, boost::bind (&AdvancedPage::maximum_j2k_bandwidth_changed, this)); + _video_display_mode->Append (_("Simple (safer)")); + _video_display_mode->Append (_("OpenGL (faster)")); + _video_display_mode->Bind (wxEVT_CHOICE, boost::bind(&AdvancedPage::video_display_mode_changed, this)); _allow_any_dcp_frame_rate->Bind (wxEVT_CHECKBOX, boost::bind (&AdvancedPage::allow_any_dcp_frame_rate_changed, this)); _allow_any_container->Bind (wxEVT_CHECKBOX, boost::bind (&AdvancedPage::allow_any_container_changed, this)); _only_servers_encode->Bind (wxEVT_CHECKBOX, boost::bind (&AdvancedPage::only_servers_encode_changed, this)); @@ -1514,6 +1525,14 @@ private: Config* config = Config::instance (); checked_set (_maximum_j2k_bandwidth, config->maximum_j2k_bandwidth() / 1000000); + switch (config->video_view_type()) { + case Config::VIDEO_VIEW_SIMPLE: + checked_set (_video_display_mode, 0); + break; + case Config::VIDEO_VIEW_OPENGL: + checked_set (_video_display_mode, 1); + break; + } checked_set (_allow_any_dcp_frame_rate, config->allow_any_dcp_frame_rate ()); checked_set (_allow_any_container, config->allow_any_container ()); checked_set (_only_servers_encode, config->only_servers_encode ()); @@ -1535,6 +1554,15 @@ private: Config::instance()->set_maximum_j2k_bandwidth (_maximum_j2k_bandwidth->GetValue() * 1000000); } + void video_display_mode_changed () + { + if (_video_display_mode->GetSelection() == 0) { + Config::instance()->set_video_view_type (Config::VIDEO_VIEW_SIMPLE); + } else { + Config::instance()->set_video_view_type (Config::VIDEO_VIEW_OPENGL); + } + } + void frames_in_memory_multiplier_changed () { Config::instance()->set_frames_in_memory_multiplier (_frames_in_memory_multiplier->GetValue()); @@ -1600,6 +1628,7 @@ private: #endif wxSpinCtrl* _maximum_j2k_bandwidth; + wxChoice* _video_display_mode; wxSpinCtrl* _frames_in_memory_multiplier; wxCheckBox* _allow_any_dcp_frame_rate; wxCheckBox* _allow_any_container; -- 2.30.2