Bv2.1 6.2.1: Check that subtitle XML <Language> conforms to RFC 5646.
authorCarl Hetherington <cth@carlh.net>
Wed, 9 Dec 2020 09:21:57 +0000 (10:21 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 17 Jan 2021 19:13:22 +0000 (20:13 +0100)
BRANCH
src/smpte_subtitle_asset.h
src/verify.cc
test/verify_test.cc

diff --git a/BRANCH b/BRANCH
index 43445112ba8a410e2a81d40f0e2c2918d240debe..5413cfb45c8938c0ae9543615eb09e7340b9a2d6 100644 (file)
--- a/BRANCH
+++ b/BRANCH
@@ -9,7 +9,7 @@ Mark things with [Bv2.1_paragraph]
     immersive audio DCPs must comply with 429-18, 429-19 [*] don't have these standards
 6.2 Language and Territory must comply with RFC 5646
     - subtitle reel <Language> /
-    - subtitle XML <Language>
+    - subtitle XML <Language> /
     - sound reel <Language>
     - ccap reel <Language>
     - MainSubtitleLanguageList
index b66b1ea6c144f211183410123d94e2504e4df58f..28aecefa25c7a674f60472c077a5c7f2e01d2b6c 100644 (file)
@@ -48,6 +48,8 @@ namespace ASDCP {
        }
 }
 
+struct verify_test26;
+
 namespace dcp {
 
 class SMPTELoadFontNode;
@@ -172,6 +174,7 @@ protected:
 private:
        friend struct ::write_smpte_subtitle_test;
        friend struct ::write_smpte_subtitle_test2;
+       friend struct ::verify_test26;
 
        void read_fonts (std::shared_ptr<ASDCP::TimedText::MXFReader>);
        void parse_xml (std::shared_ptr<cxml::Document> xml);
index b440894622e94d324cd1bde201138c77cc5bde91..89d84eef97c46fe82d503ce0bf74f75f730fa272 100644 (file)
@@ -46,6 +46,7 @@
 #include "exceptions.h"
 #include "compose.hpp"
 #include "raw_convert.h"
+#include "smpte_subtitle_asset.h"
 #include <xercesc/util/PlatformUtils.hpp>
 #include <xercesc/parsers/XercesDOMParser.hpp>
 #include <xercesc/parsers/AbstractDOMParser.hpp>
@@ -572,12 +573,19 @@ verify_main_subtitle_asset (
        list<VerificationNote>& notes
        )
 {
-       shared_ptr<ReelSubtitleAsset> reel_asset = reel->main_subtitle ();
-       stage ("Checking subtitle XML", reel->main_subtitle()->asset()->file());
+       shared_ptr<SubtitleAsset> asset = reel->main_subtitle()->asset();
+       stage ("Checking subtitle XML", asset->file());
        /* Note: we must not use SubtitleAsset::xml_as_string() here as that will mean the data on disk
         * gets passed through libdcp which may clean up and therefore hide errors.
         */
-       validate_xml (reel->main_subtitle()->asset()->raw_xml(), xsd_dtd_directory, notes);
+       validate_xml (asset->raw_xml(), xsd_dtd_directory, notes);
+
+       shared_ptr<SMPTESubtitleAsset> smpte = dynamic_pointer_cast<SMPTESubtitleAsset>(asset);
+       if (smpte) {
+               if (smpte->language()) {
+                       verify_language_tag (*smpte->language(), notes);
+               }
+       }
 }
 
 
index 3e983e4d5abaad1b8f38e26d7803aa42b9ff95ec..62b5c6c49e406917be26b0d9a9676cf084b4c41e 100644 (file)
@@ -874,13 +874,15 @@ BOOST_AUTO_TEST_CASE (verify_test25)
 }
 
 
-/* SMPTE DCP with invalid <Language> in the MainSubtitle */
+/* SMPTE DCP with invalid <Language> in the MainSubtitle reel and also in the XML within the MXF */
 BOOST_AUTO_TEST_CASE (verify_test26)
 {
        boost::filesystem::path const dir("build/test/verify_test26");
        prepare_directory (dir);
        boost::filesystem::copy_file ("test/data/subs.mxf", dir / "subs.mxf");
        shared_ptr<dcp::SMPTESubtitleAsset> asset(new dcp::SMPTESubtitleAsset(dir / "subs.mxf"));
+       asset->_language = "wrong-andbad";
+       asset->write (dir / "subs.mxf");
        shared_ptr<dcp::ReelSubtitleAsset> reel_asset(new dcp::ReelSubtitleAsset(asset, dcp::Fraction(24, 1), 16 * 24, 0));
        reel_asset->_language = "badlang";
        shared_ptr<dcp::Reel> reel(new dcp::Reel());
@@ -894,9 +896,14 @@ BOOST_AUTO_TEST_CASE (verify_test26)
        vector<boost::filesystem::path> dirs;
        dirs.push_back (dir);
        list<dcp::VerificationNote> notes = dcp::verify (dirs, &stage, &progress, xsd_test);
-       BOOST_REQUIRE_EQUAL (notes.size(), 1U);
+       BOOST_REQUIRE_EQUAL (notes.size(), 2U);
        list<dcp::VerificationNote>::const_iterator i = notes.begin ();
        BOOST_CHECK_EQUAL (i->code(), dcp::VerificationNote::BAD_LANGUAGE);
-
+       BOOST_REQUIRE (i->note());
+       BOOST_CHECK_EQUAL (*i->note(), "badlang");
+       i++;
+       BOOST_CHECK_EQUAL (i->code(), dcp::VerificationNote::BAD_LANGUAGE);
+       BOOST_REQUIRE (i->note());
+       BOOST_CHECK_EQUAL (*i->note(), "wrong-andbad");
 }