summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-01-03 00:11:16 +0000
committerCarl Hetherington <cth@carlh.net>2022-04-20 21:23:54 +0200
commit58e94d1c412cd87a28fca99b46c7d5cf408f8186 (patch)
tree02e8d01cb6dd35a6b04490015bcc49e8c1984e15 /src
parent2034cf8a82be21d4d07de81ae40c8255da1ed21e (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.cc12
-rw-r--r--src/lib/dcp_transcode_job.cc29
2 files changed, 31 insertions, 10 deletions
diff --git a/src/lib/dcp_digest_file.cc b/src/lib/dcp_digest_file.cc
index b178e3da7..0ea5ae821 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);
@@ -49,7 +49,7 @@ void add_asset(string key, shared_ptr<R> reel_asset, shared_ptr<A> asset, xmlpp:
}
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);
}
}
};
@@ -59,7 +59,7 @@ void
write_dcp_digest_file (
boost::filesystem::path path,
shared_ptr<dcp::CPL> cpl,
- string key
+ string film_key
)
{
xmlpp::Document doc;
@@ -75,13 +75,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 ae3f3f837..dd7b7d624 100644
--- a/src/lib/dcp_transcode_job.cc
+++ b/src/lib/dcp_transcode_job.cc
@@ -30,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)
@@ -48,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());
}