Make TranscoderJob able to take any sort of transcoder.
authorCarl Hetherington <cth@carlh.net>
Tue, 9 May 2017 13:04:46 +0000 (14:04 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 9 May 2017 13:04:46 +0000 (14:04 +0100)
src/lib/film.cc
src/lib/transcode_job.cc
src/lib/transcode_job.h
src/lib/transcoder.h

index 36221fb9a5ed39f5ed74130498ecce976ad10700..8637085af9a7090251f5684d4c3a1572a1c2f335 100644 (file)
@@ -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 */
index 17738deffaa97ac6c7420ad69b0636bfed91a6d6..bf878e8c2b5e6fb5432d177e4f1febe7ed4367f1 100644 (file)
@@ -64,6 +64,12 @@ TranscodeJob::json_name () const
        return N_("transcode");
 }
 
+void
+TranscodeJob::set_transcoder (shared_ptr<Transcoder> 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> 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 */
index 9e827e41259d1b0981a17edc2fa9488758577e0a..ae1a758048b4555ee42ce8468761595c018757d0 100644 (file)
@@ -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;
 };
index b6378119b1062447b731bc4f00f44634f323bc44..37710d8836fc6c99e65369a2e5ae4d21eadd5dc7 100644 (file)
@@ -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;