Try to actually use colour conversion; bump libdcp in cscript.
[dcpomatic.git] / src / lib / player.h
index 5b1b6936bc95a41ca548fef98f32cc146da9a628..2261f66eaa6aafb8c09c3c71961e5f152fc5f513 100644 (file)
 #include <boost/shared_ptr.hpp>
 #include <boost/enable_shared_from_this.hpp>
 #include "playlist.h"
-#include "audio_buffers.h"
 #include "content.h"
 #include "film.h"
 #include "rect.h"
+#include "audio_merger.h"
+#include "audio_content.h"
 
 class Job;
 class Film;
@@ -35,6 +36,7 @@ class Playlist;
 class AudioContent;
 class Piece;
 class Image;
+class Resampler;
 
 /** @class Player
  *  @brief A class which can `play' a Playlist; emitting its audio and video.
@@ -60,10 +62,11 @@ public:
        /** Emitted when a video frame is ready.
         *  First parameter is the video image.
         *  Second parameter is the eye(s) that should see this image.
-        *  Third parameter is true if the image is the same as the last one that was emitted.
-        *  Fourth parameter is the time.
+        *  Third parameter is the colour conversion that should be used for this image.
+        *  Fourth parameter is true if the image is the same as the last one that was emitted.
+        *  Fifth parameter is the time.
         */
-       boost::signals2::signal<void (boost::shared_ptr<const Image>, Eyes, bool, Time)> Video;
+       boost::signals2::signal<void (boost::shared_ptr<const Image>, Eyes, ColourConversion, bool, Time)> Video;
        
        /** Emitted when some audio data is ready */
        boost::signals2::signal<void (boost::shared_ptr<const AudioBuffers>, Time)> Audio;
@@ -89,6 +92,7 @@ private:
        void flush ();
        void emit_black ();
        void emit_silence (OutputAudioFrame);
+       boost::shared_ptr<Resampler> resampler (boost::shared_ptr<AudioContent>, bool);
        void film_changed (Film::Property);
        void update_subtitle ();
 
@@ -107,10 +111,11 @@ private:
        /** The time after the last audio that we emitted */
        Time _audio_position;
 
-       AudioBuffers _audio_buffers;
+       AudioMerger<Time, AudioContent::Frame> _audio_merger;
 
        libdcp::Size _video_container_size;
        boost::shared_ptr<Image> _black_frame;
+       std::map<boost::shared_ptr<AudioContent>, boost::shared_ptr<Resampler> > _resamplers;
 
        struct {
                boost::weak_ptr<Piece> piece;
@@ -129,7 +134,13 @@ private:
 
 #ifdef DCPOMATIC_DEBUG
        boost::shared_ptr<Content> _last_video;
-#endif 
+#endif
+
+       bool _last_emit_was_black;
+
+       boost::signals2::scoped_connection _playlist_changed_connection;
+       boost::signals2::scoped_connection _playlist_content_changed_connection;
+       boost::signals2::scoped_connection _film_changed_connection;
 };
 
 #endif