Support DCP digest files (#2109).
[dcpomatic.git] / src / lib / dcp_transcode_job.cc
1 /*
2     Copyright (C) 2021-2022 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
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.
10
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.
15
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/>.
18
19 */
20
21
22 #include "config.h"
23 #include "dcp_content.h"
24 #include "dcp_digest_file.h"
25 #include "dcp_transcode_job.h"
26 #include "film.h"
27 #include "job_manager.h"
28 #include "upload_job.h"
29 #include <dcp/cpl.h>
30 #include <dcp/search.h>
31
32
33 using std::make_shared;
34 using std::shared_ptr;
35
36
37 DCPTranscodeJob::DCPTranscodeJob (shared_ptr<const Film> film, ChangedBehaviour changed)
38         : TranscodeJob (film, changed)
39 {
40
41 }
42
43
44 void
45 DCPTranscodeJob::post_transcode ()
46 {
47         if (Config::instance()->upload_after_make_dcp()) {
48                 JobManager::instance()->add(make_shared<UploadJob>(_film));
49         }
50
51         dcp::DCP dcp(_film->dir(_film->dcp_name()));
52         dcp.read();
53
54         for (auto cpl: dcp.cpls()) {
55                 write_dcp_digest_file (_film->file(cpl->annotation_text().get_value_or(cpl->id()) + ".dcpdig"), cpl, _film->key().hex());
56         }
57 }
58