Merge master.
authorCarl Hetherington <cth@carlh.net>
Sat, 4 May 2013 14:59:31 +0000 (15:59 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 4 May 2013 14:59:31 +0000 (15:59 +0100)
src/lib/config.cc
src/lib/config.h
src/lib/film.cc
src/lib/format.cc
src/lib/format.h
src/lib/writer.cc
src/tools/dcpomatic_cli.cc
src/wx/config_dialog.cc
src/wx/config_dialog.h

index 4f90581f627b32f3201c6246516fcbd6c859a40a..b6f464717b48c7f6ca3f5a590c58ca5480d01e22 100644 (file)
@@ -27,6 +27,8 @@
 #include "server.h"
 #include "scaler.h"
 #include "filter.h"
+#include "format.h"
+#include "dcp_content_type.h"
 #include "sound_processor.h"
 
 #include "i18n.h"
@@ -50,6 +52,8 @@ Config::Config ()
        , _tms_path (N_("."))
        , _sound_processor (SoundProcessor::from_id (N_("dolby_cp750")))
        , _default_still_length (10)
+       , _default_format (0)
+       , _default_dcp_content_type (0)
 {
        _allowed_dcp_frame_rates.push_back (24);
        _allowed_dcp_frame_rates.push_back (25);
@@ -95,6 +99,20 @@ Config::Config ()
        }
 
        _language = f.optional_string_child ("Language");
+
+       c = f.optional_string_child ("DefaultFormat");
+       if (c) {
+               _default_format = Format::from_id (c.get ());
+       }
+
+       c = f.optional_string_child ("DefaultDCPContentType");
+       if (c) {
+               _default_dcp_content_type = DCPContentType::from_dci_name (c.get ());
+       }
+
+       _dcp_metadata.issuer = f.optional_string_child ("DCPMetadataIssuer").get_value_or ("");
+       _dcp_metadata.creator = f.optional_string_child ("DCPMetadataCreator").get_value_or ("");
+
        _default_dci_metadata = DCIMetadata (f.node_child ("DCIMetadata"));
        _default_still_length = f.optional_number_child<int>("DefaultStillLength").get_value_or (10);
 }
@@ -145,6 +163,16 @@ Config::read_old_metadata ()
                        _sound_processor = SoundProcessor::from_id (v);
                } else if (k == "language") {
                        _language = v;
+               } else if (k == "default_format") {
+                       _default_format = Format::from_id (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_old_metadata (k, v);
@@ -208,6 +236,14 @@ Config::write () const
        if (_language) {
                root->add_child("Language")->add_child_text (_language.get());
        }
+       if (_default_format) {
+               root->add_child("DefaultFormat")->add_child_text (_default_format->id ());
+       }
+       if (_default_dcp_content_type) {
+               root->add_child("DefaultDCPContentType")->add_child_text (_default_dcp_content_type->dci_name ());
+       }
+       root->add_child("DCPMetadataIssuer")->add_child_text (_dcp_metadata.issuer);
+       root->add_child("DCPMetadataCreator")->add_child_text (_dcp_metadata.creator);
 
        _default_dci_metadata.as_xml (root->add_child ("DCIMetadata"));
 
index 91926750b8a9a44b37096c144756fe6dca65ff95..05005e5903d374a97472821976001320351c8133 100644 (file)
 #include <vector>
 #include <boost/shared_ptr.hpp>
 #include <boost/signals2.hpp>
+#include <libdcp/metadata.h>
 #include "dci_metadata.h"
 
 class ServerDescription;
 class Scaler;
 class Filter;
 class SoundProcessor;
+class Format;
+class DCPContentType;
 
 /** @class Config
  *  @brief A singleton class holding configuration.
@@ -111,6 +114,18 @@ public:
                return _default_still_length;
        }
 
+       Format const * default_format () const {
+               return _default_format;
+       }
+
+       DCPContentType const * default_dcp_content_type () const {
+               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;
@@ -178,6 +193,18 @@ public:
                _default_still_length = s;
        }
 
+       void set_default_format (Format const * f) {
+               _default_format = f;
+       }
+
+       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;
 
        static Config* instance ();
@@ -216,6 +243,9 @@ private:
        DCIMetadata _default_dci_metadata;
        boost::optional<std::string> _language;
        int _default_still_length;
+       Format const * _default_format;
+       DCPContentType const * _default_dcp_content_type;
+       libdcp::XMLMetadata _dcp_metadata;
 
        /** Singleton instance, or 0 */
        static Config* _instance;
index 5481bd012a322d2390668ef8034fb6b14b17d912..8fed87122977bdf311d9640f1cd2c8a4d92ab496 100644 (file)
@@ -93,8 +93,8 @@ Film::Film (string d, bool must_exist)
        : _playlist (new Playlist)
        , _use_dci_name (true)
        , _trust_content_headers (true)
-       , _dcp_content_type (0)
-       , _format (Format::from_id ("185"))
+       , _dcp_content_type (Config::instance()->default_dcp_content_type ())
+       , _format (Config::instance()->default_format ())
        , _scaler (Scaler::from_id ("bicubic"))
        , _trim_start (0)
        , _trim_end (0)
index a83d53ebd1aa3ba01a486c488cb35d90b3645e67..f5026c0da8faf0ddf8267c11b0a32adcc163a9c8 100644 (file)
@@ -60,13 +60,6 @@ FixedFormat::name () const
        return s.str ();
 }
 
-/** @return Identifier for this format as metadata for a Film's metadata file */
-string
-Format::as_metadata () const
-{
-       return _id;
-}
-
 /** Fill our _formats vector with all available formats */
 void
 Format::setup_formats ()
@@ -165,16 +158,6 @@ Format::from_id (string i)
        return *j;
 }
 
-
-/** @param m Metadata, as returned from as_metadata().
- *  @return Matching Format, or 0.
- */
-Format const *
-Format::from_metadata (string m)
-{
-       return from_id (m);
-}
-
 /** @return All available formats */
 vector<Format const *>
 Format::all ()
index f240c89fc85db4b76ee45f34291e8294dfdbd5b4..d45a3a10acc4bc6f6c3d2ebf64be445d9b6c0f07 100644 (file)
@@ -67,10 +67,7 @@ public:
                return _dci_name;
        }
 
-       std::string as_metadata () const;
-
        static Format const * from_nickname (std::string n);
-       static Format const * from_metadata (std::string m);
        static Format const * from_id (std::string i);
        static std::vector<Format const *> all ();
        static void setup_formats ();
index 8e771a5e239e73044de2456310e754d042d0ff90..b545848cbcc7d871d7d2b0aaa1e234d20c38cd80 100644 (file)
@@ -23,6 +23,7 @@
 #include <libdcp/picture_frame.h>
 #include <libdcp/reel.h>
 #include <libdcp/dcp.h>
+#include <libdcp/cpl.h>
 #include "writer.h"
 #include "compose.hpp"
 #include "film.h"
@@ -32,6 +33,7 @@
 #include "dcp_content_type.h"
 #include "player.h"
 #include "audio_mapping.h"
+#include "config.h"
 
 #include "i18n.h"
 
@@ -322,7 +324,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 86c3cf4b14881a3268a96758d9716242af373362..d4a4210dee560549db7868319b9fb28e8c6d8442 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 DCP-o-matic version\n"
             << "  -h, --help         show this help\n"
             << "  -d, --deps         list DCP-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 e1fc7a20fced8ed4caf66720f2c06a8a1e3f4acf..50b8990b13a2afcd1c25319512cfc391e9a1275e 100644 (file)
@@ -31,6 +31,7 @@
 #include "lib/format.h"
 #include "lib/scaler.h"
 #include "lib/filter.h"
+#include "lib/dcp_content_type.h"
 #include "config_dialog.h"
 #include "wx_util.h"
 #include "filter_dialog.h"
@@ -52,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 ();
@@ -124,6 +127,16 @@ ConfigDialog::make_misc_panel ()
        table->Add (_default_dci_metadata_button);
        table->AddSpacer (1);
 
+       add_label_to_sizer (table, _misc_panel, _("Default format"));
+       _default_format = new wxChoice (_misc_panel, wxID_ANY);
+       table->Add (_default_format);
+       table->AddSpacer (1);
+
+       add_label_to_sizer (table, _misc_panel, _("Default content type"));
+       _default_dcp_content_type = new wxChoice (_misc_panel, wxID_ANY);
+       table->Add (_default_dcp_content_type);
+       table->AddSpacer (1);
+       
        Config* config = Config::instance ();
 
        _set_language->SetValue (config->language ());
@@ -158,6 +171,29 @@ ConfigDialog::make_misc_panel ()
 
        _default_dci_metadata_button->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (ConfigDialog::edit_default_dci_metadata_clicked), 0, this);
 
+       vector<Format const *> fmt = Format::all ();
+       int n = 0;
+       for (vector<Format const *>::iterator i = fmt.begin(); i != fmt.end(); ++i) {
+               _default_format->Append (std_to_wx ((*i)->name ()));
+               if (*i == config->default_format ()) {
+                       _default_format->SetSelection (n);
+               }
+               ++n;
+       }
+
+       _default_format->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (ConfigDialog::default_format_changed), 0, this);
+       
+       vector<DCPContentType const *> const ct = DCPContentType::all ();
+       n = 0;
+       for (vector<DCPContentType const *>::const_iterator i = ct.begin(); i != ct.end(); ++i) {
+               _default_dcp_content_type->Append (std_to_wx ((*i)->pretty_name ()));
+               if (*i == config->default_dcp_content_type ()) {
+                       _default_dcp_content_type->SetSelection (n);
+               }
+               ++n;
+       }
+
+       _default_dcp_content_type->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (ConfigDialog::default_dcp_content_type_changed), 0, this);
 }
 
 void
@@ -230,15 +266,33 @@ ConfigDialog::make_ab_panel ()
                table->Add (s, 1, wxEXPAND);
                table->AddSpacer (0);
        }
+}
+
+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 ();
-       
-       _reference_scaler->SetSelection (Scaler::as_index (config->reference_scaler ()));
-       _reference_scaler->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (ConfigDialog::reference_scaler_changed), 0, this);
 
-       pair<string, string> p = Filter::ffmpeg_strings (config->reference_filters ());
-       _reference_filters->SetLabel (std_to_wx (p.first) + N_(" ") + std_to_wx (p.second));
-       _reference_filters_button->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (ConfigDialog::edit_reference_filters_clicked), 0, this);
+       _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
@@ -477,3 +531,33 @@ ConfigDialog::default_still_length_changed (wxCommandEvent &)
 {
        Config::instance()->set_default_still_length (_default_still_length->GetValue ());
 }
+
+void
+ConfigDialog::default_format_changed (wxCommandEvent &)
+{
+       vector<Format const *> fmt = Format::all ();
+       Config::instance()->set_default_format (fmt[_default_format->GetSelection()]);
+}
+
+void
+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 852925e1da1ca0bb45e92f842c18b5e9193e9e47..5df1a634fd25041eb202404b28e23d7a9981c102 100644 (file)
@@ -57,12 +57,17 @@ private:
        void edit_server_clicked (wxCommandEvent &);
        void remove_server_clicked (wxCommandEvent &);
        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 ();
 
@@ -71,8 +76,11 @@ private:
        wxPanel* _tms_panel;
        wxPanel* _ab_panel;
        wxPanel* _servers_panel;
+       wxPanel* _metadata_panel;
        wxCheckBox* _set_language;
        wxChoice* _language;
+       wxChoice* _default_format;
+       wxChoice* _default_dcp_content_type;
        wxTextCtrl* _tms_ip;
        wxTextCtrl* _tms_path;
        wxTextCtrl* _tms_user;
@@ -92,5 +100,7 @@ private:
        wxButton* _add_server;
        wxButton* _edit_server;
        wxButton* _remove_server;
+       wxTextCtrl* _issuer;
+       wxTextCtrl* _creator;
 };