1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
|
/*
Copyright (C) 2019-2020 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
DCP-o-matic is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
DCP-o-matic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
*/
#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/test/unit_test.hpp>
using std::list;
using std::string;
using std::shared_ptr;
using std::make_shared;
using boost::optional;
/* Check that timings are done correctly for multi-reel DCPs with PNG subs */
BOOST_AUTO_TEST_CASE (subtitle_reel_test)
{
auto film = new_test_film2 ("subtitle_reel_test");
film->set_interop (true);
auto red_a = make_shared<ImageContent>("test/data/flat_red.png");
auto red_b = make_shared<ImageContent>("test/data/flat_red.png");
auto sub_a = make_shared<DCPSubtitleContent>("test/data/png_subs/subs.xml");
auto sub_b = make_shared<DCPSubtitleContent>("test/data/png_subs/subs.xml");
film->examine_and_add_content (red_a);
film->examine_and_add_content (red_b);
film->examine_and_add_content (sub_a);
film->examine_and_add_content (sub_b);
BOOST_REQUIRE (!wait_for_jobs());
red_a->set_position (film, dcpomatic::DCPTime());
red_a->video->set_length (240);
sub_a->set_position (film, dcpomatic::DCPTime());
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));
film->set_reel_type (ReelType::BY_VIDEO_CONTENT);
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<dcp::CPL> cpl = dcp.cpls().front();
auto reels = cpl->reels ();
BOOST_REQUIRE_EQUAL (reels.size(), 2U);
auto i = reels.begin ();
BOOST_REQUIRE ((*i)->main_subtitle());
BOOST_REQUIRE ((*i)->main_subtitle()->asset());
auto A = std::dynamic_pointer_cast<dcp::InteropSubtitleAsset>((*i)->main_subtitle()->asset());
BOOST_REQUIRE (A);
++i;
BOOST_REQUIRE ((*i)->main_subtitle());
BOOST_REQUIRE ((*i)->main_subtitle()->asset());
auto B = std::dynamic_pointer_cast<dcp::InteropSubtitleAsset>((*i)->main_subtitle()->asset());
BOOST_REQUIRE (B);
BOOST_REQUIRE_EQUAL (A->subtitles().size(), 1U);
BOOST_REQUIRE_EQUAL (B->subtitles().size(), 1U);
/* 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)
{
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);
for (int i = 0; i < 3; ++i) {
auto 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));
}
auto subs = content_factory("test/data/15s.srt").front();
film->examine_and_add_content (subs);
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);
auto cpl = dcp.cpls()[0];
BOOST_REQUIRE_EQUAL (cpl->reels().size(), 3U);
for (auto 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)
{
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);
for (int i = 0; i < 3; ++i) {
auto 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));
}
auto ccap1 = content_factory("test/data/15s.srt").front();
film->examine_and_add_content (ccap1);
BOOST_REQUIRE (!wait_for_jobs());
ccap1->text.front()->set_type (TextType::CLOSED_CAPTION);
ccap1->text.front()->set_dcp_track (DCPTextTrack("Test", dcp::LanguageTag("de-DE")));
auto ccap2 = content_factory("test/data/15s.srt").front();
film->examine_and_add_content (ccap2);
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
});
dcp::DCP dcp ("build/test/closed_captions_in_all_reels_test/" + film->dcp_name());
dcp.read ();
BOOST_REQUIRE_EQUAL (dcp.cpls().size(), 1U);
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);
auto first = i->closed_captions().front()->language();
auto 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")
);
}
}
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").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));
}
auto subtitle = content_factory("test/data/45s.srt").front();
film->examine_and_add_content (subtitle);
BOOST_REQUIRE (!wait_for_jobs());
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);
}
}
|