summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-12-09 13:13:23 +0100
committerCarl Hetherington <cth@carlh.net>2021-01-17 20:13:22 +0100
commit8edf0af514e285454a15f14561519608e6d6aad9 (patch)
treefd2c6727c2c26a6f3c8279ef4a194296ffb778dc
parent0b39df958f534068950669a763be7b4602740107 (diff)
Bv2.1 6.2.1: Check that the sound MXF Language tag conforms to RFC 5646.
-rw-r--r--BRANCH2
-rw-r--r--src/sound_asset.h13
-rw-r--r--src/verify.cc11
-rw-r--r--test/test.cc6
-rw-r--r--test/test.h2
-rw-r--r--test/verify_test.cc36
6 files changed, 63 insertions, 7 deletions
diff --git a/BRANCH b/BRANCH
index 5413cfb4..734b0017 100644
--- a/BRANCH
+++ b/BRANCH
@@ -10,7 +10,7 @@ Mark things with [Bv2.1_paragraph]
6.2 Language and Territory must comply with RFC 5646
- subtitle reel <Language> /
- subtitle XML <Language> /
- - sound reel <Language>
+ - sound MXF Language /
- ccap reel <Language>
- MainSubtitleLanguageList
- RFC5646SpokenLanguage
diff --git a/src/sound_asset.h b/src/sound_asset.h
index 91a213b8..d4b41a1a 100644
--- a/src/sound_asset.h
+++ b/src/sound_asset.h
@@ -45,6 +45,16 @@
#include "sound_frame.h"
#include "sound_asset_reader.h"
+
+namespace dcp {
+ class SoundAsset;
+}
+
+extern std::shared_ptr<dcp::SoundAsset> simple_sound (
+ boost::filesystem::path path, std::string suffix, dcp::MXFMetadata mxf_meta, std::string language
+ );
+
+
namespace dcp
{
@@ -95,6 +105,9 @@ public:
private:
friend class SoundAssetWriter;
+ friend std::shared_ptr<dcp::SoundAsset> (::simple_sound) (
+ boost::filesystem::path path, std::string suffix, dcp::MXFMetadata mxf_meta, std::string language
+ );
std::string pkl_type (Standard standard) const {
return static_pkl_type (standard);
diff --git a/src/verify.cc b/src/verify.cc
index 89d84eef..eec63d51 100644
--- a/src/verify.cc
+++ b/src/verify.cc
@@ -532,26 +532,31 @@ verify_main_sound_asset (
list<VerificationNote>& notes
)
{
- stage ("Checking sound asset hash", reel->main_sound()->asset()->file());
+ shared_ptr<dcp::SoundAsset> asset = reel->main_sound()->asset();
+ stage ("Checking sound asset hash", asset->file());
VerifyAssetResult const r = verify_asset (dcp, reel->main_sound(), progress);
switch (r) {
case VERIFY_ASSET_RESULT_BAD:
notes.push_back (
VerificationNote(
- VerificationNote::VERIFY_ERROR, VerificationNote::SOUND_HASH_INCORRECT, *reel->main_sound()->asset()->file()
+ VerificationNote::VERIFY_ERROR, VerificationNote::SOUND_HASH_INCORRECT, *asset->file()
)
);
break;
case VERIFY_ASSET_RESULT_CPL_PKL_DIFFER:
notes.push_back (
VerificationNote(
- VerificationNote::VERIFY_ERROR, VerificationNote::PKL_CPL_SOUND_HASHES_DISAGREE, *reel->main_sound()->asset()->file()
+ VerificationNote::VERIFY_ERROR, VerificationNote::PKL_CPL_SOUND_HASHES_DISAGREE, *asset->file()
)
);
break;
default:
break;
}
+
+ stage ("Checking sound asset metadata", asset->file());
+
+ verify_language_tag (asset->language(), notes);
}
diff --git a/test/test.cc b/test/test.cc
index c24f28cd..c8f41d05 100644
--- a/test/test.cc
+++ b/test/test.cc
@@ -271,9 +271,11 @@ simple_picture (boost::filesystem::path path, string suffix)
shared_ptr<dcp::SoundAsset>
-simple_sound (boost::filesystem::path path, string suffix, dcp::MXFMetadata mxf_meta)
+simple_sound (boost::filesystem::path path, string suffix, dcp::MXFMetadata mxf_meta, string language)
{
+ /* Set a valid language, then overwrite it, so that the language parameter can be badly formed */
shared_ptr<dcp::SoundAsset> ms (new dcp::SoundAsset(dcp::Fraction(24, 1), 48000, 1, dcp::LanguageTag("en-US"), dcp::SMPTE));
+ ms->_language = language;
ms->set_metadata (mxf_meta);
vector<dcp::Channel> active_channels;
active_channels.push_back (dcp::LEFT);
@@ -325,7 +327,7 @@ make_simple (boost::filesystem::path path, int reels)
string suffix = reels == 1 ? "" : dcp::String::compose("%1", i);
shared_ptr<dcp::MonoPictureAsset> mp = simple_picture (path, suffix);
- shared_ptr<dcp::SoundAsset> ms = simple_sound (path, suffix, mxf_meta);
+ shared_ptr<dcp::SoundAsset> ms = simple_sound (path, suffix, mxf_meta, "en-US");
cpl->add (shared_ptr<dcp::Reel> (
new dcp::Reel (
diff --git a/test/test.h b/test/test.h
index 4fc88424..1368973a 100644
--- a/test/test.h
+++ b/test/test.h
@@ -44,7 +44,7 @@ extern void check_xml (xmlpp::Element* ref, xmlpp::Element* test, std::list<std:
extern void check_xml (std::string ref, std::string test, std::list<std::string> ignore, bool ignore_whitespace = false);
extern void check_file (boost::filesystem::path ref, boost::filesystem::path check);
extern std::shared_ptr<dcp::MonoPictureAsset> simple_picture (boost::filesystem::path path, std::string suffix);
-extern std::shared_ptr<dcp::SoundAsset> simple_sound (boost::filesystem::path path, std::string suffix, dcp::MXFMetadata mxf_meta);
+extern std::shared_ptr<dcp::SoundAsset> simple_sound (boost::filesystem::path path, std::string suffix, dcp::MXFMetadata mxf_meta, std::string language);
extern std::shared_ptr<dcp::DCP> make_simple (boost::filesystem::path path, int reels = 1);
extern std::shared_ptr<dcp::DCP> make_simple_with_interop_subs (boost::filesystem::path path);
extern std::shared_ptr<dcp::DCP> make_simple_with_smpte_subs (boost::filesystem::path path);
diff --git a/test/verify_test.cc b/test/verify_test.cc
index ac2d825b..89b46d72 100644
--- a/test/verify_test.cc
+++ b/test/verify_test.cc
@@ -36,6 +36,7 @@
#include "j2k.h"
#include "reel.h"
#include "reel_mono_picture_asset.h"
+#include "reel_sound_asset.h"
#include "cpl.h"
#include "dcp.h"
#include "openjpeg_image.h"
@@ -174,6 +175,10 @@ BOOST_AUTO_TEST_CASE (verify_test1)
BOOST_REQUIRE (st->second);
BOOST_CHECK_EQUAL (st->second.get(), boost::filesystem::canonical("build/test/verify_test1/audio.mxf"));
++st;
+ BOOST_CHECK_EQUAL (st->first, "Checking sound asset metadata");
+ BOOST_REQUIRE (st->second);
+ BOOST_CHECK_EQUAL (st->second.get(), boost::filesystem::canonical("build/test/verify_test1/audio.mxf"));
+ ++st;
BOOST_CHECK_EQUAL (st->first, "Checking PKL");
BOOST_REQUIRE (st->second);
BOOST_CHECK_EQUAL (st->second.get(), boost::filesystem::canonical(pkl_file));
@@ -481,6 +486,10 @@ BOOST_AUTO_TEST_CASE (verify_test13)
BOOST_REQUIRE (st->second);
BOOST_CHECK_EQUAL (st->second.get(), boost::filesystem::canonical("build/test/verify_test13/pcm_69cf9eaf-9a99-4776-b022-6902208626c3.mxf"));
++st;
+ BOOST_CHECK_EQUAL (st->first, "Checking sound asset metadata");
+ BOOST_REQUIRE (st->second);
+ BOOST_CHECK_EQUAL (st->second.get(), boost::filesystem::canonical("build/test/verify_test13/pcm_69cf9eaf-9a99-4776-b022-6902208626c3.mxf"));
+ ++st;
BOOST_CHECK_EQUAL (st->first, "Checking PKL");
BOOST_REQUIRE (st->second);
BOOST_CHECK_EQUAL (st->second.get(), boost::filesystem::canonical(pkl_file));
@@ -906,3 +915,30 @@ BOOST_AUTO_TEST_CASE (verify_test26)
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)
+{
+ boost::filesystem::path const dir("build/test/verify_invalid_sound_reel_language");
+ prepare_directory (dir);
+
+ shared_ptr<dcp::SoundAsset> sound = simple_sound (dir, "foo", dcp::MXFMetadata(), "frobozz");
+ shared_ptr<dcp::ReelSoundAsset> reel_sound(new dcp::ReelSoundAsset(sound, 0));
+ shared_ptr<dcp::Reel> reel(new dcp::Reel());
+ reel->add (reel_sound);
+ 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(), 1U);
+ 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(), "frobozz");
+}
+