X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fconfig.cc;h=6ec3b0588fcfcd0c47a22b4fd2099fe18c00e630;hb=0aabb6497979e2df9731f8753645149d85c02bc8;hp=c0750bb4eeb3d35d61db716135444c90be85fb20;hpb=8fedaaa75c4586a4cc7ffb393bd71d1fdb091dc8;p=dcpomatic.git diff --git a/src/lib/config.cc b/src/lib/config.cc index c0750bb4e..6ec3b0588 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -175,6 +175,8 @@ Config::set_defaults () _player_playlist_directory = boost::none; _player_kdm_directory = boost::none; _audio_mapping = boost::none; + _minimum_frame_size = 65536; + _custom_languages.clear (); _allowed_dcp_frame_rates.clear (); _allowed_dcp_frame_rates.push_back (24); @@ -307,12 +309,6 @@ try _dcp_product_version = f.optional_string_child("DCPProductVersion").get_value_or(""); _dcp_j2k_comment = f.optional_string_child("DCPJ2KComment").get_value_or(""); - if (version && version.get() >= 2) { - _default_isdcf_metadata = ISDCFMetadata (f.node_child ("ISDCFMetadata")); - } else { - _default_isdcf_metadata = ISDCFMetadata (f.node_child ("DCIMetadata")); - } - _default_still_length = f.optional_number_child("DefaultStillLength").get_value_or (10); _default_j2k_bandwidth = f.optional_number_child("DefaultJ2KBandwidth").get_value_or (200000000); _default_audio_delay = f.optional_number_child("DefaultAudioDelay").get_value_or (0); @@ -549,6 +545,17 @@ try _audio_mapping = AudioMapping (f.node_child("AudioMapping"), Film::current_state_version); } + _minimum_frame_size = f.optional_number_child("MinimumFrameSize").get_value_or(65536); + + for (auto i: f.node_children("CustomLanguage")) { + try { + /* This will fail if it's called before dcp::init() as it won't recognise the + * tag. That's OK because the Config will be reloaded again later. + */ + _custom_languages.push_back (dcp::LanguageTag(i->content())); + } catch (std::runtime_error& e) {} + } + if (boost::filesystem::exists (_cinemas_file)) { cxml::Document f ("Cinemas"); f.read_file (_cinemas_file); @@ -662,7 +669,7 @@ Config::write_config () const root->add_child("DefaultDCPAudioChannels")->add_child_text (raw_convert (_default_dcp_audio_channels)); /* [XML] DCPIssuer Issuer text to write into CPL files. */ root->add_child("DCPIssuer")->add_child_text (_dcp_issuer); - /* [XML] DCPIssuer Creator text to write into CPL files. */ + /* [XML] DCPCreator Creator text to write into CPL files. */ root->add_child("DCPCreator")->add_child_text (_dcp_creator); /* [XML] Company name to write into MXF files. */ root->add_child("DCPCompanyName")->add_child_text (_dcp_company_name); @@ -675,14 +682,6 @@ Config::write_config () const /* [XML] UploadAfterMakeDCP 1 to upload to a TMS after making a DCP, 0 for no upload. */ root->add_child("UploadAfterMakeDCP")->add_child_text (_upload_after_make_dcp ? "1" : "0"); - /* [XML] ISDCFMetadata Default ISDCF metadata to use for new films; child tags are <ContentVersion>, - <AudioLanguage>, <SubtitleLanguage>, <Territory>, - <Rating>, <Studio>, <Facility>, <TempVersion>, - <PreRelease>, <RedBand>, <Chain>, <TwoDVersionOFThreeD>, - <MasteredLuminance>. - */ - _default_isdcf_metadata.as_xml (root->add_child ("ISDCFMetadata")); - /* [XML] DefaultStillLength Default length (in seconds) for still images in new films. */ root->add_child("DefaultStillLength")->add_child_text (raw_convert (_default_still_length)); /* [XML] DefaultJ2KBandwidth Default bitrate (in bits per second) for JPEG2000 data in new films. */ @@ -771,8 +770,13 @@ Config::write_config () const /* [XML] AutomaticAudioAnalysis 1 to run audio analysis automatically when audio content is added to the film, otherwise 0. */ root->add_child("AutomaticAudioAnalysis")->add_child_text (_automatic_audio_analysis ? "1" : "0"); #ifdef DCPOMATIC_WINDOWS - /* [XML] Win32Console 1 to open a console when running on Windows, otherwise 0. */ - root->add_child("Win32Console")->add_child_text (_win32_console ? "1" : "0"); + if (_win32_console) { + /* [XML] Win32Console 1 to open a console when running on Windows, otherwise 0. + * We only write this if it's true, which is a bit of a hack to allow unit tests to work + * more easily on Windows (without a platform-specific reference in config_write_utf8_test) + */ + root->add_child("Win32Console")->add_child_text ("1"); + } #endif /* [XML] Signer Certificate chain and private key to use when signing DCPs and KDMs. Should contain <Certificate> @@ -972,6 +976,10 @@ Config::write_config () const if (_audio_mapping) { _audio_mapping->as_xml (root->add_child("AudioMapping")); } + root->add_child("MinimumFrameSize")->add_child_text(raw_convert(_minimum_frame_size)); + for (auto const& i: _custom_languages) { + root->add_child("CustomLanguage")->add_child_text(i.to_string()); + } try { auto const s = doc.write_to_string_formatted (); @@ -980,7 +988,7 @@ Config::write_config () const if (!f) { throw FileError (_("Could not open file for writing"), tmp); } - checked_fwrite (s.c_str(), s.length(), f, tmp); + checked_fwrite (s.c_str(), s.bytes(), f, tmp); fclose (f); boost::filesystem::remove (config_file()); boost::filesystem::rename (tmp, config_file()); @@ -1411,3 +1419,14 @@ Config::set_audio_mapping_to_default () _audio_mapping = audio_mapping (ch); changed (AUDIO_MAPPING); } + + +void +Config::add_custom_language (dcp::LanguageTag tag) +{ + if (find(_custom_languages.begin(), _custom_languages.end(), tag) == _custom_languages.end()) { + _custom_languages.push_back (tag); + changed (); + } +} +