summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-12-18 14:23:50 +0100
committerCarl Hetherington <cth@carlh.net>2022-04-20 19:35:36 +0200
commitdf5228d00d70d68218e7f606131a0c5fa2caba9f (patch)
tree7362b301f4693051a8722945378d11d9a0ef4c1d /src/lib
parent6e0f867a69cf4e337370edc986347218afde548e (diff)
Move make_dcp() out of Film (#2132).
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/film.cc63
-rw-r--r--src/lib/film.h1
-rw-r--r--src/lib/make_dcp.cc105
-rw-r--r--src/lib/make_dcp.h29
-rw-r--r--src/lib/wscript1
5 files changed, 135 insertions, 64 deletions
diff --git a/src/lib/film.cc b/src/lib/film.cc
index 718d6c61d..7cf67546e 100644
--- a/src/lib/film.cc
+++ b/src/lib/film.cc
@@ -377,69 +377,6 @@ Film::subtitle_analysis_path (shared_ptr<const Content> content) const
}
-/** Add suitable Jobs to the JobManager to create a DCP for this Film */
-void
-Film::make_dcp (TranscodeJob::ChangedBehaviour behaviour)
-{
- if (dcp_name().find ("/") != string::npos) {
- throw BadSettingError (_("name"), _("Cannot contain slashes"));
- }
-
- if (container() == nullptr) {
- throw MissingSettingError (_("container"));
- }
-
- if (content().empty()) {
- throw runtime_error (_("You must add some content to the DCP before creating it"));
- }
-
- if (length() == DCPTime()) {
- throw runtime_error (_("The DCP is empty, perhaps because all the content has zero length."));
- }
-
- if (dcp_content_type() == nullptr) {
- throw MissingSettingError (_("content type"));
- }
-
- if (name().empty()) {
- set_name ("DCP");
- }
-
- for (auto i: content ()) {
- if (!i->paths_valid()) {
- throw runtime_error (_("some of your content is missing"));
- }
- auto dcp = dynamic_pointer_cast<const DCPContent>(i);
- if (dcp && dcp->needs_kdm()) {
- throw runtime_error (_("Some of your content needs a KDM"));
- }
- if (dcp && dcp->needs_assets()) {
- throw runtime_error (_("Some of your content needs an OV"));
- }
- }
-
- set_isdcf_date_today ();
-
- for (auto i: environment_info ()) {
- LOG_GENERAL_NC (i);
- }
-
- for (auto i: content ()) {
- LOG_GENERAL ("Content: %1", i->technical_summary());
- }
- LOG_GENERAL ("DCP video rate %1 fps", video_frame_rate());
- if (Config::instance()->only_servers_encode ()) {
- LOG_GENERAL_NC ("0 threads: ONLY SERVERS SET TO ENCODE");
- } else {
- LOG_GENERAL ("%1 threads", Config::instance()->master_encoding_threads());
- }
- LOG_GENERAL ("J2K bandwidth %1", j2k_bandwidth());
-
- auto tj = make_shared<TranscodeJob>(shared_from_this(), behaviour);
- tj->set_encoder (make_shared<DCPEncoder>(shared_from_this(), tj));
- JobManager::instance()->add (tj);
-}
-
/** Start a job to send our DCP to the configured TMS */
void
Film::send_dcp_to_tms ()
diff --git a/src/lib/film.h b/src/lib/film.h
index 7103f6271..1d1034775 100644
--- a/src/lib/film.h
+++ b/src/lib/film.h
@@ -118,7 +118,6 @@ public:
boost::filesystem::path subtitle_analysis_path (std::shared_ptr<const Content>) const;
void send_dcp_to_tms ();
- void make_dcp (TranscodeJob::ChangedBehaviour behaviour);
/** @return Logger.
* It is safe to call this from any thread.
diff --git a/src/lib/make_dcp.cc b/src/lib/make_dcp.cc
new file mode 100644
index 000000000..934387fcd
--- /dev/null
+++ b/src/lib/make_dcp.cc
@@ -0,0 +1,105 @@
+/*
+ Copyright (C) 2021 Carl Hetherington <cth@carlh.net>
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ DCP-o-matic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#include "config.h"
+#include "dcp_content.h"
+#include "dcp_encoder.h"
+#include "dcpomatic_log.h"
+#include "environment_info.h"
+#include "film.h"
+#include "job_manager.h"
+#include "make_dcp.h"
+#include "transcode_job.h"
+#include <stdexcept>
+
+#include "i18n.h"
+
+
+using std::dynamic_pointer_cast;
+using std::make_shared;
+using std::runtime_error;
+using std::shared_ptr;
+using std::string;
+
+
+/** Add suitable Jobs to the JobManager to create a DCP for a Film */
+void
+make_dcp (shared_ptr<Film> film, TranscodeJob::ChangedBehaviour behaviour)
+{
+ if (film->dcp_name().find("/") != string::npos) {
+ throw BadSettingError (_("name"), _("Cannot contain slashes"));
+ }
+
+ if (film->container() == nullptr) {
+ throw MissingSettingError (_("container"));
+ }
+
+ if (film->content().empty()) {
+ throw runtime_error (_("You must add some content to the DCP before creating it"));
+ }
+
+ if (film->length() == dcpomatic::DCPTime()) {
+ throw runtime_error (_("The DCP is empty, perhaps because all the content has zero length."));
+ }
+
+ if (film->dcp_content_type() == nullptr) {
+ throw MissingSettingError (_("content type"));
+ }
+
+ if (film->name().empty()) {
+ film->set_name ("DCP");
+ }
+
+ for (auto i: film->content()) {
+ if (!i->paths_valid()) {
+ throw runtime_error (_("Some of your content is missing"));
+ }
+ auto dcp = dynamic_pointer_cast<const DCPContent>(i);
+ if (dcp && dcp->needs_kdm()) {
+ throw runtime_error (_("Some of your content needs a KDM"));
+ }
+ if (dcp && dcp->needs_assets()) {
+ throw runtime_error (_("Some of your content needs an OV"));
+ }
+ }
+
+ film->set_isdcf_date_today ();
+
+ for (auto info: environment_info()) {
+ LOG_GENERAL_NC (info);
+ }
+
+ for (auto content: film->content()) {
+ LOG_GENERAL ("Content: %1", content->technical_summary());
+ }
+ LOG_GENERAL ("DCP video rate %1 fps", film->video_frame_rate());
+ if (Config::instance()->only_servers_encode()) {
+ LOG_GENERAL_NC ("0 threads: ONLY SERVERS SET TO ENCODE");
+ } else {
+ LOG_GENERAL ("%1 threads", Config::instance()->master_encoding_threads());
+ }
+ LOG_GENERAL ("J2K bandwidth %1", film->j2k_bandwidth());
+
+ auto tj = make_shared<TranscodeJob>(film, behaviour);
+ tj->set_encoder (make_shared<DCPEncoder>(film, tj));
+ JobManager::instance()->add (tj);
+}
+
diff --git a/src/lib/make_dcp.h b/src/lib/make_dcp.h
new file mode 100644
index 000000000..9f5072782
--- /dev/null
+++ b/src/lib/make_dcp.h
@@ -0,0 +1,29 @@
+/*
+ Copyright (C) 2021 Carl Hetherington <cth@carlh.net>
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ DCP-o-matic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#include "transcode_job.h"
+
+
+class Film;
+
+
+void make_dcp (std::shared_ptr<Film> film, TranscodeJob::ChangedBehaviour behaviour);
+
diff --git a/src/lib/wscript b/src/lib/wscript
index 5f8a6cff7..44a4da2dd 100644
--- a/src/lib/wscript
+++ b/src/lib/wscript
@@ -132,6 +132,7 @@ sources = """
kdm_with_metadata.cc
log.cc
log_entry.cc
+ make_dcp.cc
maths_util.cc
memory_util.cc
mid_side_decoder.cc