From 2f56f38ce56b36f20d59593f56981e7ed330c484 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 19 Dec 2012 23:50:17 +0000 Subject: Re-work again so that there's just one encoder; various tweaks to still-image-with-audio. --- src/lib/encoder.h | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'src/lib/encoder.h') diff --git a/src/lib/encoder.h b/src/lib/encoder.h index f355daff7..8ab4479ef 100644 --- a/src/lib/encoder.h +++ b/src/lib/encoder.h @@ -26,6 +26,8 @@ #include #include +#include +#include #include #include extern "C" { @@ -46,15 +48,14 @@ class Image; class Subtitle; class AudioBuffers; class Film; +class ServerDescription; +class DCPVideoFrame; /** @class Encoder - * @brief Parent class for classes which can encode video and audio frames. + * @brief Encoder to J2K and WAV for DCP. * * Video is supplied to process_video as YUV frames, and audio * is supplied as uncompressed PCM in blocks of various sizes. - * - * The subclass is expected to encode the video and/or audio in - * some way and write it to disk. */ class Encoder : public VideoSink, public AudioSink @@ -68,9 +69,10 @@ public: /** Call with a frame of video. * @param i Video frame image. + * @param same true if i is the same as the last time we were called. * @param s A subtitle that should be on this frame, or 0. */ - void process_video (boost::shared_ptr i, boost::shared_ptr s); + void process_video (boost::shared_ptr i, bool same, boost::shared_ptr s); /** Call with some audio data */ void process_audio (boost::shared_ptr); @@ -83,12 +85,6 @@ public: SourceFrame video_frame () const; protected: - - /** Called with a frame of video. - * @param i Video frame image. - * @param s A subtitle that should be on this frame, or 0. - */ - virtual void do_process_video (boost::shared_ptr i, boost::shared_ptr s) = 0; void frame_done (); void frame_skipped (); @@ -118,12 +114,23 @@ private: void close_sound_files (); void write_audio (boost::shared_ptr audio); + void encoder_thread (ServerDescription *); + void terminate_worker_threads (); + void link (std::string, std::string) const; + #if HAVE_SWRESAMPLE SwrContext* _swr_context; #endif std::vector _sound_files; int64_t _audio_frames_written; + + boost::optional _last_real_frame; + bool _process_end; + std::list > _queue; + std::list _worker_threads; + mutable boost::mutex _worker_mutex; + boost::condition _worker_condition; }; #endif -- cgit v1.2.3