2 Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 /** @file src/config.h
21 * @brief Class holding configuration.
24 #ifndef DCPOMATIC_CONFIG_H
25 #define DCPOMATIC_CONFIG_H
28 #include <boost/shared_ptr.hpp>
29 #include <boost/signals2.hpp>
30 #include <boost/filesystem.hpp>
31 #include <dcp/metadata.h>
32 #include <dcp/certificates.h>
33 #include <dcp/signer.h>
34 #include "isdcf_metadata.h"
35 #include "colour_conversion.h"
36 #include "video_content.h"
38 class ServerDescription;
41 class CinemaSoundProcessor;
47 * @brief A singleton class holding configuration.
49 class Config : public boost::noncopyable
53 /** @return number of threads to use for J2K encoding on the local machine */
54 int num_local_encoding_threads () const {
55 return _num_local_encoding_threads;
58 boost::filesystem::path default_directory () const {
59 return _default_directory;
62 boost::filesystem::path default_directory_or (boost::filesystem::path a) const;
64 /** @return base port number to use for J2K encoding servers */
65 int server_port_base () const {
66 return _server_port_base;
69 void set_use_any_servers (bool u) {
74 bool use_any_servers () const {
75 return _use_any_servers;
78 /** @param s New list of servers */
79 void set_servers (std::vector<std::string> s) {
84 /** @return Host names / IP addresses of J2K encoding servers that should definitely be used */
85 std::vector<std::string> servers () const {
89 /** @return The IP address of a TMS that we can copy DCPs to */
90 std::string tms_ip () const {
94 /** @return The path on a TMS that we should changed DCPs to */
95 std::string tms_path () const {
99 /** @return User name to log into the TMS with */
100 std::string tms_user () const {
104 /** @return Password to log into the TMS with */
105 std::string tms_password () const {
106 return _tms_password;
109 /** @return The cinema sound processor that we are using */
110 CinemaSoundProcessor const * cinema_sound_processor () const {
111 return _cinema_sound_processor;
114 std::list<boost::shared_ptr<Cinema> > cinemas () const {
118 std::list<int> allowed_dcp_frame_rates () const {
119 return _allowed_dcp_frame_rates;
122 bool allow_any_dcp_frame_rate () const {
123 return _allow_any_dcp_frame_rate;
126 ISDCFMetadata default_isdcf_metadata () const {
127 return _default_isdcf_metadata;
130 boost::optional<std::string> language () const {
134 int default_still_length () const {
135 return _default_still_length;
138 Ratio const * default_container () const {
139 return _default_container;
142 DCPContentType const * default_dcp_content_type () const {
143 return _default_dcp_content_type;
146 std::string dcp_issuer () const {
150 int default_j2k_bandwidth () const {
151 return _default_j2k_bandwidth;
154 int default_audio_delay () const {
155 return _default_audio_delay;
158 std::vector<PresetColourConversion> colour_conversions () const {
159 return _colour_conversions;
162 std::string mail_server () const {
166 std::string mail_user () const {
170 std::string mail_password () const {
171 return _mail_password;
174 std::string kdm_subject () const {
178 std::string kdm_from () const {
182 std::string kdm_cc () const {
186 std::string kdm_bcc () const {
190 std::string kdm_email () const {
194 boost::shared_ptr<const dcp::Signer> signer () const {
198 dcp::Certificate decryption_certificate () const {
199 return _decryption_certificate;
202 std::string decryption_private_key () const {
203 return _decryption_private_key;
206 bool check_for_updates () const {
207 return _check_for_updates;
210 bool check_for_test_updates () const {
211 return _check_for_test_updates;
214 int maximum_j2k_bandwidth () const {
215 return _maximum_j2k_bandwidth;
218 int log_types () const {
222 #ifdef DCPOMATIC_WINDOWS
223 bool win32_console () const {
224 return _win32_console;
228 std::vector<boost::filesystem::path> history () const {
232 /** @param n New number of local encoding threads */
233 void set_num_local_encoding_threads (int n) {
234 _num_local_encoding_threads = n;
238 void set_default_directory (boost::filesystem::path d) {
239 _default_directory = d;
243 /** @param p New server port */
244 void set_server_port_base (int p) {
245 _server_port_base = p;
249 /** @param i IP address of a TMS that we can copy DCPs to */
250 void set_tms_ip (std::string i) {
255 /** @param p Path on a TMS that we should changed DCPs to */
256 void set_tms_path (std::string p) {
261 /** @param u User name to log into the TMS with */
262 void set_tms_user (std::string u) {
267 /** @param p Password to log into the TMS with */
268 void set_tms_password (std::string p) {
273 void add_cinema (boost::shared_ptr<Cinema> c) {
274 _cinemas.push_back (c);
278 void remove_cinema (boost::shared_ptr<Cinema> c) {
283 void set_allowed_dcp_frame_rates (std::list<int> const & r) {
284 _allowed_dcp_frame_rates = r;
288 void set_allow_any_dcp_frame_rate (bool a) {
289 _allow_any_dcp_frame_rate = a;
293 void set_default_isdcf_metadata (ISDCFMetadata d) {
294 _default_isdcf_metadata = d;
298 void set_language (std::string l) {
303 void unset_language () {
304 _language = boost::none;
308 void set_default_still_length (int s) {
309 _default_still_length = s;
313 void set_default_container (Ratio const * c) {
314 _default_container = c;
318 void set_default_dcp_content_type (DCPContentType const * t) {
319 _default_dcp_content_type = t;
323 void set_dcp_issuer (std::string i) {
328 void set_default_j2k_bandwidth (int b) {
329 _default_j2k_bandwidth = b;
333 void set_default_audio_delay (int d) {
334 _default_audio_delay = d;
338 void set_colour_conversions (std::vector<PresetColourConversion> const & c) {
339 _colour_conversions = c;
343 void set_mail_server (std::string s) {
348 void set_mail_user (std::string u) {
353 void set_mail_password (std::string p) {
358 void set_kdm_subject (std::string s) {
363 void set_kdm_from (std::string f) {
368 void set_kdm_cc (std::string f) {
373 void set_kdm_bcc (std::string f) {
378 void set_kdm_email (std::string e) {
383 void reset_kdm_email ();
385 void set_signer (boost::shared_ptr<const dcp::Signer> s) {
390 void set_decryption_certificate (dcp::Certificate c) {
391 _decryption_certificate = c;
395 void set_decryption_private_key (std::string k) {
396 _decryption_private_key = k;
400 void set_check_for_updates (bool c) {
401 _check_for_updates = c;
405 void set_check_for_test_updates (bool c) {
406 _check_for_test_updates = c;
410 void set_maximum_j2k_bandwidth (int b) {
411 _maximum_j2k_bandwidth = b;
415 void set_log_types (int t) {
420 #ifdef DCPOMATIC_WINDOWS
421 void set_win32_console (bool c) {
427 void clear_history () {
432 void add_to_history (boost::filesystem::path p);
435 boost::signals2::signal<void ()> Changed;
437 static Config* instance ();
442 boost::filesystem::path file () const;
445 void make_decryption_keys ();
447 /** number of threads to use for J2K encoding on the local machine */
448 int _num_local_encoding_threads;
449 /** default directory to put new films in */
450 boost::filesystem::path _default_directory;
451 /** base port number to use for J2K encoding servers;
452 * this port and the one above it will be used.
454 int _server_port_base;
455 /** true to broadcast on the `any' address to look for servers */
456 bool _use_any_servers;
457 /** J2K encoding servers that should definitely be used */
458 std::vector<std::string> _servers;
459 /** The IP address of a TMS that we can copy DCPs to */
461 /** The path on a TMS that we should write DCPs to */
462 std::string _tms_path;
463 /** User name to log into the TMS with */
464 std::string _tms_user;
465 /** Password to log into the TMS with */
466 std::string _tms_password;
467 /** Our cinema sound processor */
468 CinemaSoundProcessor const * _cinema_sound_processor;
469 std::list<int> _allowed_dcp_frame_rates;
470 /** Allow any video frame rate for the DCP; if true, overrides _allowed_dcp_frame_rates */
471 bool _allow_any_dcp_frame_rate;
472 /** Default ISDCF metadata for newly-created Films */
473 ISDCFMetadata _default_isdcf_metadata;
474 boost::optional<std::string> _language;
475 int _default_still_length;
476 Ratio const * _default_container;
477 DCPContentType const * _default_dcp_content_type;
478 std::string _dcp_issuer;
479 int _default_j2k_bandwidth;
480 int _default_audio_delay;
481 std::vector<PresetColourConversion> _colour_conversions;
482 std::list<boost::shared_ptr<Cinema> > _cinemas;
483 std::string _mail_server;
484 std::string _mail_user;
485 std::string _mail_password;
486 std::string _kdm_subject;
487 std::string _kdm_from;
489 std::string _kdm_bcc;
490 std::string _kdm_email;
491 boost::shared_ptr<const dcp::Signer> _signer;
492 dcp::Certificate _decryption_certificate;
493 std::string _decryption_private_key;
494 /** true to check for updates on startup */
495 bool _check_for_updates;
496 bool _check_for_test_updates;
497 /** maximum allowed J2K bandwidth in bits per second */
498 int _maximum_j2k_bandwidth;
500 #ifdef DCPOMATIC_WINDOWS
503 std::vector<boost::filesystem::path> _history;
505 /** Singleton instance, or 0 */
506 static Config* _instance;