diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-01-03 00:11:16 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-01-04 20:56:40 +0000 |
| commit | 8c1ce3b27b2d4bb8891554641c475a4d6c502450 (patch) | |
| tree | 76277b5485f57eabb0c5732d14408aa98ef34c87 /src | |
| parent | b41d8f29bf1c435968c94faceaa00bc48949ec78 (diff) | |
Fix creation of dcpdig files in projects that make VFs (#2109).
Previously we would always get keys from the project which was
wrong with assets that already have their own key.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/dcp_digest_file.cc | 12 | ||||
| -rw-r--r-- | src/lib/dcp_transcode_job.cc | 30 |
2 files changed, 32 insertions, 10 deletions
diff --git a/src/lib/dcp_digest_file.cc b/src/lib/dcp_digest_file.cc index 739cc2b75..9e9ca7114 100644 --- a/src/lib/dcp_digest_file.cc +++ b/src/lib/dcp_digest_file.cc @@ -39,7 +39,7 @@ using std::string; template <class R, class A> -void add_asset(string key, shared_ptr<R> reel_asset, shared_ptr<A> asset, xmlpp::Element* reel, string name) +void add_asset(string film_key, shared_ptr<R> reel_asset, shared_ptr<A> asset, xmlpp::Element* reel, string name) { if (asset) { auto out = reel->add_child(name); @@ -47,7 +47,7 @@ void add_asset(string key, shared_ptr<R> reel_asset, shared_ptr<A> asset, xmlpp: out->add_child("AnnotationText")->add_child_text(reel_asset->annotation_text()); if (asset->key_id()) { out->add_child("KeyId")->add_child_text("urn:uuid:" + asset->key_id().get()); - out->add_child("Key")->add_child_text(key); + out->add_child("Key")->add_child_text(asset->key() ? asset->key()->hex() : film_key); } } }; @@ -57,7 +57,7 @@ void write_dcp_digest_file ( boost::filesystem::path path, shared_ptr<dcp::CPL> cpl, - string key + string film_key ) { xmlpp::Document doc; @@ -73,13 +73,13 @@ write_dcp_digest_file ( out_reel->add_child("Id")->add_child_text("urn:uuid:" + in_reel->id()); out_reel->add_child("AnnotationText"); if (in_reel->main_picture()) { - add_asset(key, in_reel->main_picture(), in_reel->main_picture()->asset(), out_reel, "MainPicture"); + add_asset(film_key, in_reel->main_picture(), in_reel->main_picture()->asset(), out_reel, "MainPicture"); } if (in_reel->main_sound()) { - add_asset(key, in_reel->main_sound(), in_reel->main_sound()->asset(), out_reel, "MainSound"); + add_asset(film_key, in_reel->main_sound(), in_reel->main_sound()->asset(), out_reel, "MainSound"); } if (auto smpte_sub = dynamic_pointer_cast<dcp::ReelSMPTESubtitleAsset>(in_reel->main_subtitle())) { - add_asset(key, smpte_sub, smpte_sub->smpte_asset(), out_reel, "MainSubtitle"); + add_asset(film_key, smpte_sub, smpte_sub->smpte_asset(), out_reel, "MainSubtitle"); } } doc.write_to_file_formatted(path.string()); diff --git a/src/lib/dcp_transcode_job.cc b/src/lib/dcp_transcode_job.cc index 4eb2269b2..2d3cc106b 100644 --- a/src/lib/dcp_transcode_job.cc +++ b/src/lib/dcp_transcode_job.cc @@ -22,6 +22,7 @@ #include "config.h" #include "dcp_content.h" #include "dcp_digest_file.h" +#include "dcp_transcode_job.h" #include "film.h" #include "job_manager.h" #include "upload_job.h" @@ -29,8 +30,10 @@ #include <dcp/search.h> +using std::dynamic_pointer_cast; using std::make_shared; using std::shared_ptr; +using std::vector; DCPTranscodeJob::DCPTranscodeJob (shared_ptr<const Film> film, ChangedBehaviour changed) @@ -47,11 +50,30 @@ DCPTranscodeJob::post_transcode () JobManager::instance()->add(make_shared<UploadJob>(_film)); } - dcp::DCP dcp(_film->dir(_film->dcp_name())); - dcp.read(); + /* The first directory is the project's DCP, so the first CPL will also be from the project + * (not from one of the DCPs imported into the project). + */ + vector<boost::filesystem::path> all_directories = { _film->dir(_film->dcp_name()) }; + + vector<dcp::EncryptedKDM> all_kdms; + for (auto content: _film->content()) { + if (auto dcp_content = dynamic_pointer_cast<DCPContent>(content)) { + auto directories = dcp_content->directories(); + std::copy (directories.begin(), directories.end(), std::back_inserter(all_directories)); + if (dcp_content->kdm()) { + all_kdms.push_back (dcp_content->kdm().get()); + } + } + } + + auto cpls = dcp::find_and_resolve_cpls (all_directories, true); + DCPOMATIC_ASSERT (!cpls.empty()); + auto cpl = cpls.front (); - for (auto cpl: dcp.cpls()) { - write_dcp_digest_file (_film->file(cpl->annotation_text().get_value_or(cpl->id()) + ".dcpdig"), cpl, _film->key().hex()); + for (auto const& kdm: all_kdms) { + cpl->add (decrypt_kdm_with_helpful_error(kdm)); } + + write_dcp_digest_file (_film->file(cpl->annotation_text().get_value_or(cpl->id()) + ".dcpdig"), cpl, _film->key().hex()); } |
