summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-06-04 00:26:56 +0200
committerCarl Hetherington <cth@carlh.net>2022-06-06 23:10:58 +0200
commitfcba100f0dfd1d4214291abb76f22ebd696c24d4 (patch)
treed31225dbe78d324615a55e0abdbd0f6b1740e2c4 /src/lib
parent7b30ec45f8d3d2881d633356058628373eb47057 (diff)
Preserve export video settings in the config (#2259).
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/config.cc7
-rw-r--r--src/lib/config.h38
-rw-r--r--src/lib/export_config.cc135
-rw-r--r--src/lib/export_config.h79
-rw-r--r--src/lib/wscript1
5 files changed, 245 insertions, 15 deletions
diff --git a/src/lib/config.cc b/src/lib/config.cc
index 3661d8ba5..caea995be 100644
--- a/src/lib/config.cc
+++ b/src/lib/config.cc
@@ -79,6 +79,7 @@ Config::Config ()
/* DKDMs are not considered a thing to reset on set_defaults() */
: _dkdms (new DKDMGroup ("root"))
, _default_kdm_duration (1, RoughDuration::Unit::WEEKS)
+ , _export(this)
{
set_defaults ();
}
@@ -203,6 +204,8 @@ Config::set_defaults ()
set_kdm_email_to_default ();
set_notification_email_to_default ();
set_cover_sheet_to_default ();
+
+ _export.set_defaults();
}
void
@@ -589,6 +592,8 @@ try
}
_auto_crop_threshold = f.optional_number_child<double>("AutoCropThreshold").get_value_or(0.1);
+ _export.read(f.optional_node_child("Export"));
+
if (boost::filesystem::exists (_cinemas_file)) {
cxml::Document f ("Cinemas");
f.read_file (_cinemas_file);
@@ -1026,6 +1031,8 @@ Config::write_config () const
root->add_child("DefaultKDMType")->add_child_text(dcp::formulation_to_string(_default_kdm_type));
root->add_child("AutoCropThreshold")->add_child_text(raw_convert<string>(_auto_crop_threshold));
+ _export.write(root->add_child("Export"));
+
auto target = config_write_file();
try {
diff --git a/src/lib/config.h b/src/lib/config.h
index e425a976c..9c3650f8d 100644
--- a/src/lib/config.h
+++ b/src/lib/config.h
@@ -28,6 +28,7 @@
#include "audio_mapping.h"
+#include "export_config.h"
#include "rough_duration.h"
#include "state.h"
#include "types.h"
@@ -1113,6 +1114,10 @@ public:
maybe_set (_auto_crop_threshold, threshold, AUTO_CROP_THRESHOLD);
}
+ ExportConfig& export_config() {
+ return _export;
+ }
+
void changed (Property p = OTHER);
boost::signals2::signal<void (Property)> Changed;
/** Emitted if read() failed on an existing Config file. There is nothing
@@ -1158,21 +1163,6 @@ public:
static boost::filesystem::path config_read_file ();
static boost::filesystem::path config_write_file ();
-private:
- Config ();
- void read () override;
- void set_defaults ();
- void set_kdm_email_to_default ();
- void set_notification_email_to_default ();
- void set_cover_sheet_to_default ();
- void read_cinemas (cxml::Document const & f);
- void read_dkdm_recipients (cxml::Document const & f);
- std::shared_ptr<dcp::CertificateChain> create_certificate_chain ();
- boost::filesystem::path directory_or (boost::optional<boost::filesystem::path> dir, boost::filesystem::path a) const;
- void add_to_history_internal (std::vector<boost::filesystem::path>& h, boost::filesystem::path p);
- void clean_history_internal (std::vector<boost::filesystem::path>& h);
- void backup ();
-
template <class T>
void maybe_set (T& member, T new_value, Property prop = OTHER) {
if (member == new_value) {
@@ -1191,6 +1181,21 @@ private:
changed (prop);
}
+private:
+ Config ();
+ void read () override;
+ void set_defaults ();
+ void set_kdm_email_to_default ();
+ void set_notification_email_to_default ();
+ void set_cover_sheet_to_default ();
+ void read_cinemas (cxml::Document const & f);
+ void read_dkdm_recipients (cxml::Document const & f);
+ std::shared_ptr<dcp::CertificateChain> create_certificate_chain ();
+ boost::filesystem::path directory_or (boost::optional<boost::filesystem::path> dir, boost::filesystem::path a) const;
+ void add_to_history_internal (std::vector<boost::filesystem::path>& h, boost::filesystem::path p);
+ void clean_history_internal (std::vector<boost::filesystem::path>& h);
+ void backup ();
+
/** number of threads which a master DoM should use for J2K encoding on the local machine */
int _master_encoding_threads;
/** number of threads which a server should use for J2K encoding on the local machine */
@@ -1336,10 +1341,13 @@ private:
RoughDuration _default_kdm_duration;
double _auto_crop_threshold;
+ ExportConfig _export;
+
static int const _current_version;
/** Singleton instance, or 0 */
static Config* _instance;
};
+
#endif
diff --git a/src/lib/export_config.cc b/src/lib/export_config.cc
new file mode 100644
index 000000000..6c9807935
--- /dev/null
+++ b/src/lib/export_config.cc
@@ -0,0 +1,135 @@
+/*
+ Copyright (C) 2022 Carl Hetherington <cth@carlh.net>
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ DCP-o-matic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#include "config.h"
+#include "export_config.h"
+#include <dcp/raw_convert.h>
+#include <dcp/warnings.h>
+LIBDCP_DISABLE_WARNINGS
+#include <libxml++/libxml++.h>
+LIBDCP_ENABLE_WARNINGS
+
+
+using std::string;
+
+
+ExportConfig::ExportConfig(Config* parent)
+ : _config(parent)
+{
+
+}
+
+
+void
+ExportConfig::set_defaults()
+{
+ _format = ExportFormat::PRORES;
+ _mixdown_to_stereo = false;
+ _split_reels = false;
+ _split_streams = false;
+ _x264_crf = 23;
+}
+
+
+void
+ExportConfig::read(cxml::ConstNodePtr node)
+{
+ if (!node) {
+ set_defaults();
+ return;
+ }
+
+ auto const format = node->string_child("Format");
+
+ if (format == "subtitles-dcp") {
+ _format = ExportFormat::SUBTITLES_DCP;
+ } else if (format == "h264-aac") {
+ _format = ExportFormat::H264_AAC;
+ } else {
+ _format = ExportFormat::PRORES;
+ }
+
+ _mixdown_to_stereo = node->bool_child("MixdownToStereo");
+ _split_reels = node->bool_child("SplitReels");
+ _split_streams = node->bool_child("SplitStreams");
+ _x264_crf = node->number_child<int>("X264CRF");
+}
+
+
+void
+ExportConfig::write(xmlpp::Element* node) const
+{
+ string name;
+
+ switch (_format) {
+ case ExportFormat::PRORES:
+ name = "prores";
+ break;
+ case ExportFormat::H264_AAC:
+ name = "h264-aac";
+ break;
+ case ExportFormat::SUBTITLES_DCP:
+ name = "subtitles-dcp";
+ break;
+ }
+
+ node->add_child("Format")->add_child_text(name);
+ node->add_child("MixdownToStereo")->add_child_text(_mixdown_to_stereo ? "1" : "0");
+ node->add_child("SplitReels")->add_child_text(_split_reels ? "1" : "0");
+ node->add_child("SplitStreams")->add_child_text(_split_streams ? "1" : "0");
+ node->add_child("X264CRF")->add_child_text(dcp::raw_convert<string>(_x264_crf));
+}
+
+
+void
+ExportConfig::set_format(ExportFormat format)
+{
+ _config->maybe_set(_format, format);
+}
+
+
+void
+ExportConfig::set_mixdown_to_stereo(bool mixdown)
+{
+ _config->maybe_set(_mixdown_to_stereo, mixdown);
+}
+
+
+void
+ExportConfig::set_split_reels(bool split)
+{
+ _config->maybe_set(_split_reels, split);
+}
+
+
+void
+ExportConfig::set_split_streams(bool split)
+{
+ _config->maybe_set(_split_streams, split);
+}
+
+
+void
+ExportConfig::set_x264_crf(int crf)
+{
+ _config->maybe_set(_x264_crf, crf);
+}
+
diff --git a/src/lib/export_config.h b/src/lib/export_config.h
new file mode 100644
index 000000000..2b0ddfda2
--- /dev/null
+++ b/src/lib/export_config.h
@@ -0,0 +1,79 @@
+/*
+ Copyright (C) 2022 Carl Hetherington <cth@carlh.net>
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ DCP-o-matic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#ifndef DCPOMATIC_EXPORT_CONFIG_H
+#define DCPOMATIC_EXPORT_CONFIG_H
+
+
+#include "types.h"
+#include <libcxml/cxml.h>
+
+
+class Config;
+
+
+class ExportConfig
+{
+public:
+ ExportConfig(Config* parent);
+
+ void set_defaults();
+ void read(cxml::ConstNodePtr node);
+ void write(xmlpp::Element* node) const;
+
+ ExportFormat format() const {
+ return _format;
+ }
+
+ bool mixdown_to_stereo() const {
+ return _mixdown_to_stereo;
+ }
+
+ bool split_reels() const {
+ return _split_reels;
+ }
+
+ bool split_streams() const {
+ return _split_streams;
+ }
+
+ int x264_crf() const {
+ return _x264_crf;
+ }
+
+ void set_format(ExportFormat format);
+ void set_mixdown_to_stereo(bool mixdown);
+ void set_split_reels(bool split);
+ void set_split_streams(bool split);
+ void set_x264_crf(int crf);
+
+private:
+ Config* _config;
+ ExportFormat _format;
+ bool _mixdown_to_stereo;
+ bool _split_reels;
+ bool _split_streams;
+ int _x264_crf;
+};
+
+
+#endif
+
diff --git a/src/lib/wscript b/src/lib/wscript
index 7400c5bf1..f4e478219 100644
--- a/src/lib/wscript
+++ b/src/lib/wscript
@@ -95,6 +95,7 @@ sources = """
examine_content_job.cc
examine_ffmpeg_subtitles_job.cc
exceptions.cc
+ export_config.cc
file_group.cc
file_log.cc
filter_graph.cc