diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-05-24 11:26:50 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-05-24 11:26:50 +0100 |
| commit | 437f928f7d7209c9e4c8ea3e3b5d0e8dc43b54a8 (patch) | |
| tree | 50feb1d8277cf6ad7fb8da83b36b0d5782c55326 /src | |
| parent | 23644a666637d3db3ccf2007a7cbbcdf4f2d29a2 (diff) | |
Add reporting of DCP type.
Diffstat (limited to 'src')
| -rw-r--r-- | src/cpl.cc | 8 | ||||
| -rw-r--r-- | src/cpl.h | 7 | ||||
| -rw-r--r-- | src/dcp.cc | 24 | ||||
| -rw-r--r-- | src/dcp.h | 8 | ||||
| -rw-r--r-- | src/exceptions.cc | 6 | ||||
| -rw-r--r-- | src/exceptions.h | 6 |
6 files changed, 58 insertions, 1 deletions
@@ -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 (""); @@ -114,6 +114,10 @@ public: int64_t duration () const; + boost::optional<Standard> 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<boost::shared_ptr<Reel> > _reels; + + /** Standard of CPL that was read in */ + boost::optional<Standard> _standard; }; } @@ -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<class T> 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<shared_ptr<cxml::Node> > asset_nodes = asset_map.node_child("AssetList")->node_children ("Asset"); map<string, boost::filesystem::path> paths; BOOST_FOREACH (shared_ptr<cxml::Node> 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<CPL> (new CPL (path))); + shared_ptr<CPL> 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<InteropSubtitleAsset> (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"); @@ -102,6 +102,11 @@ public: void resolve_refs (std::list<boost::shared_ptr<Asset> > assets); + /** @return Standard of a DCP that was read in */ + boost::optional<Standard> 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<boost::shared_ptr<CPL> > _cpls; + + /** Standard of DCP that was read in */ + boost::optional<Standard> _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 |
