From 85c565b56de05e93617a8dfd633d6f9d6e9cb30a Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 24 Apr 2022 22:38:52 +0200 Subject: Try to remove the PKL object, and make it so that we don't keep the PKL assets around after reading them. But verification needs to see those assets, to check the hashes. --- src/dcp.cc | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'src/dcp.cc') diff --git a/src/dcp.cc b/src/dcp.cc index 803701f5..28a00665 100644 --- a/src/dcp.cc +++ b/src/dcp.cc @@ -52,7 +52,7 @@ #include "metadata.h" #include "mono_picture_asset.h" #include "picture_asset.h" -#include "pkl.h" +#include "pkl_internal.h" #include "raw_convert.h" #include "reel_asset.h" #include "reel_subtitle_asset.h" @@ -168,13 +168,20 @@ DCP::read (vector* notes, bool ignore_incorrect_picture_m boost::throw_exception (XMLError ("No packing lists found in asset map")); } + auto pkl_assets = vector(); + + bool first = true; for (auto i: pkl_paths) { - _pkls.push_back (make_shared(_directory / i)); + auto metadata = read_pkl(_directory / i, pkl_assets); + if (first) { + _metadata = metadata; + first = false; + } } /* Now we have: paths - map of files in the DCP that are not PKLs; key is ID, value is path. - _pkls - PKL objects for each PKL. + pkl_assets - all the assets from all the PKLs that we found. Read all the assets from the asset map. */ @@ -184,10 +191,10 @@ DCP::read (vector* notes, bool ignore_incorrect_picture_m */ vector> other_assets; - for (auto i: paths) { - auto path = _directory / i.second; + for (auto const& id_and_path: paths) { + auto path = _directory / id_and_path.second; - if (i.second.empty()) { + if (id_and_path.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. @@ -206,21 +213,16 @@ DCP::read (vector* notes, bool ignore_incorrect_picture_m } /* Find the for this asset from the PKL that contains the asset */ - optional pkl_type; - for (auto j: _pkls) { - pkl_type = j->type(i.first); - if (pkl_type) { - break; - } - } - - if (!pkl_type) { + auto pkl_asset_with_id = std::find_if(pkl_assets.begin(), pkl_assets.end(), [](PKLAsset const& a) { return a.id() == id_and_path.first; }); + if (pkl_asset_with_id != pkl_assets.end() { /* This asset is in the ASSETMAP but not mentioned in any PKL so we don't * need to worry about it. */ continue; } + auto pkl_type = pkl_asset_with_id->type(); + auto remove_parameters = [](string const& n) { return n.substr(0, n.find(";")); }; -- cgit v1.2.3