+
+BOOST_AUTO_TEST_CASE (verify_invalid_xml_cpl_extension_metadata8)
+{
+ path dir = "build/test/verify_invalid_xml_cpl_extension_metadata8";
+ auto dcp = make_simple (dir);
+ dcp->write_xml (
+ dcp::Standard::SMPTE,
+ dcp::String::compose("libdcp %1", dcp::version),
+ dcp::String::compose("libdcp %1", dcp::version),
+ dcp::LocalTime().as_string(),
+ "A Test DCP"
+ );
+
+ auto const cpl = dcp->cpls()[0];
+
+ {
+ Editor e (cpl->file().get());
+ e.replace ("<meta:Property>", "<meta:PropertyX>");
+ e.replace ("</meta:Property>", "</meta:PropertyX>");
+ }
+
+ check_verify_result (
+ {dir},
+ {
+ { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_XML, string("no declaration found for element 'meta:PropertyX'"), cpl->file().get(), 77 },
+ { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_XML, string("element 'meta:PropertyX' is not allowed for content model '(Property+)'"), cpl->file().get(), 81 },
+ { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::MISMATCHED_CPL_HASHES, cpl->id(), cpl->file().get() },
+ });
+}
+
+
+BOOST_AUTO_TEST_CASE (verify_invalid_xml_cpl_extension_metadata9)
+{
+ path dir = "build/test/verify_invalid_xml_cpl_extension_metadata9";
+ auto dcp = make_simple (dir);
+ dcp->write_xml (
+ dcp::Standard::SMPTE,
+ dcp::String::compose("libdcp %1", dcp::version),
+ dcp::String::compose("libdcp %1", dcp::version),
+ dcp::LocalTime().as_string(),
+ "A Test DCP"
+ );
+
+ auto const cpl = dcp->cpls()[0];
+
+ {
+ Editor e (cpl->file().get());
+ e.replace ("<meta:PropertyList>", "<meta:PropertyListX>");
+ e.replace ("</meta:PropertyList>", "</meta:PropertyListX>");
+ }
+
+ check_verify_result (
+ {dir},
+ {
+ { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_XML, string("no declaration found for element 'meta:PropertyListX'"), cpl->file().get(), 76 },
+ { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_XML, string("element 'meta:PropertyListX' is not allowed for content model '(Name,PropertyList?,)'"), cpl->file().get(), 82 },
+ { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::MISMATCHED_CPL_HASHES, cpl->id(), cpl->file().get() },
+ });
+}
+
+
+
+BOOST_AUTO_TEST_CASE (verify_unsigned_cpl_with_encrypted_content)
+{
+ path dir = "build/test/verify_unsigned_cpl_with_encrypted_content";
+ prepare_directory (dir);
+ for (auto i: directory_iterator("test/ref/DCP/encryption_test")) {
+ copy_file (i.path(), dir / i.path().filename());
+ }
+
+ path const pkl = dir / ( "pkl_" + encryption_test_pkl_id + ".xml" );
+ path const cpl = dir / ( "cpl_" + encryption_test_cpl_id + ".xml");
+
+ {
+ Editor e (cpl);
+ e.delete_lines ("<dsig:Signature", "</dsig:Signature>");
+ }
+
+ check_verify_result (
+ {dir},
+ {
+ { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::MISMATCHED_CPL_HASHES, encryption_test_cpl_id, canonical(cpl) },
+ { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::MISMATCHED_PKL_ANNOTATION_TEXT_WITH_CPL, encryption_test_pkl_id, canonical(pkl), },
+ { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::MISSING_FFEC_IN_FEATURE },
+ { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::MISSING_FFMC_IN_FEATURE },
+ { dcp::VerificationNote::Type::WARNING, dcp::VerificationNote::Code::MISSING_FFOC },
+ { dcp::VerificationNote::Type::WARNING, dcp::VerificationNote::Code::MISSING_LFOC },
+ { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::MISSING_CPL_METADATA, encryption_test_cpl_id, canonical(cpl) },
+ { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::UNSIGNED_CPL_WITH_ENCRYPTED_CONTENT, encryption_test_cpl_id, canonical(cpl) }
+ });
+}
+
+
+BOOST_AUTO_TEST_CASE (verify_unsigned_pkl_with_encrypted_content)
+{
+ path dir = "build/test/unsigned_pkl_with_encrypted_content";
+ prepare_directory (dir);
+ for (auto i: directory_iterator("test/ref/DCP/encryption_test")) {
+ copy_file (i.path(), dir / i.path().filename());
+ }
+
+ path const cpl = dir / ("cpl_" + encryption_test_cpl_id + ".xml");
+ path const pkl = dir / ("pkl_" + encryption_test_pkl_id + ".xml");
+ {
+ Editor e (pkl);
+ e.delete_lines ("<dsig:Signature", "</dsig:Signature>");
+ }
+
+ check_verify_result (
+ {dir},
+ {
+ { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::MISMATCHED_PKL_ANNOTATION_TEXT_WITH_CPL, encryption_test_pkl_id, canonical(pkl) },
+ { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::MISSING_FFEC_IN_FEATURE },
+ { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::MISSING_FFMC_IN_FEATURE },
+ { dcp::VerificationNote::Type::WARNING, dcp::VerificationNote::Code::MISSING_FFOC },
+ { dcp::VerificationNote::Type::WARNING, dcp::VerificationNote::Code::MISSING_LFOC },
+ { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::MISSING_CPL_METADATA, encryption_test_cpl_id, canonical(cpl) },
+ { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::UNSIGNED_PKL_WITH_ENCRYPTED_CONTENT, encryption_test_pkl_id, canonical(pkl) },
+ });
+}
+
+
+BOOST_AUTO_TEST_CASE (verify_unsigned_pkl_with_unencrypted_content)
+{
+ path dir = "build/test/verify_unsigned_pkl_with_unencrypted_content";
+ prepare_directory (dir);
+ for (auto i: directory_iterator("test/ref/DCP/dcp_test1")) {
+ copy_file (i.path(), dir / i.path().filename());
+ }
+
+ {
+ Editor e (dir / dcp_test1_pkl);
+ e.delete_lines ("<dsig:Signature", "</dsig:Signature>");
+ }
+
+ check_verify_result ({dir}, {});
+}
+
+
+BOOST_AUTO_TEST_CASE (verify_partially_encrypted)
+{
+ path dir ("build/test/verify_must_not_be_partially_encrypted");
+ prepare_directory (dir);
+
+ dcp::DCP d (dir);
+
+ auto signer = make_shared<dcp::CertificateChain>();
+ signer->add (dcp::Certificate(dcp::file_to_string("test/ref/crypt/ca.self-signed.pem")));
+ signer->add (dcp::Certificate(dcp::file_to_string("test/ref/crypt/intermediate.signed.pem")));
+ signer->add (dcp::Certificate(dcp::file_to_string("test/ref/crypt/leaf.signed.pem")));
+ signer->set_key (dcp::file_to_string("test/ref/crypt/leaf.key"));
+
+ auto cpl = make_shared<dcp::CPL>("A Test DCP", dcp::ContentKind::TRAILER);
+
+ dcp::Key key;
+
+ auto mp = make_shared<dcp::MonoPictureAsset>(dcp::Fraction (24, 1), dcp::Standard::SMPTE);
+ mp->set_key (key);
+
+ auto writer = mp->start_write (dir / "video.mxf", false);
+ dcp::ArrayData j2c ("test/data/flat_red.j2c");
+ for (int i = 0; i < 24; ++i) {
+ writer->write (j2c.data(), j2c.size());
+ }
+ writer->finalize ();
+
+ auto ms = simple_sound (dir, "", dcp::MXFMetadata(), "de-DE");
+
+ auto reel = make_shared<dcp::Reel>(
+ make_shared<dcp::ReelMonoPictureAsset>(mp, 0),
+ make_shared<dcp::ReelSoundAsset>(ms, 0)
+ );
+
+ reel->add (simple_markers());
+
+ cpl->add (reel);
+
+ cpl->set_content_version (
+ {"urn:uri:81fb54df-e1bf-4647-8788-ea7ba154375b_2012-07-17T04:45:18+00:00", "81fb54df-e1bf-4647-8788-ea7ba154375b_2012-07-17T04:45:18+00:00"}
+ );
+ cpl->set_annotation_text ("A Test DCP");
+ cpl->set_issuer ("OpenDCP 0.0.25");
+ cpl->set_creator ("OpenDCP 0.0.25");
+ cpl->set_issue_date ("2012-07-17T04:45:18+00:00");
+ cpl->set_main_sound_configuration ("L,C,R,Lfe,-,-");
+ cpl->set_main_sound_sample_rate (48000);
+ cpl->set_main_picture_stored_area (dcp::Size(1998, 1080));
+ cpl->set_main_picture_active_area (dcp::Size(1440, 1080));
+ cpl->set_version_number (1);
+
+ d.add (cpl);
+
+ d.write_xml (dcp::Standard::SMPTE, "OpenDCP 0.0.25", "OpenDCP 0.0.25", "2012-07-17T04:45:18+00:00", "A Test DCP", signer);
+
+ check_verify_result (
+ {dir},
+ {
+ {dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::PARTIALLY_ENCRYPTED},
+ });
+}
+
+
+BOOST_AUTO_TEST_CASE (verify_jpeg2000_codestream_2k)
+{
+ vector<dcp::VerificationNote> notes;
+ dcp::MonoPictureAsset picture (find_file(private_test / "data" / "JourneyToJah_TLR-1_F_EN-DE-FR_CH_51_2K_LOK_20140225_DGL_SMPTE_OV", "j2c.mxf"));
+ auto reader = picture.start_read ();
+ auto frame = reader->get_frame (0);
+ verify_j2k (frame, notes);
+ BOOST_REQUIRE_EQUAL (notes.size(), 0U);
+}
+
+
+BOOST_AUTO_TEST_CASE (verify_jpeg2000_codestream_4k)
+{
+ vector<dcp::VerificationNote> notes;
+ dcp::MonoPictureAsset picture (find_file(private_test / "data" / "sul", "TLR"));
+ auto reader = picture.start_read ();
+ auto frame = reader->get_frame (0);
+ verify_j2k (frame, notes);
+ BOOST_REQUIRE_EQUAL (notes.size(), 0U);
+}
+
+
+BOOST_AUTO_TEST_CASE (verify_jpeg2000_codestream_libdcp)
+{
+ boost::filesystem::path dir = "build/test/verify_jpeg2000_codestream_libdcp";
+ prepare_directory (dir);
+ auto dcp = make_simple (dir);
+ dcp->write_xml (dcp::Standard::SMPTE);
+ vector<dcp::VerificationNote> notes;
+ dcp::MonoPictureAsset picture (find_file(dir, "video"));
+ auto reader = picture.start_read ();
+ auto frame = reader->get_frame (0);
+ verify_j2k (frame, notes);
+ BOOST_REQUIRE_EQUAL (notes.size(), 0U);
+}
+
+
+/** Check that ResourceID and the XML ID being different is spotted */
+BOOST_AUTO_TEST_CASE (verify_mismatched_subtitle_resource_id)
+{
+ boost::filesystem::path const dir = "build/test/verify_mismatched_subtitle_resource_id";
+ prepare_directory (dir);
+
+ ASDCP::WriterInfo writer_info;
+ writer_info.LabelSetType = ASDCP::LS_MXF_SMPTE;
+
+ unsigned int c;
+ auto mxf_id = dcp::make_uuid ();
+ Kumu::hex2bin (mxf_id.c_str(), writer_info.AssetUUID, Kumu::UUID_Length, &c);
+ BOOST_REQUIRE (c == Kumu::UUID_Length);
+
+ auto resource_id = dcp::make_uuid ();
+ ASDCP::TimedText::TimedTextDescriptor descriptor;
+ Kumu::hex2bin (resource_id.c_str(), descriptor.AssetID, Kumu::UUID_Length, &c);
+ DCP_ASSERT (c == Kumu::UUID_Length);
+
+ auto xml_id = dcp::make_uuid ();
+ ASDCP::TimedText::MXFWriter writer;
+ auto subs_mxf = dir / "subs.mxf";
+ auto r = writer.OpenWrite(subs_mxf.c_str(), writer_info, descriptor, 4096);
+ BOOST_REQUIRE (ASDCP_SUCCESS(r));
+ writer.WriteTimedTextResource (dcp::String::compose(
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<SubtitleReel xmlns=\"http://www.smpte-ra.org/schemas/428-7/2010/DCST\" xmlns:xs=\"http://www.w3.org/2001/schema\">"
+ "<Id>urn:uuid:%1</Id>"
+ "<ContentTitleText>Content</ContentTitleText>"
+ "<AnnotationText>Annotation</AnnotationText>"
+ "<IssueDate>2018-10-02T12:25:14+02:00</IssueDate>"
+ "<ReelNumber>1</ReelNumber>"
+ "<Language>en-US</Language>"
+ "<EditRate>25 1</EditRate>"
+ "<TimeCodeRate>25</TimeCodeRate>"
+ "<StartTime>00:00:00:00</StartTime>"
+ "<SubtitleList>"
+ "<Font ID=\"arial\" Color=\"FFFEFEFE\" Weight=\"normal\" Size=\"42\" Effect=\"border\" EffectColor=\"FF181818\" AspectAdjust=\"1.00\">"
+ "<Subtitle SpotNumber=\"1\" TimeIn=\"00:00:03:00\" TimeOut=\"00:00:04:10\" FadeUpTime=\"00:00:00:00\" FadeDownTime=\"00:00:00:00\">"
+ "<Text Hposition=\"0.0\" Halign=\"center\" Valign=\"bottom\" Vposition=\"13.5\" Direction=\"ltr\">Hello world</Text>"
+ "</Subtitle>"
+ "</Font>"
+ "</SubtitleList>"
+ "</SubtitleReel>",
+ xml_id).c_str());
+
+ writer.Finalize();
+
+ auto subs_asset = make_shared<dcp::SMPTESubtitleAsset>(subs_mxf);
+ auto subs_reel = make_shared<dcp::ReelSubtitleAsset>(subs_asset, dcp::Fraction(24, 1), 240, 0);
+
+ auto cpl = write_dcp_with_single_asset (dir, subs_reel);
+
+ check_verify_result (
+ { dir },
+ {
+ { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::MISMATCHED_TIMED_TEXT_DURATION , "240 0", boost::filesystem::canonical(subs_mxf) },
+ { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::MISMATCHED_TIMED_TEXT_RESOURCE_ID },
+ { dcp::VerificationNote::Type::WARNING, dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME },
+ { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::MISSING_CPL_METADATA, cpl->id(), cpl->file().get() }
+ });
+}
+
+
+/** Check that ResourceID and the MXF ID being the same is spotted */
+BOOST_AUTO_TEST_CASE (verify_incorrect_timed_text_id)
+{
+ boost::filesystem::path const dir = "build/test/verify_incorrect_timed_text_id";
+ prepare_directory (dir);
+
+ ASDCP::WriterInfo writer_info;
+ writer_info.LabelSetType = ASDCP::LS_MXF_SMPTE;
+
+ unsigned int c;
+ auto mxf_id = dcp::make_uuid ();
+ Kumu::hex2bin (mxf_id.c_str(), writer_info.AssetUUID, Kumu::UUID_Length, &c);
+ BOOST_REQUIRE (c == Kumu::UUID_Length);
+
+ auto resource_id = mxf_id;
+ ASDCP::TimedText::TimedTextDescriptor descriptor;
+ Kumu::hex2bin (resource_id.c_str(), descriptor.AssetID, Kumu::UUID_Length, &c);
+ DCP_ASSERT (c == Kumu::UUID_Length);
+
+ auto xml_id = resource_id;
+ ASDCP::TimedText::MXFWriter writer;
+ auto subs_mxf = dir / "subs.mxf";
+ auto r = writer.OpenWrite(subs_mxf.c_str(), writer_info, descriptor, 4096);
+ BOOST_REQUIRE (ASDCP_SUCCESS(r));
+ writer.WriteTimedTextResource (dcp::String::compose(
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<SubtitleReel xmlns=\"http://www.smpte-ra.org/schemas/428-7/2010/DCST\" xmlns:xs=\"http://www.w3.org/2001/schema\">"
+ "<Id>urn:uuid:%1</Id>"
+ "<ContentTitleText>Content</ContentTitleText>"
+ "<AnnotationText>Annotation</AnnotationText>"
+ "<IssueDate>2018-10-02T12:25:14+02:00</IssueDate>"
+ "<ReelNumber>1</ReelNumber>"
+ "<Language>en-US</Language>"
+ "<EditRate>25 1</EditRate>"
+ "<TimeCodeRate>25</TimeCodeRate>"
+ "<StartTime>00:00:00:00</StartTime>"
+ "<SubtitleList>"
+ "<Font ID=\"arial\" Color=\"FFFEFEFE\" Weight=\"normal\" Size=\"42\" Effect=\"border\" EffectColor=\"FF181818\" AspectAdjust=\"1.00\">"
+ "<Subtitle SpotNumber=\"1\" TimeIn=\"00:00:03:00\" TimeOut=\"00:00:04:10\" FadeUpTime=\"00:00:00:00\" FadeDownTime=\"00:00:00:00\">"
+ "<Text Hposition=\"0.0\" Halign=\"center\" Valign=\"bottom\" Vposition=\"13.5\" Direction=\"ltr\">Hello world</Text>"
+ "</Subtitle>"
+ "</Font>"
+ "</SubtitleList>"
+ "</SubtitleReel>",
+ xml_id).c_str());
+
+ writer.Finalize();
+
+ auto subs_asset = make_shared<dcp::SMPTESubtitleAsset>(subs_mxf);
+ auto subs_reel = make_shared<dcp::ReelSubtitleAsset>(subs_asset, dcp::Fraction(24, 1), 240, 0);
+
+ auto cpl = write_dcp_with_single_asset (dir, subs_reel);
+
+ check_verify_result (
+ { dir },
+ {
+ { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::MISMATCHED_TIMED_TEXT_DURATION , "240 0", boost::filesystem::canonical(subs_mxf) },
+ { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::INCORRECT_TIMED_TEXT_ASSET_ID },
+ { dcp::VerificationNote::Type::WARNING, dcp::VerificationNote::Code::INVALID_SUBTITLE_FIRST_TEXT_TIME },
+ { dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::MISSING_CPL_METADATA, cpl->id(), cpl->file().get() }
+ });
+}