Inspect most DCPs made during tests with dcp_inspect (#76).
[dcpomatic.git] / test / vf_test.cc
1 /*
2     Copyright (C) 2015-2021 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
6     DCP-o-matic is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     DCP-o-matic is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21
22 /** @file  test/vf_Test.cc
23  *  @brief Various VF-related tests.
24  *  @ingroup feature
25  */
26
27
28 #include "lib/content_factory.h"
29 #include "lib/dcp_content.h"
30 #include "lib/dcp_content_type.h"
31 #include "lib/examine_content_job.h"
32 #include "lib/ffmpeg_content.h"
33 #include "lib/film.h"
34 #include "lib/job_manager.h"
35 #include "lib/make_dcp.h"
36 #include "lib/player.h"
37 #include "lib/ratio.h"
38 #include "lib/text_content.h"
39 #include "lib/referenced_reel_asset.h"
40 #include "lib/video_content.h"
41 #include "test.h"
42 #include <dcp/cpl.h>
43 #include <dcp/mono_picture_asset.h>
44 #include <dcp/picture_asset_writer.h>
45 #include <dcp/reel.h>
46 #include <dcp/reel_mono_picture_asset.h>
47 #include <dcp/reel_sound_asset.h>
48 #include <dcp/reel_smpte_subtitle_asset.h>
49 #include <dcp/smpte_subtitle_asset.h>
50 #include <dcp/subtitle_string.h>
51 #include <boost/test/unit_test.hpp>
52 #include <iostream>
53
54
55 using std::cout;
56 using std::dynamic_pointer_cast;
57 using std::list;
58 using std::make_shared;
59 using std::shared_ptr;
60 using std::string;
61 using std::vector;
62 using namespace dcpomatic;
63
64
65 /** Test the logic which decides whether a DCP can be referenced or not */
66 BOOST_AUTO_TEST_CASE (vf_test1)
67 {
68         auto film = new_test_film ("vf_test1");
69         film->set_interop (false);
70         auto dcp = make_shared<DCPContent>("test/data/reels_test2");
71         film->examine_and_add_content (dcp);
72         BOOST_REQUIRE (!wait_for_jobs());
73
74         /* Multi-reel DCP can't be referenced if we are using a single reel for the project */
75         film->set_reel_type (ReelType::SINGLE);
76         string why_not;
77         BOOST_CHECK (!dcp->can_reference_video(film, why_not));
78         BOOST_CHECK (!dcp->can_reference_audio(film, why_not));
79         BOOST_CHECK (!dcp->can_reference_text(film, TextType::OPEN_SUBTITLE, why_not));
80         BOOST_CHECK (!dcp->can_reference_text(film, TextType::CLOSED_CAPTION, why_not));
81
82         /* Multi-reel DCP can be referenced if we are using by-video-content */
83         film->set_reel_type (ReelType::BY_VIDEO_CONTENT);
84         BOOST_CHECK (dcp->can_reference_video(film, why_not));
85         BOOST_CHECK (dcp->can_reference_audio(film, why_not));
86         /* (but reels_test2 has no texts to reference) */
87         BOOST_CHECK (!dcp->can_reference_text(film, TextType::OPEN_SUBTITLE, why_not));
88         BOOST_CHECK (!dcp->can_reference_text(film, TextType::CLOSED_CAPTION, why_not));
89
90         auto other = make_shared<FFmpegContent>("test/data/test.mp4");
91         film->examine_and_add_content (other);
92         BOOST_REQUIRE (!wait_for_jobs());
93         BOOST_CHECK (!other->audio);
94
95         /* Not possible if there is overlap; we only check video here as that's all test.mp4 has */
96         other->set_position (film, DCPTime());
97         BOOST_CHECK (!dcp->can_reference_video(film, why_not));
98
99         /* This should not be considered an overlap */
100         other->set_position (film, dcp->end(film));
101         BOOST_CHECK (dcp->can_reference_video(film, why_not));
102         BOOST_CHECK (dcp->can_reference_audio(film, why_not));
103         /* (reels_test2 has no texts to reference) */
104         BOOST_CHECK (!dcp->can_reference_text(film, TextType::OPEN_SUBTITLE, why_not));
105         BOOST_CHECK (!dcp->can_reference_text(film, TextType::CLOSED_CAPTION, why_not));
106 }
107
108
109 /** Make a OV with video and audio and a VF referencing the OV and adding subs */
110 BOOST_AUTO_TEST_CASE (vf_test2)
111 {
112         /* Make the OV */
113         auto ov = new_test_film ("vf_test2_ov");
114         ov->set_dcp_content_type (DCPContentType::from_isdcf_name("TST"));
115         ov->set_name ("vf_test2_ov");
116         auto video = content_factory("test/data/flat_red.png")[0];
117         ov->examine_and_add_content (video);
118         BOOST_REQUIRE (!wait_for_jobs());
119         video->video->set_length (24 * 5);
120         auto audio = content_factory("test/data/white.wav")[0];
121         ov->examine_and_add_content (audio);
122         BOOST_REQUIRE (!wait_for_jobs());
123         make_and_verify_dcp (ov);
124
125         /* Make the VF */
126         auto vf = new_test_film ("vf_test2_vf");
127         vf->set_name ("vf_test2_vf");
128         vf->set_dcp_content_type (DCPContentType::from_isdcf_name("TST"));
129         vf->set_reel_type (ReelType::BY_VIDEO_CONTENT);
130         auto dcp = make_shared<DCPContent>(ov->dir(ov->dcp_name()));
131         vf->examine_and_add_content (dcp);
132         BOOST_REQUIRE (!wait_for_jobs());
133         dcp->set_reference_video (true);
134         dcp->set_reference_audio (true);
135         auto sub = content_factory("test/data/subrip4.srt")[0];
136         vf->examine_and_add_content (sub);
137         BOOST_REQUIRE (!wait_for_jobs());
138         make_and_verify_dcp (
139                 vf,
140                 {
141                         dcp::VerificationNote::Code::EXTERNAL_ASSET,
142                         dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE,
143                         dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME,
144                         dcp::VerificationNote::Code::INVALID_SUBTITLE_DURATION
145                 },
146                 false
147                 );
148
149         dcp::DCP ov_c (ov->dir(ov->dcp_name()));
150         ov_c.read ();
151         BOOST_REQUIRE_EQUAL (ov_c.cpls().size(), 1U);
152         BOOST_REQUIRE_EQUAL (ov_c.cpls()[0]->reels().size(), 1U);
153         BOOST_REQUIRE (ov_c.cpls()[0]->reels()[0]->main_picture());
154         string const pic_id = ov_c.cpls()[0]->reels()[0]->main_picture()->id();
155         BOOST_REQUIRE (ov_c.cpls()[0]->reels()[0]->main_sound());
156         string const sound_id = ov_c.cpls()[0]->reels()[0]->main_sound()->id();
157         BOOST_REQUIRE (!ov_c.cpls()[0]->reels()[0]->main_subtitle());
158
159         dcp::DCP vf_c (vf->dir(vf->dcp_name()));
160         vf_c.read ();
161         BOOST_REQUIRE_EQUAL (vf_c.cpls().size(), 1U);
162         BOOST_REQUIRE_EQUAL (vf_c.cpls()[0]->reels().size(), 1U);
163         BOOST_REQUIRE (vf_c.cpls()[0]->reels()[0]->main_picture());
164         BOOST_CHECK_EQUAL (vf_c.cpls()[0]->reels()[0]->main_picture()->id(), pic_id);
165         BOOST_REQUIRE (vf_c.cpls()[0]->reels()[0]->main_sound());
166         BOOST_CHECK_EQUAL (vf_c.cpls()[0]->reels()[0]->main_sound()->id(), sound_id);
167         BOOST_REQUIRE (vf_c.cpls()[0]->reels()[0]->main_subtitle());
168 }
169
170
171 /** Test creation of a VF using a trimmed OV; the output should have entry point /
172  *  duration altered to effect the trimming.
173  */
174 BOOST_AUTO_TEST_CASE (vf_test3)
175 {
176         /* Make the OV */
177         auto ov = new_test_film ("vf_test3_ov");
178         ov->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST"));
179         ov->set_name ("vf_test3_ov");
180         auto video = content_factory("test/data/flat_red.png")[0];
181         ov->examine_and_add_content (video);
182         BOOST_REQUIRE (!wait_for_jobs());
183         video->video->set_length (24 * 5);
184         auto audio = content_factory("test/data/white.wav")[0];
185         ov->examine_and_add_content (audio);
186         BOOST_REQUIRE (!wait_for_jobs());
187         make_and_verify_dcp (ov);
188
189         /* Make the VF */
190         auto vf = new_test_film ("vf_test3_vf");
191         vf->set_name ("vf_test3_vf");
192         vf->set_dcp_content_type (DCPContentType::from_isdcf_name("TST"));
193         vf->set_reel_type (ReelType::BY_VIDEO_CONTENT);
194         auto dcp = make_shared<DCPContent>(ov->dir(ov->dcp_name()));
195         BOOST_REQUIRE (dcp);
196         dcp->set_trim_start(vf, ContentTime::from_seconds (1));
197         dcp->set_trim_end (ContentTime::from_seconds (1));
198         vf->examine_and_add_content (dcp);
199         BOOST_REQUIRE (!wait_for_jobs());
200         dcp->set_reference_video (true);
201         dcp->set_reference_audio (true);
202         make_and_verify_dcp(vf, {dcp::VerificationNote::Code::EXTERNAL_ASSET}, false);
203
204         dcp::DCP vf_c (vf->dir(vf->dcp_name()));
205         vf_c.read ();
206         BOOST_REQUIRE_EQUAL (vf_c.cpls().size(), 1U);
207         BOOST_REQUIRE_EQUAL (vf_c.cpls()[0]->reels().size(), 1U);
208         BOOST_REQUIRE (vf_c.cpls()[0]->reels()[0]->main_picture());
209         BOOST_CHECK_EQUAL (vf_c.cpls()[0]->reels()[0]->main_picture()->entry_point().get_value_or(0), 24);
210         BOOST_CHECK_EQUAL (vf_c.cpls()[0]->reels()[0]->main_picture()->actual_duration(), 72);
211         BOOST_REQUIRE (vf_c.cpls()[0]->reels()[0]->main_sound());
212         BOOST_CHECK_EQUAL (vf_c.cpls()[0]->reels()[0]->main_sound()->entry_point().get_value_or(0), 24);
213         BOOST_CHECK_EQUAL (vf_c.cpls()[0]->reels()[0]->main_sound()->actual_duration(), 72);
214 }
215
216
217 /** Make a OV with video and audio and a VF referencing the OV and adding some more video */
218 BOOST_AUTO_TEST_CASE (vf_test4)
219 {
220         /* Make the OV */
221         auto ov = new_test_film ("vf_test4_ov");
222         ov->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST"));
223         ov->set_name ("vf_test4_ov");
224         auto video = content_factory("test/data/flat_red.png")[0];
225         ov->examine_and_add_content (video);
226         BOOST_REQUIRE (!wait_for_jobs());
227         video->video->set_length (24 * 5);
228         auto audio = content_factory("test/data/white.wav")[0];
229         ov->examine_and_add_content (audio);
230         BOOST_REQUIRE (!wait_for_jobs());
231         make_and_verify_dcp (ov);
232
233         /* Make the VF */
234         auto vf = new_test_film ("vf_test4_vf");
235         vf->set_name ("vf_test4_vf");
236         vf->set_dcp_content_type (DCPContentType::from_isdcf_name("TST"));
237         vf->set_reel_type (ReelType::BY_VIDEO_CONTENT);
238         vf->set_sequence (false);
239         auto dcp = make_shared<DCPContent>(ov->dir(ov->dcp_name()));
240         BOOST_REQUIRE (dcp);
241         vf->examine_and_add_content (dcp);
242         BOOST_REQUIRE (!wait_for_jobs());
243         dcp->set_position(vf, DCPTime::from_seconds(10));
244         dcp->set_reference_video (true);
245         dcp->set_reference_audio (true);
246         auto more_video = content_factory("test/data/flat_red.png")[0];
247         vf->examine_and_add_content (more_video);
248         BOOST_REQUIRE (!wait_for_jobs());
249         more_video->set_position (vf, DCPTime());
250         vf->write_metadata ();
251         make_and_verify_dcp(vf, {dcp::VerificationNote::Code::EXTERNAL_ASSET}, false);
252
253         dcp::DCP ov_c (ov->dir(ov->dcp_name()));
254         ov_c.read ();
255         BOOST_REQUIRE_EQUAL (ov_c.cpls().size(), 1U);
256         BOOST_REQUIRE_EQUAL (ov_c.cpls()[0]->reels().size(), 1U);
257         BOOST_REQUIRE (ov_c.cpls()[0]->reels()[0]->main_picture());
258         string const pic_id = ov_c.cpls()[0]->reels()[0]->main_picture()->id();
259         BOOST_REQUIRE (ov_c.cpls()[0]->reels()[0]->main_sound());
260         string const sound_id = ov_c.cpls()[0]->reels()[0]->main_sound()->id();
261         BOOST_REQUIRE (!ov_c.cpls()[0]->reels()[0]->main_subtitle());
262
263         dcp::DCP vf_c (vf->dir (vf->dcp_name ()));
264         vf_c.read ();
265         BOOST_REQUIRE_EQUAL (vf_c.cpls().size(), 1U);
266         BOOST_REQUIRE_EQUAL (vf_c.cpls()[0]->reels().size(), 2U);
267         BOOST_REQUIRE (vf_c.cpls()[0]->reels().back()->main_picture());
268         BOOST_CHECK_EQUAL (vf_c.cpls()[0]->reels().back()->main_picture()->id(), pic_id);
269         BOOST_REQUIRE (vf_c.cpls()[0]->reels().back()->main_sound());
270         BOOST_CHECK_EQUAL (vf_c.cpls()[0]->reels().back()->main_sound()->id(), sound_id);
271 }
272
273
274 /** Test bug #1495 */
275 BOOST_AUTO_TEST_CASE (vf_test5)
276 {
277         /* Make the OV */
278         auto ov = new_test_film ("vf_test5_ov");
279         ov->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST"));
280         ov->set_reel_type (ReelType::BY_VIDEO_CONTENT);
281         for (int i = 0; i < 3; ++i) {
282                 auto video = content_factory("test/data/flat_red.png")[0];
283                 ov->examine_and_add_content (video);
284                 BOOST_REQUIRE (!wait_for_jobs());
285                 video->video->set_length (24 * 10);
286         }
287
288         BOOST_REQUIRE (!wait_for_jobs());
289         make_and_verify_dcp (ov);
290
291         /* Make the VF */
292         auto vf = new_test_film ("vf_test5_vf");
293         vf->set_name ("vf_test5_vf");
294         vf->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST"));
295         vf->set_reel_type (ReelType::BY_VIDEO_CONTENT);
296         vf->set_sequence (false);
297         auto dcp = make_shared<DCPContent>(ov->dir(ov->dcp_name()));
298         BOOST_REQUIRE (dcp);
299         vf->examine_and_add_content (dcp);
300         BOOST_REQUIRE (!wait_for_jobs());
301         dcp->set_reference_video (true);
302         dcp->set_reference_audio (true);
303         dcp->set_trim_end (ContentTime::from_seconds(15));
304         make_and_verify_dcp(vf, {dcp::VerificationNote::Code::EXTERNAL_ASSET}, false);
305
306         /* Check that the selected reel assets are right */
307         auto a = get_referenced_reel_assets(vf, vf->playlist());
308         BOOST_REQUIRE_EQUAL (a.size(), 4U);
309         auto i = a.begin();
310         BOOST_CHECK (i->period == DCPTimePeriod(DCPTime(0), DCPTime(960000)));
311         ++i;
312         BOOST_CHECK (i->period == DCPTimePeriod(DCPTime(0), DCPTime(960000)));
313         ++i;
314         BOOST_CHECK (i->period == DCPTimePeriod(DCPTime(960000), DCPTime(1440000)));
315         ++i;
316         BOOST_CHECK (i->period == DCPTimePeriod(DCPTime(960000), DCPTime(1440000)));
317         ++i;
318 }
319
320
321 /** Test bug #1528 */
322 BOOST_AUTO_TEST_CASE (vf_test6)
323 {
324         /* Make the OV */
325         auto ov = new_test_film ("vf_test6_ov");
326         ov->set_dcp_content_type (DCPContentType::from_isdcf_name("TST"));
327         ov->set_reel_type (ReelType::BY_VIDEO_CONTENT);
328         auto video = content_factory("test/data/flat_red.png")[0];
329         ov->examine_and_add_content (video);
330         BOOST_REQUIRE (!wait_for_jobs());
331         video->video->set_length (24 * 10);
332         make_and_verify_dcp (ov);
333
334         /* Make the VF */
335         auto vf = new_test_film ("vf_test6_vf");
336         vf->set_name ("vf_test6_vf");
337         vf->set_dcp_content_type (DCPContentType::from_isdcf_name("TST"));
338         vf->set_reel_type (ReelType::BY_VIDEO_CONTENT);
339         vf->set_sequence (false);
340         auto dcp = make_shared<DCPContent>(ov->dir(ov->dcp_name()));
341         vf->examine_and_add_content (dcp);
342         BOOST_REQUIRE (!wait_for_jobs());
343         dcp->set_reference_video (true);
344         dcp->set_reference_audio (true);
345
346         auto sub = content_factory("test/data/15s.srt")[0];
347         vf->examine_and_add_content (sub);
348         BOOST_REQUIRE (!wait_for_jobs());
349
350         make_and_verify_dcp (
351                 vf,
352                 {
353                         dcp::VerificationNote::Code::EXTERNAL_ASSET,
354                         dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE,
355                         dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME
356                 },
357                 false
358                 );
359 }
360
361
362 /** Test bug #1643 (the second part; referring fails if there are gaps) */
363 BOOST_AUTO_TEST_CASE (vf_test7)
364 {
365         /* First OV */
366         auto ov1 = new_test_film2 ("vf_test7_ov1", {content_factory("test/data/flat_red.png")[0]});
367         ov1->set_video_frame_rate (24);
368         make_and_verify_dcp (ov1);
369
370         /* Second OV */
371         auto ov2 = new_test_film2 ("vf_test7_ov2", {content_factory("test/data/flat_red.png")[0]});
372         ov2->set_video_frame_rate (24);
373         make_and_verify_dcp (ov2);
374
375         /* VF */
376         auto ov1_dcp = make_shared<DCPContent>(ov1->dir(ov1->dcp_name()));
377         auto ov2_dcp = make_shared<DCPContent>(ov2->dir(ov2->dcp_name()));
378         auto vf = new_test_film2 ("vf_test7_vf", {ov1_dcp, ov2_dcp});
379         vf->set_reel_type (ReelType::BY_VIDEO_CONTENT);
380         ov1_dcp->set_reference_video (true);
381         ov2_dcp->set_reference_video (true);
382         ov1_dcp->set_position (vf, DCPTime::from_seconds(1));
383         ov2_dcp->set_position (vf, DCPTime::from_seconds(20));
384         vf->write_metadata ();
385         make_and_verify_dcp (vf);
386 }
387
388
389 /** Test bug #2116 */
390 BOOST_AUTO_TEST_CASE (test_vf_with_trimmed_multi_reel_dcp)
391 {
392         /* Make an OV with 3 reels */
393         std::vector<std::shared_ptr<Content>> ov_content;
394         for (int i = 0; i < 3; ++i) {
395                 auto c = content_factory("test/data/flat_red.png")[0];
396                 c->video->set_length(240);
397                 ov_content.push_back(c);
398         }
399         auto ov = new_test_film2 ("test_vf_with_trimmed_multi_reel_dcp_ov", ov_content);
400         ov->set_reel_type(ReelType::BY_VIDEO_CONTENT);
401         make_and_verify_dcp (ov);
402
403         /* Make a VF with a specific arrangement */
404         auto vf_image = content_factory("test/data/flat_red.png")[0];
405         auto vf_dcp = make_shared<DCPContent>(ov->dir(ov->dcp_name()));
406         auto vf = new_test_film2 ("test_vf_with_trimmed_multi_reel_dcp_vf", { vf_image, vf_dcp });
407         vf->set_reel_type(ReelType::BY_VIDEO_CONTENT);
408         vf_dcp->set_reference_video(true);
409         vf_dcp->set_reference_audio(true);
410         vf_dcp->set_trim_start(vf, ContentTime::from_seconds(10));
411         vf_dcp->set_position(vf, DCPTime::from_seconds(10));
412         make_and_verify_dcp(vf, { dcp::VerificationNote::Code::EXTERNAL_ASSET }, false);
413 }
414
415
416 /** Test bug #2599: unable to reference open subtitles in an OV when creating a VF that adds closed captions */
417 BOOST_AUTO_TEST_CASE(test_referencing_ov_with_subs_when_adding_ccaps)
418 {
419         string const name("test_referencing_ov_with_subs_when_adding_ccaps");
420         auto subs = content_factory("test/data/15s.srt");
421         auto ov = new_test_film2(name + "_ov", subs);
422         make_and_verify_dcp(
423                 ov,
424                 {
425                         dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE,
426                         dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME,
427                         dcp::VerificationNote::Code::MISSING_CPL_METADATA
428                 });
429
430         auto ccaps = content_factory("test/data/15s.srt")[0];
431         auto ov_dcp = make_shared<DCPContent>(ov->dir(ov->dcp_name(false)));
432         auto vf = new_test_film2(name + "_vf", { ov_dcp, ccaps });
433         ccaps->text[0]->set_type(TextType::CLOSED_CAPTION);
434
435         string why_not;
436         BOOST_CHECK(ov_dcp->can_reference_text(vf, TextType::OPEN_SUBTITLE, why_not));
437         std::cout << why_not << "\n";
438 }
439
440
441 BOOST_AUTO_TEST_CASE(test_duplicate_font_id_in_vf)
442 {
443         string const name("test_duplicate_font_id_in_vf");
444         auto subs = content_factory("test/data/15s.srt");
445         auto ov = new_test_film2(name + "_ov", subs);
446         make_and_verify_dcp(
447                 ov,
448                 {
449                         dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE,
450                         dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME,
451                         dcp::VerificationNote::Code::MISSING_CPL_METADATA
452                 });
453
454         auto ccaps = content_factory("test/data/15s.srt")[0];
455         auto ov_dcp = make_shared<DCPContent>(ov->dir(ov->dcp_name(false)));
456         auto vf = new_test_film2(name + "_vf", { ov_dcp, ccaps });
457         ov_dcp->set_reference_audio(true);
458         ov_dcp->set_reference_video(true);
459         ov_dcp->text[0]->set_use(true);
460         ccaps->text[0]->set_type(TextType::CLOSED_CAPTION);
461         string why_not;
462         BOOST_CHECK_MESSAGE(ov_dcp->can_reference_text(vf, TextType::OPEN_SUBTITLE, why_not), why_not);
463         ov_dcp->set_reference_text(TextType::OPEN_SUBTITLE, true);
464         vf->write_metadata();
465         make_dcp(vf, TranscodeJob::ChangedBehaviour::IGNORE);
466         BOOST_REQUIRE(!wait_for_jobs());
467
468         auto vf_dcp = make_shared<DCPContent>(vf->dir(vf->dcp_name(false)));
469
470         auto test = new_test_film2(name + "_test", { vf_dcp });
471         vf_dcp->add_ov(ov->dir(ov->dcp_name(false)));
472         JobManager::instance()->add(make_shared<ExamineContentJob>(test, vf_dcp));
473         BOOST_CHECK(!wait_for_jobs());
474
475         make_and_verify_dcp(
476                 test,
477                 {
478                         dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE,
479                         dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME,
480                         dcp::VerificationNote::Code::MISSING_CPL_METADATA,
481                 });
482 }
483
484
485 BOOST_AUTO_TEST_CASE(test_referencing_ov_with_missing_subtitle_in_some_reels)
486 {
487         auto const path = boost::filesystem::path("build/test/test_referencing_ov_with_missing_subtitle_in_some_reels");
488         boost::filesystem::remove_all(path);
489
490         boost::filesystem::create_directories(path / "ov");
491         dcp::DCP ov(path / "ov");
492
493         auto make_picture = [path](string filename) {
494                 auto pic = make_shared<dcp::MonoPictureAsset>(dcp::Fraction(24, 1), dcp::Standard::SMPTE);
495                 auto writer = pic->start_write(path / "ov" / filename, dcp::PictureAsset::Behaviour::MAKE_NEW);
496                 auto frame = dcp::ArrayData("test/data/picture.j2c");
497                 for (int i = 0; i < 240; ++i) {
498                         writer->write(frame);
499                 }
500                 writer->finalize();
501                 return pic;
502         };
503
504         auto pic1 = make_picture("pic1.mxf");
505         auto pic2 = make_picture("pic2.mxf");
506
507         auto sub1 = make_shared<dcp::SMPTESubtitleAsset>();
508
509         sub1->add(std::make_shared<dcp::SubtitleString>(
510                 boost::optional<string>(), false, false, false, dcp::Colour(255, 255, 255),
511                 42, 1, dcp::Time(0, 0, 5, 0, 24), dcp::Time(0, 0, 9, 0, 24),
512                 0, dcp::HAlign::CENTER,
513                 0, dcp::VAlign::CENTER,
514                 0, dcp::Direction::LTR,
515                 "Hello",
516                 dcp::Effect::NONE, dcp::Colour(0, 0, 0),
517                 dcp::Time{}, dcp::Time{},
518                 0, vector<dcp::Ruby>{}
519                 ));
520         sub1->write(path / "ov" / "sub.mxf");
521
522         auto reel1_pic = make_shared<dcp::ReelMonoPictureAsset>(pic1, 0);
523         auto reel1_sub = make_shared<dcp::ReelSMPTESubtitleAsset>(sub1, dcp::Fraction(24, 1), 240, 0);
524
525         auto reel2_pic = make_shared<dcp::ReelMonoPictureAsset>(pic1, 0);
526
527         auto reel1 = make_shared<dcp::Reel>(reel1_pic, shared_ptr<dcp::ReelSoundAsset>(), reel1_sub);
528         auto reel2 = make_shared<dcp::Reel>(reel2_pic);
529
530         auto cpl = make_shared<dcp::CPL>("Test CPL", dcp::ContentKind::FEATURE, dcp::Standard::SMPTE);
531         cpl->add(reel1);
532         cpl->add(reel2);
533
534         ov.add(cpl);
535         ov.write_xml();
536
537         auto dcp_ov = make_shared<DCPContent>(path / "ov");
538         auto vf = make_shared<Film>(path / "vf");
539         vf->set_dcp_content_type(DCPContentType::from_isdcf_name("TST"));
540         vf->set_container(Ratio::from_id("185"));
541         vf->write_metadata();
542         vf->examine_and_add_content(dcp_ov);
543         BOOST_REQUIRE(!wait_for_jobs());
544         vf->set_reel_type(ReelType::BY_VIDEO_CONTENT);
545         dcp_ov->set_reference_video(true);
546         dcp_ov->set_reference_text(TextType::OPEN_SUBTITLE, true);
547
548         vf->write_metadata();
549         make_dcp(vf, TranscodeJob::ChangedBehaviour::IGNORE);
550         BOOST_REQUIRE(!wait_for_jobs());
551
552         vector<dcp::VerificationNote::Code> ignore = {
553                 dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE,
554                 dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME,
555                 dcp::VerificationNote::Code::INVALID_SUBTITLE_SPACING,
556                 dcp::VerificationNote::Code::EXTERNAL_ASSET,
557         };
558
559         verify_dcp(vf->dir(vf->dcp_name()), ignore);
560 }
561