2 Copyright (C) 2012-2022 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
21 /** @file src/config.h
22 * @brief Class holding configuration.
26 #ifndef DCPOMATIC_CONFIG_H
27 #define DCPOMATIC_CONFIG_H
30 #include "audio_mapping.h"
31 #include "enum_indexed_vector.h"
32 #include "export_config.h"
33 #include "rough_duration.h"
35 #include "video_encoding.h"
36 #include <dcp/name_format.h>
37 #include <dcp/certificate_chain.h>
38 #include <dcp/encrypted_kdm.h>
39 #include <dcp/language_tag.h>
40 #include <boost/signals2.hpp>
41 #include <boost/filesystem.hpp>
46 class CinemaSoundProcessor;
56 extern void save_all_config_as_zip (boost::filesystem::path zip_file);
60 * @brief A singleton class holding configuration.
62 class Config : public State
65 /** @return number of threads which a master DoM should use for J2K encoding on the local machine */
66 int master_encoding_threads () const {
67 return _master_encoding_threads;
70 /** @return number of threads which a server should use for J2K encoding on the local machine */
71 int server_encoding_threads () const {
72 return _server_encoding_threads;
75 boost::optional<boost::filesystem::path> default_directory () const {
76 return _default_directory;
79 boost::optional<boost::filesystem::path> default_kdm_directory () const {
80 return _default_kdm_directory;
83 boost::filesystem::path default_directory_or (boost::filesystem::path a) const;
84 boost::filesystem::path default_kdm_directory_or (boost::filesystem::path a) const;
86 enum class CinemasAction
88 /** Copy the cinemas.{xml,sqlite3} in the ZIP file to the path
89 * specified in the current config, overwriting whatever is there,
92 WRITE_TO_CURRENT_PATH,
93 /** Copy the cinemas.{xml,sqlite3} in the ZIP file over the path
94 * specified in the config.xml from the ZIP, overwriting whatever
95 * is there and creating any required directories, and use
98 WRITE_TO_PATH_IN_ZIPPED_CONFIG,
99 /** Do nothing with the cinemas.{xml,sqlite3} in the ZIP file */
103 void load_from_zip(boost::filesystem::path zip_file, CinemasAction action);
110 PLAYER_CONTENT_DIRECTORY,
111 PLAYER_PLAYLIST_DIRECTORY,
114 SHOW_EXPERIMENTAL_AUDIO_PROCESSORS,
118 ISDCF_NAME_PART_LENGTH,
120 #ifdef DCPOMATIC_GROK
126 /** @return base port number to use for J2K encoding servers */
127 int server_port_base () const {
128 return _server_port_base;
131 void set_use_any_servers (bool u) {
132 _use_any_servers = u;
133 changed (USE_ANY_SERVERS);
136 bool use_any_servers () const {
137 return _use_any_servers;
140 /** @param s New list of servers */
141 void set_servers (std::vector<std::string> s) {
146 /** @return Host names / IP addresses of J2K encoding servers that should definitely be used */
147 std::vector<std::string> servers () const {
151 bool only_servers_encode () const {
152 return _only_servers_encode;
155 FileTransferProtocol tms_protocol () const {
156 return _tms_protocol;
159 bool tms_passive() const {
163 /** @return The IP address of a TMS that we can copy DCPs to */
164 std::string tms_ip () const {
168 /** @return The path on a TMS that we should changed DCPs to */
169 std::string tms_path () const {
173 /** @return User name to log into the TMS with */
174 std::string tms_user () const {
178 /** @return Password to log into the TMS with */
179 std::string tms_password () const {
180 return _tms_password;
183 std::list<int> allowed_dcp_frame_rates () const {
184 return _allowed_dcp_frame_rates;
187 bool allow_any_dcp_frame_rate () const {
188 return _allow_any_dcp_frame_rate;
191 bool allow_any_container () const {
192 return _allow_any_container;
195 bool allow_96khz_audio () const {
196 return _allow_96khz_audio;
199 bool use_all_audio_channels () const {
200 return _use_all_audio_channels;
203 bool show_experimental_audio_processors () const {
204 return _show_experimental_audio_processors;
207 boost::optional<std::string> language () const {
211 int default_still_length () const {
212 return _default_still_length;
215 DCPContentType const * default_dcp_content_type () const {
216 return _default_dcp_content_type;
219 int default_dcp_audio_channels () const {
220 return _default_dcp_audio_channels;
223 std::string dcp_issuer () const {
227 std::string dcp_creator () const {
231 std::string dcp_company_name () const {
232 return _dcp_company_name;
235 std::string dcp_product_name () const {
236 return _dcp_product_name;
239 std::string dcp_product_version () const {
240 return _dcp_product_version;
243 std::string dcp_j2k_comment () const {
244 return _dcp_j2k_comment;
247 int64_t default_video_bit_rate(VideoEncoding encoding) const {
248 return _default_video_bit_rate[encoding];
251 int default_audio_delay () const {
252 return _default_audio_delay;
255 bool default_interop () const {
256 return _default_interop;
259 boost::optional<dcp::LanguageTag> default_audio_language() const {
260 return _default_audio_language;
263 boost::optional<dcp::LanguageTag::RegionSubtag> default_territory() const {
264 return _default_territory;
267 std::map<std::string, std::string> default_metadata () const {
268 return _default_metadata;
271 bool upload_after_make_dcp () {
272 return _upload_after_make_dcp;
275 void set_default_kdm_directory (boost::filesystem::path d) {
276 if (_default_kdm_directory && _default_kdm_directory.get() == d) {
279 _default_kdm_directory = d;
283 std::string mail_server () const {
287 int mail_port () const {
291 EmailProtocol mail_protocol () const {
292 return _mail_protocol;
295 std::string mail_user () const {
299 std::string mail_password () const {
300 return _mail_password;
303 std::string kdm_subject () const {
307 std::string kdm_from () const {
311 std::vector<std::string> kdm_cc () const {
315 std::string kdm_bcc () const {
319 std::string kdm_email () const {
323 std::string notification_subject () const {
324 return _notification_subject;
327 std::string notification_from () const {
328 return _notification_from;
331 std::string notification_to () const {
332 return _notification_to;
335 std::vector<std::string> notification_cc () const {
336 return _notification_cc;
339 std::string notification_bcc () const {
340 return _notification_bcc;
343 std::string notification_email () const {
344 return _notification_email;
347 std::shared_ptr<const dcp::CertificateChain> signer_chain () const {
348 return _signer_chain;
351 std::shared_ptr<const dcp::CertificateChain> decryption_chain () const {
352 return _decryption_chain;
355 bool check_for_updates () const {
356 return _check_for_updates;
359 bool check_for_test_updates () const {
360 return _check_for_test_updates;
363 int64_t maximum_video_bit_rate(VideoEncoding encoding) const {
364 return _maximum_video_bit_rate[encoding];
367 int log_types () const {
371 bool analyse_ebur128 () const {
372 return _analyse_ebur128;
375 bool automatic_audio_analysis () const {
376 return _automatic_audio_analysis;
379 #ifdef DCPOMATIC_WINDOWS
380 bool win32_console () const {
381 return _win32_console;
385 std::vector<boost::filesystem::path> history () const {
389 std::vector<boost::filesystem::path> player_history () const {
390 return _player_history;
393 std::shared_ptr<DKDMGroup> dkdms () const {
397 boost::filesystem::path cinemas_file () const {
398 return _cinemas_file;
401 boost::filesystem::path dkdm_recipients_file () const {
402 return _dkdm_recipients_file;
405 bool show_hints_before_make_dcp () const {
406 return _show_hints_before_make_dcp;
409 bool confirm_kdm_email () const {
410 return _confirm_kdm_email;
413 dcp::NameFormat kdm_container_name_format () const {
414 return _kdm_container_name_format;
417 dcp::NameFormat kdm_filename_format () const {
418 return _kdm_filename_format;
421 dcp::NameFormat dkdm_filename_format () const {
422 return _dkdm_filename_format;
425 dcp::NameFormat dcp_metadata_filename_format () const {
426 return _dcp_metadata_filename_format;
429 dcp::NameFormat dcp_asset_filename_format () const {
430 return _dcp_asset_filename_format;
433 bool jump_to_selected () const {
434 return _jump_to_selected;
437 /* This could be an enum class but we use the enum a lot to index _nagged
438 * so it means a lot of casts.
442 NAG_ENCRYPTED_METADATA,
443 NAG_ALTER_DECRYPTION_CHAIN,
444 NAG_BAD_SIGNER_CHAIN_UTF8,
445 NAG_IMPORT_DECRYPTION_CHAIN,
448 NAG_TOO_MANY_DROPPED_FRAMES,
449 NAG_BAD_SIGNER_CHAIN_VALIDITY,
450 NAG_BAD_SIGNER_DN_QUALIFIER,
454 bool nagged (Nag nag) const {
458 bool sound () const {
462 std::string cover_sheet () const {
466 boost::optional<std::string> sound_output () const {
467 return _sound_output;
470 boost::optional<boost::filesystem::path> last_player_load_directory () const {
471 return _last_player_load_directory;
480 boost::optional<KDMWriteType> last_kdm_write_type () const {
481 return _last_kdm_write_type;
489 boost::optional<DKDMWriteType> last_dkdm_write_type () const {
490 return _last_dkdm_write_type;
493 int frames_in_memory_multiplier () const {
494 return _frames_in_memory_multiplier;
497 boost::optional<int> decode_reduction () const {
498 return _decode_reduction;
501 bool default_notify () const {
502 return _default_notify;
511 bool notification (Notification n) const {
512 return _notification[n];
515 boost::optional<std::string> barco_username () const {
516 return _barco_username;
519 boost::optional<std::string> barco_password () const {
520 return _barco_password;
523 boost::optional<std::string> christie_username () const {
524 return _christie_username;
527 boost::optional<std::string> christie_password () const {
528 return _christie_password;
531 boost::optional<std::string> gdc_username () const {
532 return _gdc_username;
535 boost::optional<std::string> gdc_password () const {
536 return _gdc_password;
540 PLAYER_MODE_WINDOW, ///< one window containing image and controls
541 PLAYER_MODE_FULL, ///< just the image filling the screen
542 PLAYER_MODE_DUAL ///< image on one monitor and extended controls on the other
545 PlayerMode player_mode () const {
549 bool player_restricted_menus() const {
550 return _player_restricted_menus;
553 bool playlist_editor_restricted_menus() const {
554 return _playlist_editor_restricted_menus;
557 int image_display () const {
558 return _image_display;
566 VideoViewType video_view_type () const {
567 return _video_view_type;
570 bool respect_kdm_validity_periods () const {
571 return _respect_kdm_validity_periods;
574 boost::optional<boost::filesystem::path> player_debug_log_file () const {
575 return _player_debug_log_file;
578 boost::optional<boost::filesystem::path> player_content_directory () const {
579 return _player_content_directory;
582 boost::optional<boost::filesystem::path> player_playlist_directory () const {
583 return _player_playlist_directory;
586 boost::optional<boost::filesystem::path> player_kdm_directory () const {
587 return _player_kdm_directory;
590 AudioMapping audio_mapping (int output_channels);
592 std::vector<dcp::LanguageTag> custom_languages () const {
593 return _custom_languages;
596 boost::optional<boost::filesystem::path> initial_path(std::string id) const;
598 bool use_isdcf_name_by_default () const {
599 return _use_isdcf_name_by_default;
602 bool write_kdms_to_disk () const {
603 return _write_kdms_to_disk;
606 bool email_kdms () const {
610 dcp::Formulation default_kdm_type () const {
611 return _default_kdm_type;
614 RoughDuration default_kdm_duration () const {
615 return _default_kdm_duration;
618 double auto_crop_threshold () const {
619 return _auto_crop_threshold;
622 boost::optional<std::string> last_release_notes_version () const {
623 return _last_release_notes_version;
626 boost::optional<int> main_divider_sash_position() const {
627 return _main_divider_sash_position;
630 boost::optional<int> main_content_divider_sash_position() const {
631 return _main_content_divider_sash_position;
634 enum class DefaultAddFileLocation {
639 DefaultAddFileLocation default_add_file_location() const {
640 return _default_add_file_location;
643 bool allow_smpte_bv20() const {
644 return _allow_smpte_bv20;
647 #ifdef DCPOMATIC_GROK
652 Grok(cxml::ConstNodePtr node);
654 void as_xml(xmlpp::Element* node) const;
657 boost::filesystem::path binary_location;
659 std::string licence_server;
660 int licence_port = 5000;
664 boost::optional<Grok> grok() const {
669 int isdcf_name_part_length() const {
670 return _isdcf_name_part_length;
673 bool enable_player_http_server() const {
674 return _enable_player_http_server;
677 int player_http_server_port() const {
678 return _player_http_server_port;
683 void set_master_encoding_threads (int n) {
684 maybe_set (_master_encoding_threads, n);
687 void set_server_encoding_threads (int n) {
688 maybe_set (_server_encoding_threads, n);
691 void set_default_directory (boost::filesystem::path d) {
692 if (_default_directory && *_default_directory == d) {
695 _default_directory = d;
699 /** @param p New server port */
700 void set_server_port_base (int p) {
701 maybe_set (_server_port_base, p);
704 void set_only_servers_encode (bool o) {
705 maybe_set (_only_servers_encode, o);
708 void set_tms_protocol (FileTransferProtocol p) {
709 maybe_set (_tms_protocol, p);
712 void set_tms_passive(bool passive) {
713 maybe_set(_tms_passive, passive);
716 /** @param i IP address of a TMS that we can copy DCPs to */
717 void set_tms_ip (std::string i) {
718 maybe_set (_tms_ip, i);
721 /** @param p Path on a TMS that we should changed DCPs to */
722 void set_tms_path (std::string p) {
723 maybe_set (_tms_path, p);
726 /** @param u User name to log into the TMS with */
727 void set_tms_user (std::string u) {
728 maybe_set (_tms_user, u);
731 /** @param p Password to log into the TMS with */
732 void set_tms_password (std::string p) {
733 maybe_set (_tms_password, p);
736 void set_allowed_dcp_frame_rates (std::list<int> const & r) {
737 maybe_set (_allowed_dcp_frame_rates, r);
740 void set_allow_any_dcp_frame_rate (bool a) {
741 maybe_set (_allow_any_dcp_frame_rate, a);
744 void set_allow_any_container (bool a) {
745 maybe_set(_allow_any_container, a, ALLOW_ANY_CONTAINER);
748 void set_allow_96hhz_audio (bool a) {
749 maybe_set (_allow_96khz_audio, a);
752 void set_use_all_audio_channels (bool a) {
753 maybe_set (_use_all_audio_channels, a);
756 void set_show_experimental_audio_processors (bool e) {
757 maybe_set (_show_experimental_audio_processors, e, SHOW_EXPERIMENTAL_AUDIO_PROCESSORS);
760 void set_language (std::string l) {
761 if (_language && _language.get() == l) {
768 void unset_language () {
773 _language = boost::none;
777 void set_default_still_length (int s) {
778 maybe_set (_default_still_length, s);
781 void set_dcp_issuer (std::string i) {
782 maybe_set (_dcp_issuer, i);
785 void set_dcp_creator (std::string c) {
786 maybe_set (_dcp_creator, c);
789 void set_dcp_company_name (std::string c) {
790 maybe_set (_dcp_company_name, c);
793 void set_dcp_product_name (std::string c) {
794 maybe_set (_dcp_product_name, c);
797 void set_dcp_product_version (std::string c) {
798 maybe_set (_dcp_product_version, c);
801 void set_dcp_j2k_comment (std::string c) {
802 maybe_set (_dcp_j2k_comment, c);
805 void set_default_audio_delay (int d) {
806 maybe_set (_default_audio_delay, d);
809 void set_default_audio_language(dcp::LanguageTag tag) {
810 maybe_set(_default_audio_language, tag);
813 void unset_default_audio_language() {
814 maybe_set(_default_audio_language, boost::optional<dcp::LanguageTag>());
817 void set_upload_after_make_dcp (bool u) {
818 maybe_set (_upload_after_make_dcp, u);
821 void set_mail_server (std::string s) {
822 maybe_set (_mail_server, s);
825 void set_mail_port (int p) {
826 maybe_set (_mail_port, p);
829 void set_mail_protocol (EmailProtocol p) {
830 maybe_set (_mail_protocol, p);
833 void set_mail_user (std::string u) {
834 maybe_set (_mail_user, u);
837 void set_mail_password (std::string p) {
838 maybe_set (_mail_password, p);
841 void set_kdm_subject (std::string s) {
842 maybe_set (_kdm_subject, s);
845 void set_kdm_from (std::string f) {
846 maybe_set (_kdm_from, f);
849 void set_kdm_cc (std::vector<std::string> f) {
850 maybe_set (_kdm_cc, f);
853 void set_kdm_bcc (std::string f) {
854 maybe_set (_kdm_bcc, f);
857 void set_kdm_email (std::string e) {
858 maybe_set (_kdm_email, e);
861 void reset_kdm_email ();
863 void set_notification_subject (std::string s) {
864 maybe_set (_notification_subject, s);
867 void set_notification_from (std::string f) {
868 maybe_set (_notification_from, f);
871 void set_notification_to (std::string t) {
872 maybe_set (_notification_to, t);
875 void set_notification_cc (std::vector<std::string> f) {
876 maybe_set (_notification_cc, f);
879 void set_notification_bcc (std::string f) {
880 maybe_set (_notification_bcc, f);
883 void set_notification_email (std::string e) {
884 maybe_set (_notification_email, e);
887 void reset_notification_email ();
889 void set_signer_chain (std::shared_ptr<const dcp::CertificateChain> s) {
890 maybe_set (_signer_chain, s);
893 void set_decryption_chain (std::shared_ptr<const dcp::CertificateChain> c) {
894 maybe_set (_decryption_chain, c);
897 void set_check_for_updates (bool c) {
898 maybe_set (_check_for_updates, c);
900 set_check_for_test_updates (false);
904 void set_check_for_test_updates (bool c) {
905 maybe_set (_check_for_test_updates, c);
908 void set_maximum_video_bit_rate(VideoEncoding encoding, int64_t b) {
909 maybe_set(_maximum_video_bit_rate[encoding], b);
912 void set_log_types (int t) {
913 maybe_set (_log_types, t);
916 void set_analyse_ebur128 (bool a) {
917 maybe_set (_analyse_ebur128, a);
920 void set_automatic_audio_analysis (bool a) {
921 maybe_set (_automatic_audio_analysis, a);
924 #ifdef DCPOMATIC_WINDOWS
925 void set_win32_console (bool c) {
926 maybe_set (_win32_console, c);
930 void set_dkdms (std::shared_ptr<DKDMGroup> dkdms) {
935 void set_cinemas_file (boost::filesystem::path file);
937 void set_dkdm_recipients_file(boost::filesystem::path file);
939 void set_show_hints_before_make_dcp (bool s) {
940 maybe_set (_show_hints_before_make_dcp, s);
943 void set_confirm_kdm_email (bool s) {
944 maybe_set (_confirm_kdm_email, s);
947 void set_sound (bool s) {
948 maybe_set (_sound, s, SOUND);
951 void set_sound_output (std::string o) {
952 maybe_set (_sound_output, o, SOUND_OUTPUT);
955 void set_last_player_load_directory (boost::filesystem::path d) {
956 maybe_set (_last_player_load_directory, d);
959 void set_last_kdm_write_type (KDMWriteType t) {
960 maybe_set (_last_kdm_write_type, t);
963 void set_last_dkdm_write_type (DKDMWriteType t) {
964 maybe_set (_last_dkdm_write_type, t);
967 void unset_sound_output () {
968 if (!_sound_output) {
972 _sound_output = boost::none;
976 void set_kdm_container_name_format (dcp::NameFormat n) {
977 maybe_set (_kdm_container_name_format, n);
980 void set_kdm_filename_format (dcp::NameFormat n) {
981 maybe_set (_kdm_filename_format, n);
984 void set_dkdm_filename_format (dcp::NameFormat n) {
985 maybe_set (_dkdm_filename_format, n);
988 void set_dcp_metadata_filename_format (dcp::NameFormat n) {
989 maybe_set (_dcp_metadata_filename_format, n);
992 void set_dcp_asset_filename_format (dcp::NameFormat n) {
993 maybe_set (_dcp_asset_filename_format, n);
996 void set_frames_in_memory_multiplier (int m) {
997 maybe_set (_frames_in_memory_multiplier, m);
1000 void set_decode_reduction (boost::optional<int> r) {
1001 maybe_set (_decode_reduction, r);
1004 void set_default_notify (bool n) {
1005 maybe_set (_default_notify, n);
1008 void clear_history () {
1013 void clear_player_history () {
1014 _player_history.clear ();
1018 void add_to_history (boost::filesystem::path p);
1019 void clean_history ();
1020 void add_to_player_history (boost::filesystem::path p);
1021 void clean_player_history ();
1023 void set_jump_to_selected (bool j) {
1024 maybe_set (_jump_to_selected, j);
1027 void set_nagged (Nag nag, bool nagged) {
1028 maybe_set (_nagged[nag], nagged);
1031 void set_cover_sheet (std::string s) {
1032 maybe_set (_cover_sheet, s);
1035 void reset_cover_sheet ();
1037 void set_notification (Notification n, bool v) {
1038 maybe_set (_notification[n], v);
1041 void set_barco_username (std::string u) {
1042 maybe_set (_barco_username, u);
1045 void unset_barco_username () {
1046 maybe_set (_barco_username, boost::optional<std::string>());
1049 void set_barco_password (std::string p) {
1050 maybe_set (_barco_password, p);
1053 void unset_barco_password () {
1054 maybe_set (_barco_password, boost::optional<std::string>());
1057 void set_christie_username (std::string u) {
1058 maybe_set (_christie_username, u);
1061 void unset_christie_username () {
1062 maybe_set (_christie_username, boost::optional<std::string>());
1065 void set_christie_password (std::string p) {
1066 maybe_set (_christie_password, p);
1069 void unset_christie_password () {
1070 maybe_set (_christie_password, boost::optional<std::string>());
1073 void set_gdc_username (std::string u) {
1074 maybe_set (_gdc_username, u);
1077 void unset_gdc_username () {
1078 maybe_set (_gdc_username, boost::optional<std::string>());
1081 void set_gdc_password (std::string p) {
1082 maybe_set (_gdc_password, p);
1085 void unset_gdc_password () {
1086 maybe_set (_gdc_password, boost::optional<std::string>());
1089 void set_player_mode (PlayerMode m) {
1090 maybe_set (_player_mode, m);
1093 void set_image_display (int n) {
1094 maybe_set (_image_display, n);
1097 void set_video_view_type (VideoViewType v) {
1098 maybe_set (_video_view_type, v);
1101 void set_respect_kdm_validity_periods (bool r) {
1102 maybe_set (_respect_kdm_validity_periods, r);
1105 void set_player_debug_log_file (boost::filesystem::path p) {
1106 maybe_set (_player_debug_log_file, p, PLAYER_DEBUG_LOG);
1109 void unset_player_debug_log_file () {
1110 if (!_player_debug_log_file) {
1113 _player_debug_log_file = boost::none;
1114 changed (PLAYER_DEBUG_LOG);
1117 void set_player_content_directory (boost::filesystem::path p) {
1118 maybe_set (_player_content_directory, p, PLAYER_CONTENT_DIRECTORY);
1121 void unset_player_content_directory () {
1122 if (!_player_content_directory) {
1125 _player_content_directory = boost::none;
1126 changed (PLAYER_CONTENT_DIRECTORY);
1129 void set_player_playlist_directory (boost::filesystem::path p) {
1130 maybe_set (_player_playlist_directory, p, PLAYER_PLAYLIST_DIRECTORY);
1133 void unset_player_playlist_directory () {
1134 if (!_player_playlist_directory) {
1137 _player_playlist_directory = boost::none;
1138 changed (PLAYER_PLAYLIST_DIRECTORY);
1141 void set_player_kdm_directory (boost::filesystem::path p) {
1142 maybe_set (_player_kdm_directory, p);
1145 void unset_player_kdm_directory () {
1146 if (!_player_kdm_directory) {
1149 _player_kdm_directory = boost::none;
1153 void set_audio_mapping (AudioMapping m);
1154 void set_audio_mapping_to_default ();
1156 void add_custom_language (dcp::LanguageTag tag);
1158 void set_initial_path(std::string id, boost::filesystem::path path);
1160 void set_use_isdcf_name_by_default (bool use) {
1161 maybe_set (_use_isdcf_name_by_default, use);
1164 void set_write_kdms_to_disk (bool write) {
1165 maybe_set (_write_kdms_to_disk, write);
1168 void set_email_kdms (bool email) {
1169 maybe_set (_email_kdms, email);
1172 void set_default_kdm_type (dcp::Formulation type) {
1173 maybe_set (_default_kdm_type, type);
1176 void set_default_kdm_duration (RoughDuration duration) {
1177 maybe_set (_default_kdm_duration, duration);
1180 void set_auto_crop_threshold (double threshold) {
1181 maybe_set (_auto_crop_threshold, threshold, AUTO_CROP_THRESHOLD);
1184 void set_last_release_notes_version (std::string version) {
1185 maybe_set (_last_release_notes_version, version);
1188 void unset_last_release_notes_version() {
1189 maybe_set(_last_release_notes_version, boost::optional<std::string>());
1192 ExportConfig& export_config() {
1196 void set_main_divider_sash_position(int position) {
1197 maybe_set(_main_divider_sash_position, position);
1200 void set_main_content_divider_sash_position(int position) {
1201 maybe_set(_main_content_divider_sash_position, position);
1204 void set_default_add_file_location(DefaultAddFileLocation location) {
1205 maybe_set(_default_add_file_location, location);
1208 void set_allow_smpte_bv20(bool allow) {
1209 maybe_set(_allow_smpte_bv20, allow, ALLOW_SMPTE_BV20);
1212 #ifdef DCPOMATIC_GROK
1213 void set_grok(Grok const& grok);
1216 void set_isdcf_name_part_length(int length) {
1217 maybe_set(_isdcf_name_part_length, length, ISDCF_NAME_PART_LENGTH);
1220 void set_enable_player_http_server(bool enable) {
1221 maybe_set(_enable_player_http_server, enable);
1224 void set_player_http_server_port(int port) {
1225 maybe_set(_player_http_server_port, port);
1229 void changed (Property p = OTHER);
1230 boost::signals2::signal<void (Property)> Changed;
1231 /** Emitted if read() failed on an existing Config file. There is nothing
1232 a listener can do about it: this is just for information.
1234 enum class LoadFailure {
1237 static boost::signals2::signal<void (LoadFailure)> FailedToLoad;
1238 /** Emitted if read() issued a warning which the user might want to know about */
1239 static boost::signals2::signal<void (std::string)> Warning;
1240 /** Emitted if there is a something wrong the contents of our config. Handler can call
1241 * true to ask Config to solve the problem (by discarding and recreating the bad thing)
1244 BAD_SIGNER_UTF8_STRINGS, ///< signer chain contains UTF-8 strings (not PRINTABLESTRING)
1245 BAD_SIGNER_INCONSISTENT, ///< signer chain is somehow inconsistent
1246 BAD_DECRYPTION_INCONSISTENT, ///< KDM decryption chain is somehow inconsistent
1247 BAD_SIGNER_VALIDITY_TOO_LONG, ///< signer certificate validity periods are >10 years
1248 BAD_SIGNER_DN_QUALIFIER, ///< some signer certificate has a bad dnQualifier (DoM #2716).
1251 static boost::signals2::signal<bool (BadReason)> Bad;
1253 void write () const override;
1254 void write_config () const;
1255 void link (boost::filesystem::path new_file) const;
1256 void copy_and_link (boost::filesystem::path new_file) const;
1257 bool have_write_permission () const;
1259 void save_default_template(std::shared_ptr<const Film> film) const;
1260 void save_template (std::shared_ptr<const Film> film, std::string name) const;
1261 bool existing_template (std::string name) const;
1262 /** @return Template names (not including the default) */
1263 std::vector<std::string> templates() const;
1264 boost::filesystem::path template_read_path (std::string name) const;
1265 boost::filesystem::path default_template_read_path() const;
1266 void rename_template (std::string old_name, std::string new_name) const;
1267 void delete_template (std::string name) const;
1269 boost::optional<BadReason> check_certificates () const;
1271 static Config* instance ();
1272 static void drop ();
1273 static void restore_defaults ();
1274 static bool have_existing (std::string);
1275 static boost::filesystem::path config_read_file ();
1276 static boost::filesystem::path config_write_file ();
1277 static bool zip_contains_cinemas(boost::filesystem::path zip);
1278 static boost::filesystem::path cinemas_file_from_zip(boost::filesystem::path zip);
1282 void maybe_set (T& member, T new_value, Property prop = OTHER) {
1283 if (member == new_value) {
1291 void maybe_set (boost::optional<T>& member, T new_value, Property prop = OTHER) {
1292 if (member && member.get() == new_value) {
1301 void read () override;
1302 void set_defaults ();
1303 void set_kdm_email_to_default ();
1304 void set_notification_email_to_default ();
1305 void set_cover_sheet_to_default ();
1306 std::shared_ptr<dcp::CertificateChain> create_certificate_chain ();
1307 boost::filesystem::path directory_or (boost::optional<boost::filesystem::path> dir, boost::filesystem::path a) const;
1308 void add_to_history_internal (std::vector<boost::filesystem::path>& h, boost::filesystem::path p);
1309 void clean_history_internal (std::vector<boost::filesystem::path>& h);
1311 boost::filesystem::path template_write_path(std::string name) const;
1313 /** number of threads which a master DoM should use for J2K encoding on the local machine */
1314 int _master_encoding_threads;
1315 /** number of threads which a server should use for J2K encoding on the local machine */
1316 int _server_encoding_threads;
1317 /** default directory to put new films in */
1318 boost::optional<boost::filesystem::path> _default_directory;
1319 /** base port number to use for J2K encoding servers;
1320 * this port and the two above it will be used.
1322 int _server_port_base;
1323 /** true to broadcast on the `any' address to look for servers */
1324 bool _use_any_servers;
1325 /** J2K encoding servers that should definitely be used */
1326 std::vector<std::string> _servers;
1327 bool _only_servers_encode;
1328 FileTransferProtocol _tms_protocol;
1330 /** The IP address of a TMS that we can copy DCPs to */
1331 std::string _tms_ip;
1332 /** The path on a TMS that we should write DCPs to */
1333 std::string _tms_path;
1334 /** User name to log into the TMS with */
1335 std::string _tms_user;
1336 /** Password to log into the TMS with */
1337 std::string _tms_password;
1338 /** The list of possible DCP frame rates that DCP-o-matic will use */
1339 std::list<int> _allowed_dcp_frame_rates;
1340 /** Allow any video frame rate for the DCP; if true, overrides _allowed_dcp_frame_rates */
1341 bool _allow_any_dcp_frame_rate;
1342 /** Allow any container ratio, not just the standard ones. GDC SX-2001 will not play Flat
1343 DCPs at 25fps but will play 16:9, so this is very useful for some users.
1344 https://www.dcpomatic.com/forum/viewtopic.php?f=2&t=1119&p=4468
1346 bool _allow_any_container;
1347 bool _allow_96khz_audio;
1348 bool _use_all_audio_channels;
1349 /** Offer the upmixers in the audio processor settings */
1350 bool _show_experimental_audio_processors;
1351 boost::optional<std::string> _language;
1352 /** Default length of still image content (seconds) */
1353 int _default_still_length;
1354 DCPContentType const * _default_dcp_content_type;
1355 int _default_dcp_audio_channels;
1356 std::string _dcp_issuer;
1357 std::string _dcp_creator;
1358 std::string _dcp_company_name;
1359 std::string _dcp_product_name;
1360 std::string _dcp_product_version;
1361 std::string _dcp_j2k_comment;
1362 EnumIndexedVector<int64_t, VideoEncoding> _default_video_bit_rate;
1363 int _default_audio_delay;
1364 bool _default_interop;
1365 boost::optional<dcp::LanguageTag> _default_audio_language;
1366 boost::optional<dcp::LanguageTag::RegionSubtag> _default_territory;
1367 std::map<std::string, std::string> _default_metadata;
1368 /** Default directory to offer to write KDMs to; if it's not set,
1369 the home directory will be offered.
1371 boost::optional<boost::filesystem::path> _default_kdm_directory;
1372 bool _upload_after_make_dcp;
1373 std::string _mail_server;
1375 EmailProtocol _mail_protocol;
1376 std::string _mail_user;
1377 std::string _mail_password;
1378 std::string _kdm_subject;
1379 std::string _kdm_from;
1380 std::vector<std::string> _kdm_cc;
1381 std::string _kdm_bcc;
1382 std::string _kdm_email;
1383 std::string _notification_subject;
1384 std::string _notification_from;
1385 std::string _notification_to;
1386 std::vector<std::string> _notification_cc;
1387 std::string _notification_bcc;
1388 std::string _notification_email;
1389 std::shared_ptr<const dcp::CertificateChain> _signer_chain;
1390 /** Chain used to decrypt KDMs; the leaf of this chain is the target
1391 * certificate for making KDMs given to DCP-o-matic.
1393 std::shared_ptr<const dcp::CertificateChain> _decryption_chain;
1394 /** true to check for updates on startup */
1395 bool _check_for_updates;
1396 bool _check_for_test_updates;
1397 /** maximum allowed video bit rate in bits per second */
1398 EnumIndexedVector<int64_t, VideoEncoding> _maximum_video_bit_rate;
1400 bool _analyse_ebur128;
1401 bool _automatic_audio_analysis;
1402 #ifdef DCPOMATIC_WINDOWS
1403 bool _win32_console;
1405 std::vector<boost::filesystem::path> _history;
1406 std::vector<boost::filesystem::path> _player_history;
1407 std::shared_ptr<DKDMGroup> _dkdms;
1408 boost::filesystem::path _cinemas_file;
1409 boost::filesystem::path _dkdm_recipients_file;
1410 bool _show_hints_before_make_dcp;
1411 bool _confirm_kdm_email;
1412 dcp::NameFormat _kdm_filename_format;
1413 dcp::NameFormat _dkdm_filename_format;
1414 dcp::NameFormat _kdm_container_name_format;
1415 dcp::NameFormat _dcp_metadata_filename_format;
1416 dcp::NameFormat _dcp_asset_filename_format;
1417 bool _jump_to_selected;
1418 bool _nagged[NAG_COUNT];
1420 /** name of a specific sound output stream to use, or empty to use the default */
1421 boost::optional<std::string> _sound_output;
1422 std::string _cover_sheet;
1423 boost::optional<boost::filesystem::path> _last_player_load_directory;
1424 boost::optional<KDMWriteType> _last_kdm_write_type;
1425 boost::optional<DKDMWriteType> _last_dkdm_write_type;
1426 int _frames_in_memory_multiplier;
1427 boost::optional<int> _decode_reduction;
1428 bool _default_notify;
1429 bool _notification[NOTIFICATION_COUNT];
1430 boost::optional<std::string> _barco_username;
1431 boost::optional<std::string> _barco_password;
1432 boost::optional<std::string> _christie_username;
1433 boost::optional<std::string> _christie_password;
1434 boost::optional<std::string> _gdc_username;
1435 boost::optional<std::string> _gdc_password;
1436 PlayerMode _player_mode;
1437 bool _player_restricted_menus = false;
1438 bool _playlist_editor_restricted_menus = false;
1440 VideoViewType _video_view_type;
1441 bool _respect_kdm_validity_periods;
1442 /** Log file containing debug information for the player */
1443 boost::optional<boost::filesystem::path> _player_debug_log_file;
1444 /** A directory containing DCPs whose contents are presented to the user
1445 in the dual-screen player mode. DCPs on the list can be loaded
1448 boost::optional<boost::filesystem::path> _player_content_directory;
1449 boost::optional<boost::filesystem::path> _player_playlist_directory;
1450 boost::optional<boost::filesystem::path> _player_kdm_directory;
1451 boost::optional<AudioMapping> _audio_mapping;
1452 std::vector<dcp::LanguageTag> _custom_languages;
1453 std::map<std::string, boost::optional<boost::filesystem::path>> _initial_paths;
1454 bool _use_isdcf_name_by_default;
1455 bool _write_kdms_to_disk;
1457 dcp::Formulation _default_kdm_type;
1458 RoughDuration _default_kdm_duration;
1459 double _auto_crop_threshold;
1460 boost::optional<std::string> _last_release_notes_version;
1461 boost::optional<int> _main_divider_sash_position;
1462 boost::optional<int> _main_content_divider_sash_position;
1463 DefaultAddFileLocation _default_add_file_location;
1464 bool _allow_smpte_bv20;
1465 int _isdcf_name_part_length;
1466 bool _enable_player_http_server;
1467 int _player_http_server_port;
1469 #ifdef DCPOMATIC_GROK
1470 boost::optional<Grok> _grok;
1473 ExportConfig _export;
1475 static int const _current_version;
1477 /** Singleton instance, or 0 */
1478 static Config* _instance;