summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-06-05 00:32:00 +0200
committerCarl Hetherington <cth@carlh.net>2025-07-09 01:16:39 +0200
commit6ab6cd5a8c300c6db6f52bb9d74e5d7533976fe0 (patch)
tree7fc78ed20e356dd4842bd1491abdfd479f2c4b8e
parent202da27202bd644138ef4033cd2e4b6d752303b1 (diff)
Replace TMS upload with upload to any number of destinations.
-rw-r--r--src/lib/config.cc51
-rw-r--r--src/lib/config.h20
-rw-r--r--src/lib/dcp_transcode_job.cc12
-rw-r--r--src/lib/film.cc9
-rw-r--r--src/lib/film.h2
-rw-r--r--src/wx/full_config_dialog.cc95
-rw-r--r--src/wx/upload_destination_panel.cc25
-rw-r--r--src/wx/upload_destination_panel.h5
8 files changed, 83 insertions, 136 deletions
diff --git a/src/lib/config.cc b/src/lib/config.cc
index 42fd5d75a..36615a843 100644
--- a/src/lib/config.cc
+++ b/src/lib/config.cc
@@ -98,7 +98,6 @@ Config::set_defaults()
_use_any_servers = true;
_servers.clear();
_only_servers_encode = false;
- _tms = boost::none;
_allow_any_dcp_frame_rate = false;
_allow_any_container = false;
_allow_96khz_audio = false;
@@ -113,7 +112,6 @@ Config::set_defaults()
_default_audio_delay = 0;
_default_interop = false;
_default_metadata.clear();
- _upload_after_make_dcp = false;
_mail_server = "";
_mail_port = 25;
_mail_protocol = EmailProtocol::AUTO;
@@ -346,26 +344,36 @@ try
_only_servers_encode = f.optional_bool_child("OnlyServersEncode").get_value_or(false);
if (f.optional_string_child("TMSIP")) {
- _tms = UploadDestination(
- _("TMS"),
- static_cast<FileTransferProtocol>(f.optional_number_child<int>("TMSProtocol").get_value_or(static_cast<int>(FileTransferProtocol::SCP))),
- f.optional_bool_child("TMSPassive").get_value_or(true),
- boost::none,
- f.string_child("TMSIP"),
- f.string_child("TMSPath"),
- f.string_child("TMSUser"),
- f.string_child("TMSPassword")
+ _upload_destinations.push_back(
+ UploadDestination(
+ _("TMS"),
+ static_cast<FileTransferProtocol>(f.optional_number_child<int>("TMSProtocol").get_value_or(static_cast<int>(FileTransferProtocol::SCP))),
+ f.optional_bool_child("TMSPassive").get_value_or(true),
+ boost::none,
+ f.string_child("TMSIP"),
+ f.string_child("TMSPath"),
+ f.string_child("TMSUser"),
+ f.string_child("TMSPassword")
+ )
);
- }
- if (auto node = f.optional_node_child("TMS")) {
- _tms = UploadDestination(node);
+ auto up = f.optional_bool_child("UploadAfterMakeDCP");
+ if (!up) {
+ up = f.optional_bool_child("DefaultUploadAfterMakeDCP");
+ }
+ if (up && *up) {
+ _auto_upload_destinations.push_back(_("TMS"));
+ }
}
for (auto i: f.node_children("UploadDestination")) {
_upload_destinations.push_back(UploadDestination(i));
}
+ for (auto i: f.node_children("AutoUploadDestination")) {
+ _auto_upload_destinations.push_back(i->content());
+ }
+
_language = f.optional_string_child("Language");
_default_dcp_content_type = DCPContentType::from_isdcf_name(f.optional_string_child("DefaultDCPContentType").get_value_or("FTR"));
@@ -377,11 +385,6 @@ try
_dcp_issuer = f.string_child("DCPIssuer");
}
- auto up = f.optional_bool_child("UploadAfterMakeDCP");
- if (!up) {
- up = f.optional_bool_child("DefaultUploadAfterMakeDCP");
- }
- _upload_after_make_dcp = up.get_value_or(false);
_dcp_creator = f.optional_string_child("DCPCreator").get_value_or("");
_dcp_company_name = f.optional_string_child("DCPCompanyName").get_value_or("");
_dcp_product_name = f.optional_string_child("DCPProductName").get_value_or("");
@@ -789,12 +792,12 @@ Config::write_config() const
*/
cxml::add_text_child(root, "OnlyServersEncode", _only_servers_encode ? "1" : "0");
- if (_tms) {
- _tms->as_xml(cxml::add_child(root, "TMS"));
+ for (auto const& i: _upload_destinations) {
+ i.as_xml(cxml::add_child(root, "UploadDestination"));
}
- for (auto i: _upload_destinations) {
- i.as_xml(cxml::add_child(root, "UploadDestination"));
+ for (auto i: _auto_upload_destinations) {
+ cxml::add_text_child(root, "AutoUploadDestination", i);
}
if (_language) {
@@ -813,8 +816,6 @@ Config::write_config() const
cxml::add_text_child(root, "DCPProductVersion", _dcp_product_version);
/* [XML] DCPJ2KComment Comment to write into JPEG2000 data. */
cxml::add_text_child(root, "DCPJ2KComment", _dcp_j2k_comment);
- /* [XML] UploadAfterMakeDCP 1 to upload to a TMS after making a DCP, 0 for no upload. */
- cxml::add_text_child(root, "UploadAfterMakeDCP", _upload_after_make_dcp ? "1" : "0");
/* [XML] DefaultStillLength Default length (in seconds) for still images in new films. */
cxml::add_text_child(root, "DefaultStillLength", fmt::to_string(_default_still_length));
diff --git a/src/lib/config.h b/src/lib/config.h
index e33bfe3f3..722f2ae97 100644
--- a/src/lib/config.h
+++ b/src/lib/config.h
@@ -159,8 +159,8 @@ public:
return _upload_destinations;
}
- boost::optional<UploadDestination> tms() const {
- return _tms;
+ std::vector<std::string> auto_upload_destinations() const {
+ return _auto_upload_destinations;
}
std::list<int> allowed_dcp_frame_rates() const {
@@ -251,10 +251,6 @@ public:
return _default_metadata;
}
- bool upload_after_make_dcp() {
- return _upload_after_make_dcp;
- }
-
void set_default_kdm_directory(boost::filesystem::path d) {
if (_default_kdm_directory && _default_kdm_directory.get() == d) {
return;
@@ -705,9 +701,8 @@ public:
maybe_set(_upload_destinations, destinations);
}
- void set_tms(UploadDestination tms) {
- _tms = tms;
- changed();
+ void set_auto_upload_destinations(std::vector<std::string> const& destinations) {
+ maybe_set(_auto_upload_destinations, destinations);
}
void set_allowed_dcp_frame_rates(std::list<int> const & r) {
@@ -791,10 +786,6 @@ public:
maybe_set(_default_audio_language, boost::optional<dcp::LanguageTag>());
}
- void set_upload_after_make_dcp(bool u) {
- maybe_set(_upload_after_make_dcp, u);
- }
-
void set_mail_server(std::string s) {
maybe_set(_mail_server, s);
}
@@ -1328,7 +1319,7 @@ private:
std::vector<std::string> _servers;
bool _only_servers_encode;
std::vector<UploadDestination> _upload_destinations;
- boost::optional<UploadDestination> _tms;
+ std::vector<std::string> _auto_upload_destinations;
/** The list of possible DCP frame rates that DCP-o-matic will use */
std::list<int> _allowed_dcp_frame_rates;
/** Allow any video frame rate for the DCP; if true, overrides _allowed_dcp_frame_rates */
@@ -1363,7 +1354,6 @@ private:
the home directory will be offered.
*/
boost::optional<boost::filesystem::path> _default_kdm_directory;
- bool _upload_after_make_dcp;
std::string _mail_server;
int _mail_port;
EmailProtocol _mail_protocol;
diff --git a/src/lib/dcp_transcode_job.cc b/src/lib/dcp_transcode_job.cc
index 55e88e646..f93a7b3db 100644
--- a/src/lib/dcp_transcode_job.cc
+++ b/src/lib/dcp_transcode_job.cc
@@ -46,8 +46,16 @@ DCPTranscodeJob::DCPTranscodeJob (shared_ptr<const Film> film, ChangedBehaviour
void
DCPTranscodeJob::post_transcode ()
{
- if (Config::instance()->upload_after_make_dcp() && Config::instance()->tms()) {
- JobManager::instance()->add(make_shared<UploadJob>(_film, *Config::instance()->tms()));
+ auto destinations = Config::instance()->upload_destinations();
+ for (auto name: Config::instance()->auto_upload_destinations()) {
+ auto iter = std::find_if(
+ destinations.begin(),
+ destinations.end(),
+ [name](UploadDestination const& dest) { return dest.name == name; }
+ );
+ if (iter != destinations.end()) {
+ JobManager::instance()->add(make_shared<UploadJob>(_film, *iter));
+ }
}
/* The first directory is the project's DCP, so the first CPL will also be from the project
diff --git a/src/lib/film.cc b/src/lib/film.cc
index 36af31bf1..96c985968 100644
--- a/src/lib/film.cc
+++ b/src/lib/film.cc
@@ -376,15 +376,6 @@ Film::subtitle_analysis_path(shared_ptr<const Content> content) const
}
-/** Start a job to send our DCP to the configured TMS */
-void
-Film::send_dcp_to_tms()
-{
- if (Config::instance()->tms()) {
- JobManager::instance()->add(make_shared<UploadJob>(shared_from_this(), *Config::instance()->tms()));
- }
-}
-
shared_ptr<xmlpp::Document>
Film::metadata(bool with_content_paths) const
{
diff --git a/src/lib/film.h b/src/lib/film.h
index 1af21849e..4a5bb0b94 100644
--- a/src/lib/film.h
+++ b/src/lib/film.h
@@ -107,8 +107,6 @@ public:
boost::filesystem::path subtitle_analysis_path(std::shared_ptr<const Content>) const;
boost::filesystem::path assets_path() const;
- void send_dcp_to_tms();
-
/** @return Logger.
* It is safe to call this from any thread.
*/
diff --git a/src/wx/full_config_dialog.cc b/src/wx/full_config_dialog.cc
index d4d7af686..71084f79b 100644
--- a/src/wx/full_config_dialog.cc
+++ b/src/wx/full_config_dialog.cc
@@ -53,6 +53,7 @@
#ifdef DCPOMATIC_GROK
#include "grok/gpu_config_panel.h"
#endif
+#include "upload_destination_panel.h"
#include "wx_util.h"
#include "wx_variant.h"
#include "lib/config.h"
@@ -535,98 +536,32 @@ public:
private:
void setup() override
{
- _upload = new CheckBox(_panel, _("Upload DCP to TMS after creation"));
- _panel->GetSizer()->Add(_upload, 0, wxALL | wxEXPAND, _border);
+ add_label_to_sizer(_panel->GetSizer(), _panel, _("Upload DCP after creation to"), true, 0, wxALL);
- wxFlexGridSizer* table = new wxFlexGridSizer(2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
- table->AddGrowableCol(1, 1);
- _panel->GetSizer()->Add(table, 1, wxALL | wxEXPAND, _border);
-
- add_label_to_sizer(table, _panel, _("Protocol"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL);
- _tms_protocol = new wxChoice(_panel, wxID_ANY);
- table->Add(_tms_protocol, 1, wxEXPAND);
-
- _tms_passive = new CheckBox(_panel, _("Passive mode"));
- table->Add(_tms_passive, 1, wxEXPAND);
- table->AddSpacer(0);
-
- add_label_to_sizer(table, _panel, _("IP address"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL);
- _tms_ip = new wxTextCtrl(_panel, wxID_ANY);
- table->Add(_tms_ip, 1, wxEXPAND);
-
- add_label_to_sizer(table, _panel, _("Target path"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL);
- _tms_path = new wxTextCtrl(_panel, wxID_ANY);
- table->Add(_tms_path, 1, wxEXPAND);
-
- add_label_to_sizer(table, _panel, _("User name"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL);
- _tms_user = new wxTextCtrl(_panel, wxID_ANY);
- table->Add(_tms_user, 1, wxEXPAND);
-
- add_label_to_sizer(table, _panel, _("Password"), true, 0, wxLEFT | wxRIGHT | wxALIGN_CENTRE_VERTICAL);
- _tms_password = new PasswordEntry(_panel);
- table->Add(_tms_password->get_panel(), 1, wxEXPAND);
-
- _tms_protocol->Append(_("SCP (for AAM and Doremi)"));
- _tms_protocol->Append(_("FTP (for Dolby)"));
+ _destinations = new UploadDestinationPanel(_panel);
+ _panel->GetSizer()->Add(_destinations, 1, wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND, DCPOMATIC_SIZER_GAP);
- _upload->bind(&UploadPage::upload_changed, this);
- _tms_protocol->Bind(wxEVT_CHOICE, boost::bind(&UploadPage::tms_changed, this));
- _tms_passive->bind(&UploadPage::tms_changed, this);
-
- _tms_ip->Bind(wxEVT_TEXT, boost::bind(&UploadPage::tms_changed, this));
- _tms_path->Bind(wxEVT_TEXT, boost::bind(&UploadPage::tms_changed, this));
- _tms_user->Bind(wxEVT_TEXT, boost::bind(&UploadPage::tms_changed, this));
- _tms_password->Changed.connect(boost::bind(&UploadPage::tms_changed, this));
+ _destinations->DestinationsChanged.connect(boost::bind(&UploadPage::destinations_changed, this));
}
void config_changed() override
{
- auto config = Config::instance();
-
- checked_set(_upload, config->upload_after_make_dcp());
- if (auto tms = Config::instance()->tms()) {
- checked_set(_tms_protocol, static_cast<int>(tms->protocol));
- checked_set(_tms_passive, tms->protocol == FileTransferProtocol::FTP && tms->passive_ftp);
- checked_set(_tms_ip, tms->host);
- checked_set(_tms_path, tms->path);
- checked_set(_tms_user, tms->user);
- checked_set(_tms_password, tms->password);
- } else {
- checked_set(_tms_protocol, static_cast<int>(FileTransferProtocol::FTP));
- checked_set(_tms_passive, false);
- checked_set(_tms_ip, "");
- checked_set(_tms_path, "");
- checked_set(_tms_user, "");
- checked_set(_tms_password, "");
- }
+ _destinations->set_upload_destinations(Config::instance()->upload_destinations());
+ _destinations->enable_upload_destinations(Config::instance()->auto_upload_destinations());
}
- void upload_changed()
+ void destinations_changed()
{
- Config::instance()->set_upload_after_make_dcp(_upload->GetValue());
+ vector<string> names;
+ for (auto const& destination: _destinations->destinations()) {
+ names.push_back(destination.name);
+ }
+ Config::instance()->set_auto_upload_destinations(names);
}
- void tms_changed()
- {
- Config::instance()->set_tms({
- wx_to_std(_("TMS")),
- static_cast<FileTransferProtocol>(_tms_protocol->GetSelection()),
- _tms_passive->get(),
- boost::none,
- wx_to_std(_tms_ip->GetValue()),
- wx_to_std(_tms_path->GetValue()),
- wx_to_std(_tms_user->GetValue()),
- _tms_password->get()
- });
- }
+private:
+ UploadDestinationPanel* _destinations;
- CheckBox* _upload;
- CheckBox* _tms_passive;
- wxChoice* _tms_protocol;
- wxTextCtrl* _tms_ip;
- wxTextCtrl* _tms_path;
- wxTextCtrl* _tms_user;
- PasswordEntry* _tms_password;
};
diff --git a/src/wx/upload_destination_panel.cc b/src/wx/upload_destination_panel.cc
index 6465400d9..3e9ffc47e 100644
--- a/src/wx/upload_destination_panel.cc
+++ b/src/wx/upload_destination_panel.cc
@@ -41,9 +41,7 @@ UploadDestinationPanel::UploadDestinationPanel(wxWindow* parent)
_list = new wxTreeListCtrl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTL_NO_HEADER | wxTL_3STATE);
_list->AppendColumn(char_to_wx("foo"), 640);
- for (auto destination: Config::instance()->upload_destinations()) {
- add_destination(destination);
- }
+ set_upload_destinations(Config::instance()->upload_destinations());
auto buttons = new wxBoxSizer(wxVERTICAL);
@@ -187,3 +185,24 @@ UploadDestinationPanel::destinations() const
return checked;
}
+
+void
+UploadDestinationPanel::set_upload_destinations(vector<UploadDestination> const& destinations)
+{
+ _list->DeleteAllItems();
+ _destinations.clear();
+
+ for (auto destination: destinations) {
+ add_destination(destination);
+ }
+}
+
+
+void
+UploadDestinationPanel::enable_upload_destinations(vector<string> const& names)
+{
+ for (auto const& dest: _destinations) {
+ _list->CheckItem(dest.first, std::find(names.begin(), names.end(), dest.second.name) != names.end() ? wxCHK_CHECKED : wxCHK_UNCHECKED);
+ }
+}
+
diff --git a/src/wx/upload_destination_panel.h b/src/wx/upload_destination_panel.h
index fb2fee99e..3ea3694b3 100644
--- a/src/wx/upload_destination_panel.h
+++ b/src/wx/upload_destination_panel.h
@@ -37,6 +37,11 @@ public:
/** @return ticked, i.e. "enabled" destinations */
std::vector<UploadDestination> destinations() const;
+ void set_upload_destinations(std::vector<UploadDestination> const& destinations);
+
+ /** Specify a list of upload destination names to enable (tick) */
+ void enable_upload_destinations(std::vector<std::string> const& names);
+
boost::signals2::signal<void ()> DestinationsChanged;
private: