/*
- 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
#include "config.h"
#include "server.h"
-#include "scaler.h"
#include "filter.h"
#include "ratio.h"
#include "dcp_content_type.h"
#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>
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 | Log::TYPE_DEBUG)
+{
+ 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);
_allowed_dcp_frame_rates.push_back (50);
_allowed_dcp_frame_rates.push_back (60);
- _colour_conversions.push_back (PresetColourConversion (_("sRGB"), dcp::ColourConversion::srgb_to_xyz ()));
- _colour_conversions.push_back (PresetColourConversion (_("Rec. 709"), dcp::ColourConversion::rec709_to_xyz ()));
+ set_kdm_email_to_default ();
+}
- reset_kdm_email ();
+void
+Config::restore_defaults ()
+{
+ Config::instance()->set_defaults ();
+ Config::instance()->changed ();
}
void
_default_j2k_bandwidth = f.optional_number_child<int>("DefaultJ2KBandwidth").get_value_or (200000000);
_default_audio_delay = f.optional_number_child<int>("DefaultAudioDelay").get_value_or (0);
- list<cxml::NodePtr> cc = f.node_children ("ColourConversion");
-
- if (!cc.empty ()) {
- _colour_conversions.clear ();
- }
-
- try {
- for (list<cxml::NodePtr>::iterator i = cc.begin(); i != cc.end(); ++i) {
- /* This is a bit of a hack; use 32 (the first Film state file version for the 2.x branch)
- for version 2 and 10 (the current Film state version for the 1.x branch) for version 1.
- */
- _colour_conversions.push_back (PresetColourConversion (*i, version == 2 ? 32 : 10));
- }
- } catch (cxml::Error) {
- /* Probably failed to load an old-style ColourConversion tag; just give up */
- _colour_conversions.push_back (PresetColourConversion (_("sRGB"), dcp::ColourConversion::srgb_to_xyz ()));
- _colour_conversions.push_back (PresetColourConversion (_("Rec. 709"), dcp::ColourConversion::rec709_to_xyz ()));
- }
-
list<cxml::NodePtr> cin = f.node_children ("Cinema");
for (list<cxml::NodePtr>::iterator i = cin.begin(); i != cin.end(); ++i) {
/* Slightly grotty two-part construction of Cinema here so that we can use
root->add_child("DefaultJ2KBandwidth")->add_child_text (raw_convert<string> (_default_j2k_bandwidth));
root->add_child("DefaultAudioDelay")->add_child_text (raw_convert<string> (_default_audio_delay));
- for (vector<PresetColourConversion>::const_iterator i = _colour_conversions.begin(); i != _colour_conversions.end(); ++i) {
- i->as_xml (root->add_child ("ColourConversion"));
- }
-
for (list<shared_ptr<Cinema> >::const_iterator i = _cinemas.begin(); i != _cinemas.end(); ++i) {
(*i)->as_xml (root->add_child ("Cinema"));
}
void
Config::changed ()
{
- write ();
Changed ();
}
void
-Config::reset_kdm_email ()
+Config::set_kdm_email_to_default ()
{
_kdm_email = _(
"Dear Projectionist\n\n"
);
}
+void
+Config::reset_kdm_email ()
+{
+ set_kdm_email_to_default ();
+ changed ();
+}
+
void
Config::add_to_history (boost::filesystem::path p)
{