2 Copyright (C) 2021-2022 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
23 #include "dcp_content.h"
24 #include "dcp_digest_file.h"
25 #include "dcp_transcode_job.h"
27 #include "job_manager.h"
28 #include "upload_job.h"
30 #include <dcp/search.h>
33 using std::dynamic_pointer_cast;
34 using std::make_shared;
35 using std::shared_ptr;
39 DCPTranscodeJob::DCPTranscodeJob (shared_ptr<const Film> film, ChangedBehaviour changed)
40 : TranscodeJob (film, changed)
47 DCPTranscodeJob::post_transcode ()
49 if (Config::instance()->upload_after_make_dcp()) {
50 JobManager::instance()->add(make_shared<UploadJob>(_film));
53 /* The first directory is the project's DCP, so the first CPL will also be from the project
54 * (not from one of the DCPs imported into the project).
56 vector<boost::filesystem::path> all_directories = { _film->dir(_film->dcp_name()) };
58 vector<dcp::EncryptedKDM> all_kdms;
59 for (auto content: _film->content()) {
60 if (auto dcp_content = dynamic_pointer_cast<DCPContent>(content)) {
61 auto directories = dcp_content->directories();
62 std::copy (directories.begin(), directories.end(), std::back_inserter(all_directories));
63 if (dcp_content->kdm()) {
64 all_kdms.push_back (dcp_content->kdm().get());
69 auto cpls = dcp::find_and_resolve_cpls (all_directories, true);
70 DCPOMATIC_ASSERT (!cpls.empty());
71 auto cpl = cpls.front ();
73 for (auto const& kdm: all_kdms) {
74 cpl->add (decrypt_kdm_with_helpful_error(kdm));
77 write_dcp_digest_file (_film->file(cpl->annotation_text().get_value_or(cpl->id()) + ".dcpdig"), cpl, _film->key().hex());