From bb6b53bdb63754fe0cea1368f69f39a3c3cbbdfd Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 9 May 2017 14:04:46 +0100 Subject: [PATCH] Make TranscoderJob able to take any sort of transcoder. --- src/lib/film.cc | 7 +++++-- src/lib/transcode_job.cc | 11 +++++++++-- src/lib/transcode_job.h | 6 ++++-- src/lib/transcoder.h | 1 + 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 (new TranscodeJob (shared_from_this()))); + shared_ptr tj (new TranscodeJob (shared_from_this())); + tj->set_transcoder (shared_ptr (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 @@ -64,6 +64,12 @@ TranscodeJob::json_name () const return N_("transcode"); } +void +TranscodeJob::set_transcoder (shared_ptr t) +{ + _transcoder = t; +} + void TranscodeJob::run () { @@ -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 (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 t = _transcoder; + shared_ptr 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 -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 t); + private: int remaining_time () const; - boost::shared_ptr _transcoder; + boost::shared_ptr _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, DCPTime) = 0; -- 2.30.2