Make class hierarchy to handle different J2K encoder 'worker's.
[dcpomatic.git] / src / lib / j2k_encoder.h
index cc8a854eb1f852515bcf80adb4d7bbd7d6d467d9..ff48ebbda6448ccf1fb54240316cabf1088d9ac0 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2019 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -45,6 +45,7 @@ class DCPVideo;
 class Writer;
 class Job;
 class PlayerVideo;
+class J2KEncodeWorker;
 
 /** @class J2KEncoder
  *  @brief Class to manage encoding to J2K.
@@ -63,12 +64,12 @@ public:
        void begin ();
 
        /** Called to pass a bit of video to be encoded as the next DCP frame */
-       void encode (boost::shared_ptr<PlayerVideo> pv, DCPTime time);
+       void encode (boost::shared_ptr<PlayerVideo> pv, dcpomatic::DCPTime time);
 
        /** Called when a processing run has finished */
        void end ();
 
-       float current_encoding_rate () const;
+       boost::optional<float> current_encoding_rate () const;
        int video_frames_enqueued () const;
 
        void servers_list_changed ();
@@ -79,7 +80,7 @@ private:
 
        void frame_done ();
 
-       void encoder_thread (boost::optional<EncodeServerDescription>);
+       void encoder_thread (boost::weak_ptr<J2KEncodeWorker>);
        void terminate_threads ();
 
        /** Film that we are encoding */
@@ -87,11 +88,11 @@ private:
 
        EventHistory _history;
 
-       /** Mutex for _threads */
-       mutable boost::mutex _threads_mutex;
-       std::list<boost::thread *> _threads;
+       boost::shared_ptr<boost::thread_group> _threads;
+
        mutable boost::mutex _queue_mutex;
        std::list<boost::shared_ptr<DCPVideo> > _queue;
+       std::list<boost::shared_ptr<J2KEncodeWorker> > _workers;
        /** condition to manage thread wakeups when we have nothing to do */
        boost::condition _empty_condition;
        /** condition to manage thread wakeups when we have too much to do */
@@ -100,8 +101,8 @@ private:
        boost::shared_ptr<Writer> _writer;
        Waker _waker;
 
-       boost::shared_ptr<PlayerVideo> _last_player_video;
-       boost::optional<DCPTime> _last_player_video_time;
+       boost::shared_ptr<PlayerVideo> _last_player_video[EYES_COUNT];
+       boost::optional<dcpomatic::DCPTime> _last_player_video_time;
 
        boost::signals2::scoped_connection _server_found_connection;
 };