summaryrefslogtreecommitdiff
path: root/src/lib/j2k_encoder.h
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2023-09-10 22:56:51 +0200
committerCarl Hetherington <cth@carlh.net>2023-09-10 22:56:51 +0200
commit96f25981e914d27377d13cccdd733d9996130703 (patch)
tree91d779656477467d17a6661cb8b22f65cce866cd /src/lib/j2k_encoder.h
parent23306255085a0b48168d51629f38597ee0bf80ce (diff)
Rearrange encoder.rearrange-encoder
Diffstat (limited to 'src/lib/j2k_encoder.h')
-rw-r--r--src/lib/j2k_encoder.h25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/lib/j2k_encoder.h b/src/lib/j2k_encoder.h
index 63228a6b8..94490f16a 100644
--- a/src/lib/j2k_encoder.h
+++ b/src/lib/j2k_encoder.h
@@ -32,6 +32,7 @@
#include "enum_indexed_vector.h"
#include "event_history.h"
#include "exception_store.h"
+#include "types.h"
#include "writer.h"
#include <boost/optional.hpp>
#include <boost/signals2.hpp>
@@ -45,9 +46,14 @@
class DCPVideo;
class EncodeServerDescription;
class Film;
+class J2KEncoderThread;
class Job;
class PlayerVideo;
+struct local_threads_created_and_destroyed;
+struct remote_threads_created_and_destroyed;
+struct frames_not_lost_when_threads_disappear;
+
/** @class J2KEncoder
* @brief Class to manage encoding to J2K.
@@ -76,22 +82,33 @@ public:
boost::optional<float> current_encoding_rate () const;
int video_frames_enqueued () const;
- void servers_list_changed ();
+ DCPVideo pop();
+ void retry(DCPVideo frame);
+ void write(std::shared_ptr<const dcp::Data> data, int index, Eyes eyes);
private:
- void frame_done ();
+ friend struct ::local_threads_created_and_destroyed;
+ friend struct ::remote_threads_created_and_destroyed;
+ friend struct ::frames_not_lost_when_threads_disappear;
- void encoder_thread (boost::optional<EncodeServerDescription>);
+ void frame_done ();
void terminate_threads ();
+ void servers_list_changed ();
+ void remake_threads(int local, std::list<EncodeServerDescription> servers);
+
/** Film that we are encoding */
std::shared_ptr<const Film> _film;
EventHistory _history;
boost::mutex _threads_mutex;
- std::shared_ptr<boost::thread_group> _threads;
+ std::list<std::shared_ptr<J2KEncoderThread>> _threads;
+ /** true if we shouldn't make any more threads, even if remake_threads()
+ * or servers_list_changed() is called.
+ */
+ bool _ending = false;
mutable boost::mutex _queue_mutex;
std::list<DCPVideo> _queue;