From aca38e865ed9907b4e739cfe944f84bae5924b22 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 9 Oct 2022 14:15:58 +0200 Subject: [PATCH] Make CPL metadata writing optional. --- cscript | 4 +- src/lib/film.cc | 11 ++++++ src/lib/film.h | 7 ++++ src/lib/writer.cc | 2 +- src/wx/advanced_dcp_settings_dialog.cc | 55 ++++++++++++++++++++++++++ src/wx/advanced_dcp_settings_dialog.h | 40 +++++++++++++++++++ src/wx/dcp_panel.cc | 17 ++++++++ src/wx/dcp_panel.h | 2 + src/wx/wscript | 1 + 9 files changed, 136 insertions(+), 3 deletions(-) create mode 100644 src/wx/advanced_dcp_settings_dialog.cc create mode 100644 src/wx/advanced_dcp_settings_dialog.h diff --git a/cscript b/cscript index 591ffd54d..796155eec 100644 --- 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 diff --git a/src/lib/film.cc b/src/lib/film.cc index d5597b5a1..ca13772cb 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -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 path) _chain = isdcf->optional_string_child("Chain"); } + _write_cpl_metadata = f.optional_bool_child("WriteCPLMetadata").get_value_or(true); + list 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; +} + diff --git a/src/lib/film.h b/src/lib/film.h index 72d6d5e8d..8d0d6187a 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -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 l = boost::none); void set_audio_language (boost::optional 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 _luminance; boost::optional _audio_language; int _audio_frame_rate = 48000; + bool _write_cpl_metadata = true; int _state_version; diff --git a/src/lib/writer.cc b/src/lib/writer.cc index 2dd46f0b2..50886d957 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -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 index 000000000..f5419fb4e --- /dev/null +++ b/src/wx/advanced_dcp_settings_dialog.cc @@ -0,0 +1,55 @@ +/* + Copyright (C) 2022 Carl Hetherington + + 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 . + +*/ + + +#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 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 index 000000000..27c803a54 --- /dev/null +++ b/src/wx/advanced_dcp_settings_dialog.h @@ -0,0 +1,40 @@ +/* + Copyright (C) 2022 Carl Hetherington + + 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 . + +*/ + + +#include +#include + + +class CheckBox; +class Film; + + +class AdvancedDCPSettingsDialog : public wxDialog +{ +public: + AdvancedDCPSettingsDialog(wxWindow* parent, std::shared_ptr film); + + bool write_cpl_metadata() const; + +private: + CheckBox* _write_cpl_metadata; +}; + diff --git a/src/wx/dcp_panel.cc b/src/wx/dcp_panel.cc index 895aed9c9..ea170d331 100644 --- a/src/wx/dcp_panel.cc +++ b/src/wx/dcp_panel.cc @@ -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, weak_ptr 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, weak_ptr 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) { diff --git a/src/wx/dcp_panel.h b/src/wx/dcp_panel.h index 37bc20aa3..ebbc0f924 100644 --- a/src/wx/dcp_panel.h +++ b/src/wx/dcp_panel.h @@ -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; diff --git a/src/wx/wscript b/src/wx/wscript index 236e99f97..fc3002d7c 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -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 -- 2.30.2