Make video view type configurable.
authorCarl Hetherington <cth@carlh.net>
Thu, 9 May 2019 00:36:11 +0000 (01:36 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 10 May 2019 22:43:55 +0000 (23:43 +0100)
src/lib/config.cc
src/lib/config.h
src/wx/film_viewer.cc
src/wx/full_config_dialog.cc

index 74f916b21e49e52fa26ba224ccdb9b062e2f4059..fdd0516629c9c268153551c30456fec0991850b8 100644 (file)
@@ -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<int>("ImageDisplay").get_value_or(0);
+       optional<string> 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<string>(_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) {
index a8427663dd6c2fa4cd648842420437dfe365a617..e25cb06da5d4601e485e4ca32a0edac3792e2f53 100644 (file)
@@ -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.
index 5b2c5ff95abc78f21a9cbf47314bb9cef4f3eed5..4066710e7e90936c5dbd86ca9d74293c4fc11c64 100644 (file)
@@ -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));
index 27c969cc283d575912d7ab209ff095018755a68a..ffe7b4749c67c22a9fce59281c8ff8fceb3e7c5c 100644 (file)
@@ -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;