Add config options for some of the DCP XML metadata (#122).
authorCarl Hetherington <cth@carlh.net>
Sat, 4 May 2013 10:08:46 +0000 (11:08 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 4 May 2013 10:08:46 +0000 (11:08 +0100)
src/lib/config.cc
src/lib/config.h
src/lib/writer.cc
src/tools/makedcp.cc
src/wx/config_dialog.cc
src/wx/config_dialog.h

index 0e2e33a16deaabf75db58318fc187561f6e9078a..8c65e371a229aef9ff090f50f7e9deb57170d6c6 100644 (file)
@@ -104,6 +104,12 @@ Config::Config ()
                        _default_format = Format::from_metadata (v);
                } else if (k == "default_dcp_content_type") {
                        _default_dcp_content_type = DCPContentType::from_dci_name (v);
+               } else if (k == "dcp_metadata_issuer") {
+                       _dcp_metadata.issuer = v;
+               } else if (k == "dcp_metadata_creator") {
+                       _dcp_metadata.creator = v;
+               } else if (k == "dcp_metadata_issue_date") {
+                       _dcp_metadata.issue_date = v;
                }
 
                _default_dci_metadata.read (k, v);
@@ -136,26 +142,26 @@ void
 Config::write () const
 {
        ofstream f (file().c_str ());
-       f << N_("num_local_encoding_threads ") << _num_local_encoding_threads << N_("\n")
-         << N_("default_directory ") << _default_directory << N_("\n")
-         << N_("server_port ") << _server_port << N_("\n");
+       f << "num_local_encoding_threads " << _num_local_encoding_threads << "\n"
+         << "default_directory " << _default_directory << "\n"
+         << "server_port " << _server_port << "\n";
 
        if (_reference_scaler) {
                f << "reference_scaler " << _reference_scaler->id () << "\n";
        }
 
        for (vector<Filter const *>::const_iterator i = _reference_filters.begin(); i != _reference_filters.end(); ++i) {
-               f << N_("reference_filter ") << (*i)->id () << N_("\n");
+               f << "reference_filter " << (*i)->id () << "\n";
        }
        
        for (vector<ServerDescription*>::const_iterator i = _servers.begin(); i != _servers.end(); ++i) {
-               f << N_("server ") << (*i)->as_metadata () << N_("\n");
+               f << "server " << (*i)->as_metadata () << "\n";
        }
 
-       f << N_("tms_ip ") << _tms_ip << N_("\n");
-       f << N_("tms_path ") << _tms_path << N_("\n");
-       f << N_("tms_user ") << _tms_user << N_("\n");
-       f << N_("tms_password ") << _tms_password << N_("\n");
+       f << "tms_ip " << _tms_ip << "\n";
+       f << "tms_path " << _tms_path << "\n";
+       f << "tms_user " << _tms_user << "\n";
+       f << "tms_password " << _tms_password << "\n";
        if (_sound_processor) {
                f << "sound_processor " << _sound_processor->id () << "\n";
        }
@@ -168,6 +174,9 @@ Config::write () const
        if (_default_dcp_content_type) {
                f << "default_dcp_content_type " << _default_dcp_content_type->dci_name() << "\n";
        }
+       f << "dcp_metadata_issuer " << _dcp_metadata.issuer << "\n";
+       f << "dcp_metadata_creator " << _dcp_metadata.creator << "\n";
+       f << "dcp_metadata_issue_date " << _dcp_metadata.issue_date << "\n";
 
        _default_dci_metadata.write (f);
 }
index 6041045cfc8e176f2290371e043c3d5d9c563c30..a59cdcae0df448e61fb03c0e7694162e25a1600d 100644 (file)
@@ -27,6 +27,7 @@
 #include <vector>
 #include <boost/shared_ptr.hpp>
 #include <boost/signals2.hpp>
+#include <libdcp/metadata.h>
 #include "dci_metadata.h"
 
 class ServerDescription;
@@ -117,6 +118,10 @@ public:
                return _default_dcp_content_type;
        }
 
+       libdcp::XMLMetadata dcp_metadata () const {
+               return _dcp_metadata;
+       }
+
        /** @param n New number of local encoding threads */
        void set_num_local_encoding_threads (int n) {
                _num_local_encoding_threads = n;
@@ -187,6 +192,10 @@ public:
        void set_default_dcp_content_type (DCPContentType const * t) {
                _default_dcp_content_type = t;
        }
+
+       void set_dcp_metadata (libdcp::XMLMetadata m) {
+               _dcp_metadata = m;
+       }
        
        void write () const;
 
@@ -226,6 +235,7 @@ private:
        boost::optional<std::string> _language;
        Format const * _default_format;
        DCPContentType const * _default_dcp_content_type;
+       libdcp::XMLMetadata _dcp_metadata;
 
        /** Singleton instance, or 0 */
        static Config* _instance;
index ad81686d108a9e4ea3603a90250b4a2046383925..177e929aebf2e64c989f0d4146ace0e0c296f82a 100644 (file)
 #include <libdcp/sound_asset.h>
 #include <libdcp/picture_frame.h>
 #include <libdcp/reel.h>
+#include <libdcp/cpl.h>
 #include "writer.h"
 #include "compose.hpp"
 #include "film.h"
 #include "format.h"
 #include "log.h"
 #include "dcp_video_frame.h"
+#include "config.h"
 
 #include "i18n.h"
 
@@ -320,7 +322,9 @@ Writer::finish ()
                                                         )
                               ));
 
-       dcp.write_xml ();
+       libdcp::XMLMetadata meta = Config::instance()->dcp_metadata ();
+       meta.set_issue_date_now ();
+       dcp.write_xml (meta);
 
        _film->log()->log (String::compose (N_("Wrote %1 FULL, %2 FAKE, %3 REPEAT; %4 pushed to disk"), _full_written, _fake_written, _repeat_written, _pushed_to_disk));
 }
index c594991a6bf41b5738e5617754d9365cdaad6da3..e73930d3cf0760c33a00b1aa2a939e7475e7aeee 100644 (file)
@@ -20,7 +20,6 @@
 #include <iostream>
 #include <iomanip>
 #include <getopt.h>
-#include <libdcp/test_mode.h>
 #include <libdcp/version.h>
 #include "format.h"
 #include "film.h"
@@ -50,7 +49,6 @@ help (string n)
             << "  -v, --version      show DVD-o-matic version\n"
             << "  -h, --help         show this help\n"
             << "  -d, --deps         list DVD-o-matic dependency details and quit\n"
-            << "  -t, --test         run in test mode (repeatable UUID generation, timestamps etc.)\n"
             << "  -n, --no-progress  do not print progress to stdout\n"
             << "  -r, --no-remote    do not use any remote servers\n"
             << "\n"
@@ -61,7 +59,6 @@ int
 main (int argc, char* argv[])
 {
        string film_dir;
-       bool test_mode = false;
        bool progress = true;
        bool no_remote = false;
        int log_level = 0;
@@ -72,14 +69,13 @@ main (int argc, char* argv[])
                        { "version", no_argument, 0, 'v'},
                        { "help", no_argument, 0, 'h'},
                        { "deps", no_argument, 0, 'd'},
-                       { "test", no_argument, 0, 't'},
                        { "no-progress", no_argument, 0, 'n'},
                        { "no-remote", no_argument, 0, 'r'},
                        { "log-level", required_argument, 0, 'l' },
                        { 0, 0, 0, 0 }
                };
 
-               int c = getopt_long (argc, argv, "vhdtnrl:", long_options, &option_index);
+               int c = getopt_long (argc, argv, "vhdnrl:", long_options, &option_index);
 
                if (c == -1) {
                        break;
@@ -95,9 +91,6 @@ main (int argc, char* argv[])
                case 'd':
                        cout << dependency_version_summary () << "\n";
                        exit (EXIT_SUCCESS);
-               case 't':
-                       test_mode = true;
-                       break;
                case 'n':
                        progress = false;
                        break;
@@ -130,11 +123,6 @@ main (int argc, char* argv[])
        }
        cout << "\n";
 
-       if (test_mode) {
-               libdcp::enable_test_mode ();
-               cout << dependency_version_summary() << "\n";
-       }
-
        shared_ptr<Film> film;
        try {
                film.reset (new Film (film_dir, true));
@@ -150,7 +138,6 @@ main (int argc, char* argv[])
                cout << "A/B ";
        }
        cout << "DCP for " << film->name() << "\n";
-       cout << "Test mode: " << (test_mode ? "yes" : "no") << "\n";
        cout << "Content: " << film->content() << "\n";
        pair<string, string> const f = Filter::ffmpeg_strings (film->filters ());
        cout << "Filters: " << f.first << " " << f.second << "\n";
index a91bfd64c6f423e2bad013fce64585d9bb31e2b0..98657b666fd09f06e0a69514aa6fac3bc51dd516 100644 (file)
@@ -53,6 +53,8 @@ ConfigDialog::ConfigDialog (wxWindow* parent)
        _notebook->AddPage (_misc_panel, _("Miscellaneous"), true);
        make_servers_panel ();
        _notebook->AddPage (_servers_panel, _("Encoding servers"), false);
+       make_metadata_panel ();
+       _notebook->AddPage (_metadata_panel, _("Metadata"), false);
        make_tms_panel ();
        _notebook->AddPage (_tms_panel, _("TMS"), false);
        make_ab_panel ();
@@ -224,6 +226,33 @@ ConfigDialog::make_tms_panel ()
        _tms_password->Connect (wxID_ANY, wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler (ConfigDialog::tms_password_changed), 0, this);
 }
 
+void
+ConfigDialog::make_metadata_panel ()
+{
+       _metadata_panel = new wxPanel (_notebook);
+       wxBoxSizer* s = new wxBoxSizer (wxVERTICAL);
+       _metadata_panel->SetSizer (s);
+
+       wxFlexGridSizer* table = new wxFlexGridSizer (2, 6, 6);
+       table->AddGrowableCol (1, 1);
+       s->Add (table, 1, wxALL | wxEXPAND, 8);
+
+       add_label_to_sizer (table, _metadata_panel, _("Issuer"));
+       _issuer = new wxTextCtrl (_metadata_panel, wxID_ANY);
+       table->Add (_issuer, 1, wxEXPAND);
+
+       add_label_to_sizer (table, _metadata_panel, _("Creator"));
+       _creator = new wxTextCtrl (_metadata_panel, wxID_ANY);
+       table->Add (_creator, 1, wxEXPAND);
+
+       Config* config = Config::instance ();
+
+       _issuer->SetValue (std_to_wx (config->dcp_metadata().issuer));
+       _issuer->Connect (wxID_ANY, wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler (ConfigDialog::issuer_changed), 0, this);
+       _creator->SetValue (std_to_wx (config->dcp_metadata().creator));
+       _creator->Connect (wxID_ANY, wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler (ConfigDialog::creator_changed), 0, this);
+}
+
 void
 ConfigDialog::make_ab_panel ()
 {
@@ -510,3 +539,19 @@ ConfigDialog::default_dcp_content_type_changed (wxCommandEvent &)
        vector<DCPContentType const *> ct = DCPContentType::all ();
        Config::instance()->set_default_dcp_content_type (ct[_default_dcp_content_type->GetSelection()]);
 }
+
+void
+ConfigDialog::issuer_changed (wxCommandEvent &)
+{
+       libdcp::XMLMetadata m = Config::instance()->dcp_metadata ();
+       m.issuer = wx_to_std (_issuer->GetValue ());
+       Config::instance()->set_dcp_metadata (m);
+}
+
+void
+ConfigDialog::creator_changed (wxCommandEvent &)
+{
+       libdcp::XMLMetadata m = Config::instance()->dcp_metadata ();
+       m.creator = wx_to_std (_creator->GetValue ());
+       Config::instance()->set_dcp_metadata (m);
+}
index c926b0937d84fcb35f64d0cb118b009a9cd8d035..526480912abade4c92ef56030b65f07bf928cd59 100644 (file)
@@ -58,12 +58,15 @@ private:
        void server_selection_changed (wxListEvent &);
        void default_format_changed (wxCommandEvent &);
        void default_dcp_content_type_changed (wxCommandEvent &);
+       void issuer_changed (wxCommandEvent &);
+       void creator_changed (wxCommandEvent &);
 
        void add_server_to_control (ServerDescription *);
        void setup_language_sensitivity ();
 
        void make_misc_panel ();
        void make_tms_panel ();
+       void make_metadata_panel ();
        void make_ab_panel ();
        void make_servers_panel ();
 
@@ -72,6 +75,7 @@ private:
        wxPanel* _tms_panel;
        wxPanel* _ab_panel;
        wxPanel* _servers_panel;
+       wxPanel* _metadata_panel;
        wxCheckBox* _set_language;
        wxChoice* _language;
        wxChoice* _default_format;
@@ -94,5 +98,7 @@ private:
        wxButton* _add_server;
        wxButton* _edit_server;
        wxButton* _remove_server;
+       wxTextCtrl* _issuer;
+       wxTextCtrl* _creator;
 };