summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-08-17 01:39:45 +0100
committerCarl Hetherington <cth@carlh.net>2018-08-17 01:39:45 +0100
commit28ab65a9d625e03753cd40e22d9f991d59460a16 (patch)
tree0e069ed40bb9b2c53edf45dcd10b05d1719e9519 /src
parent5eb0ff8f094517ab6d82751288a69c8fcea74eb1 (diff)
Use PKL types rather than file extensions.
Diffstat (limited to 'src')
-rw-r--r--src/atmos_asset.cc2
-rw-r--r--src/atmos_asset.h5
-rw-r--r--src/cpl.cc6
-rw-r--r--src/cpl.h2
-rw-r--r--src/dcp.cc23
-rw-r--r--src/font_asset.cc2
-rw-r--r--src/font_asset.h6
-rw-r--r--src/interop_subtitle_asset.h8
-rw-r--r--src/picture_asset.cc8
-rw-r--r--src/picture_asset.h2
-rw-r--r--src/pkl.cc13
-rw-r--r--src/pkl.h1
-rw-r--r--src/smpte_subtitle_asset.h7
-rw-r--r--src/sound_asset.cc2
-rw-r--r--src/sound_asset.h5
15 files changed, 72 insertions, 20 deletions
diff --git a/src/atmos_asset.cc b/src/atmos_asset.cc
index 1e4d9c18..171c8e8b 100644
--- a/src/atmos_asset.cc
+++ b/src/atmos_asset.cc
@@ -83,7 +83,7 @@ AtmosAsset::AtmosAsset (boost::filesystem::path file)
}
string
-AtmosAsset::pkl_type (Standard) const
+AtmosAsset::static_pkl_type (Standard)
{
return "application/mxf";
}
diff --git a/src/atmos_asset.h b/src/atmos_asset.h
index 8e9190c8..61f94055 100644
--- a/src/atmos_asset.h
+++ b/src/atmos_asset.h
@@ -51,7 +51,10 @@ public:
boost::shared_ptr<AtmosAssetWriter> start_write (boost::filesystem::path file);
boost::shared_ptr<AtmosAssetReader> start_read () const;
- std::string pkl_type (Standard) const;
+ static std::string static_pkl_type (Standard);
+ std::string pkl_type (Standard s) const {
+ return static_pkl_type (s);
+ }
Fraction edit_rate () const {
return _edit_rate;
diff --git a/src/cpl.cc b/src/cpl.cc
index aa61ec7a..d23cd4aa 100644
--- a/src/cpl.cc
+++ b/src/cpl.cc
@@ -270,6 +270,12 @@ CPL::resolve_refs (list<shared_ptr<Asset> > assets)
string
CPL::pkl_type (Standard standard) const
{
+ return static_pkl_type (standard);
+}
+
+string
+CPL::static_pkl_type (Standard standard)
+{
switch (standard) {
case INTEROP:
return "text/xml;asdcpKind=CPL";
diff --git a/src/cpl.h b/src/cpl.h
index 7e6dac6f..bcc1f06b 100644
--- a/src/cpl.h
+++ b/src/cpl.h
@@ -140,6 +140,8 @@ public:
return _standard;
}
+ static std::string static_pkl_type (Standard standard);
+
protected:
/** @return type string for PKLs for this asset */
std::string pkl_type (Standard standard) const;
diff --git a/src/dcp.cc b/src/dcp.cc
index 523ec053..232c1443 100644
--- a/src/dcp.cc
+++ b/src/dcp.cc
@@ -110,7 +110,7 @@ survivable_error (bool keep_going, dcp::DCP::ReadErrors* errors, T const & e)
void
DCP::read (bool keep_going, ReadErrors* errors, bool ignore_incorrect_picture_mxf_type)
{
- /* Read the ASSETMAP */
+ /* Read the ASSETMAP and PKL */
boost::filesystem::path asset_map_file;
if (boost::filesystem::exists (_directory / "ASSETMAP")) {
@@ -143,10 +143,11 @@ DCP::read (bool keep_going, ReadErrors* errors, bool ignore_incorrect_picture_mx
if (starts_with (p, "file://")) {
p = p.substr (7);
}
- paths.insert (make_pair (remove_urn_uuid (i->string_child ("Id")), p));
optional<string> pkl_bool = i->optional_string_child("PackingList");
if (pkl_bool && *pkl_bool == "true") {
pkl_path = p;
+ } else {
+ paths.insert (make_pair (remove_urn_uuid (i->string_child ("Id")), p));
}
}
@@ -157,11 +158,8 @@ DCP::read (bool keep_going, ReadErrors* errors, bool ignore_incorrect_picture_mx
_pkl.reset (new PKL (_directory / *pkl_path));
/* Read all the assets from the asset map */
- /* XXX: I think we should be looking at the PKL here to decide type, not
- the extension of the file.
- */
- /* Make a list of non-CPL assets so that we can resolve the references
+ /* Make a list of non-CPL/PKL assets so that we can resolve the references
from the CPLs.
*/
list<shared_ptr<Asset> > other_assets;
@@ -174,7 +172,9 @@ DCP::read (bool keep_going, ReadErrors* errors, bool ignore_incorrect_picture_mx
continue;
}
- if (boost::filesystem::extension (path) == ".xml") {
+ string const pkl_type = _pkl->type(i->first);
+
+ if (pkl_type == CPL::static_pkl_type(*_standard) || pkl_type == InteropSubtitleAsset::static_pkl_type(*_standard)) {
xmlpp::DomParser* p = new xmlpp::DomParser;
try {
p->parse_file (path.string());
@@ -198,7 +198,12 @@ DCP::read (bool keep_going, ReadErrors* errors, bool ignore_incorrect_picture_mx
}
other_assets.push_back (shared_ptr<InteropSubtitleAsset> (new InteropSubtitleAsset (path)));
}
- } else if (boost::filesystem::extension (path) == ".mxf") {
+ } else if (
+ pkl_type == PictureAsset::static_pkl_type(*_standard) ||
+ pkl_type == SoundAsset::static_pkl_type(*_standard) ||
+ pkl_type == AtmosAsset::static_pkl_type(*_standard) ||
+ pkl_type == SMPTESubtitleAsset::static_pkl_type(*_standard)
+ ) {
/* XXX: asdcplib does not appear to support discovery of read MXFs standard
(Interop / SMPTE)
@@ -240,7 +245,7 @@ DCP::read (bool keep_going, ReadErrors* errors, bool ignore_incorrect_picture_mx
default:
throw DCPReadError (String::compose ("Unknown MXF essence type %1 in %2", int(type), path.string()));
}
- } else if (boost::filesystem::extension (path) == ".ttf") {
+ } else if (pkl_type == FontAsset::static_pkl_type(*_standard)) {
other_assets.push_back (shared_ptr<FontAsset> (new FontAsset (i->first, path)));
}
}
diff --git a/src/font_asset.cc b/src/font_asset.cc
index f20ebfb4..f201d649 100644
--- a/src/font_asset.cc
+++ b/src/font_asset.cc
@@ -48,7 +48,7 @@ FontAsset::FontAsset (string id, boost::filesystem::path file)
}
string
-FontAsset::pkl_type (Standard) const
+FontAsset::static_pkl_type (Standard)
{
return "application/ttf";
}
diff --git a/src/font_asset.h b/src/font_asset.h
index 5b431650..1d412619 100644
--- a/src/font_asset.h
+++ b/src/font_asset.h
@@ -47,8 +47,12 @@ class FontAsset : public Asset
public:
FontAsset (std::string id, boost::filesystem::path file);
+ static std::string static_pkl_type (Standard standard);
+
private:
- std::string pkl_type (Standard standard) const;
+ std::string pkl_type (Standard standard) const {
+ return static_pkl_type (standard);
+ }
};
}
diff --git a/src/interop_subtitle_asset.h b/src/interop_subtitle_asset.h
index 72cd0022..703229a7 100644
--- a/src/interop_subtitle_asset.h
+++ b/src/interop_subtitle_asset.h
@@ -105,10 +105,14 @@ public:
return _movie_title;
}
+ static std::string static_pkl_type (Standard) {
+ return "text/xml;asdcpKind=Subtitle";
+ }
+
protected:
- std::string pkl_type (Standard) const {
- return "text/xml;asdcpKind=Subtitle";
+ std::string pkl_type (Standard s) const {
+ return static_pkl_type (s);
}
private:
diff --git a/src/picture_asset.cc b/src/picture_asset.cc
index 7c4eb7b5..68af0896 100644
--- a/src/picture_asset.cc
+++ b/src/picture_asset.cc
@@ -200,7 +200,7 @@ PictureAsset::frame_buffer_equals (
}
string
-PictureAsset::pkl_type (Standard standard) const
+PictureAsset::static_pkl_type (Standard standard)
{
switch (standard) {
case INTEROP:
@@ -211,3 +211,9 @@ PictureAsset::pkl_type (Standard standard) const
DCP_ASSERT (false);
}
}
+
+string
+PictureAsset::pkl_type (Standard standard) const
+{
+ return static_pkl_type (standard);
+}
diff --git a/src/picture_asset.h b/src/picture_asset.h
index 696776da..cc1be9f0 100644
--- a/src/picture_asset.h
+++ b/src/picture_asset.h
@@ -101,6 +101,8 @@ public:
return _intrinsic_duration;
}
+ static std::string static_pkl_type (Standard standard);
+
protected:
friend class MonoPictureAssetWriter;
friend class StereoPictureAssetWriter;
diff --git a/src/pkl.cc b/src/pkl.cc
index a46ab313..621cf465 100644
--- a/src/pkl.cc
+++ b/src/pkl.cc
@@ -38,6 +38,7 @@
#include "dcp_assert.h"
#include <libxml++/libxml++.h>
#include <boost/foreach.hpp>
+#include <iostream>
using std::string;
using boost::shared_ptr;
@@ -125,3 +126,15 @@ PKL::hash (string id) const
DCP_ASSERT (false);
}
+
+string
+PKL::type (string id) const
+{
+ BOOST_FOREACH (shared_ptr<Asset> i, _asset_list) {
+ if (i->id() == id) {
+ return i->type;
+ }
+ }
+
+ DCP_ASSERT (false);
+}
diff --git a/src/pkl.h b/src/pkl.h
index d17b8fe1..aa78ae21 100644
--- a/src/pkl.h
+++ b/src/pkl.h
@@ -61,6 +61,7 @@ public:
}
std::string hash (std::string id) const;
+ std::string type (std::string id) const;
void add_asset (std::string id, boost::optional<std::string> annotation_text, std::string hash, int64_t size, std::string type);
void write (boost::filesystem::path file, boost::shared_ptr<const CertificateChain> signer) const;
diff --git a/src/smpte_subtitle_asset.h b/src/smpte_subtitle_asset.h
index 6631b31e..79a0024b 100644
--- a/src/smpte_subtitle_asset.h
+++ b/src/smpte_subtitle_asset.h
@@ -156,11 +156,14 @@ public:
}
static bool valid_mxf (boost::filesystem::path);
+ static std::string static_pkl_type (Standard) {
+ return "application/mxf";
+ }
protected:
- std::string pkl_type (Standard) const {
- return "application/mxf";
+ std::string pkl_type (Standard s) const {
+ return static_pkl_type (s);
}
private:
diff --git a/src/sound_asset.cc b/src/sound_asset.cc
index 641dc09a..1f1c2f43 100644
--- a/src/sound_asset.cc
+++ b/src/sound_asset.cc
@@ -206,7 +206,7 @@ SoundAsset::start_read () const
}
string
-SoundAsset::pkl_type (Standard standard) const
+SoundAsset::static_pkl_type (Standard standard)
{
switch (standard) {
case INTEROP:
diff --git a/src/sound_asset.h b/src/sound_asset.h
index 77495152..509ae559 100644
--- a/src/sound_asset.h
+++ b/src/sound_asset.h
@@ -86,11 +86,14 @@ public:
}
static bool valid_mxf (boost::filesystem::path);
+ static std::string static_pkl_type (Standard standard);
private:
friend class SoundAssetWriter;
- std::string pkl_type (Standard standard) const;
+ std::string pkl_type (Standard standard) const {
+ return static_pkl_type (standard);
+ }
Fraction _edit_rate;
/** The total length of this content in video frames. The amount of