2 Copyright (C) 2012 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 <libdcp/metadata.h>
31 #include "dci_metadata.h"
32 #include "colour_conversion.h"
35 class ServerDescription;
44 * @brief A singleton class holding configuration.
46 class Config : public boost::noncopyable
50 /** @return number of threads to use for J2K encoding on the local machine */
51 int num_local_encoding_threads () const {
52 return _num_local_encoding_threads;
55 std::string default_directory () const {
56 return _default_directory;
59 std::string default_directory_or (std::string a) const;
61 /** @return port to use for J2K encoding servers */
62 int server_port () const {
66 /** @return J2K encoding servers to use */
67 std::vector<ServerDescription> servers () const {
71 /** @return The IP address of a TMS that we can copy DCPs to */
72 std::string tms_ip () const {
76 /** @return The path on a TMS that we should write DCPs to */
77 std::string tms_path () const {
81 /** @return User name to log into the TMS with */
82 std::string tms_user () const {
86 /** @return Password to log into the TMS with */
87 std::string tms_password () const {
91 /** @return The sound processor that we are using */
92 SoundProcessor const * sound_processor () const {
93 return _sound_processor;
96 std::list<boost::shared_ptr<Cinema> > cinemas () const {
100 std::list<int> allowed_dcp_frame_rates () const {
101 return _allowed_dcp_frame_rates;
104 DCIMetadata default_dci_metadata () const {
105 return _default_dci_metadata;
108 boost::optional<std::string> language () const {
112 int default_still_length () const {
113 return _default_still_length;
116 Ratio const * default_container () const {
117 return _default_container;
120 DCPContentType const * default_dcp_content_type () const {
121 return _default_dcp_content_type;
124 libdcp::XMLMetadata dcp_metadata () const {
125 return _dcp_metadata;
128 int default_j2k_bandwidth () const {
129 return _default_j2k_bandwidth;
132 std::vector<PresetColourConversion> colour_conversions () const {
133 return _colour_conversions;
136 /** @param n New number of local encoding threads */
137 void set_num_local_encoding_threads (int n) {
138 _num_local_encoding_threads = n;
141 void set_default_directory (std::string d) {
142 _default_directory = d;
145 /** @param p New server port */
146 void set_server_port (int p) {
150 /** @param s New list of servers */
151 void set_servers (std::vector<ServerDescription> s) {
155 void set_reference_scaler (Scaler const * s) {
156 _reference_scaler = s;
159 void set_reference_filters (std::vector<Filter const *> const & f) {
160 _reference_filters = f;
163 /** @param i IP address of a TMS that we can copy DCPs to */
164 void set_tms_ip (std::string i) {
168 /** @param p Path on a TMS that we should write DCPs to */
169 void set_tms_path (std::string p) {
173 /** @param u User name to log into the TMS with */
174 void set_tms_user (std::string u) {
178 /** @param p Password to log into the TMS with */
179 void set_tms_password (std::string p) {
183 void add_cinema (boost::shared_ptr<Cinema> c) {
184 _cinemas.push_back (c);
187 void remove_cinema (boost::shared_ptr<Cinema> c) {
191 void set_allowed_dcp_frame_rates (std::list<int> const & r) {
192 _allowed_dcp_frame_rates = r;
195 void set_default_dci_metadata (DCIMetadata d) {
196 _default_dci_metadata = d;
199 void set_language (std::string l) {
203 void unset_language () {
204 _language = boost::none;
207 void set_default_still_length (int s) {
208 _default_still_length = s;
211 void set_default_container (Ratio const * c) {
212 _default_container = c;
215 void set_default_dcp_content_type (DCPContentType const * t) {
216 _default_dcp_content_type = t;
219 void set_dcp_metadata (libdcp::XMLMetadata m) {
223 void set_default_j2k_bandwidth (int b) {
224 _default_j2k_bandwidth = b;
227 void set_colour_conversions (std::vector<PresetColourConversion> const & c) {
228 _colour_conversions = c;
233 std::string crypt_chain_directory () const;
235 static Config* instance ();
240 std::string file (bool) const;
242 void read_old_metadata ();
244 /** number of threads to use for J2K encoding on the local machine */
245 int _num_local_encoding_threads;
246 /** default directory to put new films in */
247 std::string _default_directory;
248 /** port to use for J2K encoding servers */
251 /** J2K encoding servers to use */
252 std::vector<ServerDescription> _servers;
253 /** Scaler to use for the "A" part of A/B comparisons */
254 Scaler const * _reference_scaler;
255 /** Filters to use for the "A" part of A/B comparisons */
256 std::vector<Filter const *> _reference_filters;
257 /** The IP address of a TMS that we can copy DCPs to */
259 /** The path on a TMS that we should write DCPs to */
260 std::string _tms_path;
261 /** User name to log into the TMS with */
262 std::string _tms_user;
263 /** Password to log into the TMS with */
264 std::string _tms_password;
265 /** Our sound processor */
266 SoundProcessor const * _sound_processor;
267 std::list<int> _allowed_dcp_frame_rates;
268 /** Default DCI metadata for newly-created Films */
269 DCIMetadata _default_dci_metadata;
270 boost::optional<std::string> _language;
271 int _default_still_length;
272 Ratio const * _default_container;
273 DCPContentType const * _default_dcp_content_type;
274 libdcp::XMLMetadata _dcp_metadata;
275 int _default_j2k_bandwidth;
276 std::vector<PresetColourConversion> _colour_conversions;
278 std::list<boost::shared_ptr<Cinema> > _cinemas;
280 /** Singleton instance, or 0 */
281 static Config* _instance;