From 869462070671b273ac528e075ac1c00a417cc8a0 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 17 Apr 2024 22:19:02 +0200 Subject: [PATCH] Make some not-so-important CPL read errors non-fatal (DoM #2797). --- src/cpl.cc | 25 ++++++++++++++++++++++--- src/cpl.h | 8 ++++++-- src/dcp.cc | 2 +- src/verify.cc | 4 ++++ src/verify.h | 10 ++++++++++ 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* 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 #include #include @@ -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* notes = nullptr); bool equals ( std::shared_ptr 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* notes, bool ignore_incorrect_picture_m delete p; if (root == "CompositionPlaylist") { - auto cpl = make_shared(path); + auto cpl = make_shared(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 in a 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 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 __ tag + * note contains the CPL ID + * file contains the CPL filename + */ + MISSING_CPL_CONTENT_VERSION }; VerificationNote (Type type, Code code) -- 2.30.2