Cleanup: using/include sorting.
[dcpomatic.git] / src / tools / dcpomatic_create.cc
index a4f8dda6ac65e36435133a0d327ece208ee86e37..5b5f4dba2455f48739679a9f62a06d80ea3ada26 100644 (file)
@@ -25,7 +25,6 @@
 #include "lib/cross.h"
 #include "lib/dcp_content.h"
 #include "lib/dcp_content_type.h"
-#include "lib/dcpomatic_log.h"
 #include "lib/film.h"
 #include "lib/image_content.h"
 #include "lib/job.h"
@@ -37,6 +36,7 @@
 #include "lib/version.h"
 #include "lib/video_content.h"
 #include <dcp/exceptions.h>
+#include <dcp/filesystem.h>
 #include <libxml++/libxml++.h>
 #include <boost/filesystem.hpp>
 #include <getopt.h>
@@ -92,40 +92,21 @@ main (int argc, char* argv[])
        auto jm = JobManager::instance ();
 
        try {
-               auto film = std::make_shared<Film>(cc.output_dir);
-               dcpomatic_log = film->log ();
-               dcpomatic_log->set_types (Config::instance()->log_types());
-               if (cc.template_name) {
-                       film->use_template (cc.template_name.get());
-               }
-               film->set_name (cc.name);
-
-               if (cc.container_ratio) {
-                       film->set_container (cc.container_ratio);
-               }
-               film->set_dcp_content_type (cc.dcp_content_type);
-               film->set_interop (cc.standard == dcp::Standard::INTEROP);
-               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);
-               }
-               if (cc.j2k_bandwidth) {
-                       film->set_j2k_bandwidth (*cc.j2k_bandwidth);
-               }
+               auto film = cc.make_film();
 
                for (auto cli_content: cc.content) {
-                       auto const can = boost::filesystem::canonical (cli_content.path);
+                       auto const can = dcp::filesystem::canonical(cli_content.path);
                        vector<shared_ptr<Content>> film_content_list;
 
-                       if (boost::filesystem::exists (can / "ASSETMAP") || (boost::filesystem::exists (can / "ASSETMAP.xml"))) {
+                       if (dcp::filesystem::exists(can / "ASSETMAP") || (dcp::filesystem::exists(can / "ASSETMAP.xml"))) {
                                auto dcp = make_shared<DCPContent>(can);
                                film_content_list.push_back (dcp);
-                               dcp->add_kdm (dcp::EncryptedKDM(dcp::file_to_string(*cli_content.kdm)));
+                               if (cli_content.kdm) {
+                                       dcp->add_kdm (dcp::EncryptedKDM(dcp::file_to_string(*cli_content.kdm)));
+                               }
+                               if (cli_content.cpl) {
+                                       dcp->set_cpl(*cli_content.cpl);
+                               }
                        } else {
                                /* I guess it's not a DCP */
                                film_content_list = content_factory (can);
@@ -167,15 +148,17 @@ main (int argc, char* argv[])
                for (auto i: film->content()) {
                        auto ic = dynamic_pointer_cast<ImageContent> (i);
                        if (ic && ic->still()) {
-                               ic->video->set_length (cc.still_length * 24);
+                               ic->video->set_length(cc.still_length.get_value_or(10) * 24);
                        }
                }
 
                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);