X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=test%2Fsubtitle_reel_test.cc;h=147f5c5237d25f2e27ee66c31cfa39f522394c75;hb=HEAD;hp=906477963fa318a71cca9f26414ef6214e4748fc;hpb=cb6729aa79b555b219974207fbe2ff0510f9d3ea;p=dcpomatic.git diff --git a/test/subtitle_reel_test.cc b/test/subtitle_reel_test.cc index 906477963..147f5c523 100644 --- a/test/subtitle_reel_test.cc +++ b/test/subtitle_reel_test.cc @@ -19,9 +19,9 @@ */ #include "lib/content_factory.h" +#include "lib/dcp_subtitle_content.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" @@ -35,20 +35,20 @@ using std::list; +using std::make_shared; using std::string; using boost::optional; -using std::shared_ptr; /* Check that timings are done correctly for multi-reel DCPs with PNG subs */ BOOST_AUTO_TEST_CASE (subtitle_reel_test) { - shared_ptr film = new_test_film2 ("subtitle_reel_test"); + auto film = new_test_film2 ("subtitle_reel_test"); film->set_interop (true); - shared_ptr red_a (new ImageContent("test/data/flat_red.png")); - shared_ptr red_b (new ImageContent("test/data/flat_red.png")); - shared_ptr sub_a (new DCPSubtitleContent("test/data/png_subs/subs.xml")); - shared_ptr sub_b (new DCPSubtitleContent("test/data/png_subs/subs.xml")); + auto red_a = make_shared("test/data/flat_red.png"); + auto red_b = make_shared("test/data/flat_red.png"); + auto sub_a = make_shared("test/data/png_subs/subs.xml"); + auto sub_b = make_shared("test/data/png_subs/subs.xml"); film->examine_and_add_content (red_a); film->examine_and_add_content (red_b); @@ -60,19 +60,20 @@ BOOST_AUTO_TEST_CASE (subtitle_reel_test) red_a->set_position (film, dcpomatic::DCPTime()); red_a->video->set_length (240); sub_a->set_position (film, dcpomatic::DCPTime()); + sub_a->only_text()->set_language(dcp::LanguageTag("de")); red_b->set_position (film, dcpomatic::DCPTime::from_seconds(10)); red_b->video->set_length (240); sub_b->set_position (film, dcpomatic::DCPTime::from_seconds(10)); + sub_b->only_text()->set_language(dcp::LanguageTag("de")); - film->set_reel_type (REELTYPE_BY_VIDEO_CONTENT); + film->set_reel_type (ReelType::BY_VIDEO_CONTENT); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp (film, {dcp::VerificationNote::Code::INVALID_STANDARD}); dcp::DCP dcp ("build/test/subtitle_reel_test/" + film->dcp_name()); dcp.read (); BOOST_REQUIRE_EQUAL (dcp.cpls().size(), 1U); - shared_ptr cpl = dcp.cpls().front(); + auto cpl = dcp.cpls().front(); auto reels = cpl->reels (); BOOST_REQUIRE_EQUAL (reels.size(), 2U); @@ -101,27 +102,32 @@ BOOST_AUTO_TEST_CASE (subtitle_reel_test) */ BOOST_AUTO_TEST_CASE (subtitle_in_all_reels_test) { - shared_ptr film = new_test_film2 ("subtitle_in_all_reels_test"); + auto 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); + film->set_reel_type (ReelType::BY_VIDEO_CONTENT); for (int i = 0; i < 3; ++i) { - shared_ptr video = content_factory("test/data/flat_red.png").front(); + auto video = content_factory("test/data/flat_red.png")[0]; 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 subs = content_factory("test/data/15s.srt").front(); + auto subs = content_factory("test/data/15s.srt")[0]; film->examine_and_add_content (subs); BOOST_REQUIRE (!wait_for_jobs()); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs()); + make_and_verify_dcp ( + film, + { + dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE, + dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME, + dcp::VerificationNote::Code::INVALID_SUBTITLE_SPACING + }); dcp::DCP dcp ("build/test/subtitle_in_all_reels_test/" + film->dcp_name()); dcp.read (); BOOST_REQUIRE_EQUAL (dcp.cpls().size(), 1U); - shared_ptr cpl = dcp.cpls().front(); + auto cpl = dcp.cpls()[0]; BOOST_REQUIRE_EQUAL (cpl->reels().size(), 3U); for (auto i: cpl->reels()) { @@ -135,44 +141,52 @@ BOOST_AUTO_TEST_CASE (subtitle_in_all_reels_test) */ BOOST_AUTO_TEST_CASE (closed_captions_in_all_reels_test) { - shared_ptr film = new_test_film2 ("closed_captions_in_all_reels_test"); + auto 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); + film->set_reel_type (ReelType::BY_VIDEO_CONTENT); for (int i = 0; i < 3; ++i) { - shared_ptr video = content_factory("test/data/flat_red.png").front(); + auto video = content_factory("test/data/flat_red.png")[0]; 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 ccap1 = content_factory("test/data/15s.srt").front(); + auto ccap1 = content_factory("test/data/15s.srt")[0]; 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")); + ccap1->text.front()->set_type (TextType::CLOSED_CAPTION); + ccap1->text.front()->set_dcp_track (DCPTextTrack("Test", dcp::LanguageTag("de-DE"))); - shared_ptr ccap2 = content_factory("test/data/15s.srt").front(); + auto ccap2 = content_factory("test/data/15s.srt")[0]; 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()); + ccap2->text.front()->set_type (TextType::CLOSED_CAPTION); + ccap2->text.front()->set_dcp_track (DCPTextTrack("Other", dcp::LanguageTag("en-GB"))); + + make_and_verify_dcp ( + film, + { + dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME, + dcp::VerificationNote::Code::INVALID_SUBTITLE_SPACING + }, + true, + /* ClairMeta gives an error with multiple ClosedCaption assets */ + false + ); dcp::DCP dcp ("build/test/closed_captions_in_all_reels_test/" + film->dcp_name()); dcp.read (); BOOST_REQUIRE_EQUAL (dcp.cpls().size(), 1U); - shared_ptr cpl = dcp.cpls().front(); + auto cpl = dcp.cpls().front(); BOOST_REQUIRE_EQUAL (cpl->reels().size(), 3U); for (auto i: cpl->reels()) { BOOST_REQUIRE_EQUAL (i->closed_captions().size(), 2U); - optional first = i->closed_captions().front()->language(); - optional second = i->closed_captions().back()->language(); + auto first = i->closed_captions().front()->language(); + auto second = i->closed_captions().back()->language(); BOOST_REQUIRE (first); BOOST_REQUIRE (second); BOOST_CHECK ( @@ -181,3 +195,43 @@ BOOST_AUTO_TEST_CASE (closed_captions_in_all_reels_test) ); } } + + +BOOST_AUTO_TEST_CASE (subtitles_split_at_reel_boundaries) +{ + auto film = new_test_film2 ("subtitles_split_at_reel_boundaries"); + film->set_interop (true); + + film->set_sequence (false); + film->set_reel_type (ReelType::BY_VIDEO_CONTENT); + + for (int i = 0; i < 3; ++i) { + auto video = content_factory("test/data/flat_red.png")[0]; + 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)); + } + + auto subtitle = content_factory("test/data/45s.srt")[0]; + film->examine_and_add_content (subtitle); + BOOST_REQUIRE (!wait_for_jobs()); + subtitle->only_text()->set_language(dcp::LanguageTag("de")); + + make_and_verify_dcp (film, { dcp::VerificationNote::Code::INVALID_STANDARD }); + + dcp::DCP dcp (film->dir(film->dcp_name())); + dcp.read(); + BOOST_REQUIRE_EQUAL (dcp.cpls().size(), 1U); + auto cpl = dcp.cpls()[0]; + BOOST_REQUIRE_EQUAL (cpl->reels().size(), 3U); + + for (auto i: cpl->reels()) { + auto reel_sub = i->main_subtitle(); + BOOST_REQUIRE (reel_sub); + auto sub = reel_sub->asset(); + BOOST_REQUIRE (sub); + BOOST_CHECK_EQUAL (sub->subtitles().size(), 1U); + } +} +