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"
37 class ServerDescription;
40 class CinemaSoundProcessor;
46 * @brief A singleton class holding configuration.
48 class Config : public boost::noncopyable
52 /** @return number of threads to use for J2K encoding on the local machine */
53 int num_local_encoding_threads () const {
54 return _num_local_encoding_threads;
57 boost::filesystem::path default_directory () const {
58 return _default_directory;
61 boost::filesystem::path default_directory_or (boost::filesystem::path a) const;
63 /** @return base port number to use for J2K encoding servers */
64 int server_port_base () const {
65 return _server_port_base;
68 void set_use_any_servers (bool u) {
73 bool use_any_servers () const {
74 return _use_any_servers;
77 /** @param s New list of servers */
78 void set_servers (std::vector<std::string> s) {
83 /** @return Host names / IP addresses of J2K encoding servers that should definitely be used */
84 std::vector<std::string> servers () const {
88 /** @return The IP address of a TMS that we can copy DCPs to */
89 std::string tms_ip () const {
93 /** @return The path on a TMS that we should changed DCPs to */
94 std::string tms_path () const {
98 /** @return User name to log into the TMS with */
99 std::string tms_user () const {
103 /** @return Password to log into the TMS with */
104 std::string tms_password () const {
105 return _tms_password;
108 /** @return The cinema sound processor that we are using */
109 CinemaSoundProcessor const * cinema_sound_processor () const {
110 return _cinema_sound_processor;
113 std::list<boost::shared_ptr<Cinema> > cinemas () const {
117 std::list<int> allowed_dcp_frame_rates () const {
118 return _allowed_dcp_frame_rates;
121 bool allow_any_dcp_frame_rate () const {
122 return _allow_any_dcp_frame_rate;
125 ISDCFMetadata default_isdcf_metadata () const {
126 return _default_isdcf_metadata;
129 boost::optional<std::string> language () const {
133 int default_still_length () const {
134 return _default_still_length;
137 Ratio const * default_scale () const {
138 return _default_scale;
141 Ratio const * default_container () const {
142 return _default_container;
145 DCPContentType const * default_dcp_content_type () const {
146 return _default_dcp_content_type;
149 dcp::XMLMetadata dcp_metadata () const {
150 return _dcp_metadata;
153 int default_j2k_bandwidth () const {
154 return _default_j2k_bandwidth;
157 int default_audio_delay () const {
158 return _default_audio_delay;
161 std::vector<PresetColourConversion> colour_conversions () const {
162 return _colour_conversions;
165 std::string mail_server () const {
169 std::string mail_user () const {
173 std::string mail_password () const {
174 return _mail_password;
177 std::string kdm_subject () const {
181 std::string kdm_from () const {
185 std::string kdm_cc () const {
189 std::string kdm_bcc () const {
193 std::string kdm_email () const {
197 boost::shared_ptr<const dcp::Signer> signer () const {
201 dcp::Certificate decryption_certificate () const {
202 return _decryption_certificate;
205 std::string decryption_private_key () const {
206 return _decryption_private_key;
209 bool check_for_updates () const {
210 return _check_for_updates;
213 bool check_for_test_updates () const {
214 return _check_for_test_updates;
217 int maximum_j2k_bandwidth () const {
218 return _maximum_j2k_bandwidth;
221 int log_types () const {
225 /** @param n New number of local encoding threads */
226 void set_num_local_encoding_threads (int n) {
227 _num_local_encoding_threads = n;
231 void set_default_directory (boost::filesystem::path d) {
232 _default_directory = d;
236 /** @param p New server port */
237 void set_server_port_base (int p) {
238 _server_port_base = p;
242 /** @param i IP address of a TMS that we can copy DCPs to */
243 void set_tms_ip (std::string i) {
248 /** @param p Path on a TMS that we should changed DCPs to */
249 void set_tms_path (std::string p) {
254 /** @param u User name to log into the TMS with */
255 void set_tms_user (std::string u) {
260 /** @param p Password to log into the TMS with */
261 void set_tms_password (std::string p) {
266 void add_cinema (boost::shared_ptr<Cinema> c) {
267 _cinemas.push_back (c);
271 void remove_cinema (boost::shared_ptr<Cinema> c) {
276 void set_allowed_dcp_frame_rates (std::list<int> const & r) {
277 _allowed_dcp_frame_rates = r;
281 void set_allow_any_dcp_frame_rate (bool a) {
282 _allow_any_dcp_frame_rate = a;
286 void set_default_isdcf_metadata (ISDCFMetadata d) {
287 _default_isdcf_metadata = d;
291 void set_language (std::string l) {
296 void unset_language () {
297 _language = boost::none;
301 void set_default_still_length (int s) {
302 _default_still_length = s;
306 void set_default_scale (Ratio const * s) {
311 void set_default_container (Ratio const * c) {
312 _default_container = c;
316 void set_default_dcp_content_type (DCPContentType const * t) {
317 _default_dcp_content_type = t;
321 void set_dcp_metadata (dcp::XMLMetadata m) {
326 void set_default_j2k_bandwidth (int b) {
327 _default_j2k_bandwidth = b;
331 void set_default_audio_delay (int d) {
332 _default_audio_delay = d;
336 void set_colour_conversions (std::vector<PresetColourConversion> const & c) {
337 _colour_conversions = c;
341 void set_mail_server (std::string s) {
346 void set_mail_user (std::string u) {
351 void set_mail_password (std::string p) {
356 void set_kdm_subject (std::string s) {
361 void set_kdm_from (std::string f) {
366 void set_kdm_cc (std::string f) {
371 void set_kdm_bcc (std::string f) {
376 void set_kdm_email (std::string e) {
381 void reset_kdm_email ();
383 void set_signer (boost::shared_ptr<const dcp::Signer> s) {
388 void set_decryption_certificate (dcp::Certificate c) {
389 _decryption_certificate = c;
393 void set_decryption_private_key (std::string k) {
394 _decryption_private_key = k;
398 void set_check_for_updates (bool c) {
399 _check_for_updates = c;
403 void set_check_for_test_updates (bool c) {
404 _check_for_test_updates = c;
408 void set_maximum_j2k_bandwidth (int b) {
409 _maximum_j2k_bandwidth = b;
413 void set_log_types (int t) {
419 boost::signals2::signal<void ()> Changed;
421 static Config* instance ();
426 boost::filesystem::path file (bool) const;
430 /** number of threads to use for J2K encoding on the local machine */
431 int _num_local_encoding_threads;
432 /** default directory to put new films in */
433 boost::filesystem::path _default_directory;
434 /** base port number to use for J2K encoding servers;
435 * this port and the one above it will be used.
437 int _server_port_base;
438 /** true to broadcast on the `any' address to look for servers */
439 bool _use_any_servers;
440 /** J2K encoding servers that should definitely be used */
441 std::vector<std::string> _servers;
442 /** The IP address of a TMS that we can copy DCPs to */
444 /** The path on a TMS that we should write DCPs to */
445 std::string _tms_path;
446 /** User name to log into the TMS with */
447 std::string _tms_user;
448 /** Password to log into the TMS with */
449 std::string _tms_password;
450 /** Our cinema sound processor */
451 CinemaSoundProcessor const * _cinema_sound_processor;
452 std::list<int> _allowed_dcp_frame_rates;
453 /** Allow any video frame rate for the DCP; if true, overrides _allowed_dcp_frame_rates */
454 bool _allow_any_dcp_frame_rate;
455 /** Default ISDCF metadata for newly-created Films */
456 ISDCFMetadata _default_isdcf_metadata;
457 boost::optional<std::string> _language;
458 int _default_still_length;
459 Ratio const * _default_scale;
460 Ratio const * _default_container;
461 DCPContentType const * _default_dcp_content_type;
462 dcp::XMLMetadata _dcp_metadata;
463 int _default_j2k_bandwidth;
464 int _default_audio_delay;
465 std::vector<PresetColourConversion> _colour_conversions;
466 std::list<boost::shared_ptr<Cinema> > _cinemas;
467 std::string _mail_server;
468 std::string _mail_user;
469 std::string _mail_password;
470 std::string _kdm_subject;
471 std::string _kdm_from;
473 std::string _kdm_bcc;
474 std::string _kdm_email;
475 boost::shared_ptr<const dcp::Signer> _signer;
476 dcp::Certificate _decryption_certificate;
477 std::string _decryption_private_key;
478 /** true to check for updates on startup */
479 bool _check_for_updates;
480 bool _check_for_test_updates;
481 /** maximum allowed J2K bandwidth in bits per second */
482 int _maximum_j2k_bandwidth;
485 /** Singleton instance, or 0 */
486 static Config* _instance;