Basic support for calculating audio gains based on the sound processor's gain curve.
[dcpomatic.git] / src / lib / config.h
1 /*
2     Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
3
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.
8
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.
13
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.
17
18 */
19
20 /** @file src/config.h
21  *  @brief Class holding configuration.
22  */
23
24 #ifndef DVDOMATIC_CONFIG_H
25 #define DVDOMATIC_CONFIG_H
26
27 #include <vector>
28 #include <boost/shared_ptr.hpp>
29 #include <sigc++/signal.h>
30
31 class Server;
32 class Screen;
33 class Scaler;
34 class Filter;
35 class SoundProcessor;
36
37 /** @class Config
38  *  @brief A singleton class holding configuration.
39  */
40 class Config
41 {
42 public:
43
44         /** @return number of threads to use for J2K encoding on the local machine */
45         int num_local_encoding_threads () const {
46                 return _num_local_encoding_threads;
47         }
48
49         /** @return port to use for J2K encoding servers */
50         int server_port () const {
51                 return _server_port;
52         }
53
54         /** @return index of colour LUT to use when converting RGB to XYZ.
55          *  0: sRGB
56          *  1: Rec 709
57          *  2: DC28
58          */
59         int colour_lut_index () const {
60                 return _colour_lut_index;
61         }
62
63         /** @return bandwidth for J2K files in bits per second */
64         int j2k_bandwidth () const {
65                 return _j2k_bandwidth;
66         }
67
68         /** @return J2K encoding servers to use */
69         std::vector<Server*> servers () const {
70                 return _servers;
71         }
72
73         std::vector<boost::shared_ptr<Screen> > screens () const {
74                 return _screens;
75         }
76
77         Scaler const * reference_scaler () const {
78                 return _reference_scaler;
79         }
80
81         std::vector<Filter const *> reference_filters () const {
82                 return _reference_filters;
83         }
84
85         std::string tms_ip () const {
86                 return _tms_ip;
87         }
88
89         std::string tms_path () const {
90                 return _tms_path;
91         }
92
93         std::string tms_user () const {
94                 return _tms_user;
95         }
96
97         std::string tms_password () const {
98                 return _tms_password;
99         }
100
101         SoundProcessor const * sound_processor () const {
102                 return _sound_processor;
103         }
104
105         /** @param n New number of local encoding threads */
106         void set_num_local_encoding_threads (int n) {
107                 _num_local_encoding_threads = n;
108                 Changed ();
109         }
110
111         /** @param p New server port */
112         void set_server_port (int p) {
113                 _server_port = p;
114                 Changed ();
115         }
116
117         /** @param i New colour LUT index */
118         void set_colour_lut_index (int i) {
119                 _colour_lut_index = i;
120                 Changed ();
121         }
122
123         /** @param b New J2K bandwidth */
124         void set_j2k_bandwidth (int b) {
125                 _j2k_bandwidth = b;
126                 Changed ();
127         }
128
129         /** @param s New list of servers */
130         void set_servers (std::vector<Server*> s) {
131                 _servers = s;
132                 Changed ();
133         }
134
135         void set_screens (std::vector<boost::shared_ptr<Screen> > s) {
136                 _screens = s;
137                 Changed ();
138         }
139
140         void set_reference_scaler (Scaler const * s) {
141                 _reference_scaler = s;
142                 Changed ();
143         }
144         
145         void set_reference_filters (std::vector<Filter const *> const & f) {
146                 _reference_filters = f;
147                 Changed ();
148         }
149
150         void set_tms_ip (std::string i) {
151                 _tms_ip = i;
152                 Changed ();
153         }
154
155         void set_tms_path (std::string p) {
156                 _tms_path = p;
157                 Changed ();
158         }
159
160         void set_tms_user (std::string u) {
161                 _tms_user = u;
162                 Changed ();
163         }
164
165         void set_tms_password (std::string p) {
166                 _tms_password = p;
167                 Changed ();
168         }
169         
170         void write () const;
171
172         sigc::signal0<void> Changed;
173
174         static Config* instance ();
175
176 private:
177         Config ();
178         std::string file () const;
179
180         /** number of threads to use for J2K encoding on the local machine */
181         int _num_local_encoding_threads;
182         /** port to use for J2K encoding servers */
183         int _server_port;
184         /** index of colour LUT to use when converting RGB to XYZ
185          *  (see colour_lut_index ())
186          */
187         int _colour_lut_index;
188         /** bandwidth for J2K files in Mb/s */
189         int _j2k_bandwidth;
190
191         /** J2K encoding servers to use */
192         std::vector<Server *> _servers;
193
194         /** Screen definitions */
195         std::vector<boost::shared_ptr<Screen> > _screens;
196
197         /** Scaler to use for the "A" part of A/B comparisons */
198         Scaler const * _reference_scaler;
199
200         /** Filters to use for the "A" part of A/B comparisons */
201         std::vector<Filter const *> _reference_filters;
202
203         std::string _tms_ip;
204         std::string _tms_path;
205         std::string _tms_user;
206         std::string _tms_password;
207
208         SoundProcessor const * _sound_processor;
209
210         /** Singleton instance, or 0 */
211         static Config* _instance;
212 };
213
214 #endif