diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-06-08 09:58:16 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-06-12 15:40:33 +0200 |
| commit | c8a036eb727ceddc64a0304d781c916eb952c001 (patch) | |
| tree | 86154aac21fd268af47bead23d0077c36d9e5f72 /test | |
| parent | 922dc3605c29bd742a18b02fbe1faae5739b70df (diff) | |
Set up TextDecoder position based on the time that the next thing willv2.16.14
be emitted, instead of the time that the last thing was (#2268).
This is to avoid problems with the example shown in the test, where
just because a subtitle in source A comes before a subtitle in source B,
source A is pass()ed next and may then emit a subtitle which should
be after the next one in B.
Diffstat (limited to 'test')
| -rw-r--r-- | test/player_test.cc | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/test/player_test.cc b/test/player_test.cc index e78e0ee35..80c7cf9eb 100644 --- a/test/player_test.cc +++ b/test/player_test.cc @@ -501,3 +501,40 @@ BOOST_AUTO_TEST_CASE (encrypted_dcp_with_no_kdm_gives_no_butler_error) BOOST_CHECK_NO_THROW(butler.rethrow()); } + +BOOST_AUTO_TEST_CASE (interleaved_subtitle_are_emitted_correctly) +{ + boost::filesystem::path paths[2] = { + "build/test/interleaved_subtitle_are_emitted_correctly1.srt", + "build/test/interleaved_subtitle_are_emitted_correctly2.srt" + }; + + dcp::File subs_file[2] = { dcp::File(paths[0], "w"), dcp::File(paths[1], "w") }; + + fprintf(subs_file[0].get(), "1\n00:00:01,000 -> 00:00:02,000\nSub 1/1\n\n"); + fprintf(subs_file[0].get(), "2\n00:00:05,000 -> 00:00:06,000\nSub 1/2\n\n"); + + fprintf(subs_file[1].get(), "1\n00:00:00,500 -> 00:00:01,500\nSub 2/1\n\n"); + fprintf(subs_file[1].get(), "2\n00:00:02,000 -> 00:00:03,000\nSub 2/2\n\n"); + + subs_file[0].close(); + subs_file[1].close(); + + auto subs1 = content_factory(paths[0]).front(); + auto subs2 = content_factory(paths[1]).front(); + auto film = new_test_film2("interleaved_subtitle_are_emitted_correctly", { subs1, subs2 }); + film->set_sequence(false); + subs1->set_position(film, DCPTime()); + subs2->set_position(film, DCPTime()); + + auto player = std::make_shared<Player>(film, Image::Alignment::COMPACT); + dcp::Time last; + player->Text.connect([&last](PlayerText text, TextType, optional<DCPTextTrack>, dcpomatic::DCPTimePeriod) { + for (auto sub: text.string) { + BOOST_CHECK(sub.in() >= last); + last = sub.in(); + } + }); + while (!player->pass()) {} +} + |
