Clean up a hack by adding DCPTranscodeJob.
authorCarl Hetherington <cth@carlh.net>
Tue, 28 Dec 2021 23:54:19 +0000 (00:54 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 29 Dec 2021 00:48:54 +0000 (01:48 +0100)
src/lib/dcp_transcode_job.cc [new file with mode: 0644]
src/lib/dcp_transcode_job.h [new file with mode: 0644]
src/lib/make_dcp.cc
src/lib/transcode_job.cc
src/lib/transcode_job.h
src/lib/wscript

diff --git a/src/lib/dcp_transcode_job.cc b/src/lib/dcp_transcode_job.cc
new file mode 100644 (file)
index 0000000..e9ff4f4
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+    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_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<const Film> film, ChangedBehaviour changed)
+       : TranscodeJob (film, changed)
+{
+
+}
+
+
+void
+DCPTranscodeJob::post_transcode ()
+{
+       if (Config::instance()->upload_after_make_dcp()) {
+               JobManager::instance()->add(make_shared<UploadJob>(_film));
+       }
+}
diff --git a/src/lib/dcp_transcode_job.h b/src/lib/dcp_transcode_job.h
new file mode 100644 (file)
index 0000000..4699884
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+    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 DCPTranscodeJob : public TranscodeJob
+{
+public:
+       DCPTranscodeJob (std::shared_ptr<const Film> film, ChangedBehaviour changed);
+
+private:
+       void post_transcode () override;
+};
index 934387fcd00519ed56d266b7fde8ebb2b29ad808..17d45be46e13416869977b6951d73a95573b2bdf 100644 (file)
 #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 <stdexcept>
 
 #include "i18n.h"
@@ -98,7 +98,7 @@ make_dcp (shared_ptr<Film> film, TranscodeJob::ChangedBehaviour behaviour)
        }
        LOG_GENERAL ("J2K bandwidth %1", film->j2k_bandwidth());
 
-       auto tj = make_shared<TranscodeJob>(film, behaviour);
+       auto tj = make_shared<DCPTranscodeJob>(film, behaviour);
        tj->set_encoder (make_shared<DCPEncoder>(film, tj));
        JobManager::instance()->add (tj);
 }
index 6e19854003ef207d724eb17520598738184863d8..f5ddf17544bdcc4c4641807c129a449e8dd502d6 100644 (file)
@@ -144,10 +144,7 @@ TranscodeJob::run ()
                        }
                }
 
-               /* XXX: this shouldn't be here */
-               if (Config::instance()->upload_after_make_dcp() && dynamic_pointer_cast<DCPEncoder>(_encoder)) {
-                       JobManager::instance()->add(make_shared<UploadJob>(_film));
-               }
+               post_transcode ();
 
                _encoder.reset ();
 
index 6b2e8f9235d3637bddc22789ee63d6ec2ea8087f..8b145e362333279e97daec904e61757f8cb832fb 100644 (file)
@@ -64,6 +64,8 @@ public:
        void set_encoder (std::shared_ptr<Encoder> t);
 
 private:
+       virtual void post_transcode () {}
+
        int remaining_time () const override;
 
        std::shared_ptr<Encoder> _encoder;
index 0a0790fcd16f2ec8096c5f6b6de2d266dada0a14..4063eafdb394adf1b796cd5f478f16ab450bbb0b 100644 (file)
@@ -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