Make CPL metadata writing optional.
authorCarl Hetherington <cth@carlh.net>
Sun, 9 Oct 2022 12:15:58 +0000 (14:15 +0200)
committerCarl Hetherington <cth@carlh.net>
Sun, 9 Oct 2022 12:38:11 +0000 (14:38 +0200)
cscript
src/lib/film.cc
src/lib/film.h
src/lib/writer.cc
src/wx/advanced_dcp_settings_dialog.cc [new file with mode: 0644]
src/wx/advanced_dcp_settings_dialog.h [new file with mode: 0644]
src/wx/dcp_panel.cc
src/wx/dcp_panel.h
src/wx/wscript

diff --git a/cscript b/cscript
index 591ffd54d764809068cb4f6fd99b519be19befa6..796155eec6579240241b055ede7353f019908d5c 100644 (file)
--- a/cscript
+++ b/cscript
@@ -446,8 +446,8 @@ def dependencies(target, options):
         # Use distro-provided FFmpeg on Arch
         deps = []
 
-    deps.append(('libdcp', 'v1.8.30'))
-    deps.append(('libsub', 'v1.6.33'))
+    deps.append(('libdcp', 'c1229ba3e750fa0c877ef8444da82e8ea4a9638f'))
+    deps.append(('libsub', 'e1686d1511801439385f0c1fd333aaf1a33d1827'))
     deps.append(('leqm-nrt', '93ae9e6'))
     deps.append(('rtaudio', 'f619b76'))
     # We get our OpenSSL libraries from the environment, but we
index d5597b5a12dfa49b13255fd49b42f7fd38a65977..ca13772cb24f57e87c50d12396b214c3ab978e3e 100644 (file)
@@ -468,6 +468,7 @@ Film::metadata (bool with_content_paths) const
        if (_audio_language) {
                root->add_child("AudioLanguage")->add_child_text(_audio_language->to_string());
        }
+       root->add_child("WriteCPLMetadata")->add_child_text(_write_cpl_metadata ? "1" : "0");
        _playlist->as_xml (root->add_child ("Playlist"), with_content_paths);
 
        return doc;
@@ -698,6 +699,8 @@ Film::read_metadata (optional<boost::filesystem::path> path)
                _chain = isdcf->optional_string_child("Chain");
        }
 
+       _write_cpl_metadata = f.optional_bool_child("WriteCPLMetadata").get_value_or(true);
+
        list<string> notes;
        _playlist->set_from_xml (shared_from_this(), f.node_child ("Playlist"), _state_version, notes);
 
@@ -2208,3 +2211,11 @@ Film::last_written_by_earlier_than(int major, int minor, int micro) const
        return our_micro < micro;
 }
 
+
+void
+Film::set_write_cpl_metadata(bool write)
+{
+       FilmChangeSignaller ch (this, Property::WRITE_CPL_METADATA);
+       _write_cpl_metadata = write;
+}
+
index 72d6d5e8d409bce8b2751e565c6fce1de789e751..8d0d6187aa92fef705964c83a018a79d3a02fa92 100644 (file)
@@ -257,6 +257,7 @@ public:
                RED_BAND,
                TWO_D_VERSION_OF_THREE_D,
                LUMINANCE,
+               WRITE_CPL_METADATA,
        };
 
 
@@ -418,6 +419,10 @@ public:
                return _audio_frame_rate;
        }
 
+       bool write_cpl_metadata() const {
+               return _write_cpl_metadata;
+       }
+
        /* SET */
 
        void set_directory (boost::filesystem::path);
@@ -465,6 +470,7 @@ public:
        void set_luminance (boost::optional<dcp::Luminance> l = boost::none);
        void set_audio_language (boost::optional<dcp::LanguageTag> language);
        void set_audio_frame_rate (int rate);
+       void set_write_cpl_metadata(bool write);
 
        void add_ffoc_lfoc (Markers& markers) const;
 
@@ -578,6 +584,7 @@ private:
        boost::optional<dcp::Luminance> _luminance;
        boost::optional<dcp::LanguageTag> _audio_language;
        int _audio_frame_rate = 48000;
+       bool _write_cpl_metadata = true;
 
        int _state_version;
 
index 2dd46f0b2324f4516364b319ab2a1561542cba26..50886d957dfebea9c79064eff2852617144a8009 100644 (file)
@@ -696,7 +696,7 @@ Writer::finish (boost::filesystem::path output_dcp)
        dcp.set_creator(creator);
        dcp.set_annotation_text(film()->dcp_name());
 
-       dcp.write_xml (signer, Config::instance()->dcp_metadata_filename_format());
+       dcp.write_xml(signer, Config::instance()->dcp_metadata_filename_format(), film()->write_cpl_metadata());
 
        LOG_GENERAL (
                N_("Wrote %1 FULL, %2 FAKE, %3 REPEAT, %4 pushed to disk"), _full_written, _fake_written, _repeat_written, _pushed_to_disk
diff --git a/src/wx/advanced_dcp_settings_dialog.cc b/src/wx/advanced_dcp_settings_dialog.cc
new file mode 100644 (file)
index 0000000..f5419fb
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+    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 "advanced_dcp_settings_dialog.h"
+#include "check_box.h"
+#include "wx_util.h"
+#include "lib/film.h"
+
+
+using std::shared_ptr;
+
+
+AdvancedDCPSettingsDialog::AdvancedDCPSettingsDialog(wxWindow* parent, shared_ptr<const Film> film)
+       : wxDialog(parent, wxID_ANY, _("Advanced DCP settings"))
+{
+       auto sizer = new wxBoxSizer(wxVERTICAL);
+
+       _write_cpl_metadata = new CheckBox(this, _("Write CPL metadata"));
+       _write_cpl_metadata->set(film->write_cpl_metadata());
+
+       sizer->Add(_write_cpl_metadata, 0, wxALL, DCPOMATIC_SIZER_GAP);
+
+       auto buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
+       if (buttons) {
+               sizer->Add(buttons, wxSizerFlags().Expand().DoubleBorder());
+       }
+
+       SetSizerAndFit(sizer);
+}
+
+
+bool
+AdvancedDCPSettingsDialog::write_cpl_metadata() const
+{
+       return _write_cpl_metadata->get();
+}
+
diff --git a/src/wx/advanced_dcp_settings_dialog.h b/src/wx/advanced_dcp_settings_dialog.h
new file mode 100644 (file)
index 0000000..27c803a
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+    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 <wx/dialog.h>
+#include <memory>
+
+
+class CheckBox;
+class Film;
+
+
+class AdvancedDCPSettingsDialog : public wxDialog
+{
+public:
+       AdvancedDCPSettingsDialog(wxWindow* parent, std::shared_ptr<const Film> film);
+
+       bool write_cpl_metadata() const;
+
+private:
+       CheckBox* _write_cpl_metadata;
+};
+
index 895aed9c9cc98e36b47eb5ecc9e1665d2c309d3e..ea170d33150539870864852041c5b6601841b761 100644 (file)
@@ -19,6 +19,7 @@
 */
 
 
+#include "advanced_dcp_settings_dialog.h"
 #include "audio_dialog.h"
 #include "check_box.h"
 #include "check_box.h"
@@ -40,6 +41,7 @@
 #include "lib/ffmpeg_content.h"
 #include "lib/film.h"
 #include "lib/ratio.h"
+#include "lib/scope_guard.h"
 #include "lib/text_content.h"
 #include "lib/util.h"
 #include "lib/video_content.h"
@@ -121,6 +123,7 @@ DCPPanel::DCPPanel (wxNotebook* n, shared_ptr<Film> film, weak_ptr<FilmViewer> v
 
        _markers = new Button (_panel, _("Markers..."));
        _metadata = new Button (_panel, _("Metadata..."));
+       _advanced = new Button(_panel, _("Advanced..."));
 
        _notebook = new wxNotebook (_panel, wxID_ANY);
        _sizer->Add (_notebook, 1, wxEXPAND | wxTOP, 6);
@@ -138,6 +141,7 @@ DCPPanel::DCPPanel (wxNotebook* n, shared_ptr<Film> film, weak_ptr<FilmViewer> v
        _standard->Bind              (wxEVT_CHOICE,   boost::bind(&DCPPanel::standard_changed, this));
        _markers->Bind               (wxEVT_BUTTON,   boost::bind(&DCPPanel::markers_clicked, this));
        _metadata->Bind              (wxEVT_BUTTON,   boost::bind(&DCPPanel::metadata_clicked, this));
+       _advanced->Bind              (wxEVT_BUTTON,   boost::bind(&DCPPanel::advanced_clicked, this));
        _enable_audio_language->Bind (wxEVT_CHECKBOX, boost::bind(&DCPPanel::enable_audio_language_toggled, this));
        _edit_audio_language->Bind   (wxEVT_BUTTON,   boost::bind(&DCPPanel::edit_audio_language_clicked, this));
 
@@ -223,6 +227,7 @@ DCPPanel::add_to_grid ()
        auto extra = new wxBoxSizer (wxHORIZONTAL);
        extra->Add (_markers, 1, wxRIGHT, DCPOMATIC_SIZER_X_GAP);
        extra->Add (_metadata, 1, wxRIGHT, DCPOMATIC_SIZER_X_GAP);
+       extra->Add(_advanced, 1, wxRIGHT, DCPOMATIC_SIZER_X_GAP);
        _grid->Add (extra, wxGBPosition(r, 0), wxGBSpan(1, 2));
        ++r;
 }
@@ -361,6 +366,18 @@ DCPPanel::metadata_clicked ()
 }
 
 
+void
+DCPPanel::advanced_clicked()
+{
+       auto dialog = new AdvancedDCPSettingsDialog(_panel, _film);
+       ScopeGuard sg = [dialog]() { dialog->Destroy(); };
+
+       if (dialog->ShowModal() == wxID_OK) {
+               _film->set_write_cpl_metadata(dialog->write_cpl_metadata());
+       }
+}
+
+
 void
 DCPPanel::film_changed (Film::Property p)
 {
index 37bc20aa39f68b25a6b085fe5e7559a3a022819b..ebbc0f9241a7b48fca584bf75132a51984ff9dfb 100644 (file)
@@ -85,6 +85,7 @@ private:
        void reel_length_changed ();
        void markers_clicked ();
        void metadata_clicked ();
+       void advanced_clicked();
        void reencode_j2k_changed ();
        void enable_audio_language_toggled ();
        void edit_audio_language_clicked ();
@@ -157,6 +158,7 @@ private:
        wxSpinCtrl* _reel_length;
        wxButton* _markers;
        wxButton* _metadata;
+       wxButton* _advanced;
        wxSizer* _audio_panel_sizer;
 
        AudioDialog* _audio_dialog = nullptr;
index 236e99f975f091f5befe60123222c4ff9317740c..fc3002d7cea820c7a73e159514ea9c498f415e43 100644 (file)
@@ -26,6 +26,7 @@ import i18n
 
 sources = """
           about_dialog.cc
+          advanced_dcp_settings_dialog.cc
           audio_dialog.cc
           audio_gain_dialog.cc
           audio_mapping_view.cc