summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2019-12-09 00:44:07 +0100
committerCarl Hetherington <cth@carlh.net>2019-12-22 01:21:00 +0100
commit66bd89f87412736ba2488f5b3ca4aec9dea8ef94 (patch)
tree05e961c0b4ca0f90f376e63f5adf6d8b03a1985b /src
parent84d01dde2fb2520572d122d53e1ffebefed48157 (diff)
Check ASSETMAP; add a PKL test; tidy up calls to validate_xml().
Diffstat (limited to 'src')
-rw-r--r--src/dcp.cc8
-rw-r--r--src/dcp.h11
-rw-r--r--src/verify.cc49
3 files changed, 33 insertions, 35 deletions
diff --git a/src/dcp.cc b/src/dcp.cc
index e057f25f..da12e4d9 100644
--- a/src/dcp.cc
+++ b/src/dcp.cc
@@ -112,18 +112,17 @@ DCP::read (list<dcp::VerificationNote>* notes, bool ignore_incorrect_picture_mxf
{
/* Read the ASSETMAP and PKL */
- boost::filesystem::path asset_map_file;
if (boost::filesystem::exists (_directory / "ASSETMAP")) {
- asset_map_file = _directory / "ASSETMAP";
+ _asset_map = _directory / "ASSETMAP";
} else if (boost::filesystem::exists (_directory / "ASSETMAP.xml")) {
- asset_map_file = _directory / "ASSETMAP.xml";
+ _asset_map = _directory / "ASSETMAP.xml";
} else {
boost::throw_exception (DCPReadError (String::compose ("could not find ASSETMAP nor ASSETMAP.xml in `%1'", _directory.string())));
}
cxml::Document asset_map ("AssetMap");
- asset_map.read_file (asset_map_file);
+ asset_map.read_file (_asset_map.get());
if (asset_map.namespace_uri() == assetmap_interop_ns) {
_standard = INTEROP;
} else if (asset_map.namespace_uri() == assetmap_smpte_ns) {
@@ -436,6 +435,7 @@ DCP::write_assetmap (Standard standard, string pkl_uuid, boost::filesystem::path
}
doc.write_to_file_formatted (p.string (), "UTF-8");
+ _asset_map = p;
}
/** Write all the XML files for this DCP.
diff --git a/src/dcp.h b/src/dcp.h
index 34611fb7..0ac93f49 100644
--- a/src/dcp.h
+++ b/src/dcp.h
@@ -134,6 +134,10 @@ public:
return _pkls;
}
+ boost::optional<boost::filesystem::path> asset_map_path () {
+ return _asset_map;
+ }
+
static std::vector<boost::filesystem::path> directories_from_files (std::vector<boost::filesystem::path> files);
private:
@@ -146,11 +150,14 @@ private:
*/
void write_assetmap (Standard standard, std::string pkl_uuid, boost::filesystem::path pkl_path, XMLMetadata metadata) const;
- /** the directory that we are writing to */
+ /** The directory that we are writing to */
boost::filesystem::path _directory;
- /** the CPLs that make up this DCP */
+ /** The CPLs that make up this DCP */
std::list<boost::shared_ptr<CPL> > _cpls;
+ /** The PKLs that make up this DCP */
std::list<boost::shared_ptr<PKL> > _pkls;
+ /** File that the ASSETMAP was read from or last written to */
+ mutable boost::optional<boost::filesystem::path> _asset_map;
/** Standard of DCP that was read in */
boost::optional<Standard> _standard;
diff --git a/src/verify.cc b/src/verify.cc
index 9a2b0f70..cb2b1287 100644
--- a/src/verify.cc
+++ b/src/verify.cc
@@ -229,8 +229,8 @@ private:
};
static
-list<XMLValidationError>
-validate_xml (boost::filesystem::path xml_file, boost::filesystem::path xsd_dtd_directory)
+void
+validate_xml (boost::filesystem::path xml_file, boost::filesystem::path xsd_dtd_directory, list<VerificationNote>& notes)
{
try {
XMLPlatformUtils::Initialize ();
@@ -252,6 +252,7 @@ validate_xml (boost::filesystem::path xml_file, boost::filesystem::path xsd_dtd_
schema["http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd"] = "xmldsig-core-schema.xsd";
schema["http://www.smpte-ra.org/schemas/429-7/2006/CPL"] = "SMPTE-429-7-2006-CPL.xsd";
schema["http://www.smpte-ra.org/schemas/429-8/2006/PKL"] = "SMPTE-429-8-2006-PKL.xsd";
+ schema["http://www.smpte-ra.org/schemas/429-9/2007/AM"] = "SMPTE-429-9-2007-AM.xsd";
schema["http://www.w3.org/2001/03/xml.xsd"] = "xml.xsd";
string locations;
@@ -283,7 +284,17 @@ validate_xml (boost::filesystem::path xml_file, boost::filesystem::path xsd_dtd_
XMLPlatformUtils::Terminate ();
- return error_handler.errors ();
+ BOOST_FOREACH (XMLValidationError i, error_handler.errors()) {
+ notes.push_back (
+ VerificationNote(
+ VerificationNote::VERIFY_ERROR,
+ VerificationNote::Code::XML_VALIDATION_ERROR,
+ i.message(),
+ xml_file,
+ i.line()
+ )
+ );
+ }
}
static Result
@@ -349,19 +360,7 @@ dcp::verify (
BOOST_FOREACH (shared_ptr<CPL> cpl, dcp->cpls()) {
stage ("Checking CPL", cpl->file());
-
- list<XMLValidationError> errors = validate_xml (cpl->file().get(), xsd_dtd_directory);
- BOOST_FOREACH (XMLValidationError i, errors) {
- notes.push_back (
- VerificationNote(
- VerificationNote::VERIFY_ERROR,
- VerificationNote::Code::XML_VALIDATION_ERROR,
- i.message(),
- cpl->file().get(),
- i.line()
- )
- );
- }
+ validate_xml (cpl->file().get(), xsd_dtd_directory, notes);
/* Check that the CPL's hash corresponds to the PKL */
BOOST_FOREACH (shared_ptr<PKL> i, dcp->pkls()) {
@@ -437,20 +436,12 @@ dcp::verify (
BOOST_FOREACH (shared_ptr<PKL> pkl, dcp->pkls()) {
stage ("Checking PKL", pkl->file());
-
- list<XMLValidationError> errors = validate_xml (pkl->file().get(), xsd_dtd_directory);
- BOOST_FOREACH (XMLValidationError i, errors) {
- notes.push_back (
- VerificationNote(
- VerificationNote::VERIFY_ERROR,
- VerificationNote::Code::XML_VALIDATION_ERROR,
- i.message(),
- pkl->file().get(),
- i.line()
- )
- );
- }
+ validate_xml (pkl->file().get(), xsd_dtd_directory, notes);
}
+
+ stage ("Checking ASSETMAP", dcp->asset_map_path().get());
+ validate_xml (dcp->asset_map_path().get(), xsd_dtd_directory, notes);
+
}
return notes;