diff options
| author | Carl Hetherington <cth@carlh.net> | 2020-12-08 22:22:30 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2020-12-08 23:23:54 +0100 |
| commit | 4ba4258d1a3c89aa1ec4bdcfacb3ceec18adb6b7 (patch) | |
| tree | 96ae477548fe7df84fd16fe466251cf3c67e3338 /test | |
| parent | 3239ce7c2cde98a6d70777f7e408b356a5f01a94 (diff) | |
In a DCP with any subs/ccaps, make sure every reel has them (#1340).
Diffstat (limited to 'test')
| -rw-r--r-- | test/subtitle_reel_test.cc | 98 |
1 files changed, 97 insertions, 1 deletions
diff --git a/test/subtitle_reel_test.cc b/test/subtitle_reel_test.cc index 156581932..2938c6d10 100644 --- a/test/subtitle_reel_test.cc +++ b/test/subtitle_reel_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2019 Carl Hetherington <cth@carlh.net> + Copyright (C) 2019-2020 Carl Hetherington <cth@carlh.net> This file is part of DCP-o-matic. @@ -18,21 +18,29 @@ */ +#include "lib/content_factory.h" #include "lib/film.h" #include "lib/image_content.h" #include "lib/dcp_subtitle_content.h" +#include "lib/text_content.h" #include "lib/video_content.h" #include "test.h" #include <dcp/dcp.h> #include <dcp/cpl.h> #include <dcp/reel.h> #include <dcp/interop_subtitle_asset.h> +#include <dcp/reel_closed_caption_asset.h> #include <dcp/reel_subtitle_asset.h> +#include <boost/foreach.hpp> #include <boost/test/unit_test.hpp> + using std::list; +using std::string; +using boost::optional; using boost::shared_ptr; + /* Check that timings are done correctly for multi-reel DCPs with PNG subs */ BOOST_AUTO_TEST_CASE (subtitle_reel_test) { @@ -86,3 +94,91 @@ BOOST_AUTO_TEST_CASE (subtitle_reel_test) /* These times should be the same as they are should be offset from the start of the reel */ BOOST_CHECK (A->subtitles().front()->in() == B->subtitles().front()->in()); } + + + +/** Check that with a SMPTE DCP if we have subtitles in one reel, all reels have a + * SubtitleAsset (even if it's empty); SMPTE Bv2.1 section 8.3.1. + */ +BOOST_AUTO_TEST_CASE (subtitle_in_all_reels_test) +{ + shared_ptr<Film> film = new_test_film2 ("subtitle_in_all_reels_test"); + film->set_interop (false); + film->set_sequence (false); + film->set_reel_type (REELTYPE_BY_VIDEO_CONTENT); + for (int i = 0; i < 3; ++i) { + shared_ptr<Content> video = content_factory("test/data/flat_red.png").front(); + film->examine_and_add_content (video); + BOOST_REQUIRE (!wait_for_jobs()); + video->video->set_length (15 * 24); + video->set_position (film, dcpomatic::DCPTime::from_seconds(15 * i)); + } + shared_ptr<Content> subs = content_factory("test/data/15s.srt").front(); + film->examine_and_add_content (subs); + BOOST_REQUIRE (!wait_for_jobs()); + film->make_dcp (); + BOOST_REQUIRE (!wait_for_jobs()); + + dcp::DCP dcp ("build/test/subtitle_in_all_reels_test/" + film->dcp_name()); + dcp.read (); + BOOST_REQUIRE_EQUAL (dcp.cpls().size(), 1); + shared_ptr<dcp::CPL> cpl = dcp.cpls().front(); + BOOST_REQUIRE_EQUAL (cpl->reels().size(), 3); + + BOOST_FOREACH (shared_ptr<dcp::Reel> i, cpl->reels()) { + BOOST_CHECK (i->main_subtitle()); + } +} + + +/** Check that with a SMPTE DCP if we have closed captions in one reel, all reels have a + * ClosedCaptionAssets for the same set of tracks (even if they are empty); SMPTE Bv2.1 section 8.3.1. + */ +BOOST_AUTO_TEST_CASE (closed_captions_in_all_reels_test) +{ + shared_ptr<Film> film = new_test_film2 ("closed_captions_in_all_reels_test"); + film->set_interop (false); + film->set_sequence (false); + film->set_reel_type (REELTYPE_BY_VIDEO_CONTENT); + + for (int i = 0; i < 3; ++i) { + shared_ptr<Content> video = content_factory("test/data/flat_red.png").front(); + film->examine_and_add_content (video); + BOOST_REQUIRE (!wait_for_jobs()); + video->video->set_length (15 * 24); + video->set_position (film, dcpomatic::DCPTime::from_seconds(15 * i)); + } + + shared_ptr<Content> ccap1 = content_factory("test/data/15s.srt").front(); + film->examine_and_add_content (ccap1); + BOOST_REQUIRE (!wait_for_jobs()); + ccap1->text.front()->set_type (TEXT_CLOSED_CAPTION); + ccap1->text.front()->set_dcp_track (DCPTextTrack("Test", "de-DE")); + + shared_ptr<Content> ccap2 = content_factory("test/data/15s.srt").front(); + film->examine_and_add_content (ccap2); + BOOST_REQUIRE (!wait_for_jobs()); + ccap2->text.front()->set_type (TEXT_CLOSED_CAPTION); + ccap2->text.front()->set_dcp_track (DCPTextTrack("Other", "en-GB")); + + film->make_dcp (); + BOOST_REQUIRE (!wait_for_jobs()); + + dcp::DCP dcp ("build/test/closed_captions_in_all_reels_test/" + film->dcp_name()); + dcp.read (); + BOOST_REQUIRE_EQUAL (dcp.cpls().size(), 1); + shared_ptr<dcp::CPL> cpl = dcp.cpls().front(); + BOOST_REQUIRE_EQUAL (cpl->reels().size(), 3); + + BOOST_FOREACH (shared_ptr<dcp::Reel> i, cpl->reels()) { + BOOST_REQUIRE_EQUAL (i->closed_captions().size(), 2); + optional<string> first = i->closed_captions().front()->language(); + optional<string> second = i->closed_captions().back()->language(); + BOOST_REQUIRE (first); + BOOST_REQUIRE (second); + BOOST_CHECK ( + (*first == "en-GB" && *second == "de-DE") || + (*first == "de-DE" && *second == "en-GB") + ); + } +} |
