summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-12-09 16:27:26 +0100
committerCarl Hetherington <cth@carlh.net>2021-01-17 20:13:22 +0100
commitf5bd0937a730e9dbb58f955c11df41abc56e89b5 (patch)
tree408ce49aee9a923300994f0ffc12c57e23ef8f0e
parent02e0e7febed98d2b9375c7638b61a25003603c9a (diff)
Bv2.1 6.2.1: Check that closed caption reel and XML <Language> conform to RFC 5646.
-rw-r--r--BRANCH2
-rw-r--r--src/reel_closed_caption_asset.h6
-rw-r--r--src/smpte_subtitle_asset.h2
-rw-r--r--src/verify.cc27
-rw-r--r--test/verify_test.cc35
5 files changed, 66 insertions, 6 deletions
diff --git a/BRANCH b/BRANCH
index 734b0017..fb9fc2b7 100644
--- a/BRANCH
+++ b/BRANCH
@@ -11,7 +11,7 @@ Mark things with [Bv2.1_paragraph]
- subtitle reel <Language> /
- subtitle XML <Language> /
- sound MXF Language /
- - ccap reel <Language>
+ - ccap reel <Language> /
- MainSubtitleLanguageList
- RFC5646SpokenLanguage
- CPL metadata ReleaseTerritory
diff --git a/src/reel_closed_caption_asset.h b/src/reel_closed_caption_asset.h
index 47645a8f..25f1f569 100644
--- a/src/reel_closed_caption_asset.h
+++ b/src/reel_closed_caption_asset.h
@@ -43,6 +43,10 @@
#include "reel_asset.h"
#include "reel_mxf.h"
+
+struct verify_invalid_closed_caption_languages;
+
+
namespace dcp {
class SubtitleAsset;
@@ -76,6 +80,8 @@ public:
}
private:
+ friend struct ::verify_invalid_closed_caption_languages;
+
std::string key_type () const;
std::string cpl_node_name (Standard standard) const;
std::pair<std::string, std::string> cpl_node_namespace (Standard standard) const;
diff --git a/src/smpte_subtitle_asset.h b/src/smpte_subtitle_asset.h
index 28aecefa..6d7019a5 100644
--- a/src/smpte_subtitle_asset.h
+++ b/src/smpte_subtitle_asset.h
@@ -48,6 +48,7 @@ namespace ASDCP {
}
}
+struct verify_invalid_closed_caption_languages;
struct verify_test26;
namespace dcp {
@@ -174,6 +175,7 @@ protected:
private:
friend struct ::write_smpte_subtitle_test;
friend struct ::write_smpte_subtitle_test2;
+ friend struct ::verify_invalid_closed_caption_languages;
friend struct ::verify_test26;
void read_fonts (std::shared_ptr<ASDCP::TimedText::MXFReader>);
diff --git a/src/verify.cc b/src/verify.cc
index 1b245331..e5deb789 100644
--- a/src/verify.cc
+++ b/src/verify.cc
@@ -35,6 +35,7 @@
#include "dcp.h"
#include "cpl.h"
#include "reel.h"
+#include "reel_closed_caption_asset.h"
#include "reel_picture_asset.h"
#include "reel_sound_asset.h"
#include "reel_subtitle_asset.h"
@@ -571,21 +572,30 @@ verify_main_subtitle_reel (shared_ptr<const ReelSubtitleAsset> reel_asset, list<
static void
-verify_main_subtitle_asset (
- shared_ptr<const ReelSubtitleAsset> reel_asset,
+verify_closed_caption_reel (shared_ptr<const ReelClosedCaptionAsset> reel_asset, list<VerificationNote>& notes)
+{
+ /* XXX: is Language compulsory? */
+ if (reel_asset->language()) {
+ verify_language_tag (*reel_asset->language(), notes);
+ }
+}
+
+
+static void
+verify_subtitle_asset (
+ shared_ptr<const SubtitleAsset> asset,
function<void (string, optional<boost::filesystem::path>)> stage,
boost::filesystem::path xsd_dtd_directory,
list<VerificationNote>& notes
)
{
- shared_ptr<SubtitleAsset> asset = reel_asset->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 (asset->raw_xml(), xsd_dtd_directory, notes);
- shared_ptr<SMPTESubtitleAsset> smpte = dynamic_pointer_cast<SMPTESubtitleAsset>(asset);
+ shared_ptr<const SMPTESubtitleAsset> smpte = dynamic_pointer_cast<const SMPTESubtitleAsset>(asset);
if (smpte) {
if (smpte->language()) {
verify_language_tag (*smpte->language(), notes);
@@ -679,7 +689,14 @@ dcp::verify (
if (reel->main_subtitle()) {
verify_main_subtitle_reel (reel->main_subtitle(), notes);
if (reel->main_subtitle()->asset_ref().resolved()) {
- verify_main_subtitle_asset (reel->main_subtitle(), stage, xsd_dtd_directory, notes);
+ verify_subtitle_asset (reel->main_subtitle()->asset(), stage, xsd_dtd_directory, notes);
+ }
+ }
+
+ BOOST_FOREACH (shared_ptr<dcp::ReelClosedCaptionAsset> i, reel->closed_captions()) {
+ verify_closed_caption_reel (i, notes);
+ if (i->asset_ref().resolved()) {
+ verify_subtitle_asset (i->asset(), stage, xsd_dtd_directory, notes);
}
}
}
diff --git a/test/verify_test.cc b/test/verify_test.cc
index 89b46d72..b2c4b542 100644
--- a/test/verify_test.cc
+++ b/test/verify_test.cc
@@ -44,6 +44,7 @@
#include "mono_picture_asset_writer.h"
#include "interop_subtitle_asset.h"
#include "smpte_subtitle_asset.h"
+#include "reel_closed_caption_asset.h"
#include "reel_subtitle_asset.h"
#include "compose.hpp"
#include "test.h"
@@ -916,6 +917,40 @@ BOOST_AUTO_TEST_CASE (verify_test26)
}
+/* SMPTE DCP with invalid <Language> in the MainClosedCaption reel and also in the XML within the MXF */
+BOOST_AUTO_TEST_CASE (verify_invalid_closed_caption_languages)
+{
+ boost::filesystem::path const dir("build/test/verify_invalid_closed_caption_languages");
+ 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::ReelClosedCaptionAsset> reel_asset(new dcp::ReelClosedCaptionAsset(asset, dcp::Fraction(24, 1), 16 * 24, 0));
+ reel_asset->_language = "badlang";
+ shared_ptr<dcp::Reel> reel(new dcp::Reel());
+ reel->add (reel_asset);
+ shared_ptr<dcp::CPL> cpl(new dcp::CPL("hello", dcp::FEATURE));
+ cpl->add (reel);
+ shared_ptr<dcp::DCP> dcp(new dcp::DCP(dir));
+ dcp->add (cpl);
+ dcp->write_xml (dcp::SMPTE);
+
+ 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(), 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");
+}
+
+
/* SMPTE DCP with invalid <Language> in the MainSound reel */
BOOST_AUTO_TEST_CASE (verify_invalid_sound_reel_language)
{