Allow specification of the CPL ID to use in a DCP with _create (#2302).
authorCarl Hetherington <cth@carlh.net>
Sat, 17 Sep 2022 20:32:04 +0000 (22:32 +0200)
committerCarl Hetherington <cth@carlh.net>
Sat, 17 Sep 2022 20:32:04 +0000 (22:32 +0200)
src/lib/create_cli.cc
src/lib/create_cli.h
src/tools/dcpomatic_create.cc
test/create_cli_test.cc

index 2ca17f91b002ba4b8339c5afb2945a04a48f3165..a6e13c8bc04a26ed0df26aaabf0c2f9b8b72c4f0 100644 (file)
@@ -57,6 +57,7 @@ string CreateCLI::_help =
        "      --right-eye               next piece of content is for the right eye\n"
        "      --channel <channel>       next piece of content should be mapped to audio channel L, R, C, Lfe, Ls or Rs\n"
        "      --gain                    next piece of content should have the given audio gain (in dB)\n"
+       "      --cpl <id>                CPL ID to use from the next piece of content (which is a DCP)\n"
        "      --kdm <file>              KDM for next piece of content\n";
 
 
@@ -138,6 +139,7 @@ CreateCLI::CreateCLI (int argc, char* argv[])
        optional<dcp::Channel> channel;
        optional<float> gain;
        optional<boost::filesystem::path> kdm;
+       optional<std::string> cpl;
 
        int i = 1;
        while (i < argc) {
@@ -210,6 +212,7 @@ CreateCLI::CreateCLI (int argc, char* argv[])
                argument_option(i, argc, argv, "", "--channel", &claimed, &error, &channel, convert_channel);
                argument_option(i, argc, argv, "", "--gain", &claimed, &error, &gain);
                argument_option(i, argc, argv, "", "--kdm", &claimed, &error, &kdm, string_to_path);
+               argument_option(i, argc, argv, "", "--cpl", &claimed, &error, &cpl);
 
                if (!claimed) {
                        if (a.length() > 2 && a.substr(0, 2) == "--") {
@@ -222,6 +225,7 @@ CreateCLI::CreateCLI (int argc, char* argv[])
                                c.channel = channel;
                                c.gain = gain;
                                c.kdm = kdm;
+                               c.cpl = cpl;
                                content.push_back (c);
                                next_frame_type = VideoFrameType::TWO_D;
                                channel = {};
index e6fa69378b479455e36a8d8a3444f78343651793..a5e0c394130e2bd476df1652243012c2e4d737f9 100644 (file)
@@ -41,6 +41,7 @@ public:
                boost::optional<dcp::Channel> channel;
                boost::optional<float> gain;
                boost::optional<boost::filesystem::path> kdm;
+               boost::optional<std::string> cpl;
        };
 
        bool version;
index 345c0182bc8215765c9b57de17469f114a51f9e8..62428b1a24484990e287d8f147f59e3e5d84b829 100644 (file)
@@ -128,6 +128,9 @@ main (int argc, char* argv[])
                                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);
index 97ac25374da8a135e3e6c7f38e46c099f93749f3..71281a63e34630cc40d7684ee45ab4a17f6044b5 100644 (file)
@@ -184,4 +184,10 @@ BOOST_AUTO_TEST_CASE (create_cli_test)
        BOOST_CHECK_CLOSE (*cc.content[1].gain, -6, 0.001);
        BOOST_CHECK_EQUAL (cc.content[2].path, "sheila.wav");
        BOOST_CHECK_CLOSE (*cc.content[2].gain, 2, 0.001);
+
+       cc = run("dcpomatic2_create --cpl 123456-789-0 dcp");
+       BOOST_REQUIRE_EQUAL(cc.content.size(), 1U);
+       BOOST_CHECK_EQUAL(cc.content[0].path, "dcp");
+       BOOST_REQUIRE(static_cast<bool>(cc.content[0].cpl));
+       BOOST_CHECK_EQUAL(*cc.content[0].cpl, "123456-789-0");
 }