X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fencoder.h;h=792029a9164f0ea4ce30054af0496501e113ea49;hb=70f5ab36c2b985b8b82aea3187964de41930fc94;hp=6b830abba15f6585e28fc101137861cbdcae4ea7;hpb=538af3d961b5017303cedb56fa35c9be23d1658a;p=dcpomatic.git diff --git a/src/lib/encoder.h b/src/lib/encoder.h index 6b830abba..792029a91 100644 --- a/src/lib/encoder.h +++ b/src/lib/encoder.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2015 Carl Hetherington + Copyright (C) 2012-2017 Carl Hetherington This file is part of DCP-o-matic. @@ -21,95 +21,40 @@ #ifndef DCPOMATIC_ENCODER_H #define DCPOMATIC_ENCODER_H -/** @file src/encoder.h - * @brief Encoder class. - */ - -#include "util.h" -#include "cross.h" -#include "exception_store.h" -#include -#include -#include -#include -#include +#include "types.h" +#include "player_text.h" +#include #include -#include -#include class Film; -class EncodeServerDescription; -class DCPVideo; -class Writer; +class Encoder; +class Player; class Job; class PlayerVideo; +class AudioBuffers; -/** @class Encoder - * @brief Class to manage encoding to JPEG2000. - * - * This class keeps a queue of frames to be encoded and distributes - * the work around threads and encoding servers. - */ - -class Encoder : public boost::noncopyable, public ExceptionStore +/** @class Encoder */ +class Encoder : public boost::noncopyable { public: - Encoder (boost::shared_ptr, boost::shared_ptr); - ~Encoder (); - - /** Called to indicate that a processing run is about to begin */ - void begin (); - - /** Called to pass in zero or more bits of video to be encoded - * as the next DCP frame. - */ - void encode (std::list > f); - - /** Called when a processing run has finished */ - void end (); - - float current_encoding_rate () const; - int video_frames_out () const; + Encoder (boost::shared_ptr film, boost::weak_ptr job); + virtual ~Encoder () {} -private: + virtual void go () = 0; - void enqueue (boost::shared_ptr f); - void frame_done (); + /** @return the current frame rate over the last short while */ + virtual boost::optional current_rate () const { + return boost::optional(); + } - void encoder_thread (boost::optional); - void terminate_threads (); - void servers_list_changed (); + /** @return the number of frames that are done */ + virtual Frame frames_done () const = 0; + virtual bool finishing () const = 0; - /** Film that we are encoding */ +protected: boost::shared_ptr _film; - - /** Mutex for _time_history and _video_frames_enqueued */ - mutable boost::mutex _state_mutex; - /** List of the times of completion of the last _history_size frames; - first is the most recently completed. - */ - std::list _time_history; - /** Number of frames that we should keep history for */ - static int const _history_size; - /** Current DCP frame index */ - Frame _position; - - /** Mutex for _threads */ - mutable boost::mutex _threads_mutex; - std::list _threads; - mutable boost::mutex _queue_mutex; - std::list > _queue; - /** 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 */ - boost::condition _full_condition; - - boost::shared_ptr _writer; - Waker _waker; - - boost::shared_ptr _last_player_video; - - boost::signals2::scoped_connection _server_found_connection; + boost::weak_ptr _job; + boost::shared_ptr _player; }; #endif