summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2017-05-09 14:04:46 +0100
committerCarl Hetherington <cth@carlh.net>2017-05-09 14:04:46 +0100
commitbb6b53bdb63754fe0cea1368f69f39a3c3cbbdfd (patch)
tree1fa27846ece11d0f30b124b22d3d514333a80563
parent9fa69f9a195c102fb32f285527e8171378c9b6c0 (diff)
Make TranscoderJob able to take any sort of transcoder.
-rw-r--r--src/lib/film.cc7
-rw-r--r--src/lib/transcode_job.cc11
-rw-r--r--src/lib/transcode_job.h6
-rw-r--r--src/lib/transcoder.h1
4 files changed, 19 insertions, 6 deletions
diff --git a/src/lib/film.cc b/src/lib/film.cc
index 36221fb9a..8637085af 100644
--- a/src/lib/film.cc
+++ b/src/lib/film.cc
@@ -19,7 +19,7 @@
*/
/** @file src/film.cc
- * @brief A representation of some audio and video content, and details of
+ * @brief A representation of some audio, video and subtitle content, and details of
* how they should be presented in a DCP.
*/
@@ -27,6 +27,7 @@
#include "job.h"
#include "util.h"
#include "job_manager.h"
+#include "dcp_transcoder.h"
#include "transcode_job.h"
#include "upload_job.h"
#include "null_log.h"
@@ -341,7 +342,9 @@ Film::make_dcp ()
}
LOG_GENERAL ("J2K bandwidth %1", j2k_bandwidth());
- JobManager::instance()->add (shared_ptr<Job> (new TranscodeJob (shared_from_this())));
+ shared_ptr<TranscodeJob> tj (new TranscodeJob (shared_from_this()));
+ tj->set_transcoder (shared_ptr<Transcoder> (new DCPTranscoder (shared_from_this(), tj)));
+ JobManager::instance()->add (tj);
}
/** Start a job to send our DCP to the configured TMS */
diff --git a/src/lib/transcode_job.cc b/src/lib/transcode_job.cc
index 17738deff..bf878e8c2 100644
--- a/src/lib/transcode_job.cc
+++ b/src/lib/transcode_job.cc
@@ -65,6 +65,12 @@ TranscodeJob::json_name () const
}
void
+TranscodeJob::set_transcoder (shared_ptr<Transcoder> t)
+{
+ _transcoder = t;
+}
+
+void
TranscodeJob::run ()
{
try {
@@ -72,7 +78,7 @@ TranscodeJob::run ()
gettimeofday (&start, 0);
LOG_GENERAL_NC (N_("Transcode job starting"));
- _transcoder.reset (new DCPTranscoder (_film, shared_from_this ()));
+ DCPOMATIC_ASSERT (_transcoder);
_transcoder->go ();
set_progress (1);
set_state (FINISHED_OK);
@@ -88,6 +94,7 @@ TranscodeJob::run ()
LOG_GENERAL (N_("Transcode job completed successfully: %1 fps"), fps);
_transcoder.reset ();
+ /* XXX: this shouldn't be here */
if (_film->upload_after_make_dcp ()) {
shared_ptr<Job> job (new UploadJob (_film));
JobManager::instance()->add (job);
@@ -135,7 +142,7 @@ int
TranscodeJob::remaining_time () const
{
/* _transcoder might be destroyed by the job-runner thread */
- shared_ptr<DCPTranscoder> t = _transcoder;
+ shared_ptr<Transcoder> t = _transcoder;
if (!t || t->finishing()) {
/* We aren't doing any actual encoding so just use the job's guess */
diff --git a/src/lib/transcode_job.h b/src/lib/transcode_job.h
index 9e827e412..ae1a75804 100644
--- a/src/lib/transcode_job.h
+++ b/src/lib/transcode_job.h
@@ -25,7 +25,7 @@
#include "job.h"
#include <boost/shared_ptr.hpp>
-class DCPTranscoder;
+class Transcoder;
/** @class TranscodeJob
* @brief A job which transcodes from one format to another.
@@ -40,8 +40,10 @@ public:
void run ();
std::string status () const;
+ void set_transcoder (boost::shared_ptr<Transcoder> t);
+
private:
int remaining_time () const;
- boost::shared_ptr<DCPTranscoder> _transcoder;
+ boost::shared_ptr<Transcoder> _transcoder;
};
diff --git a/src/lib/transcoder.h b/src/lib/transcoder.h
index b6378119b..37710d883 100644
--- a/src/lib/transcoder.h
+++ b/src/lib/transcoder.h
@@ -43,6 +43,7 @@ public:
virtual float current_encoding_rate () const = 0;
virtual int video_frames_enqueued () const = 0;
+ virtual bool finishing () const = 0;
protected:
virtual void video (boost::shared_ptr<PlayerVideo>, DCPTime) = 0;