From 2c3f7f03e50c6bb618b3f1b321b4ed27788152f9 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 9 Dec 2020 01:08:14 +0100 Subject: Bv2.1 6.2.1: Check that subtitle reel conforms to RFC 5646. --- src/reel_subtitle_asset.h | 4 ++++ src/verify.cc | 30 ++++++++++++++++++++++++++++-- src/verify.h | 2 ++ 3 files changed, 34 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/reel_subtitle_asset.h b/src/reel_subtitle_asset.h index 13e72133..8c3b7d18 100644 --- a/src/reel_subtitle_asset.h +++ b/src/reel_subtitle_asset.h @@ -43,6 +43,8 @@ #include "reel_mxf.h" #include "subtitle_asset.h" +struct verify_test26; + namespace dcp { class SubtitleAsset; @@ -70,6 +72,8 @@ public: } private: + friend struct ::verify_test26; + std::string key_type () const; std::string cpl_node_name (Standard standard) const; diff --git a/src/verify.cc b/src/verify.cc index f3ecb1f4..b4408946 100644 --- a/src/verify.cc +++ b/src/verify.cc @@ -394,6 +394,17 @@ verify_asset (shared_ptr dcp, shared_ptr reel_mxf, fun } +void +verify_language_tag (string tag, list& notes) +{ + try { + dcp::LanguageTag test (tag); + } catch (dcp::LanguageTagError &) { + notes.push_back (VerificationNote(VerificationNote::VERIFY_BV21_ERROR, VerificationNote::BAD_LANGUAGE, tag)); + } +} + + enum VerifyPictureAssetResult { VERIFY_PICTURE_ASSET_RESULT_GOOD, @@ -543,6 +554,16 @@ verify_main_sound_asset ( } +static void +verify_main_subtitle_reel (shared_ptr reel_asset, list& notes) +{ + /* XXX: is Language compulsory? */ + if (reel_asset->language()) { + verify_language_tag (*reel_asset->language(), notes); + } +} + + static void verify_main_subtitle_asset ( shared_ptr reel, @@ -642,8 +663,11 @@ dcp::verify ( verify_main_sound_asset (dcp, reel, stage, progress, notes); } - if (reel->main_subtitle() && reel->main_subtitle()->asset_ref().resolved()) { - verify_main_subtitle_asset (reel, stage, xsd_dtd_directory, notes); + if (reel->main_subtitle()) { + verify_main_subtitle_reel (reel->main_subtitle(), notes); + if (reel->main_subtitle()->asset_ref().resolved()) { + verify_main_subtitle_asset (reel, stage, xsd_dtd_directory, notes); + } } } } @@ -704,6 +728,8 @@ dcp::note_to_string (dcp::VerificationNote note) return String::compose("An asset that this DCP refers to is not included in the DCP. It may be a VF. Missing asset is %1.", note.note().get()); case dcp::VerificationNote::NOT_SMPTE: return "This DCP does not use the SMPTE standard, which is required for Bv2.1 compliance."; + case dcp::VerificationNote::BAD_LANGUAGE: + return String::compose("The DCP specifies a language '%1' which does not conform to the RFC 5646 standard.", note.note().get()); } return ""; diff --git a/src/verify.h b/src/verify.h index 0140066e..8eb5aa12 100644 --- a/src/verify.h +++ b/src/verify.h @@ -92,6 +92,8 @@ public: EXTERNAL_ASSET, /** DCP is Interop, not SMPTE [Bv2.1_6.1] */ NOT_SMPTE, + /** A language or territory does not conform to RFC 5646 [Bv2.1_6.2.1] */ + BAD_LANGUAGE, }; VerificationNote (Type type, Code code) -- cgit v1.2.3