Split Options into encode / decode.
[dcpomatic.git] / src / lib / j2k_wav_encoder.h
index 1c2f5006590028aa503876c507173787dcd21f58..064f4221ed648ff98ba4189f75075916ca1d88d0 100644 (file)
 #include <boost/thread/condition.hpp>
 #include <boost/thread/mutex.hpp>
 #include <boost/thread.hpp>
+#ifdef HAVE_SWRESAMPLE
+extern "C" {
+#include <libswresample/swresample.h>
+}
+#endif
 #include <sndfile.h>
 #include "encoder.h"
 
@@ -33,6 +38,8 @@ class ServerDescription;
 class DCPVideoFrame;
 class Image;
 class Log;
+class Subtitle;
+class AudioBuffers;
 
 /** @class J2KWAVEncoder
  *  @brief An encoder which writes JPEG2000 and WAV files.
@@ -40,23 +47,28 @@ class Log;
 class J2KWAVEncoder : public Encoder
 {
 public:
-       J2KWAVEncoder (boost::shared_ptr<const FilmState>, boost::shared_ptr<const Options>, Log *);
+       J2KWAVEncoder (boost::shared_ptr<const Film>, boost::shared_ptr<const EncodeOptions>);
        ~J2KWAVEncoder ();
 
        void process_begin ();
-       void process_video (boost::shared_ptr<Image>, int);
-       void process_audio (uint8_t *, int);
        void process_end ();
 
-private:       
+private:
 
+       void do_process_video (boost::shared_ptr<Image>, boost::shared_ptr<Subtitle>);
+       void do_process_audio (boost::shared_ptr<AudioBuffers>);
+       
+       void write_audio (boost::shared_ptr<const AudioBuffers> audio);
        void encoder_thread (ServerDescription *);
        void close_sound_files ();
        void terminate_worker_threads ();
 
+#if HAVE_SWRESAMPLE    
+       SwrContext* _swr_context;
+#endif 
+
        std::vector<SNDFILE*> _sound_files;
-       int _deinterleave_buffer_size;
-       uint8_t* _deinterleave_buffer;
+       int64_t _audio_frames_written;
 
        bool _process_end;
        std::list<boost::shared_ptr<DCPVideoFrame> > _queue;