Allow DCP content type from template to work.
authorCarl Hetherington <cth@carlh.net>
Sat, 30 Sep 2023 10:32:42 +0000 (12:32 +0200)
committerCarl Hetherington <cth@carlh.net>
Sat, 30 Sep 2023 10:32:42 +0000 (12:32 +0200)
src/lib/create_cli.cc
test/create_cli_test.cc

index 41dd44d1a2dc1eae678a2e9a9fd90c27c466ffa4..ed62abefb1d2fd695a20ce68446f9d0a4d782165 100644 (file)
@@ -127,7 +127,7 @@ argument_option (
 CreateCLI::CreateCLI (int argc, char* argv[])
        : version (false)
 {
-       string dcp_content_type_string = "TST";
+       optional<string> dcp_content_type_string;
        string container_ratio_string;
        optional<string> standard_string;
        int dcp_frame_rate_int = 0;
@@ -273,10 +273,12 @@ CreateCLI::CreateCLI (int argc, char* argv[])
                _j2k_bandwidth = j2k_bandwidth_int * 1000000;
        }
 
-       _dcp_content_type = DCPContentType::from_isdcf_name(dcp_content_type_string);
-       if (!_dcp_content_type) {
-               error = String::compose("%1: unrecognised DCP content type '%2'", argv[0], dcp_content_type_string);
-               return;
+       if (dcp_content_type_string) {
+               _dcp_content_type = DCPContentType::from_isdcf_name(*dcp_content_type_string);
+               if (!_dcp_content_type) {
+                       error = String::compose("%1: unrecognised DCP content type '%2'", argv[0], *dcp_content_type_string);
+                       return;
+               }
        }
 
        if (!container_ratio_string.empty()) {
@@ -337,13 +339,16 @@ CreateCLI::make_film() const
                 * or not.
                 */
                film->set_interop(false);
+               film->set_dcp_content_type(DCPContentType::from_isdcf_name("TST"));
        }
        film->set_name(_name);
 
        if (_container_ratio) {
                film->set_container(_container_ratio);
        }
-       film->set_dcp_content_type(_dcp_content_type);
+       if (_dcp_content_type) {
+               film->set_dcp_content_type(_dcp_content_type);
+       }
        if (_standard) {
                film->set_interop(*_standard == dcp::Standard::INTEROP);
        }
index 0359b2f358fb9183982b8c5279dde0d80d3433cd..aae5fb6de051d81b83719ba8275918d80c47cde5 100644 (file)
@@ -304,5 +304,9 @@ BOOST_AUTO_TEST_CASE(create_cli_defaults_test)
        auto film = cc.make_film();
        BOOST_CHECK(!film->interop());
 
+       Config::instance()->set_default_dcp_content_type(DCPContentType::from_isdcf_name("FT"));
+       cc = run("dcpomatic2_create test/data/flat_red.png");
+       film = cc.make_film();
+       BOOST_CHECK_EQUAL(film->dcp_content_type()->isdcf_name(), "TST");
 }