Missed update to private test repo version.
[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         film->set_audio_channels(16);
77         string why_not;
78         BOOST_CHECK (!dcp->can_reference_video(film, why_not));
79         BOOST_CHECK (!dcp->can_reference_audio(film, why_not));
80         BOOST_CHECK (!dcp->can_reference_text(film, TextType::OPEN_SUBTITLE, why_not));
81         BOOST_CHECK (!dcp->can_reference_text(film, TextType::CLOSED_CAPTION, why_not));
82
83         /* Multi-reel DCP can be referenced if we are using by-video-content */
84         film->set_reel_type (ReelType::BY_VIDEO_CONTENT);
85         BOOST_CHECK (dcp->can_reference_video(film, why_not));
86         BOOST_CHECK (dcp->can_reference_audio(film, why_not));
87         /* (but reels_test2 has no texts to reference) */
88         BOOST_CHECK (!dcp->can_reference_text(film, TextType::OPEN_SUBTITLE, why_not));
89         BOOST_CHECK (!dcp->can_reference_text(film, TextType::CLOSED_CAPTION, why_not));
90
91         auto other = make_shared<FFmpegContent>("test/data/test.mp4");
92         film->examine_and_add_content (other);
93         BOOST_REQUIRE (!wait_for_jobs());
94         BOOST_CHECK (!other->audio);
95
96         /* Not possible if there is overlap; we only check video here as that's all test.mp4 has */
97         other->set_position (film, DCPTime());
98         BOOST_CHECK (!dcp->can_reference_video(film, why_not));
99
100         /* This should not be considered an overlap */
101         other->set_position (film, dcp->end(film));
102         BOOST_CHECK (dcp->can_reference_video(film, why_not));
103         BOOST_CHECK (dcp->can_reference_audio(film, why_not));
104         /* (reels_test2 has no texts to reference) */
105         BOOST_CHECK (!dcp->can_reference_text(film, TextType::OPEN_SUBTITLE, why_not));
106         BOOST_CHECK (!dcp->can_reference_text(film, TextType::CLOSED_CAPTION, why_not));
107 }
108
109
110 /** Make a OV with video and audio and a VF referencing the OV and adding subs */
111 BOOST_AUTO_TEST_CASE (vf_test2)
112 {
113         /* Make the OV */
114         auto ov = new_test_film ("vf_test2_ov");
115         ov->set_dcp_content_type (DCPContentType::from_isdcf_name("TST"));
116         ov->set_name ("vf_test2_ov");
117         auto video = content_factory("test/data/flat_red.png")[0];
118         ov->examine_and_add_content (video);
119         BOOST_REQUIRE (!wait_for_jobs());
120         video->video->set_length (24 * 5);
121         auto audio = content_factory("test/data/white.wav")[0];
122         ov->examine_and_add_content (audio);
123         BOOST_REQUIRE (!wait_for_jobs());
124         make_and_verify_dcp (ov);
125
126         /* Make the VF */
127         auto vf = new_test_film ("vf_test2_vf");
128         vf->set_name ("vf_test2_vf");
129         vf->set_dcp_content_type (DCPContentType::from_isdcf_name("TST"));
130         vf->set_reel_type (ReelType::BY_VIDEO_CONTENT);
131         auto dcp = make_shared<DCPContent>(ov->dir(ov->dcp_name()));
132         vf->examine_and_add_content (dcp);
133         BOOST_REQUIRE (!wait_for_jobs());
134         dcp->set_reference_video (true);
135         dcp->set_reference_audio (true);
136         auto sub = content_factory("test/data/subrip4.srt")[0];
137         vf->examine_and_add_content (sub);
138         BOOST_REQUIRE (!wait_for_jobs());
139         make_and_verify_dcp (
140                 vf,
141                 {
142                         dcp::VerificationNote::Code::EXTERNAL_ASSET,
143                         dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE,
144                         dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME,
145                         dcp::VerificationNote::Code::INVALID_SUBTITLE_DURATION
146                 },
147                 false
148                 );
149
150         dcp::DCP ov_c (ov->dir(ov->dcp_name()));
151         ov_c.read ();
152         BOOST_REQUIRE_EQUAL (ov_c.cpls().size(), 1U);
153         BOOST_REQUIRE_EQUAL (ov_c.cpls()[0]->reels().size(), 1U);
154         BOOST_REQUIRE (ov_c.cpls()[0]->reels()[0]->main_picture());
155         string const pic_id = ov_c.cpls()[0]->reels()[0]->main_picture()->id();
156         BOOST_REQUIRE (ov_c.cpls()[0]->reels()[0]->main_sound());
157         string const sound_id = ov_c.cpls()[0]->reels()[0]->main_sound()->id();
158         BOOST_REQUIRE (!ov_c.cpls()[0]->reels()[0]->main_subtitle());
159
160         dcp::DCP vf_c (vf->dir(vf->dcp_name()));
161         vf_c.read ();
162         BOOST_REQUIRE_EQUAL (vf_c.cpls().size(), 1U);
163         BOOST_REQUIRE_EQUAL (vf_c.cpls()[0]->reels().size(), 1U);
164         BOOST_REQUIRE (vf_c.cpls()[0]->reels()[0]->main_picture());
165         BOOST_CHECK_EQUAL (vf_c.cpls()[0]->reels()[0]->main_picture()->id(), pic_id);
166         BOOST_REQUIRE (vf_c.cpls()[0]->reels()[0]->main_sound());
167         BOOST_CHECK_EQUAL (vf_c.cpls()[0]->reels()[0]->main_sound()->id(), sound_id);
168         BOOST_REQUIRE (vf_c.cpls()[0]->reels()[0]->main_subtitle());
169 }
170
171
172 /** Test creation of a VF using a trimmed OV; the output should have entry point /
173  *  duration altered to effect the trimming.
174  */
175 BOOST_AUTO_TEST_CASE (vf_test3)
176 {
177         /* Make the OV */
178         auto ov = new_test_film ("vf_test3_ov");
179         ov->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST"));
180         ov->set_name ("vf_test3_ov");
181         auto video = content_factory("test/data/flat_red.png")[0];
182         ov->examine_and_add_content (video);
183         BOOST_REQUIRE (!wait_for_jobs());
184         video->video->set_length (24 * 5);
185         auto audio = content_factory("test/data/white.wav")[0];
186         ov->examine_and_add_content (audio);
187         BOOST_REQUIRE (!wait_for_jobs());
188         make_and_verify_dcp (ov);
189
190         /* Make the VF */
191         auto vf = new_test_film ("vf_test3_vf");
192         vf->set_name ("vf_test3_vf");
193         vf->set_dcp_content_type (DCPContentType::from_isdcf_name("TST"));
194         vf->set_reel_type (ReelType::BY_VIDEO_CONTENT);
195         auto dcp = make_shared<DCPContent>(ov->dir(ov->dcp_name()));
196         BOOST_REQUIRE (dcp);
197         dcp->set_trim_start(vf, ContentTime::from_seconds (1));
198         dcp->set_trim_end (ContentTime::from_seconds (1));
199         vf->examine_and_add_content (dcp);
200         BOOST_REQUIRE (!wait_for_jobs());
201         dcp->set_reference_video (true);
202         dcp->set_reference_audio (true);
203         make_and_verify_dcp(vf, {dcp::VerificationNote::Code::EXTERNAL_ASSET}, false);
204
205         dcp::DCP vf_c (vf->dir(vf->dcp_name()));
206         vf_c.read ();
207         BOOST_REQUIRE_EQUAL (vf_c.cpls().size(), 1U);
208         BOOST_REQUIRE_EQUAL (vf_c.cpls()[0]->reels().size(), 1U);
209         BOOST_REQUIRE (vf_c.cpls()[0]->reels()[0]->main_picture());
210         BOOST_CHECK_EQUAL (vf_c.cpls()[0]->reels()[0]->main_picture()->entry_point().get_value_or(0), 24);
211         BOOST_CHECK_EQUAL (vf_c.cpls()[0]->reels()[0]->main_picture()->actual_duration(), 72);
212         BOOST_REQUIRE (vf_c.cpls()[0]->reels()[0]->main_sound());
213         BOOST_CHECK_EQUAL (vf_c.cpls()[0]->reels()[0]->main_sound()->entry_point().get_value_or(0), 24);
214         BOOST_CHECK_EQUAL (vf_c.cpls()[0]->reels()[0]->main_sound()->actual_duration(), 72);
215 }
216
217
218 /** Make a OV with video and audio and a VF referencing the OV and adding some more video */
219 BOOST_AUTO_TEST_CASE (vf_test4)
220 {
221         /* Make the OV */
222         auto ov = new_test_film ("vf_test4_ov");
223         ov->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST"));
224         ov->set_name ("vf_test4_ov");
225         auto video = content_factory("test/data/flat_red.png")[0];
226         ov->examine_and_add_content (video);
227         BOOST_REQUIRE (!wait_for_jobs());
228         video->video->set_length (24 * 5);
229         auto audio = content_factory("test/data/white.wav")[0];
230         ov->examine_and_add_content (audio);
231         BOOST_REQUIRE (!wait_for_jobs());
232         make_and_verify_dcp (ov);
233
234         /* Make the VF */
235         auto vf = new_test_film ("vf_test4_vf");
236         vf->set_name ("vf_test4_vf");
237         vf->set_dcp_content_type (DCPContentType::from_isdcf_name("TST"));
238         vf->set_reel_type (ReelType::BY_VIDEO_CONTENT);
239         vf->set_sequence (false);
240         auto dcp = make_shared<DCPContent>(ov->dir(ov->dcp_name()));
241         BOOST_REQUIRE (dcp);
242         vf->examine_and_add_content (dcp);
243         BOOST_REQUIRE (!wait_for_jobs());
244         dcp->set_position(vf, DCPTime::from_seconds(10));
245         dcp->set_reference_video (true);
246         dcp->set_reference_audio (true);
247         auto more_video = content_factory("test/data/flat_red.png")[0];
248         vf->examine_and_add_content (more_video);
249         BOOST_REQUIRE (!wait_for_jobs());
250         more_video->set_position (vf, DCPTime());
251         vf->write_metadata ();
252         make_and_verify_dcp(vf, {dcp::VerificationNote::Code::EXTERNAL_ASSET}, false);
253
254         dcp::DCP ov_c (ov->dir(ov->dcp_name()));
255         ov_c.read ();
256         BOOST_REQUIRE_EQUAL (ov_c.cpls().size(), 1U);
257         BOOST_REQUIRE_EQUAL (ov_c.cpls()[0]->reels().size(), 1U);
258         BOOST_REQUIRE (ov_c.cpls()[0]->reels()[0]->main_picture());
259         string const pic_id = ov_c.cpls()[0]->reels()[0]->main_picture()->id();
260         BOOST_REQUIRE (ov_c.cpls()[0]->reels()[0]->main_sound());
261         string const sound_id = ov_c.cpls()[0]->reels()[0]->main_sound()->id();
262         BOOST_REQUIRE (!ov_c.cpls()[0]->reels()[0]->main_subtitle());
263
264         dcp::DCP vf_c (vf->dir (vf->dcp_name ()));
265         vf_c.read ();
266         BOOST_REQUIRE_EQUAL (vf_c.cpls().size(), 1U);
267         BOOST_REQUIRE_EQUAL (vf_c.cpls()[0]->reels().size(), 2U);
268         BOOST_REQUIRE (vf_c.cpls()[0]->reels().back()->main_picture());
269         BOOST_CHECK_EQUAL (vf_c.cpls()[0]->reels().back()->main_picture()->id(), pic_id);
270         BOOST_REQUIRE (vf_c.cpls()[0]->reels().back()->main_sound());
271         BOOST_CHECK_EQUAL (vf_c.cpls()[0]->reels().back()->main_sound()->id(), sound_id);
272 }
273
274
275 /** Test bug #1495 */
276 BOOST_AUTO_TEST_CASE (vf_test5)
277 {
278         /* Make the OV */
279         auto ov = new_test_film ("vf_test5_ov");
280         ov->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST"));
281         ov->set_reel_type (ReelType::BY_VIDEO_CONTENT);
282         for (int i = 0; i < 3; ++i) {
283                 auto video = content_factory("test/data/flat_red.png")[0];
284                 ov->examine_and_add_content (video);
285                 BOOST_REQUIRE (!wait_for_jobs());
286                 video->video->set_length (24 * 10);
287         }
288
289         BOOST_REQUIRE (!wait_for_jobs());
290         make_and_verify_dcp (ov);
291
292         /* Make the VF */
293         auto vf = new_test_film ("vf_test5_vf");
294         vf->set_name ("vf_test5_vf");
295         vf->set_dcp_content_type (DCPContentType::from_isdcf_name ("TST"));
296         vf->set_reel_type (ReelType::BY_VIDEO_CONTENT);
297         vf->set_sequence (false);
298         auto dcp = make_shared<DCPContent>(ov->dir(ov->dcp_name()));
299         BOOST_REQUIRE (dcp);
300         vf->examine_and_add_content (dcp);
301         BOOST_REQUIRE (!wait_for_jobs());
302         dcp->set_reference_video (true);
303         dcp->set_reference_audio (true);
304         dcp->set_trim_end (ContentTime::from_seconds(15));
305         make_and_verify_dcp(vf, {dcp::VerificationNote::Code::EXTERNAL_ASSET}, false);
306
307         /* Check that the selected reel assets are right */
308         auto a = get_referenced_reel_assets(vf, vf->playlist());
309         BOOST_REQUIRE_EQUAL (a.size(), 4U);
310         auto i = a.begin();
311         BOOST_CHECK (i->period == DCPTimePeriod(DCPTime(0), DCPTime(960000)));
312         ++i;
313         BOOST_CHECK (i->period == DCPTimePeriod(DCPTime(0), DCPTime(960000)));
314         ++i;
315         BOOST_CHECK (i->period == DCPTimePeriod(DCPTime(960000), DCPTime(1440000)));
316         ++i;
317         BOOST_CHECK (i->period == DCPTimePeriod(DCPTime(960000), DCPTime(1440000)));
318         ++i;
319 }
320
321
322 /** Test bug #1528 */
323 BOOST_AUTO_TEST_CASE (vf_test6)
324 {
325         /* Make the OV */
326         auto ov = new_test_film ("vf_test6_ov");
327         ov->set_dcp_content_type (DCPContentType::from_isdcf_name("TST"));
328         ov->set_reel_type (ReelType::BY_VIDEO_CONTENT);
329         auto video = content_factory("test/data/flat_red.png")[0];
330         ov->examine_and_add_content (video);
331         BOOST_REQUIRE (!wait_for_jobs());
332         video->video->set_length (24 * 10);
333         make_and_verify_dcp (ov);
334
335         /* Make the VF */
336         auto vf = new_test_film ("vf_test6_vf");
337         vf->set_name ("vf_test6_vf");
338         vf->set_dcp_content_type (DCPContentType::from_isdcf_name("TST"));
339         vf->set_reel_type (ReelType::BY_VIDEO_CONTENT);
340         vf->set_sequence (false);
341         auto dcp = make_shared<DCPContent>(ov->dir(ov->dcp_name()));
342         vf->examine_and_add_content (dcp);
343         BOOST_REQUIRE (!wait_for_jobs());
344         dcp->set_reference_video (true);
345         dcp->set_reference_audio (true);
346
347         auto sub = content_factory("test/data/15s.srt")[0];
348         vf->examine_and_add_content (sub);
349         BOOST_REQUIRE (!wait_for_jobs());
350
351         make_and_verify_dcp (
352                 vf,
353                 {
354                         dcp::VerificationNote::Code::EXTERNAL_ASSET,
355                         dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE,
356                         dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME
357                 },
358                 false
359                 );
360 }
361
362
363 /** Test bug #1643 (the second part; referring fails if there are gaps) */
364 BOOST_AUTO_TEST_CASE (vf_test7)
365 {
366         /* First OV */
367         auto ov1 = new_test_film2 ("vf_test7_ov1", {content_factory("test/data/flat_red.png")[0]});
368         ov1->set_video_frame_rate (24);
369         make_and_verify_dcp (ov1);
370
371         /* Second OV */
372         auto ov2 = new_test_film2 ("vf_test7_ov2", {content_factory("test/data/flat_red.png")[0]});
373         ov2->set_video_frame_rate (24);
374         make_and_verify_dcp (ov2);
375
376         /* VF */
377         auto ov1_dcp = make_shared<DCPContent>(ov1->dir(ov1->dcp_name()));
378         auto ov2_dcp = make_shared<DCPContent>(ov2->dir(ov2->dcp_name()));
379         auto vf = new_test_film2 ("vf_test7_vf", {ov1_dcp, ov2_dcp});
380         vf->set_reel_type (ReelType::BY_VIDEO_CONTENT);
381         ov1_dcp->set_reference_video (true);
382         ov2_dcp->set_reference_video (true);
383         ov1_dcp->set_position (vf, DCPTime::from_seconds(1));
384         ov2_dcp->set_position (vf, DCPTime::from_seconds(20));
385         vf->write_metadata ();
386         make_and_verify_dcp (vf);
387 }
388
389
390 /** Test bug #2116 */
391 BOOST_AUTO_TEST_CASE (test_vf_with_trimmed_multi_reel_dcp)
392 {
393         /* Make an OV with 3 reels */
394         std::vector<std::shared_ptr<Content>> ov_content;
395         for (int i = 0; i < 3; ++i) {
396                 auto c = content_factory("test/data/flat_red.png")[0];
397                 c->video->set_length(240);
398                 ov_content.push_back(c);
399         }
400         auto ov = new_test_film2 ("test_vf_with_trimmed_multi_reel_dcp_ov", ov_content);
401         ov->set_reel_type(ReelType::BY_VIDEO_CONTENT);
402         make_and_verify_dcp (ov);
403
404         /* Make a VF with a specific arrangement */
405         auto vf_image = content_factory("test/data/flat_red.png")[0];
406         auto vf_dcp = make_shared<DCPContent>(ov->dir(ov->dcp_name()));
407         auto vf = new_test_film2 ("test_vf_with_trimmed_multi_reel_dcp_vf", { vf_image, vf_dcp });
408         vf->set_reel_type(ReelType::BY_VIDEO_CONTENT);
409         vf_dcp->set_reference_video(true);
410         vf_dcp->set_reference_audio(true);
411         vf_dcp->set_trim_start(vf, ContentTime::from_seconds(10));
412         vf_dcp->set_position(vf, DCPTime::from_seconds(10));
413         make_and_verify_dcp(vf, { dcp::VerificationNote::Code::EXTERNAL_ASSET }, false);
414 }
415
416
417 /** Test bug #2599: unable to reference open subtitles in an OV when creating a VF that adds closed captions */
418 BOOST_AUTO_TEST_CASE(test_referencing_ov_with_subs_when_adding_ccaps)
419 {
420         string const name("test_referencing_ov_with_subs_when_adding_ccaps");
421         auto subs = content_factory("test/data/15s.srt");
422         auto ov = new_test_film2(name + "_ov", subs);
423         make_and_verify_dcp(
424                 ov,
425                 {
426                         dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE,
427                         dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME,
428                         dcp::VerificationNote::Code::MISSING_CPL_METADATA
429                 });
430
431         auto ccaps = content_factory("test/data/15s.srt")[0];
432         auto ov_dcp = make_shared<DCPContent>(ov->dir(ov->dcp_name(false)));
433         auto vf = new_test_film2(name + "_vf", { ov_dcp, ccaps });
434         ccaps->text[0]->set_type(TextType::CLOSED_CAPTION);
435
436         string why_not;
437         BOOST_CHECK(ov_dcp->can_reference_text(vf, TextType::OPEN_SUBTITLE, why_not));
438         std::cout << why_not << "\n";
439 }
440
441
442 BOOST_AUTO_TEST_CASE(test_duplicate_font_id_in_vf)
443 {
444         string const name("test_duplicate_font_id_in_vf");
445         auto subs = content_factory("test/data/15s.srt");
446         auto ov = new_test_film2(name + "_ov", subs);
447         make_and_verify_dcp(
448                 ov,
449                 {
450                         dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE,
451                         dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME,
452                         dcp::VerificationNote::Code::MISSING_CPL_METADATA
453                 });
454
455         auto ccaps = content_factory("test/data/15s.srt")[0];
456         auto ov_dcp = make_shared<DCPContent>(ov->dir(ov->dcp_name(false)));
457         auto vf = new_test_film2(name + "_vf", { ov_dcp, ccaps });
458         ov_dcp->set_reference_audio(true);
459         ov_dcp->set_reference_video(true);
460         ov_dcp->text[0]->set_use(true);
461         ccaps->text[0]->set_type(TextType::CLOSED_CAPTION);
462         string why_not;
463         BOOST_CHECK_MESSAGE(ov_dcp->can_reference_text(vf, TextType::OPEN_SUBTITLE, why_not), why_not);
464         ov_dcp->set_reference_text(TextType::OPEN_SUBTITLE, true);
465         vf->write_metadata();
466         make_dcp(vf, TranscodeJob::ChangedBehaviour::IGNORE);
467         BOOST_REQUIRE(!wait_for_jobs());
468
469         auto vf_dcp = make_shared<DCPContent>(vf->dir(vf->dcp_name(false)));
470
471         auto test = new_test_film2(name + "_test", { vf_dcp });
472         vf_dcp->add_ov(ov->dir(ov->dcp_name(false)));
473         JobManager::instance()->add(make_shared<ExamineContentJob>(test, vf_dcp));
474         BOOST_CHECK(!wait_for_jobs());
475
476         make_and_verify_dcp(
477                 test,
478                 {
479                         dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE,
480                         dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME,
481                         dcp::VerificationNote::Code::MISSING_CPL_METADATA,
482                 });
483 }
484
485
486 BOOST_AUTO_TEST_CASE(test_referencing_ov_with_missing_subtitle_in_some_reels)
487 {
488         auto const path = boost::filesystem::path("build/test/test_referencing_ov_with_missing_subtitle_in_some_reels");
489         boost::filesystem::remove_all(path);
490
491         boost::filesystem::create_directories(path / "ov");
492         dcp::DCP ov(path / "ov");
493
494         auto make_picture = [path](string filename) {
495                 auto pic = make_shared<dcp::MonoPictureAsset>(dcp::Fraction(24, 1), dcp::Standard::SMPTE);
496                 auto writer = pic->start_write(path / "ov" / filename, dcp::PictureAsset::Behaviour::MAKE_NEW);
497                 auto frame = dcp::ArrayData("test/data/picture.j2c");
498                 for (int i = 0; i < 240; ++i) {
499                         writer->write(frame);
500                 }
501                 writer->finalize();
502                 return pic;
503         };
504
505         auto pic1 = make_picture("pic1.mxf");
506         auto pic2 = make_picture("pic2.mxf");
507
508         auto sub1 = make_shared<dcp::SMPTESubtitleAsset>();
509
510         sub1->add(std::make_shared<dcp::SubtitleString>(
511                 boost::optional<string>(), false, false, false, dcp::Colour(255, 255, 255),
512                 42, 1, dcp::Time(0, 0, 5, 0, 24), dcp::Time(0, 0, 9, 0, 24),
513                 0, dcp::HAlign::CENTER,
514                 0, dcp::VAlign::CENTER,
515                 0, dcp::Direction::LTR,
516                 "Hello",
517                 dcp::Effect::NONE, dcp::Colour(0, 0, 0),
518                 dcp::Time{}, dcp::Time{},
519                 0, vector<dcp::Ruby>{}
520                 ));
521         sub1->write(path / "ov" / "sub.mxf");
522
523         auto reel1_pic = make_shared<dcp::ReelMonoPictureAsset>(pic1, 0);
524         auto reel1_sub = make_shared<dcp::ReelSMPTESubtitleAsset>(sub1, dcp::Fraction(24, 1), 240, 0);
525
526         auto reel2_pic = make_shared<dcp::ReelMonoPictureAsset>(pic1, 0);
527
528         auto reel1 = make_shared<dcp::Reel>(reel1_pic, shared_ptr<dcp::ReelSoundAsset>(), reel1_sub);
529         auto reel2 = make_shared<dcp::Reel>(reel2_pic);
530
531         auto cpl = make_shared<dcp::CPL>("Test CPL", dcp::ContentKind::FEATURE, dcp::Standard::SMPTE);
532         cpl->add(reel1);
533         cpl->add(reel2);
534
535         ov.add(cpl);
536         ov.write_xml();
537
538         auto dcp_ov = make_shared<DCPContent>(path / "ov");
539         auto vf = make_shared<Film>(path / "vf");
540         vf->set_dcp_content_type(DCPContentType::from_isdcf_name("TST"));
541         vf->set_container(Ratio::from_id("185"));
542         vf->write_metadata();
543         vf->examine_and_add_content(dcp_ov);
544         BOOST_REQUIRE(!wait_for_jobs());
545         vf->set_reel_type(ReelType::BY_VIDEO_CONTENT);
546         dcp_ov->set_reference_video(true);
547         dcp_ov->set_reference_text(TextType::OPEN_SUBTITLE, true);
548
549         vf->write_metadata();
550         make_dcp(vf, TranscodeJob::ChangedBehaviour::IGNORE);
551         BOOST_REQUIRE(!wait_for_jobs());
552
553         vector<dcp::VerificationNote::Code> ignore = {
554                 dcp::VerificationNote::Code::MISSING_SUBTITLE_LANGUAGE,
555                 dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME,
556                 dcp::VerificationNote::Code::INVALID_SUBTITLE_SPACING,
557                 dcp::VerificationNote::Code::EXTERNAL_ASSET,
558         };
559
560         verify_dcp(vf->dir(vf->dcp_name()), ignore);
561 }
562
563
564 /* Test bug #2703: a VF that refers to some OV subs does not get the correct subtitle language in the ISDCF name */
565 BOOST_AUTO_TEST_CASE(ov_subs_in_vf_name)
566 {
567         auto subs = content_factory("test/data/short.srt")[0];
568         auto ov = new_test_film2("ov_subs_in_vf_name_ov", { subs });
569         subs->only_text()->set_language(dcp::LanguageTag("de"));
570         make_and_verify_dcp(
571                 ov,
572                 {
573                         dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME,
574                         dcp::VerificationNote::Code::MISSING_CPL_METADATA
575                 });
576
577         auto ov_dcp = make_shared<DCPContent>(ov->dir(ov->dcp_name()));
578         auto vf = new_test_film2("ov_subs_in_vf_name_vf", { ov_dcp });
579         vf->set_name("foo");
580         ov_dcp->set_reference_text(TextType::OPEN_SUBTITLE, true);
581         vf->_isdcf_date = boost::gregorian::date(2023, boost::gregorian::Jan, 18);
582
583         BOOST_CHECK_EQUAL(vf->isdcf_name(false), "Foo_TST-1_F_XX-DE_51-HI-VI_2K_20230118_SMPTE_VF");
584 }