summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-05-24 11:26:50 +0100
committerCarl Hetherington <cth@carlh.net>2016-05-24 11:26:50 +0100
commit437f928f7d7209c9e4c8ea3e3b5d0e8dc43b54a8 (patch)
tree50feb1d8277cf6ad7fb8da83b36b0d5782c55326 /src
parent23644a666637d3db3ccf2007a7cbbcdf4f2d29a2 (diff)
Add reporting of DCP type.
Diffstat (limited to 'src')
-rw-r--r--src/cpl.cc8
-rw-r--r--src/cpl.h7
-rw-r--r--src/dcp.cc24
-rw-r--r--src/dcp.h8
-rw-r--r--src/exceptions.cc6
-rw-r--r--src/exceptions.h6
6 files changed, 58 insertions, 1 deletions
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> 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; ///< &lt;Id&gt; in &lt;ContentVersion&gt;
std::string _content_version_label_text; ///< &lt;LabelText&gt; in &lt;ContentVersion&gt;
std::list<boost::shared_ptr<Reel> > _reels;
+
+ /** Standard of CPL that was read in */
+ boost::optional<Standard> _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<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");
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<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