From 74be5a6cc63e3d87d7ec2156fb75eb16f6d0ffcb Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 29 Dec 2021 00:54:19 +0100 Subject: [PATCH] Clean up a hack by adding DCPTranscodeJob. --- src/lib/dcp_transcode_job.cc | 46 ++++++++++++++++++++++++++++++++++++ src/lib/dcp_transcode_job.h | 32 +++++++++++++++++++++++++ src/lib/make_dcp.cc | 4 ++-- src/lib/transcode_job.cc | 5 +--- src/lib/transcode_job.h | 2 ++ src/lib/wscript | 1 + 6 files changed, 84 insertions(+), 6 deletions(-) create mode 100644 src/lib/dcp_transcode_job.cc create mode 100644 src/lib/dcp_transcode_job.h diff --git a/src/lib/dcp_transcode_job.cc b/src/lib/dcp_transcode_job.cc new file mode 100644 index 000000000..e9ff4f4e0 --- /dev/null +++ b/src/lib/dcp_transcode_job.cc @@ -0,0 +1,46 @@ +/* + Copyright (C) 2021 Carl Hetherington + + 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 . + +*/ + + +#include "config.h" +#include "dcp_transcode_job.h" +#include "film.h" +#include "job_manager.h" +#include "upload_job.h" + + +using std::make_shared; +using std::shared_ptr; + + +DCPTranscodeJob::DCPTranscodeJob (shared_ptr film, ChangedBehaviour changed) + : TranscodeJob (film, changed) +{ + +} + + +void +DCPTranscodeJob::post_transcode () +{ + if (Config::instance()->upload_after_make_dcp()) { + JobManager::instance()->add(make_shared(_film)); + } +} diff --git a/src/lib/dcp_transcode_job.h b/src/lib/dcp_transcode_job.h new file mode 100644 index 000000000..4699884ed --- /dev/null +++ b/src/lib/dcp_transcode_job.h @@ -0,0 +1,32 @@ +/* + Copyright (C) 2021 Carl Hetherington + + 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 . + +*/ + + +#include "transcode_job.h" + + +class DCPTranscodeJob : public TranscodeJob +{ +public: + DCPTranscodeJob (std::shared_ptr film, ChangedBehaviour changed); + +private: + void post_transcode () override; +}; diff --git a/src/lib/make_dcp.cc b/src/lib/make_dcp.cc index 934387fcd..17d45be46 100644 --- a/src/lib/make_dcp.cc +++ b/src/lib/make_dcp.cc @@ -22,12 +22,12 @@ #include "config.h" #include "dcp_content.h" #include "dcp_encoder.h" +#include "dcp_transcode_job.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 #include "i18n.h" @@ -98,7 +98,7 @@ make_dcp (shared_ptr film, TranscodeJob::ChangedBehaviour behaviour) } LOG_GENERAL ("J2K bandwidth %1", film->j2k_bandwidth()); - auto tj = make_shared(film, behaviour); + auto tj = make_shared(film, behaviour); tj->set_encoder (make_shared(film, tj)); JobManager::instance()->add (tj); } diff --git a/src/lib/transcode_job.cc b/src/lib/transcode_job.cc index 6e1985400..f5ddf1754 100644 --- a/src/lib/transcode_job.cc +++ b/src/lib/transcode_job.cc @@ -144,10 +144,7 @@ TranscodeJob::run () } } - /* XXX: this shouldn't be here */ - if (Config::instance()->upload_after_make_dcp() && dynamic_pointer_cast(_encoder)) { - JobManager::instance()->add(make_shared(_film)); - } + post_transcode (); _encoder.reset (); diff --git a/src/lib/transcode_job.h b/src/lib/transcode_job.h index 6b2e8f923..8b145e362 100644 --- a/src/lib/transcode_job.h +++ b/src/lib/transcode_job.h @@ -64,6 +64,8 @@ public: void set_encoder (std::shared_ptr t); private: + virtual void post_transcode () {} + int remaining_time () const override; std::shared_ptr _encoder; diff --git a/src/lib/wscript b/src/lib/wscript index 0a0790fcd..4063eafdb 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -72,6 +72,7 @@ sources = """ dcp_subtitle_content.cc dcp_subtitle_decoder.cc dcp_text_track.cc + dcp_transcode_job.cc dcp_video.cc dcpomatic_log.cc dcpomatic_socket.cc -- 2.30.2