Handle fonts/subdirs correctly for CCAPs with _map (#2584).
authorCarl Hetherington <cth@carlh.net>
Thu, 24 Aug 2023 21:50:18 +0000 (23:50 +0200)
committerCarl Hetherington <cth@carlh.net>
Sun, 27 Aug 2023 10:11:38 +0000 (12:11 +0200)
src/lib/map_cli.cc
test/map_cli_test.cc

index c7f21be4a0ed85e8a00147e256fca4f72222a9d3..31adf3a519ba00fcebf01b7f8b49fbbbd512b74e 100644 (file)
@@ -267,25 +267,31 @@ map_cli(int argc, char* argv[], std::function<void (string)> out)
                }
        };
 
+       auto maybe_copy_font = [&maybe_copy](shared_ptr<const dcp::SubtitleAsset> asset, bool rename, bool hard_link, bool soft_link) {
+               auto interop = dynamic_pointer_cast<const dcp::InteropSubtitleAsset>(asset);
+               boost::optional<boost::filesystem::path> extra;
+               if (interop) {
+                       extra = interop->id();
+                       for (auto font_asset: interop->font_assets()) {
+                               maybe_copy(font_asset->id(), rename, hard_link, soft_link, extra);
+                       }
+               }
+               return extra;
+       };
+
        /* Copy assets that the CPLs need */
        try {
                for (auto cpl: cpls) {
                        for (auto reel: cpl->reels()) {
                                maybe_copy_from_reel(reel->main_picture(), rename, hard_link, soft_link);
                                maybe_copy_from_reel(reel->main_sound(), rename, hard_link, soft_link);
-                               boost::optional<boost::filesystem::path> extra;
                                if (reel->main_subtitle()) {
-                                       auto interop = dynamic_pointer_cast<dcp::InteropSubtitleAsset>(reel->main_subtitle()->asset());
-                                       if (interop) {
-                                               extra = interop->id();
-                                               for (auto font_asset: interop->font_assets()) {
-                                                       maybe_copy(font_asset->id(), rename, hard_link, soft_link, extra);
-                                               }
-                                       }
+                                       auto extra = maybe_copy_font(reel->main_subtitle()->asset(), rename, hard_link, soft_link);
+                                       maybe_copy_from_reel(reel->main_subtitle(), rename, hard_link, soft_link, extra);
                                }
-                               maybe_copy_from_reel(reel->main_subtitle(), rename, hard_link, soft_link, extra);
                                for (auto ccap: reel->closed_captions()) {
-                                       maybe_copy_from_reel(ccap, rename, hard_link, soft_link);
+                                       auto extra = maybe_copy_font(ccap->asset(), rename, hard_link, soft_link);
+                                       maybe_copy_from_reel(ccap, rename, hard_link, soft_link, extra);
                                }
                                maybe_copy_from_reel(reel->atmos(), rename, hard_link, soft_link);
                        }
index 143f391b1cf4f06c15b25828634449b612bd9cb5..1267e9b4ccb3064b66cb5666d3efb889656d8017 100644 (file)
@@ -25,6 +25,7 @@
 #include "lib/content_factory.h"
 #include "lib/film.h"
 #include "lib/map_cli.h"
+#include "lib/text_content.h"
 #include "test.h"
 #include <dcp/cpl.h>
 #include <dcp/dcp.h>
@@ -441,3 +442,65 @@ BOOST_AUTO_TEST_CASE(map_with_given_config)
        /* It should be signed by the key in test/data/map_with_given_config, not the one in test/data/signer_key */
        BOOST_CHECK(dcp::file_to_string(find_file(out, "cpl_")).find("dnQualifier=\\+uOcNN2lPuxpxgd/5vNkkBER0GE=,CN=CS.dcpomatic.smpte-430-2.LEAF,OU=dcpomatic.com,O=dcpomatic.com") != std::string::npos);
 }
+
+
+BOOST_AUTO_TEST_CASE(map_multireel_interop_ov_and_vf_adding_ccaps)
+{
+       string const name = "map_multireel_interop_ov_and_vf_adding_ccaps";
+       string const out = String::compose("build/test/%1_out", name);
+
+       vector<shared_ptr<Content>> video = {
+               content_factory("test/data/flat_red.png")[0],
+               content_factory("test/data/flat_red.png")[0],
+               content_factory("test/data/flat_red.png")[0]
+       };
+
+       auto ov = new_test_film2(name + "_ov", { video[0], video[1], video[2] });
+       ov->set_reel_type(ReelType::BY_VIDEO_CONTENT);
+       ov->set_interop(true);
+       make_and_verify_dcp(ov, { dcp::VerificationNote::Code::INVALID_STANDARD });
+
+       auto ov_dcp = make_shared<DCPContent>(ov->dir(ov->dcp_name()));
+
+       vector<shared_ptr<Content>> ccap = {
+               content_factory("test/data/short.srt")[0],
+               content_factory("test/data/short.srt")[0],
+               content_factory("test/data/short.srt")[0]
+       };
+
+       auto vf = new_test_film2(name + "_vf", { ov_dcp, ccap[0], ccap[1], ccap[2] });
+       vf->set_interop(true);
+       vf->set_reel_type(ReelType::BY_VIDEO_CONTENT);
+       ov_dcp->set_reference_video(true);
+       ov_dcp->set_reference_audio(true);
+       for (auto i = 0; i < 3; ++i) {
+               ccap[i]->text[0]->set_use(true);
+               ccap[i]->text[0]->set_type(TextType::CLOSED_CAPTION);
+       }
+       make_and_verify_dcp(
+               vf,
+               {
+                       dcp::VerificationNote::Code::INVALID_STANDARD,
+                       dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME,
+                       dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE,
+                       dcp::VerificationNote::Code::EXTERNAL_ASSET
+               });
+
+       vector<string> const args = {
+               "map_cli",
+               "-o", out,
+               "-d", ov->dir(ov->dcp_name()).string(),
+               "-d", vf->dir(vf->dcp_name()).string(),
+               find_cpl(vf->dir(vf->dcp_name())).string()
+       };
+
+       boost::filesystem::remove_all(out);
+
+       vector<string> output_messages;
+       auto error = run(args, output_messages);
+       BOOST_CHECK(!error);
+
+       verify_dcp(out, { dcp::VerificationNote::Code::INVALID_STANDARD });
+}
+
+