summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2023-09-30 12:28:05 +0200
committerCarl Hetherington <cth@carlh.net>2023-09-30 12:28:05 +0200
commit8a112904ee3cbdcd8e6c88e0a46c67e8d387ba9e (patch)
treede7000e0e6e51110464fc2ef21507a6a3878e636
parent5e34ba58c0c6821756308c09ddcbf08f8a775f3f (diff)
Allow SMPTE/interop setting from template to work.
-rw-r--r--src/lib/create_cli.cc29
-rw-r--r--src/lib/create_cli.h2
-rw-r--r--test/create_cli_test.cc43
m---------test/data0
4 files changed, 62 insertions, 12 deletions
diff --git a/src/lib/create_cli.cc b/src/lib/create_cli.cc
index b0f7a843e..41dd44d1a 100644
--- a/src/lib/create_cli.cc
+++ b/src/lib/create_cli.cc
@@ -129,7 +129,7 @@ CreateCLI::CreateCLI (int argc, char* argv[])
{
string dcp_content_type_string = "TST";
string container_ratio_string;
- string standard_string = "SMPTE";
+ optional<string> standard_string;
int dcp_frame_rate_int = 0;
string template_name_string;
int j2k_bandwidth_int = 0;
@@ -287,13 +287,15 @@ CreateCLI::CreateCLI (int argc, char* argv[])
}
}
- if (standard_string != "SMPTE" && standard_string != "interop") {
- error = String::compose("%1: standard must be SMPTE or interop", argv[0]);
- return;
- }
-
- if (standard_string == "interop") {
- _standard = dcp::Standard::INTEROP;
+ if (standard_string) {
+ if (*standard_string == "interop") {
+ _standard = dcp::Standard::INTEROP;
+ } else if (*standard_string == "SMPTE") {
+ _standard = dcp::Standard::SMPTE;
+ } else {
+ error = String::compose("%1: standard must be SMPTE or interop", argv[0]);
+ return;
+ }
}
if (_twod && _threed) {
@@ -328,6 +330,13 @@ CreateCLI::make_film() const
dcpomatic_log->set_types(Config::instance()->log_types());
if (_template_name) {
film->use_template(_template_name.get());
+ } else {
+ /* No template: apply our own CLI tool defaults to override the ones in Config.
+ * Maybe one day there will be no defaults in Config any more (as they'll be in
+ * a default template) and we can decide whether to use the default template
+ * or not.
+ */
+ film->set_interop(false);
}
film->set_name(_name);
@@ -335,7 +344,9 @@ CreateCLI::make_film() const
film->set_container(_container_ratio);
}
film->set_dcp_content_type(_dcp_content_type);
- film->set_interop(_standard == dcp::Standard::INTEROP);
+ if (_standard) {
+ film->set_interop(*_standard == dcp::Standard::INTEROP);
+ }
film->set_use_isdcf_name(!_no_use_isdcf_name);
if (_no_encrypt) {
film->set_encrypted(false);
diff --git a/src/lib/create_cli.h b/src/lib/create_cli.h
index ee15fb0b8..782aaf974 100644
--- a/src/lib/create_cli.h
+++ b/src/lib/create_cli.h
@@ -68,7 +68,7 @@ private:
bool _twod = false;
bool _threed = false;
DCPContentType const* _dcp_content_type = nullptr;
- dcp::Standard _standard = dcp::Standard::SMPTE;
+ boost::optional<dcp::Standard> _standard;
bool _no_use_isdcf_name = false;
bool _twok = false;
bool _fourk = false;
diff --git a/test/create_cli_test.cc b/test/create_cli_test.cc
index 3ebdcb81b..0359b2f35 100644
--- a/test/create_cli_test.cc
+++ b/test/create_cli_test.cc
@@ -102,11 +102,13 @@ BOOST_AUTO_TEST_CASE (create_cli_test)
cc = run ("dcpomatic2_create x --standard SMPTE");
BOOST_CHECK (!cc.error);
- BOOST_CHECK_EQUAL(cc._standard, dcp::Standard::SMPTE);
+ BOOST_REQUIRE(cc._standard);
+ BOOST_CHECK_EQUAL(*cc._standard, dcp::Standard::SMPTE);
cc = run ("dcpomatic2_create x --standard interop");
BOOST_CHECK (!cc.error);
- BOOST_CHECK_EQUAL(cc._standard, dcp::Standard::INTEROP);
+ BOOST_REQUIRE(cc._standard);
+ BOOST_CHECK_EQUAL(*cc._standard, dcp::Standard::INTEROP);
cc = run ("dcpomatic2_create x --standard SMPTEX");
BOOST_CHECK (cc.error);
@@ -265,5 +267,42 @@ BOOST_AUTO_TEST_CASE(create_cli_template_test)
cc = run("dcpomatic2_create test/data/flat_red.png --template encrypted --no-encrypt");
film = cc.make_film();
BOOST_CHECK(!film->encrypted());
+
+ cc = run("dcpomatic2_create test/data/flat_red.png");
+ film = cc.make_film();
+ BOOST_CHECK(!film->interop());
+
+ cc = run("dcpomatic2_create test/data/flat_red.png --template interop");
+ film = cc.make_film();
+ BOOST_CHECK(film->interop());
+
+ cc = run("dcpomatic2_create test/data/flat_red.png --template interop --standard SMPTE");
+ film = cc.make_film();
+ BOOST_CHECK(!film->interop());
+
+ cc = run("dcpomatic2_create test/data/flat_red.png --template smpte");
+ film = cc.make_film();
+ BOOST_CHECK(!film->interop());
+
+ cc = run("dcpomatic2_create test/data/flat_red.png --template smpte --standard interop");
+ film = cc.make_film();
+ BOOST_CHECK(film->interop());
+}
+
+
+BOOST_AUTO_TEST_CASE(create_cli_defaults_test)
+{
+ ConfigRestorer cr;
+
+ /* I think on balance dcpomatic2_create should not use the defaults from Config;
+ * it seems a bit surprising that settings from a GUI tool can change the behaviour of
+ * a CLI tool, and at some point we're probably going to remove all the default config
+ * options from the main DoM anyway (in favour of a default template).
+ */
+ Config::instance()->set_default_interop(true);
+ auto cc = run("dcpomatic2_create test/data/flat_red.png");
+ auto film = cc.make_film();
+ BOOST_CHECK(!film->interop());
+
}
diff --git a/test/data b/test/data
-Subproject 31f3a1e8d0217e065b9a2e6efbebe194f4dbae7
+Subproject a8cdef5f99fcf9fc6506d0f2e6471ab064ad205