summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-04-17 22:19:02 +0200
committerCarl Hetherington <cth@carlh.net>2024-04-17 22:19:02 +0200
commit869462070671b273ac528e075ac1c00a417cc8a0 (patch)
treec6a98899ff9a7f86ab061730a5fdc9b52d787a2c
parent0a8f2a1a2058f0461a7f978295e31af34a03bb40 (diff)
Make some not-so-important CPL read errors non-fatal (DoM #2797).v1.8.99
-rw-r--r--src/cpl.cc25
-rw-r--r--src/cpl.h8
-rw-r--r--src/dcp.cc2
-rw-r--r--src/verify.cc4
-rw-r--r--src/verify.h10
5 files changed, 43 insertions, 6 deletions
diff --git a/src/cpl.cc b/src/cpl.cc
index 5ff86fda..6a25863a 100644
--- a/src/cpl.cc
+++ b/src/cpl.cc
@@ -104,7 +104,7 @@ CPL::CPL (string annotation_text, ContentKind content_kind, Standard standard)
}
-CPL::CPL (boost::filesystem::path file)
+CPL::CPL (boost::filesystem::path file, vector<dcp::VerificationNote>* notes)
: Asset (file)
, _content_kind (ContentKind::FEATURE)
{
@@ -116,7 +116,17 @@ CPL::CPL (boost::filesystem::path file)
} else if (f.namespace_uri() == cpl_smpte_ns) {
_standard = Standard::SMPTE;
} else {
- boost::throw_exception (XMLError ("Unrecognised CPL namespace " + f.namespace_uri()));
+ if (notes) {
+ notes->push_back(
+ dcp::VerificationNote(
+ dcp::VerificationNote::Type::ERROR,
+ dcp::VerificationNote::Code::INVALID_CPL_NAMESPACE,
+ f.namespace_uri(),
+ file
+ )
+ );
+ }
+ _standard = Standard::INTEROP;
}
_id = remove_urn_uuid (f.string_child ("Id"));
@@ -139,7 +149,16 @@ CPL::CPL (boost::filesystem::path file)
content_version->done ();
} else if (_standard == Standard::SMPTE) {
/* ContentVersion is required in SMPTE */
- throw XMLError ("Missing ContentVersion tag in CPL");
+ if (notes) {
+ notes->push_back(
+ dcp::VerificationNote(
+ dcp::VerificationNote::Type::ERROR,
+ dcp::VerificationNote::Code::MISSING_CPL_CONTENT_VERSION,
+ _id,
+ file
+ )
+ );
+ }
}
auto rating_list = f.node_child ("RatingList");
for (auto i: rating_list->node_children("Rating")) {
diff --git a/src/cpl.h b/src/cpl.h
index fb4f3376..824faaa1 100644
--- a/src/cpl.h
+++ b/src/cpl.h
@@ -47,6 +47,7 @@
#include "key.h"
#include "language_tag.h"
#include "rating.h"
+#include "verify.h"
#include <boost/filesystem.hpp>
#include <boost/function.hpp>
#include <boost/optional.hpp>
@@ -82,8 +83,11 @@ class CPL : public Asset
public:
CPL (std::string annotation_text, ContentKind content_kind, Standard standard);
- /** Construct a CPL object from a XML file */
- explicit CPL (boost::filesystem::path file);
+ /** Construct a CPL object from a XML file.
+ * If notes is not null, non-fatal errors will be added.
+ * Exceptions will be thrown on non-recoverable errors.
+ */
+ explicit CPL(boost::filesystem::path file, std::vector<dcp::VerificationNote>* notes = nullptr);
bool equals (
std::shared_ptr<const Asset> other,
diff --git a/src/dcp.cc b/src/dcp.cc
index d603cfae..eb21b47d 100644
--- a/src/dcp.cc
+++ b/src/dcp.cc
@@ -234,7 +234,7 @@ DCP::read (vector<dcp::VerificationNote>* notes, bool ignore_incorrect_picture_m
delete p;
if (root == "CompositionPlaylist") {
- auto cpl = make_shared<CPL>(path);
+ auto cpl = make_shared<CPL>(path, notes);
if (cpl->standard() != standard && notes) {
notes->push_back ({VerificationNote::Type::ERROR, VerificationNote::Code::MISMATCHED_STANDARD});
}
diff --git a/src/verify.cc b/src/verify.cc
index 9715c020..112a5bb5 100644
--- a/src/verify.cc
+++ b/src/verify.cc
@@ -2178,6 +2178,10 @@ dcp::note_to_string (VerificationNote note)
return String::compose("The asset with ID %1 in the asset map actually has an id of %2", note.id().get(), note.other_id().get());
case VerificationNote::Code::EMPTY_CONTENT_VERSION_LABEL_TEXT:
return String::compose("The <LabelText> in a <ContentVersion> in CPL %1 is empty", note.id().get());
+ case VerificationNote::Code::INVALID_CPL_NAMESPACE:
+ return String::compose("The namespace %1 in CPL %2 is invalid", note.note().get(), note.file()->filename());
+ case VerificationNote::Code::MISSING_CPL_CONTENT_VERSION:
+ return String::compose("The CPL %1 has no <ContentVersion> tag", note.note().get());
}
return "";
diff --git a/src/verify.h b/src/verify.h
index 4ca3297a..b5d913bd 100644
--- a/src/verify.h
+++ b/src/verify.h
@@ -475,6 +475,16 @@ public:
* file contains the CPL filename
*/
EMPTY_CONTENT_VERSION_LABEL_TEXT,
+ /** The CPL namespace is not valid.
+ * note contains the invalid namespace
+ * file contains the CPL filename
+ */
+ INVALID_CPL_NAMESPACE,
+ /** A SMPTE CPL does not contain a _<ContentVersion>_ tag
+ * note contains the CPL ID
+ * file contains the CPL filename
+ */
+ MISSING_CPL_CONTENT_VERSION
};
VerificationNote (Type type, Code code)