Don't dump empty error details.
[dcpomatic.git] / src / tools / dcpomatic_create.cc
index d78aef3df117ac346552c0e10386b92f314aac25..345c0182bc8215765c9b57de17469f114a51f9e8 100644 (file)
@@ -45,6 +45,7 @@
 #include <stdexcept>
 #include <string>
 
+
 using std::cerr;
 using std::cout;
 using std::dynamic_pointer_cast;
@@ -53,15 +54,17 @@ using std::list;
 using std::make_shared;
 using std::shared_ptr;
 using std::string;
+using std::vector;
 using boost::optional;
 
+
 class SimpleSignalManager : public SignalManager
 {
 public:
        /* Do nothing in this method so that UI events happen in our thread
           when we call SignalManager::ui_idle().
        */
-       void wake_ui () {}
+       void wake_ui () override {}
 };
 
 int
@@ -105,6 +108,9 @@ main (int argc, char* argv[])
                film->set_use_isdcf_name (!cc.no_use_isdcf_name);
                film->set_encrypted (cc.encrypt);
                film->set_three_d (cc.threed);
+               if (cc.twok) {
+                       film->set_resolution (Resolution::TWO_K);
+               }
                if (cc.fourk) {
                        film->set_resolution (Resolution::FOUR_K);
                }
@@ -112,19 +118,23 @@ main (int argc, char* argv[])
                        film->set_j2k_bandwidth (*cc.j2k_bandwidth);
                }
 
-               for (auto i: cc.content) {
-                       boost::filesystem::path const can = boost::filesystem::canonical (i.path);
-                       list<shared_ptr<Content> > content;
+               for (auto cli_content: cc.content) {
+                       auto const can = boost::filesystem::canonical (cli_content.path);
+                       vector<shared_ptr<Content>> film_content_list;
 
                        if (boost::filesystem::exists (can / "ASSETMAP") || (boost::filesystem::exists (can / "ASSETMAP.xml"))) {
-                               content.push_back (make_shared<DCPContent>(can));
+                               auto dcp = make_shared<DCPContent>(can);
+                               film_content_list.push_back (dcp);
+                               if (cli_content.kdm) {
+                                       dcp->add_kdm (dcp::EncryptedKDM(dcp::file_to_string(*cli_content.kdm)));
+                               }
                        } else {
                                /* I guess it's not a DCP */
-                               content = content_factory (can);
+                               film_content_list = content_factory (can);
                        }
 
-                       for (auto j: content) {
-                               film->examine_and_add_content (j);
+                       for (auto film_content: film_content_list) {
+                               film->examine_and_add_content (film_content);
                        }
 
                        while (jm->work_to_do ()) {
@@ -133,19 +143,22 @@ main (int argc, char* argv[])
 
                        while (signal_manager->ui_idle() > 0) {}
 
-                       for (auto j: content) {
-                               if (j->video) {
-                                       j->video->set_frame_type (i.frame_type);
+                       for (auto film_content: film_content_list) {
+                               if (film_content->video) {
+                                       film_content->video->set_frame_type (cli_content.frame_type);
                                }
-                               if (j->audio && i.channel) {
-                                       for (auto stream: j->audio->streams()) {
+                               if (film_content->audio && cli_content.channel) {
+                                       for (auto stream: film_content->audio->streams()) {
                                                AudioMapping mapping(stream->channels(), film->audio_channels());
                                                for (int channel = 0; channel < stream->channels(); ++channel) {
-                                                       mapping.set(channel, *i.channel, 1.0f);
+                                                       mapping.set(channel, *cli_content.channel, 1.0f);
                                                }
                                                stream->set_mapping (mapping);
                                        }
                                }
+                               if (film_content->audio && cli_content.gain) {
+                                       film_content->audio->set_gain (*cli_content.gain);
+                               }
                        }
                }
 
@@ -163,8 +176,10 @@ main (int argc, char* argv[])
                if (jm->errors ()) {
                        for (auto i: jm->get()) {
                                if (i->finished_in_error()) {
-                                       cerr << i->error_summary() << "\n"
-                                            << i->error_details() << "\n";
+                                       cerr << i->error_summary() << "\n";
+                                       if (!i->error_details().empty()) {
+                                            cout << i->error_details() << "\n";
+                                       }
                                }
                        }
                        exit (EXIT_FAILURE);