From aa8b4d4348394ea01e97f4c83e55fdbca3aa6cdb Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 30 Aug 2019 22:28:06 +0100 Subject: [PATCH] Allow DCP reading to continue even with empty nodes in ASSETMAP. --- src/dcp.cc | 18 ++++++++++++++++-- src/exceptions.cc | 11 ++++++++++- src/exceptions.h | 8 +++++++- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/dcp.cc b/src/dcp.cc index 5d908530..69875235 100644 --- a/src/dcp.cc +++ b/src/dcp.cc @@ -173,7 +173,12 @@ DCP::read (bool keep_going, ReadErrors* errors, bool ignore_incorrect_picture_mx _pkls.push_back (shared_ptr(new PKL(_directory / i))); } - /* Read all the assets from the asset map */ + /* Now we have: + paths - files in the DCP that are not PKLs. + _pkls - PKL objects for each PKL. + + Read all the assets from the asset map. + */ /* Make a list of non-CPL/PKL assets so that we can resolve the references from the CPLs. @@ -183,11 +188,20 @@ DCP::read (bool keep_going, ReadErrors* errors, bool ignore_incorrect_picture_mx for (map::const_iterator i = paths.begin(); i != paths.end(); ++i) { boost::filesystem::path path = _directory / i->second; - if (!boost::filesystem::exists (path)) { + if (i->second.empty()) { + /* I can't see how this is valid, but it's + been seen in the wild with a DCP that + claims to come from ClipsterDCI 5.10.0.5. + */ + survivable_error (keep_going, errors, EmptyAssetPathError(i->first)); + } + + if (i->second.empty() || !boost::filesystem::exists(path)) { survivable_error (keep_going, errors, MissingAssetError (path)); continue; } + /* Find the for this asset from the PKL that contains the asset */ optional pkl_type; BOOST_FOREACH (shared_ptr j, _pkls) { pkl_type = j->type(i->first); diff --git a/src/exceptions.cc b/src/exceptions.cc index 7516d085..0b8978dc 100644 --- a/src/exceptions.cc +++ b/src/exceptions.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2018 Carl Hetherington + Copyright (C) 2014-2019 Carl Hetherington This file is part of libdcp. @@ -129,3 +129,12 @@ MissingSubtitleImageError::MissingSubtitleImageError (string id) { } + +/** The in the ASSETMAP is empty for asset. I can't see how this is valid, + but it's been seen in the wild with a DCP that claims to come from ClipsterDCI 5.10.0.5. + */ +EmptyAssetPathError::EmptyAssetPathError (string id) + : DCPReadError (String::compose("Asset map path is empty for asset %1", id)) +{ + +} diff --git a/src/exceptions.h b/src/exceptions.h index 65271c16..1e9bd2d7 100644 --- a/src/exceptions.h +++ b/src/exceptions.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2018 Carl Hetherington + Copyright (C) 2012-2019 Carl Hetherington This file is part of libdcp. @@ -228,6 +228,12 @@ public: MissingSubtitleImageError (std::string id); }; +class EmptyAssetPathError : public DCPReadError +{ +public: + EmptyAssetPathError (std::string id); +}; + } #endif -- 2.30.2