From 437f928f7d7209c9e4c8ea3e3b5d0e8dc43b54a8 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 24 May 2016 11:26:50 +0100 Subject: Add reporting of DCP type. --- src/cpl.cc | 8 ++++++++ src/cpl.h | 7 +++++++ src/dcp.cc | 24 +++++++++++++++++++++++- src/dcp.h | 8 ++++++++ src/exceptions.cc | 6 ++++++ src/exceptions.h | 6 ++++++ 6 files changed, 58 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/cpl.cc b/src/cpl.cc index b96e15d2..0d8221e2 100644 --- a/src/cpl.cc +++ b/src/cpl.cc @@ -70,6 +70,14 @@ CPL::CPL (boost::filesystem::path file) cxml::Document f ("CompositionPlaylist"); f.read_file (file); + if (f.namespace_uri() == cpl_interop_ns) { + _standard = INTEROP; + } else if (f.namespace_uri() == cpl_smpte_ns) { + _standard = SMPTE; + } else { + boost::throw_exception (XMLError ("Unrecognised CPL namespace " + f.namespace_uri())); + } + _id = remove_urn_uuid (f.string_child ("Id")); _annotation_text = f.optional_string_child ("AnnotationText").get_value_or (""); _metadata.issuer = f.optional_string_child ("Issuer").get_value_or (""); diff --git a/src/cpl.h b/src/cpl.h index 9d22cbd4..5ff320d2 100644 --- a/src/cpl.h +++ b/src/cpl.h @@ -114,6 +114,10 @@ public: int64_t duration () const; + boost::optional standard () const { + return _standard; + } + protected: /** @return type string for PKLs for this asset */ std::string pkl_type (Standard standard) const; @@ -129,6 +133,9 @@ private: std::string _content_version_id; ///< <Id> in <ContentVersion> std::string _content_version_label_text; ///< <LabelText> in <ContentVersion> std::list > _reels; + + /** Standard of CPL that was read in */ + boost::optional _standard; }; } diff --git a/src/dcp.cc b/src/dcp.cc index 3298cfae..11146562 100644 --- a/src/dcp.cc +++ b/src/dcp.cc @@ -81,6 +81,7 @@ DCP::DCP (boost::filesystem::path directory) _directory = boost::filesystem::canonical (_directory); } +/** Call this instead of throwing an exception if the error can be tolerated */ template void survivable_error (bool keep_going, dcp::DCP::ReadErrors* errors, T const & e) { @@ -108,7 +109,16 @@ DCP::read (bool keep_going, ReadErrors* errors, bool ignore_incorrect_picture_mx } cxml::Document asset_map ("AssetMap"); + asset_map.read_file (asset_map_file); + if (asset_map.namespace_uri() == assetmap_interop_ns) { + _standard = INTEROP; + } else if (asset_map.namespace_uri() == assetmap_smpte_ns) { + _standard = SMPTE; + } else { + boost::throw_exception (XMLError ("Unrecognised Assetmap namespace " + asset_map.namespace_uri())); + } + list > asset_nodes = asset_map.node_child("AssetList")->node_children ("Asset"); map paths; BOOST_FOREACH (shared_ptr i, asset_nodes) { @@ -153,11 +163,23 @@ DCP::read (bool keep_going, ReadErrors* errors, bool ignore_incorrect_picture_mx delete p; if (root == "CompositionPlaylist") { - _cpls.push_back (shared_ptr (new CPL (path))); + shared_ptr cpl (new CPL (path)); + if (_standard && cpl->standard() && cpl->standard().get() != _standard.get()) { + survivable_error (keep_going, errors, MismatchedStandardError ()); + } + _cpls.push_back (cpl); } else if (root == "DCSubtitle") { + if (_standard && _standard.get() == SMPTE) { + survivable_error (keep_going, errors, MismatchedStandardError ()); + } other_assets.push_back (shared_ptr (new InteropSubtitleAsset (path))); } } else if (boost::filesystem::extension (path) == ".mxf") { + + /* XXX: asdcplib does not appear to support discovery of read MXFs standard + (Interop / SMPTE) + */ + ASDCP::EssenceType_t type; if (ASDCP::EssenceType (path.string().c_str(), type) != ASDCP::RESULT_OK) { throw DCPReadError ("Could not find essence type"); diff --git a/src/dcp.h b/src/dcp.h index 05c2026b..7d6d1567 100644 --- a/src/dcp.h +++ b/src/dcp.h @@ -102,6 +102,11 @@ public: void resolve_refs (std::list > assets); + /** @return Standard of a DCP that was read in */ + boost::optional standard () const { + return _standard; + } + private: /** Write the PKL file. @@ -126,6 +131,9 @@ private: boost::filesystem::path _directory; /** the CPLs that make up this DCP */ std::list > _cpls; + + /** Standard of DCP that was read in */ + boost::optional _standard; }; } diff --git a/src/exceptions.cc b/src/exceptions.cc index ed6edaa4..14ae8e9c 100644 --- a/src/exceptions.cc +++ b/src/exceptions.cc @@ -70,3 +70,9 @@ ProgrammingError::ProgrammingError (string file, int line) { } + +MismatchedStandardError::MismatchedStandardError () + : DCPReadError ("DCP contains both Interop and SMPTE parts") +{ + +} diff --git a/src/exceptions.h b/src/exceptions.h index 801bfb01..3410337e 100644 --- a/src/exceptions.h +++ b/src/exceptions.h @@ -153,6 +153,12 @@ public: ProgrammingError (std::string file, int line); }; +class MismatchedStandardError : public DCPReadError +{ +public: + MismatchedStandardError (); +}; + } #endif -- cgit v1.2.3