summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-12-15 00:51:34 +0100
committerCarl Hetherington <cth@carlh.net>2021-01-17 20:13:22 +0100
commite182156f75a74457c4452cc3bfe91d778d0d7148 (patch)
tree7c929330d3953a76c801d4ba22bc9936da7c94d2 /src
parent7c5237f7f45b85a6030b345cf4542ed4059fa5c9 (diff)
Bv2.1 7.2.2: Check that subtitle languages are the same for all reels.
Diffstat (limited to 'src')
-rw-r--r--src/verify.cc33
-rw-r--r--src/verify.h2
2 files changed, 29 insertions, 6 deletions
diff --git a/src/verify.cc b/src/verify.cc
index 1b476ef2..0b7def3c 100644
--- a/src/verify.cc
+++ b/src/verify.cc
@@ -640,12 +640,19 @@ verify_closed_caption_reel (shared_ptr<const ReelClosedCaptionAsset> reel_asset,
}
+struct State
+{
+ boost::optional<string> subtitle_language;
+};
+
+
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
+ list<VerificationNote>& notes,
+ State& state
)
{
stage ("Checking subtitle XML", asset->file());
@@ -657,7 +664,17 @@ verify_subtitle_asset (
shared_ptr<const SMPTESubtitleAsset> smpte = dynamic_pointer_cast<const SMPTESubtitleAsset>(asset);
if (smpte) {
if (smpte->language()) {
- verify_language_tag (*smpte->language(), notes);
+ string const language = *smpte->language();
+ verify_language_tag (language, notes);
+ if (!state.subtitle_language) {
+ state.subtitle_language = language;
+ } else if (state.subtitle_language != language) {
+ notes.push_back (
+ VerificationNote(
+ VerificationNote::VERIFY_BV21_ERROR, VerificationNote::SUBTITLE_LANGUAGES_DIFFER, *asset->file()
+ )
+ );
+ }
} else {
notes.push_back (
VerificationNote(
@@ -696,10 +713,11 @@ verify_closed_caption_asset (
shared_ptr<const SubtitleAsset> asset,
function<void (string, optional<boost::filesystem::path>)> stage,
boost::filesystem::path xsd_dtd_directory,
- list<VerificationNote>& notes
+ list<VerificationNote>& notes,
+ State& state
)
{
- verify_subtitle_asset (asset, stage, xsd_dtd_directory, notes);
+ verify_subtitle_asset (asset, stage, xsd_dtd_directory, notes, state);
if (asset->raw_xml().size() > 256 * 1024) {
notes.push_back (
@@ -722,6 +740,7 @@ dcp::verify (
xsd_dtd_directory = boost::filesystem::canonical (xsd_dtd_directory);
list<VerificationNote> notes;
+ State state;
list<shared_ptr<DCP> > dcps;
BOOST_FOREACH (boost::filesystem::path i, directories) {
@@ -804,14 +823,14 @@ dcp::verify (
if (reel->main_subtitle()) {
verify_main_subtitle_reel (reel->main_subtitle(), notes);
if (reel->main_subtitle()->asset_ref().resolved()) {
- verify_subtitle_asset (reel->main_subtitle()->asset(), stage, xsd_dtd_directory, notes);
+ verify_subtitle_asset (reel->main_subtitle()->asset(), stage, xsd_dtd_directory, notes, state);
}
}
BOOST_FOREACH (shared_ptr<dcp::ReelClosedCaptionAsset> i, reel->closed_captions()) {
verify_closed_caption_reel (i, notes);
if (i->asset_ref().resolved()) {
- verify_closed_caption_asset (i->asset(), stage, xsd_dtd_directory, notes);
+ verify_closed_caption_asset (i->asset(), stage, xsd_dtd_directory, notes, state);
}
}
}
@@ -891,6 +910,8 @@ dcp::note_to_string (dcp::VerificationNote note)
return String::compose("The total size of the fonts in timed text asset %1 is larger than the 10MB maximum required by Bv2.1", note.file()->filename());
case dcp::VerificationNote::MISSING_SUBTITLE_LANGUAGE:
return String::compose("The XML for a SMPTE subtitle asset has no <Language> tag, which is required by Bv2.1", note.file()->filename());
+ case dcp::VerificationNote::SUBTITLE_LANGUAGES_DIFFER:
+ return String::compose("Some subtitle assets have different <Language> tags than others", note.file()->filename());
}
return "";
diff --git a/src/verify.h b/src/verify.h
index 8a049dd5..170aeb8b 100644
--- a/src/verify.h
+++ b/src/verify.h
@@ -110,6 +110,8 @@ public:
TIMED_TEXT_FONTS_TOO_LARGE_IN_BYTES,
/** Some SMPTE subtitle XML has no <Language> tag [Bv2.1_7.2.2] */
MISSING_SUBTITLE_LANGUAGE,
+ /** Not all subtitle assets specify the same <Language> tag [Bv2.1_7.2.2] */
+ SUBTITLE_LANGUAGES_DIFFER,
};
VerificationNote (Type type, Code code)