2 Copyright (C) 2021 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_encoder.h"
25 #include "dcp_transcode_job.h"
26 #include "dcpomatic_log.h"
27 #include "environment_info.h"
29 #include "job_manager.h"
36 using std::dynamic_pointer_cast;
37 using std::make_shared;
38 using std::runtime_error;
39 using std::shared_ptr;
43 /** Add suitable Jobs to the JobManager to create a DCP for a Film */
45 make_dcp (shared_ptr<Film> film, TranscodeJob::ChangedBehaviour behaviour)
47 if (film->dcp_name().find("/") != string::npos) {
48 throw BadSettingError (_("name"), _("Cannot contain slashes"));
51 if (film->container() == nullptr) {
52 throw MissingSettingError (_("container"));
55 if (film->content().empty()) {
56 throw runtime_error (_("You must add some content to the DCP before creating it"));
59 if (film->length() == dcpomatic::DCPTime()) {
60 throw runtime_error (_("The DCP is empty, perhaps because all the content has zero length."));
63 if (film->dcp_content_type() == nullptr) {
64 throw MissingSettingError (_("content type"));
67 if (film->name().empty()) {
68 film->set_name ("DCP");
71 for (auto i: film->content()) {
72 if (!i->paths_valid()) {
73 throw runtime_error (_("Some of your content is missing"));
75 auto dcp = dynamic_pointer_cast<const DCPContent>(i);
76 if (dcp && dcp->needs_kdm()) {
77 throw runtime_error (_("Some of your content needs a KDM"));
79 if (dcp && dcp->needs_assets()) {
80 throw runtime_error (_("Some of your content needs an OV"));
84 film->set_isdcf_date_today ();
86 for (auto info: environment_info()) {
87 LOG_GENERAL_NC (info);
90 for (auto content: film->content()) {
91 LOG_GENERAL ("Content: %1", content->technical_summary());
93 LOG_GENERAL ("DCP video rate %1 fps", film->video_frame_rate());
94 if (Config::instance()->only_servers_encode()) {
95 LOG_GENERAL_NC ("0 threads: ONLY SERVERS SET TO ENCODE");
97 LOG_GENERAL ("%1 threads", Config::instance()->master_encoding_threads());
99 LOG_GENERAL ("J2K bandwidth %1", film->j2k_bandwidth());
101 auto tj = make_shared<DCPTranscodeJob>(film, behaviour);
102 tj->set_encoder (make_shared<DCPEncoder>(film, tj));
103 JobManager::instance()->add (tj);