}
-CPL::CPL (boost::filesystem::path file)
+CPL::CPL (boost::filesystem::path file, vector<dcp::VerificationNote>* notes)
: Asset (file)
, _content_kind (ContentKind::FEATURE)
{
} 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"));
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")) {
#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>
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,
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});
}
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 "";
* 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)