summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-02-19 23:22:31 +0100
committerCarl Hetherington <cth@carlh.net>2024-02-19 23:22:31 +0100
commit51dda295b5bd63e6635ae17786e4657c41a3678a (patch)
tree77e57cb29e188d3b66f9d60c11b5ed6176ad4c93
parent8af709285d056476933dbfaf63c9b2121fbd4ce8 (diff)
parentf23b9491dcd25d02f7966f39dfdbb0ad998aa5ad (diff)
Merge tag 'v2.16.77' into v2.17.x
-rw-r--r--DEVELOP.md2
-rw-r--r--cscript2
-rw-r--r--src/lib/config.cc40
-rw-r--r--src/lib/config.h2
-rw-r--r--src/lib/unzipper.cc89
-rw-r--r--src/lib/unzipper.h43
-rw-r--r--src/lib/wscript1
-rw-r--r--src/lib/zipper.h2
-rw-r--r--src/tools/dcpomatic.cc18
-rw-r--r--src/tools/dcpomatic_cli.cc3
-rw-r--r--src/wx/simple_video_view.cc18
-rw-r--r--src/wx/supporters.cc3
-rw-r--r--test/unzipper_test.cc59
-rw-r--r--test/wscript1
14 files changed, 265 insertions, 18 deletions
diff --git a/DEVELOP.md b/DEVELOP.md
index 3ba1eeac2..be8ed61e6 100644
--- a/DEVELOP.md
+++ b/DEVELOP.md
@@ -29,7 +29,7 @@ As we have no `film' folder to log to during disk writes, the logs end up:
The main dcpomatic repo has the following branches:
* `main` - the main development branch; contains 2.16.x versions
-* `v2.17.x` - development branch for v2.17.x versions; periodically rebased onto `main`
+* `v2.17.x` - development branch for v2.17.x versions; `main` is merged into this branch.
The `test/data` submodule has the following branches:
diff --git a/cscript b/cscript
index e3a3f26e2..af1db69a6 100644
--- a/cscript
+++ b/cscript
@@ -507,7 +507,7 @@ def dependencies(target, options):
# Use distro-provided FFmpeg on Arch
deps = []
- deps.append(('libdcp', 'v1.8.96'))
+ deps.append(('libdcp', 'v1.8.97'))
deps.append(('libsub', 'v1.6.47'))
deps.append(('leqm-nrt', '30dcaea1373ac62fba050e02ce5b0c1085797a23'))
deps.append(('rtaudio', 'f619b76'))
diff --git a/src/lib/config.cc b/src/lib/config.cc
index 530834bc7..8dce6237a 100644
--- a/src/lib/config.cc
+++ b/src/lib/config.cc
@@ -32,6 +32,7 @@
#include "filter.h"
#include "log.h"
#include "ratio.h"
+#include "unzipper.h"
#include "zipper.h"
#include <dcp/certificate_chain.h>
#include <dcp/name_format.h>
@@ -196,6 +197,7 @@ Config::set_defaults ()
_initial_paths["DebugLogPath"] = boost::none;
_initial_paths["CinemaDatabasePath"] = boost::none;
_initial_paths["ConfigFilePath"] = boost::none;
+ _initial_paths["Preferences"] = boost::none;
_use_isdcf_name_by_default = true;
_write_kdms_to_disk = true;
_email_kdms = false;
@@ -1235,7 +1237,7 @@ void
Config::drop ()
{
delete _instance;
- _instance = 0;
+ _instance = nullptr;
}
void
@@ -1648,6 +1650,38 @@ save_all_config_as_zip (boost::filesystem::path zip_file)
void
+Config::load_from_zip(boost::filesystem::path zip_file)
+{
+ Unzipper unzipper(zip_file);
+ dcp::write_string_to_file(unzipper.get("config.xml"), config_write_file());
+
+ try {
+ dcp::write_string_to_file(unzipper.get("cinemas.xml"), cinemas_file());
+ dcp::write_string_to_file(unzipper.get("dkdm_recipient.xml"), dkdm_recipients_file());
+ } catch (std::runtime_error&) {}
+
+ read();
+
+ changed(Property::USE_ANY_SERVERS);
+ changed(Property::SERVERS);
+ changed(Property::CINEMAS);
+ changed(Property::DKDM_RECIPIENTS);
+ changed(Property::SOUND);
+ changed(Property::SOUND_OUTPUT);
+ changed(Property::PLAYER_CONTENT_DIRECTORY);
+ changed(Property::PLAYER_PLAYLIST_DIRECTORY);
+ changed(Property::PLAYER_DEBUG_LOG);
+ changed(Property::HISTORY);
+ changed(Property::SHOW_EXPERIMENTAL_AUDIO_PROCESSORS);
+ changed(Property::AUDIO_MAPPING);
+ changed(Property::AUTO_CROP_THRESHOLD);
+ changed(Property::ALLOW_SMPTE_BV20);
+ changed(Property::ISDCF_NAME_PART_LENGTH);
+ changed(Property::OTHER);
+}
+
+
+void
Config::set_initial_path(string id, boost::filesystem::path path)
{
auto iter = _initial_paths.find(id);
@@ -1661,7 +1695,9 @@ optional<boost::filesystem::path>
Config::initial_path(string id) const
{
auto iter = _initial_paths.find(id);
- DCPOMATIC_ASSERT(iter != _initial_paths.end());
+ if (iter == _initial_paths.end()) {
+ return {};
+ }
return iter->second;
}
diff --git a/src/lib/config.h b/src/lib/config.h
index d990068ad..74b4316d2 100644
--- a/src/lib/config.h
+++ b/src/lib/config.h
@@ -79,6 +79,8 @@ public:
boost::filesystem::path default_directory_or (boost::filesystem::path a) const;
boost::filesystem::path default_kdm_directory_or (boost::filesystem::path a) const;
+ void load_from_zip(boost::filesystem::path zip_file);
+
enum Property {
USE_ANY_SERVERS,
SERVERS,
diff --git a/src/lib/unzipper.cc b/src/lib/unzipper.cc
new file mode 100644
index 000000000..2add8f2a9
--- /dev/null
+++ b/src/lib/unzipper.cc
@@ -0,0 +1,89 @@
+/*
+ Copyright (C) 2024 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 "dcpomatic_assert.h"
+#include "exceptions.h"
+#include "unzipper.h"
+#include <dcp/filesystem.h>
+#include <dcp/scope_guard.h>
+#include <zip.h>
+#include <boost/filesystem.hpp>
+#include <stdexcept>
+
+#include "i18n.h"
+
+
+using std::runtime_error;
+using std::shared_ptr;
+using std::string;
+
+
+Unzipper::Unzipper(boost::filesystem::path file)
+{
+ int error;
+ _zip = zip_open(dcp::filesystem::fix_long_path(file).string().c_str(), ZIP_RDONLY, &error);
+ if (!_zip) {
+ throw FileError("could not open ZIP file", file);
+ }
+}
+
+
+Unzipper::~Unzipper()
+{
+ zip_close(_zip);
+}
+
+
+string
+Unzipper::get(string const& filename)
+{
+ auto file = zip_fopen(_zip, filename.c_str(), 0);
+ if (!file) {
+ throw runtime_error(String::compose(_("Could not find file %1 in ZIP file"), filename));
+ }
+
+ dcp::ScopeGuard sg = [file]() { zip_fclose(file); };
+
+ int constexpr maximum = 65536;
+
+ dcp::ArrayData data(maximum);
+ int remaining = maximum;
+ uint8_t* next = data.data();
+
+ while (remaining > 0) {
+ auto read = zip_fread(file, next, remaining);
+ if (read == 0) {
+ break;
+ } else if (read == -1) {
+ throw runtime_error("Could not read from ZIP file");
+ }
+
+ next += read;
+ remaining -= read;
+ }
+
+ if (remaining == 0) {
+ throw runtime_error("File from ZIP is too big");
+ }
+
+ return string(reinterpret_cast<char*>(data.data()), maximum - remaining);
+}
+
diff --git a/src/lib/unzipper.h b/src/lib/unzipper.h
new file mode 100644
index 000000000..7cab6e5f4
--- /dev/null
+++ b/src/lib/unzipper.h
@@ -0,0 +1,43 @@
+/*
+ Copyright (C) 2024 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 <boost/filesystem.hpp>
+#include <memory>
+#include <vector>
+
+
+class Unzipper
+{
+public:
+ explicit Unzipper(boost::filesystem::path file);
+ ~Unzipper();
+
+ Unzipper(Unzipper const&) = delete;
+ Unzipper& operator=(Unzipper const&) = delete;
+
+ std::string get(std::string const& filename);
+
+private:
+ struct zip* _zip;
+ std::vector<std::shared_ptr<std::string>> _store;
+};
+
+
diff --git a/src/lib/wscript b/src/lib/wscript
index 296a77805..5bae3e0d1 100644
--- a/src/lib/wscript
+++ b/src/lib/wscript
@@ -198,6 +198,7 @@ sources = """
rough_duration.cc
signal_manager.cc
stdout_log.cc
+ unzipper.cc
update_checker.cc
upload_job.cc
uploader.cc
diff --git a/src/lib/zipper.h b/src/lib/zipper.h
index f554e2e8f..8b634423d 100644
--- a/src/lib/zipper.h
+++ b/src/lib/zipper.h
@@ -27,7 +27,7 @@
class Zipper
{
public:
- Zipper (boost::filesystem::path file);
+ explicit Zipper(boost::filesystem::path file);
~Zipper ();
Zipper (Zipper const&) = delete;
diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc
index 5333f34ae..f65037c2f 100644
--- a/src/tools/dcpomatic.cc
+++ b/src/tools/dcpomatic.cc
@@ -37,6 +37,7 @@
#include "wx/full_config_dialog.h"
#include "wx/hints_dialog.h"
#include "wx/html_dialog.h"
+#include "wx/file_dialog.h"
#include "wx/i18n_hook.h"
#include "wx/id.h"
#include "wx/job_manager_view.h"
@@ -250,6 +251,7 @@ enum {
ID_tools_system_information,
ID_tools_restore_default_preferences,
ID_tools_export_preferences,
+ ID_tools_import_preferences,
ID_help_report_a_problem,
/* IDs for shortcuts (with no associated menu item) */
ID_add_file,
@@ -362,6 +364,7 @@ public:
Bind (wxEVT_MENU, boost::bind (&DOMFrame::tools_system_information, this),ID_tools_system_information);
Bind (wxEVT_MENU, boost::bind (&DOMFrame::tools_restore_default_preferences, this), ID_tools_restore_default_preferences);
Bind (wxEVT_MENU, boost::bind (&DOMFrame::tools_export_preferences, this), ID_tools_export_preferences);
+ Bind (wxEVT_MENU, boost::bind (&DOMFrame::tools_import_preferences, this), ID_tools_import_preferences);
Bind (wxEVT_MENU, boost::bind (&DOMFrame::help_about, this), wxID_ABOUT);
Bind (wxEVT_MENU, boost::bind (&DOMFrame::help_report_a_problem, this), ID_help_report_a_problem);
@@ -765,9 +768,8 @@ private:
void tools_export_preferences ()
{
- wxFileDialog dialog(
- this, _("Specify ZIP file"), wxEmptyString, wxT("dcpomatic_config.zip"), wxT("ZIP files (*.zip)|*.zip"),
- wxFD_SAVE | wxFD_OVERWRITE_PROMPT
+ FileDialog dialog(
+ this, _("Specify ZIP file"), wxT("ZIP files (*.zip)|*.zip"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT, "Preferences", string("dcpomatic_config.zip")
);
if (dialog.ShowModal() == wxID_OK) {
@@ -785,6 +787,15 @@ private:
}
}
+ void tools_import_preferences()
+ {
+ FileDialog dialog(this, _("Specify ZIP file"), wxT("ZIP files (*.zip)|*.zip"), wxFD_OPEN, "Preferences");
+
+ if (dialog.show()) {
+ Config::instance()->load_from_zip(dialog.path());
+ }
+ }
+
void jobs_make_dcp ()
{
double required;
@@ -1426,6 +1437,7 @@ private:
add_item (tools, _("Restore default preferences"), ID_tools_restore_default_preferences, ALWAYS);
tools->AppendSeparator ();
add_item (tools, _("Export preferences..."), ID_tools_export_preferences, ALWAYS);
+ add_item (tools, _("Import preferences..."), ID_tools_import_preferences, ALWAYS);
wxMenu* help = new wxMenu;
#ifdef __WXOSX__
diff --git a/src/tools/dcpomatic_cli.cc b/src/tools/dcpomatic_cli.cc
index c335db616..9cb3c832a 100644
--- a/src/tools/dcpomatic_cli.cc
+++ b/src/tools/dcpomatic_cli.cc
@@ -94,12 +94,13 @@ print_dump (shared_ptr<Film> film)
cout << film->dcp_name (true) << "\n"
<< film->container()->container_nickname() << " at " << ((film->resolution() == Resolution::TWO_K) ? "2K" : "4K") << "\n"
<< (film->j2k_bandwidth() / 1000000) << "Mbit/s" << "\n"
+ << "Duration " << (film->length().timecode(film->video_frame_rate())) << "\n"
<< "Output " << film->video_frame_rate() << "fps " << (film->three_d() ? "3D" : "2D") << " " << (film->audio_frame_rate() / 1000) << "kHz\n"
<< (film->interop() ? "Inter-Op" : "SMPTE") << " " << (film->encrypted() ? "encrypted" : "unencrypted") << "\n";
for (auto c: film->content()) {
cout << "\n"
- << c->path(0) << "\n"
+ << c->path(0).string() << "\n"
<< "\tat " << c->position().seconds ()
<< " length " << c->full_length(film).seconds ()
<< " start trim " << c->trim_start().seconds ()
diff --git a/src/wx/simple_video_view.cc b/src/wx/simple_video_view.cc
index 8524c1fe9..cbfd7d4ac 100644
--- a/src/wx/simple_video_view.cc
+++ b/src/wx/simple_video_view.cc
@@ -75,7 +75,7 @@ SimpleVideoView::paint ()
auto scale = 1 / dpi_scale_factor (_panel);
dc.SetLogicalScale (scale, scale);
- auto const panel_size = _panel->GetSize ();
+ auto const panel_size = dcp::Size(_panel->GetSize().GetWidth() / scale, _panel->GetSize().GetHeight() / scale);
auto pad = pad_colour();
dcp::Size out_size;
@@ -88,32 +88,32 @@ SimpleVideoView::paint ()
out_size = _image->size();
wxImage frame (out_size.width, out_size.height, _image->data()[0], true);
wxBitmap frame_bitmap (frame);
- dc.DrawBitmap (frame_bitmap, 0, max(0, (panel_size.GetHeight() - out_size.height) / 2));
+ dc.DrawBitmap(frame_bitmap, 0, max(0, (panel_size.height - out_size.height) / 2));
}
- if (out_size.width < panel_size.GetWidth()) {
+ if (out_size.width < panel_size.width) {
wxPen p (pad);
wxBrush b (pad);
dc.SetPen (p);
dc.SetBrush (b);
- dc.DrawRectangle (out_size.width, 0, panel_size.GetWidth() - out_size.width, panel_size.GetHeight());
+ dc.DrawRectangle(out_size.width, 0, panel_size.width - out_size.width, panel_size.height);
}
- if (out_size.height < panel_size.GetHeight()) {
+ if (out_size.height < panel_size.height) {
wxPen p (pad);
wxBrush b (pad);
dc.SetPen (p);
dc.SetBrush (b);
- int const gap = (panel_size.GetHeight() - out_size.height) / 2;
- dc.DrawRectangle (0, 0, panel_size.GetWidth(), gap);
- dc.DrawRectangle (0, gap + out_size.height + 1, panel_size.GetWidth(), gap + 1);
+ int const gap = (panel_size.height - out_size.height) / 2;
+ dc.DrawRectangle(0, 0, panel_size.width, gap);
+ dc.DrawRectangle(0, gap + out_size.height + 1, panel_size.width, gap + 1);
}
if (_viewer->outline_content()) {
wxPen p (outline_content_colour(), 2);
dc.SetPen (p);
dc.SetBrush (*wxTRANSPARENT_BRUSH);
- dc.DrawRectangle (_inter_position.x, _inter_position.y + (panel_size.GetHeight() - out_size.height) / 2, _inter_size.width, _inter_size.height);
+ dc.DrawRectangle(_inter_position.x, _inter_position.y + (panel_size.height - out_size.height) / 2, _inter_size.width, _inter_size.height);
}
auto subs = _viewer->outline_subtitles();
diff --git a/src/wx/supporters.cc b/src/wx/supporters.cc
index 6f987de45..260081fe3 100644
--- a/src/wx/supporters.cc
+++ b/src/wx/supporters.cc
@@ -152,6 +152,7 @@ supported_by.Add (wxT ("Jonathan Bygraves"));
supported_by.Add (wxT ("Kinokriminalitat C.I.C."));
supported_by.Add (wxT ("Jorge Caballero"));
supported_by.Add (wxT ("Gemma Rodriguez Cabello"));
+supported_by.Add (wxT ("Pietro Caccavo"));
supported_by.Add (wxT ("Endcredits Film Club Cairns"));
supported_by.Add (wxT ("Russell Calabrese"));
supported_by.Add (wxT ("Steven Calcote"));
@@ -282,6 +283,7 @@ supported_by.Add (wxT ("Thomas Dickens"));
supported_by.Add (wxT ("Callen Diederichs"));
supported_by.Add (wxT ("Ageless Digitworks"));
supported_by.Add (wxT ("Philippe Diier"));
+supported_by.Add (wxT ("Thomas Dineen"));
supported_by.Add (wxT ("Uwe Dittes"));
supported_by.Add (wxT ("Dizale"));
supported_by.Add (wxT ("Hadzi-Aleksandar Djurovic"));
@@ -974,6 +976,7 @@ supported_by.Add (wxT ("CUT productions"));
supported_by.Add (wxT ("Red Vault Productions"));
supported_by.Add (wxT ("Zakatak Music Productions"));
supported_by.Add (wxT ("Richard Anderson Productions"));
+supported_by.Add (wxT ("Pentimenti Productions"));
supported_by.Add (wxT ("Hitman Productions"));
supported_by.Add (wxT ("WLFK Productions"));
supported_by.Add (wxT ("Ceridwen Productions"));
diff --git a/test/unzipper_test.cc b/test/unzipper_test.cc
new file mode 100644
index 000000000..f78f15c3f
--- /dev/null
+++ b/test/unzipper_test.cc
@@ -0,0 +1,59 @@
+/*
+ Copyright (C) 2024 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/>.
+
+*/
+
+
+/** @file test/unzipper_test.cc
+ * @brief Test Unzipper class.
+ * @ingroup selfcontained
+ */
+
+
+#include "lib/exceptions.h"
+#include "lib/unzipper.h"
+#include "lib/zipper.h"
+#include "test.h"
+#include <dcp/filesystem.h>
+#include <dcp/util.h>
+#include <boost/test/unit_test.hpp>
+#include <boost/filesystem.hpp>
+
+
+using std::string;
+
+
+/** Basic test of Unzipper working normally */
+BOOST_AUTO_TEST_CASE(unzipper_test1)
+{
+ boost::system::error_code ec;
+ boost::filesystem::remove("build/test/zipped.zip", ec);
+
+ Zipper zipper("build/test/zipped.zip");
+ zipper.add("foo.txt", "1234567890");
+ zipper.add("bar.txt", "xxxxxxCCCCbbbbbbb1");
+ zipper.add("its_bigger_than_that_chris_its_large.txt", string(128 * 1024, 'X'));
+ zipper.close();
+
+ Unzipper unzipper("build/test/zipped.zip");
+ BOOST_CHECK_EQUAL(unzipper.get("foo.txt"), "1234567890");
+ BOOST_CHECK_EQUAL(unzipper.get("bar.txt"), "xxxxxxCCCCbbbbbbb1");
+ BOOST_CHECK_THROW(unzipper.get("hatstand"), std::runtime_error);
+ BOOST_CHECK_THROW(unzipper.get("its_bigger_than_that_chris_its_large.txt"), std::runtime_error);
+}
+
diff --git a/test/wscript b/test/wscript
index f464b34cd..ab10fe838 100644
--- a/test/wscript
+++ b/test/wscript
@@ -164,6 +164,7 @@ def build(bld):
threed_test.cc
time_calculation_test.cc
torture_test.cc
+ unzipper_test.cc
update_checker_test.cc
upmixer_a_test.cc
util_test.cc