Hand-apply 2ee558ec90623b570360e8e55c918b5bb37f9aac from master; various snapping...
[dcpomatic.git] / src / lib / config.cc
index 306b48a9fd50b067d124248362a6928861077cb2..ab57c1afcc89aea6674b929b0727d13a2b9ad7b7 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -19,7 +19,6 @@
 
 #include "config.h"
 #include "server.h"
-#include "scaler.h"
 #include "filter.h"
 #include "ratio.h"
 #include "dcp_content_type.h"
@@ -28,8 +27,8 @@
 #include "cinema.h"
 #include "util.h"
 #include "cross.h"
+#include "raw_convert.h"
 #include <dcp/colour_matrix.h>
-#include <dcp/raw_convert.h>
 #include <dcp/signer.h>
 #include <dcp/certificate_chain.h>
 #include <libcxml/cxml.h>
@@ -53,31 +52,38 @@ using std::cerr;
 using boost::shared_ptr;
 using boost::optional;
 using boost::algorithm::trim;
-using dcp::raw_convert;
 
 Config* Config::_instance = 0;
 
 /** Construct default configuration */
 Config::Config ()
-       : _num_local_encoding_threads (max (2U, boost::thread::hardware_concurrency()))
-       , _server_port_base (6192)
-       , _use_any_servers (true)
-       , _tms_path (".")
-       , _cinema_sound_processor (CinemaSoundProcessor::from_id (N_("dolby_cp750")))
-       , _allow_any_dcp_frame_rate (false)
-       , _default_still_length (10)
-       , _default_container (Ratio::from_id ("185"))
-       , _default_dcp_content_type (DCPContentType::from_isdcf_name ("FTR"))
-       , _default_j2k_bandwidth (100000000)
-       , _default_audio_delay (0)
-       , _check_for_updates (false)
-       , _check_for_test_updates (false)
-       , _maximum_j2k_bandwidth (250000000)
-       , _log_types (Log::TYPE_GENERAL | Log::TYPE_WARNING | Log::TYPE_ERROR)
+{
+       set_defaults ();
+}
+
+void
+Config::set_defaults ()
+{
+       _num_local_encoding_threads = max (2U, boost::thread::hardware_concurrency ());
+       _server_port_base = 6192;
+       _use_any_servers = true;
+       _tms_path = ".";
+       _cinema_sound_processor = CinemaSoundProcessor::from_id (N_("dolby_cp750"));
+       _allow_any_dcp_frame_rate = false;
+       _default_still_length = 10;
+       _default_container = Ratio::from_id ("185");
+       _default_dcp_content_type = DCPContentType::from_isdcf_name ("FTR");
+       _default_j2k_bandwidth = 100000000;
+       _default_audio_delay = 0;
+       _check_for_updates = false;
+       _check_for_test_updates = false;
+       _maximum_j2k_bandwidth = 250000000;
+       _log_types = Log::TYPE_GENERAL | Log::TYPE_WARNING | Log::TYPE_ERROR | Log::TYPE_DEBUG;
 #ifdef DCPOMATIC_WINDOWS         
-       , _win32_console (false)
+       _win32_console = false;
 #endif   
-{
+
+       _allowed_dcp_frame_rates.clear ();
        _allowed_dcp_frame_rates.push_back (24);
        _allowed_dcp_frame_rates.push_back (25);
        _allowed_dcp_frame_rates.push_back (30);
@@ -85,10 +91,20 @@ Config::Config ()
        _allowed_dcp_frame_rates.push_back (50);
        _allowed_dcp_frame_rates.push_back (60);
 
+       _colour_conversions.clear ();
        _colour_conversions.push_back (PresetColourConversion (_("sRGB"), dcp::ColourConversion::srgb_to_xyz ()));
+       _colour_conversions.push_back (PresetColourConversion (_("Rec. 601"), dcp::ColourConversion::rec601_to_xyz ()));
        _colour_conversions.push_back (PresetColourConversion (_("Rec. 709"), dcp::ColourConversion::rec709_to_xyz ()));
+       _colour_conversions.push_back (PresetColourConversion (_("P3 (from SMPTE RP 431-2)"), dcp::ColourConversion::p3_to_xyz ()));
+
+       set_kdm_email_to_default ();
+}
 
-       reset_kdm_email ();
+void
+Config::restore_defaults ()
+{
+       Config::instance()->set_defaults ();
+       Config::instance()->changed ();
 }
 
 void
@@ -420,7 +436,7 @@ Config::changed ()
 }
 
 void
-Config::reset_kdm_email ()
+Config::set_kdm_email_to_default ()
 {
        _kdm_email = _(
                "Dear Projectionist\n\n"
@@ -432,6 +448,13 @@ Config::reset_kdm_email ()
                );
 }
 
+void
+Config::reset_kdm_email ()
+{
+       set_kdm_email_to_default ();
+       changed ();
+}
+
 void
 Config::add_to_history (boost::filesystem::path p)
 {